-
Notifications
You must be signed in to change notification settings - Fork 0
/
Runner.java
61 lines (44 loc) · 1.31 KB
/
Runner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import javax.swing.*;
import java.awt.*;
import java.io.*;
import abc.notation.*;
import abc.parser.TuneParser;
import abc.midi.TunePlayer;
import abc.ui.swing.JScoreComponent;
public class Runner{
public static String style;
public static void main (String args[]) throws IOException{
Runner r = new Runner();
style=args[0];
r.go();
}
public void go() throws IOException{
File flt = new File("output.txt");
FileWriter wrt = new FileWriter(flt);
TuneWriter t = new TuneWriter(style);
String s = t.makeTune();
Tune tune = new TuneParser().parse(s);
wrt.write(s);
TunePlayer play = new TunePlayer();
play.start();
play.play(tune);
System.out.println(play.isPlaying());
JFrame j = new JFrame();
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScoreComponent scoreUI =new JScoreComponent();
scoreUI.setJustification(true);
scoreUI.setTune(tune);
scoreUI.writeScoreTo(new File("output.png"));
Container pane = j.getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
pane.setBackground(Color.white);
JButton n = new JButton("new");
n.addActionListener(new AListener(t,tune,scoreUI,j));
n.setPreferredSize(new Dimension(25,25));
pane.add(n);
pane.add(scoreUI);
j.pack();
j.setVisible(true);
wrt.flush();
}
}