Chris@2
|
1 /* Performance Worm: Visualisation of Expressive Musical Performance
|
Chris@2
|
2 Copyright (C) 2001, 2006 by Simon Dixon
|
Chris@2
|
3
|
Chris@2
|
4 This program is free software; you can redistribute it and/or modify
|
Chris@2
|
5 it under the terms of the GNU General Public License as published by
|
Chris@2
|
6 the Free Software Foundation; either version 2 of the License, or
|
Chris@2
|
7 (at your option) any later version.
|
Chris@2
|
8
|
Chris@2
|
9 This program is distributed in the hope that it will be useful,
|
Chris@2
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@2
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@2
|
12 GNU General Public License for more details.
|
Chris@2
|
13
|
Chris@2
|
14 You should have received a copy of the GNU General Public License along
|
Chris@2
|
15 with this program (the file gpl.txt); if not, download it from
|
Chris@2
|
16 http://www.gnu.org/licenses/gpl.txt or write to the
|
Chris@2
|
17 Free Software Foundation, Inc.,
|
Chris@2
|
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
Chris@2
|
19 */
|
Chris@2
|
20
|
Chris@2
|
21 package at.ofai.music.worm;
|
Chris@2
|
22
|
Chris@2
|
23 import javax.swing.JButton;
|
Chris@2
|
24 import javax.swing.JDialog;
|
Chris@2
|
25 import javax.swing.JLabel;
|
Chris@2
|
26 import javax.swing.JPanel;
|
Chris@2
|
27 import java.awt.Container;
|
Chris@2
|
28 import java.awt.Dimension;
|
Chris@2
|
29 import java.awt.GridLayout;
|
Chris@2
|
30 import java.awt.TextField;
|
Chris@2
|
31 import java.awt.event.ActionEvent;
|
Chris@2
|
32 import java.awt.event.ActionListener;
|
Chris@2
|
33 import java.awt.event.TextEvent;
|
Chris@2
|
34 import java.awt.event.TextListener;
|
Chris@2
|
35
|
Chris@2
|
36 import at.ofai.music.util.FrameMargins;
|
Chris@2
|
37
|
Chris@2
|
38 class WormLoadDialog extends JDialog {
|
Chris@2
|
39
|
Chris@2
|
40 static final long serialVersionUID = 0;
|
Chris@2
|
41
|
Chris@2
|
42 class MyButton extends JButton {
|
Chris@2
|
43
|
Chris@2
|
44 static final long serialVersionUID = 0;
|
Chris@2
|
45 public MyButton(String text, ActionListener al) {
|
Chris@2
|
46 super(text);
|
Chris@2
|
47 setBackground(WormConstants.buttonColor);
|
Chris@2
|
48 setForeground(WormConstants.buttonTextColor);
|
Chris@2
|
49 addActionListener(al);
|
Chris@2
|
50 }
|
Chris@2
|
51 } // inner class MyButton
|
Chris@2
|
52
|
Chris@2
|
53 class MyTextField extends TextField {
|
Chris@2
|
54
|
Chris@2
|
55 static final long serialVersionUID = 0;
|
Chris@2
|
56 public MyTextField(String text, TextListener tl) {
|
Chris@2
|
57 super(text);
|
Chris@2
|
58 setBackground(WormConstants.buttonColor);
|
Chris@2
|
59 setForeground(WormConstants.buttonTextColor);
|
Chris@2
|
60 addTextListener(tl);
|
Chris@2
|
61 }
|
Chris@2
|
62
|
Chris@2
|
63 } // inner class MyTextField
|
Chris@2
|
64
|
Chris@2
|
65 class MyLabel extends JLabel {
|
Chris@2
|
66
|
Chris@2
|
67 static final long serialVersionUID = 0;
|
Chris@2
|
68 public MyLabel(String text) {
|
Chris@2
|
69 super(text);
|
Chris@2
|
70 setForeground(WormConstants.buttonTextColor);
|
Chris@2
|
71 }
|
Chris@2
|
72
|
Chris@2
|
73 } // inner class MyLabel
|
Chris@2
|
74
|
Chris@2
|
75 Worm worm;
|
Chris@2
|
76 TextField inputFileField, matchFileField, wormFileField, timingOffsetField,
|
Chris@2
|
77 synchronisationField;
|
Chris@2
|
78 JButton inputFileButton, matchFileButton, wormFileButton, cancelButton,
|
Chris@2
|
79 okButton;
|
Chris@2
|
80 MyFileChooser chooser;
|
Chris@2
|
81
|
Chris@2
|
82 public WormLoadDialog(Worm w) {
|
Chris@2
|
83 super(w.theFrame, "Input Data", true);
|
Chris@2
|
84 worm = w;
|
Chris@2
|
85 worm.stop();
|
Chris@2
|
86 chooser = new MyFileChooser();
|
Chris@2
|
87 inputFileField = new MyTextField(worm.getInputFile(),new TextListener(){
|
Chris@2
|
88 public void textValueChanged(TextEvent e) {
|
Chris@2
|
89 worm.setInputFile(inputFileField.getText());
|
Chris@2
|
90 worm.clearWormFile();
|
Chris@2
|
91 }
|
Chris@2
|
92 });
|
Chris@2
|
93 matchFileField = new MyTextField(worm.getMatchFile(),new TextListener(){
|
Chris@2
|
94 public void textValueChanged(TextEvent e) {
|
Chris@2
|
95 worm.setMatchFile(matchFileField.getText());
|
Chris@2
|
96 }
|
Chris@2
|
97 });
|
Chris@2
|
98 wormFileField = new MyTextField(worm.getWormFileName(),
|
Chris@2
|
99 new TextListener() {
|
Chris@2
|
100 public void textValueChanged(TextEvent e) {
|
Chris@2
|
101 worm.setWormFile(wormFileField.getText());
|
Chris@2
|
102 }
|
Chris@2
|
103 }
|
Chris@2
|
104 );
|
Chris@2
|
105 timingOffsetField = new MyTextField(worm.getTimingOffsetString(),
|
Chris@2
|
106 new TextListener() {
|
Chris@2
|
107 public void textValueChanged(TextEvent e) {
|
Chris@2
|
108 worm.setTimingOffsetString(timingOffsetField.getText());
|
Chris@2
|
109 }
|
Chris@2
|
110 }
|
Chris@2
|
111 );
|
Chris@2
|
112 synchronisationField = new MyTextField(worm.getFileDelayString(),
|
Chris@2
|
113 new TextListener() {
|
Chris@2
|
114 public void textValueChanged(TextEvent e) {
|
Chris@2
|
115 worm.setFileDelayString(synchronisationField.getText());
|
Chris@2
|
116 }
|
Chris@2
|
117 }
|
Chris@2
|
118 );
|
Chris@2
|
119 inputFileButton = new MyButton("Browse", new ActionListener() {
|
Chris@2
|
120 public void actionPerformed(ActionEvent e) {
|
Chris@2
|
121 worm.setInputFile(chooser.browseOpen(inputFileField,
|
Chris@2
|
122 MyFileFilter.waveFilter));
|
Chris@2
|
123 }
|
Chris@2
|
124 });
|
Chris@2
|
125 matchFileButton = new MyButton("Browse", new ActionListener() {
|
Chris@2
|
126 public void actionPerformed(ActionEvent e) {
|
Chris@2
|
127 worm.setMatchFile(chooser.browseOpen(matchFileField,
|
Chris@2
|
128 MyFileFilter.matchFilter));
|
Chris@2
|
129 }
|
Chris@2
|
130 });
|
Chris@2
|
131 wormFileButton = new MyButton("Browse", new ActionListener() {
|
Chris@2
|
132 public void actionPerformed(ActionEvent e) {
|
Chris@2
|
133 worm.setWormFile(chooser.browseOpen(wormFileField,
|
Chris@2
|
134 MyFileFilter.wormFilter));
|
Chris@2
|
135 }
|
Chris@2
|
136 });
|
Chris@2
|
137 cancelButton = new MyButton("OK", new ActionListener() {
|
Chris@2
|
138 public void actionPerformed(ActionEvent e) {
|
Chris@2
|
139 setVisible(false);
|
Chris@2
|
140 }
|
Chris@2
|
141 });
|
Chris@2
|
142 okButton = new MyButton("OK", new ActionListener() {
|
Chris@2
|
143 public void actionPerformed(ActionEvent e) {
|
Chris@2
|
144 setVisible(false);
|
Chris@2
|
145 }
|
Chris@2
|
146 });
|
Chris@2
|
147 Container cp = getContentPane();
|
Chris@2
|
148 cp.setLayout(null);
|
Chris@2
|
149 JPanel p1 = new JPanel(new GridLayout(5,1));
|
Chris@2
|
150 JPanel p2 = new JPanel(new GridLayout(5,1));
|
Chris@2
|
151 JPanel p3 = new JPanel(new GridLayout(5,1));
|
Chris@2
|
152 JLabel inputLabel = new MyLabel("Input file: ");
|
Chris@2
|
153 JLabel matchLabel = new MyLabel("Match file: ");
|
Chris@2
|
154 JLabel wormLabel = new MyLabel("Worm file: ");
|
Chris@2
|
155 JLabel timingOffsetLabel = new MyLabel("Match/Audio Offset: ");
|
Chris@2
|
156 JLabel synchronisationLabel = new MyLabel("Synchronisation: ");
|
Chris@2
|
157 cp.setBackground(WormConstants.buttonColor);
|
Chris@2
|
158 p1.setBackground(WormConstants.buttonColor);
|
Chris@2
|
159 p1.add(inputLabel);
|
Chris@2
|
160 p2.add(inputFileField);
|
Chris@2
|
161 p3.add(inputFileButton);
|
Chris@2
|
162 p1.add(matchLabel);
|
Chris@2
|
163 p2.add(matchFileField);
|
Chris@2
|
164 p3.add(matchFileButton);
|
Chris@2
|
165 p1.add(wormLabel);
|
Chris@2
|
166 p2.add(wormFileField);
|
Chris@2
|
167 p3.add(wormFileButton);
|
Chris@2
|
168 p1.add(timingOffsetLabel);
|
Chris@2
|
169 p2.add(timingOffsetField);
|
Chris@2
|
170 p3.add(cancelButton);
|
Chris@2
|
171 p1.add(synchronisationLabel);
|
Chris@2
|
172 p2.add(synchronisationField);
|
Chris@2
|
173 p3.add(okButton);
|
Chris@2
|
174 p1.setBounds(10,5,130,150);
|
Chris@2
|
175 p2.setBounds(150,5,500,150);
|
Chris@2
|
176 p3.setBounds(660,5,100,150);
|
Chris@2
|
177 cp.add(p1);
|
Chris@2
|
178 cp.add(p2);
|
Chris@2
|
179 cp.add(p3);
|
Chris@2
|
180 Dimension d = FrameMargins.get(false);
|
Chris@2
|
181 setSize(770 + d.width, 160 + d.height);
|
Chris@2
|
182 int x = w.getLocationOnScreen().x + (w.getWidth() - getWidth()) / 2;
|
Chris@2
|
183 int y = w.getLocationOnScreen().y + (w.getHeight() - getHeight()) / 2;
|
Chris@2
|
184 setLocation(x, y);
|
Chris@2
|
185 setVisible(true);
|
Chris@2
|
186 } // constructor
|
Chris@2
|
187
|
Chris@2
|
188 } // class WormLoadDialog
|