public class MooDialog extends JDialog {
- private JLabel labelA, labelB, labelC, labelD, labelE, labelF;
- private JTextField textFieldA, textFieldB, textFieldC, textFieldD, textFieldE, textFieldF;
- private JTextField textFieldG, textFieldH, textFieldI, textFieldJ, textFieldK;
+ private Container pane;
+ private Track[] tracks;
+
+ private JLabel labelA, labelB, labelC, labelD, labelE, labelF, labelG, labelH;
+ private JTextField textFieldA, textFieldB, textFieldC, textFieldD, textFieldE,
+ textFieldF, textFieldG, textFieldH, textFieldI, textFieldJ,
+ textFieldK;
private JComboBox trackListA, trackListB;
private JButton okButton, cancelButton;
public static final int ADD_TRACK = 1,
MANUAL = 6,
INSERT_MEASURE = 7,
DELETE_MEASURE = 8,
- SET_TEMPO = 9;
+ SET_TEMPO = 9,
+ PREFERENCES = 10,
+ TRANSPOSE = 11,
+ SCALE_VELOCITY = 12,
+ RECORD = 13;
+ public static final String[] noteSizes = {"Whole", "Half", "Quarter", "Eighth", "Sixteenth"};
/**
* Constructor of the dialogs.
public MooDialog(int type) {
super(Moosique.getGUI(), false);
- Container pane = getContentPane();
+ pane = getContentPane();
pane.setLayout(null);
- Track[] tracks = Moosique.getSequence().getTracks();
+ tracks = Moosique.getSequence().getTracks();
switch (type) {
- case ADD_TRACK: makeAddDialog(pane, tracks); break;
- case DELETE_TRACK: makeDelDialog(pane, tracks); break;
- case COPY_TRACK: makeCopyDialog(pane, tracks); break;
- case MOVE_TRACK: makeMoveDialog(pane, tracks); break;
- case SET_POSITION: makeSetPositionDialog(pane); break;
- case MANUAL: makeTextDialog(pane, "Manual.txt"); break;
- case INSERT_MEASURE: makeInsertMeasureDialog(pane); break;
- case DELETE_MEASURE: makeDeleteMeasureDialog(pane); break;
- case SET_TEMPO: makeSetTempoDialog(pane); break;
+ case ADD_TRACK: makeAddDialog(); break;
+ case DELETE_TRACK: makeDelDialog(); break;
+ case COPY_TRACK: makeCopyDialog(); break;
+ case MOVE_TRACK: makeMoveDialog(); break;
+ case SET_POSITION: makeSetPositionDialog(); break;
+ case MANUAL: makeTextDialog("User Manual", "Manual.txt", 30, 95); break;
+ case INSERT_MEASURE: makeInsertMeasureDialog(); break;
+ case DELETE_MEASURE: makeDeleteMeasureDialog(); break;
+ case SET_TEMPO: makeSetTempoDialog(); break;
+ case PREFERENCES: makePrefsDialog(); break;
+ case TRANSPOSE: makeTransposeDialog(); break;
+ case SCALE_VELOCITY: makeScaleVelocityDialog(); break;
+ case RECORD: makeRecordDialog(); break;
}
}
* @param pane The container to put the dialog in.
* @param tracks A array containing miditracks.
*/
- private void makeAddDialog(Container pane, Track[] tracks) {
-
+ private void makeAddDialog() {
setTitle("Add track");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Name of track", JLabel.CENTER);
pane.add(labelA);
+ // textfield for naming track
textFieldA = new JTextField();
pane.add(textFieldA);
labelB = new JLabel("Add after", JLabel.CENTER);
pane.add(labelB);
+ // list of where to add track
trackListA = new JComboBox();
- for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ for (int i = 1; i < tracks.length; i++) trackListA.addItem("Track " + i);
pane.add(trackListA);
+ // ok and cancel button
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layout prop
labelA.setBounds(50, 10, 100, 20);
textFieldA.setBounds(40, 35, 120, 20);
labelB.setBounds(50, 70, 100, 20);
trackListA.setBounds(40, 95, 120, 20);
cancelButton.setBounds(10, 150, 80, 30);
okButton.setBounds(120, 150, 60, 30);
-
setResizable(false);
pack();
setSize(200,220);
* @param pane The container to put the dialog in.
* @param tracks A array containing miditracks.
*/
- private void makeDelDialog(Container pane, Track[] tracks) {
-
+ private void makeDelDialog() {
setTitle("Delete track");
+ // create the contents of the dialog and add to container
labelB = new JLabel("Delete track", JLabel.CENTER);
pane.add(labelB);
+ // list of what track to delete
trackListA = new JComboBox();
for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
pane.add(trackListA);
+ // ok and cancelbutton
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layout prop
labelB.setBounds(50, 10, 100, 20);
trackListA.setBounds(40, 35, 120, 20);
cancelButton.setBounds(10, 90, 80, 30);
okButton.setBounds(120, 90, 60, 30);
-
setResizable(false);
pack();
setSize(200,165);
* @param pane The container to put the dialog in.
* @param tracks A array containing miditracks.
*/
- private void makeCopyDialog(Container pane, Track[] tracks) {
-
+ private void makeCopyDialog() {
setTitle("Copy Track");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Track to copy", JLabel.CENTER);
pane.add(labelA);
+ // list of what track to copy
trackListA = new JComboBox();
for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
pane.add(trackListA);
labelB = new JLabel("Insert after", JLabel.CENTER);
pane.add(labelB);
+ // list of where to put copied track
trackListB = new JComboBox();
for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
pane.add(trackListB);
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layout prop
labelA.setBounds(50, 10, 100, 20);
trackListA.setBounds(40, 35, 120, 20);
labelB.setBounds(50, 70, 100, 20);
trackListB.setBounds(40, 95, 120, 20);
cancelButton.setBounds(10, 150, 80, 30);
okButton.setBounds(120, 150, 60, 30);
-
setResizable(false);
pack();
setSize(200,220);
* @param pane The container to put the dialog in.
* @param tracks A array containing miditracks.
*/
- private void makeMoveDialog(Container pane, Track[] tracks) {
-
+ private void makeMoveDialog() {
setTitle("Move track");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Track to move", JLabel.CENTER);
pane.add(labelA);
+ // list of track to move
trackListA = new JComboBox();
for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
pane.add(trackListA);
labelB = new JLabel("Insert after", JLabel.CENTER);
pane.add(labelB);
+ // list of where to put moved track
trackListB = new JComboBox();
for (int i = 1; i <= tracks.length; i++) trackListB.addItem("Track " + i);
pane.add(trackListB);
+ // ok and cancelbuttons
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layoutprop
labelA.setBounds(40, 10, 120, 20);
trackListA.setBounds(40, 35, 120, 20);
labelB.setBounds(50, 70, 100, 20);
trackListB.setBounds(40, 95, 120, 20);
cancelButton.setBounds(10, 150, 80, 30);
okButton.setBounds(120, 150, 60, 30);
-
setResizable(false);
pack();
setSize(200,220);
* @param pane The container to put the dialog in.
* @param tracks A array containing miditracks.
*/
- private void makeSetPositionDialog(Container pane) {
+ private void makeSetPositionDialog() {
setTitle("Set edit position");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Measure", JLabel.CENTER);
pane.add(labelA);
labelB = new JLabel("Beat", JLabel.CENTER);
pane.add(textFieldB);
textFieldC = new JTextField();
pane.add(textFieldC);
+ // ok and cancel buttons
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layoutprop
labelA.setBounds(40, 25, 50, 20);
labelB.setBounds(105, 25, 50, 20);
labelC.setBounds(170, 25, 50, 20);
textFieldC.setBounds(170, 45, 50, 20);
cancelButton.setBounds(35, 90, 80, 30);
okButton.setBounds(155, 90, 60, 30);
-
setResizable(false);
pack();
setSize(260,165);
* Builds the insert measure popupdialog.
* @param pane The container to put the dialog in.
*/
- private void makeInsertMeasureDialog(Container pane){
-
+ private void makeInsertMeasureDialog(){
setTitle("Insert Measure");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Insert at:", JLabel.RIGHT);
pane.add(labelA);
labelB = new JLabel("Measure count:", JLabel.RIGHT);
pane.add(textFieldA);
textFieldB = new JTextField();
pane.add(textFieldB);
+ // ok and cancelbutton
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layout prop
labelA.setBounds(20, 20, 110 ,20);
labelB.setBounds(20, 50, 110, 20);
textFieldA.setBounds(140 ,20 , 40, 20);
textFieldB.setBounds(140,50, 40, 20);
cancelButton.setBounds(20 ,95 , 80, 30);
okButton.setBounds(120, 95, 60, 30);
-
setResizable(false);
pack();
setSize(210,175);
* Builds the delete measure popupdialog.
* @param pane The container to put the dialog in.
*/
- private void makeDeleteMeasureDialog(Container pane) {
-
+ private void makeDeleteMeasureDialog() {
setTitle("Delete Measure");
+ // create the contents of the dialog and add to container
labelA = new JLabel("Delete at:", JLabel.RIGHT);
pane.add(labelA);
labelB = new JLabel("Measure count:", JLabel.RIGHT);
pane.add(textFieldA);
textFieldB = new JTextField();
pane.add(textFieldB);
+ // ok and cancelbutton
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set layout prop
labelA.setBounds(20, 20, 110 ,20);
labelB.setBounds(20, 50, 110, 20);
textFieldA.setBounds(140 ,20 , 40, 20);
textFieldB.setBounds(140,50, 40, 20);
cancelButton.setBounds(20 ,95 , 80, 30);
okButton.setBounds(120, 95, 60, 30);
-
setResizable(false);
pack();
setSize(210,175);
/**
* Builds the set tempo dialog.
* @param pane The container to put the dialog in.
- * @param tracks A array containing miditracks.
*/
- private void makeSetTempoDialog(Container pane) {
-
+ private void makeSetTempoDialog() {
setTitle("Set tempo");
- // creating labels and adding them to a container
+ // create contents of dialog and add to container
+ // track edit-intervall labels
labelA = new JLabel("Measure", JLabel.CENTER);
pane.add(labelA);
labelB = new JLabel("Beat", JLabel.CENTER);
pane.add(labelB);
labelC = new JLabel("Tick", JLabel.CENTER);
pane.add(labelC);
+ // start and end labels
labelD = new JLabel("Start at:", JLabel.RIGHT);
pane.add(labelD);
labelE = new JLabel("End at:", JLabel.RIGHT);
pane.add(labelE);
+ // from-to label
labelF = new JLabel("to", JLabel.CENTER);
pane.add(labelF);
-
- // the starting textfields and adding them to the container
+ // start inputvaluefields
textFieldA = new JTextField();
pane.add(textFieldA);
textFieldB = new JTextField();
pane.add(textFieldB);
textFieldC = new JTextField();
pane.add(textFieldC);
- // ending textfields and adding them to the container
+ // end inputvaluefield
textFieldD = new JTextField();
pane.add(textFieldD);
textFieldE = new JTextField();
pane.add(textFieldE);
textFieldF = new JTextField();
pane.add(textFieldF);
- // the amount to edit textfields and adding them to a container
+ // the radiobuttonlists inputvaluefields
textFieldG = new JTextField();
pane.add(textFieldG);
textFieldH = new JTextField();
pane.add(textFieldJ);
textFieldK = new JTextField();
pane.add(textFieldK);
-
- // creating the buttons and adding them to the container
+ // the radiobuttonlist with associating titles
JRadioButton constant = new JRadioButton("Set constant tempo of:");
constant.setSelected(true);
pane.add(constant);
pane.add(scale);
JRadioButton add = new JRadioButton("Add to current tempo:");
pane.add(add);
-
- // creating a buttongroup and adding the buttons above
+ // a buttongroup for the radiobuttons
ButtonGroup group = new ButtonGroup();
group.add(constant);
group.add(change);
group.add(scale);
group.add(add);
-
- // creating the cancel and ok button
+ // ok and cancelbutton
cancelButton = new JButton("Cancel");
pane.add(cancelButton);
okButton = new JButton("OK");
pane.add(okButton);
-
+ // set bounds of track edit-intervall labels
labelA.setBounds(80, 25, 50, 20);
labelB.setBounds(145, 25, 50, 20);
labelC.setBounds(210, 25, 50, 20);
+ // set bounds of start and end labels
labelD.setBounds(20, 45, 60, 20);
labelE.setBounds(20, 65, 60, 20);
+ // set bounds of from-to label
labelF.setBounds(255, 125, 20 ,20);
-
+ // set bounds of start inputvaluefields
textFieldA.setBounds(80, 45, 50, 20);
textFieldB.setBounds(145, 45, 50, 20);
textFieldC.setBounds(210, 45, 50, 20);
+ // set bounds of end inputvaluefield
textFieldD.setBounds(80, 65, 50, 20);
textFieldE.setBounds(145, 65, 50, 20);
textFieldF.setBounds(210, 65, 50, 20);
-
- textFieldG.setBounds(205, 100, 35, 20);
+ // set bounds of radiobuttonlists inputvaluefields
+ textFieldG.setBounds(220, 100, 35, 20);
textFieldH.setBounds(220, 125, 35, 20);
textFieldI.setBounds(280, 125, 35, 20);
- textFieldJ.setBounds(170, 150, 35, 20);
- textFieldK.setBounds(200, 175, 35, 20);
-
+ textFieldJ.setBounds(220, 150, 35, 20);
+ textFieldK.setBounds(220, 175, 35, 20);
+ // set bounds of radiobuttonlist items
constant.setBounds(20, 100, 180, 20);
change.setBounds(20, 125, 200, 20);
scale.setBounds(20, 150, 150, 20);
add.setBounds(20, 175, 175, 20);
-
+ // set bounds of ok and cancelbutton
cancelButton.setBounds(75, 215, 80, 30);
okButton.setBounds(195, 215, 60, 30);
-
+ // set layout prop
setResizable(false);
pack();
setSize(340,300);
setVisible(true);
}
+ /**
+ * Builds the transpose dialog.
+ * @param pane The container to put the dialog in.
+ * @param tracks A array containing miditracks.
+ */
+ private void makeTransposeDialog() {
+ setTitle("Transpose");
+ // create contents of dialog and add to container
+ // track edit-intervall labels
+ labelA = new JLabel("Measure", JLabel.CENTER);
+ pane.add(labelA);
+ labelB = new JLabel("Beat", JLabel.CENTER);
+ pane.add(labelB);
+ labelC = new JLabel("Tick", JLabel.CENTER);
+ pane.add(labelC);
+ // start and end labels
+ labelD = new JLabel("Start at:", JLabel.RIGHT);
+ pane.add(labelD);
+ labelE = new JLabel("End at:", JLabel.RIGHT);
+ pane.add(labelE);
+ // oktave inputvalue labels
+ labelF = new JLabel("Octaves", JLabel.LEFT);
+ pane.add(labelF);
+ labelG = new JLabel("1/2 octaves", JLabel.LEFT);
+ pane.add(labelG);
+ // what track to edit label
+ labelH = new JLabel("Track to edit:", JLabel.CENTER);
+ pane.add(labelH);
+ // combobox representing the tracks
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ // start inputvaluefields
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ textFieldB = new JTextField();
+ pane.add(textFieldB);
+ textFieldC = new JTextField();
+ pane.add(textFieldC);
+ // end inputvaluefield
+ textFieldD = new JTextField();
+ pane.add(textFieldD);
+ textFieldE = new JTextField();
+ pane.add(textFieldE);
+ textFieldF = new JTextField();
+ pane.add(textFieldF);
+ // the radiobuttonlists inputvaluefields
+ textFieldG = new JTextField();
+ pane.add(textFieldG);
+ textFieldH = new JTextField();
+ pane.add(textFieldH);
+ // the radiobuttonlist with associating titles
+ JRadioButton up = new JRadioButton("Change up");
+ up.setSelected(true);
+ pane.add(up);
+ JRadioButton down = new JRadioButton("Change down");
+ pane.add(down);
+ // a buttongroup for the radiobuttons
+ ButtonGroup group = new ButtonGroup();
+ group.add(up);
+ group.add(down);
+ // ok and cancelbutton
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ // set bounds of track edit-intervall labels
+ labelA.setBounds(90, 70, 50, 20);
+ labelB.setBounds(155, 70, 50, 20);
+ labelC.setBounds(220, 70, 50, 20);
+ // set bounds of start and end labels
+ labelD.setBounds(30, 90, 60, 20);
+ labelE.setBounds(30, 110, 60, 20);
+ // set bounds of octave inputvaluefields
+ labelF.setBounds(210, 150, 80, 20);
+ labelG.setBounds(210, 175, 100, 20);
+ // set bounds of trackslist label
+ labelH.setBounds(30, 30, 100, 20);
+ // set bounds of start inputvaluefields
+ textFieldA.setBounds(90, 90, 50, 20);
+ textFieldB.setBounds(155, 90, 50, 20);
+ textFieldC.setBounds(220, 90, 50, 20);
+ // set bounds of end inputvaluefield
+ textFieldD.setBounds(90, 110, 50, 20);
+ textFieldE.setBounds(155, 110, 50, 20);
+ textFieldF.setBounds(220, 110, 50, 20);
+ // set bounds of octave inputvaluefields
+ textFieldG.setBounds(170, 150, 35, 20);
+ textFieldH.setBounds(170, 175, 35, 20);
+ // set bounds of radiobuttonlist items
+ up.setBounds(30, 150, 100, 20);
+ down.setBounds(30, 175, 120, 20);
+ // set bounds of tracklist
+ trackListA.setBounds(145, 30, 120, 20);
+ // set bounds of ok and cancelbutton
+ cancelButton.setBounds(75, 215, 80, 30);
+ okButton.setBounds(195, 215, 60, 30);
+ // set layoutprop
+ setResizable(false);
+ pack();
+ setSize(340,300);
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
- private void makeTextDialog(Container pane, String filename) {
- setTitle("User Manual");
+ /**
+ * Builds the scale velocity dialog.
+ * @param pane The container to put the dialog in.
+ * @param tracks A array containing miditracks.
+ */
+ private void makeScaleVelocityDialog() {
+ setTitle("Scale velocity");
+ // create contents of dialog and add to container
+ // track edit-intervall labels
+ labelA = new JLabel("Measure", JLabel.CENTER);
+ pane.add(labelA);
+ labelB = new JLabel("Beat", JLabel.CENTER);
+ pane.add(labelB);
+ labelC = new JLabel("Tick", JLabel.CENTER);
+ pane.add(labelC);
+ // start and end labels
+ labelD = new JLabel("Start at:", JLabel.RIGHT);
+ pane.add(labelD);
+ labelE = new JLabel("End at:", JLabel.RIGHT);
+ pane.add(labelE);
+ // from-to label
+ labelF = new JLabel("to", JLabel.CENTER);
+ pane.add(labelF);
+ // what track to edit label
+ labelG = new JLabel("Track to edit:", JLabel.CENTER);
+ pane.add(labelG);
+ // combobox representing the tracks
+ trackListA = new JComboBox();
+ for (int i = 1; i <= tracks.length; i++) trackListA.addItem("Track " + i);
+ pane.add(trackListA);
+ // start inputvaluefields
+ textFieldA = new JTextField();
+ pane.add(textFieldA);
+ textFieldB = new JTextField();
+ pane.add(textFieldB);
+ textFieldC = new JTextField();
+ pane.add(textFieldC);
+ // end inputvaluefield
+ textFieldD = new JTextField();
+ pane.add(textFieldD);
+ textFieldE = new JTextField();
+ pane.add(textFieldE);
+ textFieldF = new JTextField();
+ pane.add(textFieldF);
+ // the radiobuttonlists inputvaluefields
+ textFieldG = new JTextField();
+ pane.add(textFieldG);
+ textFieldH = new JTextField();
+ pane.add(textFieldH);
+ textFieldI = new JTextField();
+ pane.add(textFieldI);
+ textFieldJ = new JTextField();
+ pane.add(textFieldJ);
+ textFieldK = new JTextField();
+ pane.add(textFieldK);
+ // the radiobuttonlist with associating titles
+ JRadioButton constant = new JRadioButton("Change all values to:");
+ constant.setSelected(true);
+ pane.add(constant);
+ JRadioButton change = new JRadioButton("Gradually change value:");
+ pane.add(change);
+ JRadioButton scale = new JRadioButton("Scale values to %:");
+ pane.add(scale);
+ JRadioButton add = new JRadioButton("Add to current value:");
+ pane.add(add);
+ // a buttongroup for the radiobuttons
+ ButtonGroup group = new ButtonGroup();
+ group.add(constant);
+ group.add(change);
+ group.add(scale);
+ group.add(add);
+ // ok and cancelbutton
+ cancelButton = new JButton("Cancel");
+ pane.add(cancelButton);
+ okButton = new JButton("OK");
+ pane.add(okButton);
+
+ // set bounds of track edit-intervall labels
+ labelA.setBounds(80, 75, 50, 20);
+ labelB.setBounds(145, 75, 50, 20);
+ labelC.setBounds(210, 75, 50, 20);
+ // set bounds of start and end labels
+ labelD.setBounds(20, 95, 60, 20);
+ labelE.setBounds(20, 115, 60, 20);
+ // set bounds of from-to label
+ labelF.setBounds(255, 175, 20 ,20);
+ // set bounds of trackslist label
+ labelG.setBounds(30, 30, 100, 20);
+ // set bounds of start inputvaluefields
+ textFieldA.setBounds(80, 95, 50, 20);
+ textFieldB.setBounds(145, 95, 50, 20);
+ textFieldC.setBounds(210, 95, 50, 20);
+ // set bounds of end inputvaluefield
+ textFieldD.setBounds(80, 115, 50, 20);
+ textFieldE.setBounds(145,115, 50, 20);
+ textFieldF.setBounds(210, 115, 50, 20);
+ // set bounds of radiobuttonlists inputvaluefields
+ textFieldG.setBounds(220, 150, 35, 20);
+ textFieldH.setBounds(220, 175, 35, 20);
+ textFieldI.setBounds(280, 175, 35, 20);
+ textFieldJ.setBounds(220, 200, 35, 20);
+ textFieldK.setBounds(220, 225, 35, 20);
+ // set bounds of radiobuttonlist items
+ constant.setBounds(20, 150, 180, 20);
+ change.setBounds(20, 175, 200, 20);
+ scale.setBounds(20, 200, 150, 20);
+ add.setBounds(20, 225, 175, 20);
+ // set bounds of tracklist
+ trackListA.setBounds(145, 30, 120, 20);
+ // set bounds of ok and cancelbutton
+ cancelButton.setBounds(75, 265, 80, 30);
+ okButton.setBounds(195, 265, 60, 30);
+ // set layout prop
+ setResizable(false);
+ pack();
+ setSize(340,350);
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+ /** creates the "User manual dialog" that displays a textfile
+ */
+ private void makeTextDialog(String title, String filename, int rows, int columns) {
+ setTitle(title);
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
File manual = new File(filename);
String s;
br.read(chars, 0, (int)manual.length());
s = new String(chars);
} catch (Exception ex) {
- s = "Manual not found";
+ s = "File not found";
}
- pane.add(new JScrollPane(new JTextArea(s, 30, 95)));
+ JTextArea text = new JTextArea(s, rows, columns);
+ text.setLineWrap(true);
+ text.setWrapStyleWord(true);
+ text.setEnabled(false);
+ text.setDisabledTextColor(Color.black);
+ pane.add(new JScrollPane(text));
Action close = new AbstractAction("Close") {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
setVisible(true);
}
+ private void makePrefsDialog() {
+ /*
+ MidiDevice.Info[] devInfo = MidiSystem.getMidiDeviceInfo();
+ for (int i = 0; i < devInfo.length; i++) {
+ if (MidiSystem.getMidiDevice(devInfo[i]) instanceof Sequencer) {
+
+ } else if (MidiSystem.getMidiDevice(devInfo[i]) instanceof Synthesizer) {
+
+ }
+ }
+ String[] seqNames, synthNames;
+ JPanel pane = (JPanel) this.getContentPane();
+ pane.add(new JLabel("Sequencer"));
+ JComboBox seqBox = new JComboBox(seqNames);
+ pane.add(new JLabel("Synthesizer"));
+ JComboBox synthBox = new JComboBox(synthNames);
+ */
+ }
+
+ private void makeRecordDialog() {
+ setTitle("Record");
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ // Creating track combo box,
+ panel.add(new Label("Track: "));
+ trackListA = new JComboBox();
+ for (int i = 1; i < tracks.length; i++) trackListA.addItem("Track " + i);
+ trackListA.setFont(Moosique.getGUI().FONT);
+ panel.add(trackListA);
+
+ // Creating channel combo box
+ panel.add(new Label("Channel: "));
+ JComboBox channelList = new JComboBox();
+ for (int i = 1; i <= 16; i++) channelList.addItem("Channel " + i);
+ channelList.setFont(Moosique.getGUI().FONT);
+ panel.add(channelList);
+
+ // Creating quantize pane
+ JLayeredPane quantizePane = new JLayeredPane();
+ quantizePane.setBorder(BorderFactory.createTitledBorder("Quantize"));
+ JCheckBox quantizeBox = new JCheckBox("Quantize");
+ quantizePane.add(quantizeBox);
+ JLabel quantizeSizeLabel = new JLabel("Resolution");
+ JComboBox quantizeSize = new JComboBox(noteSizes);
+ quantizeSize.setSelectedIndex(4);
+ quantizeSize.setEnabled(false);
+ quantizeSize.setFont(Moosique.getGUI().FONT);
+ quantizeSizeLabel.setLabelFor(quantizeSize);
+ quantizePane.add(quantizeSizeLabel);
+ quantizePane.add(quantizeSize);
+ JCheckBox quantizeLocationBox = new JCheckBox("Affect location", true);
+ quantizeLocationBox.setEnabled(false);
+ quantizePane.add(quantizeLocationBox);
+ JCheckBox quantizeDurationBox = new JCheckBox("Affect duration", true);
+ quantizeDurationBox.setEnabled(false);
+ quantizePane.add(quantizeDurationBox);
+ panel.add(quantizePane);
+
+ // Creating buttons
+ final String btnString1 = "Record!";
+ final String btnString2 = "Cancel";
+ Object[] options = {btnString1, btnString2};
+
+ // Creating option pane
+ optionPane = new JOptionPane(panel,
+ JOptionPane.QUESTION_MESSAGE,
+ JOptionPane.YES_NO_OPTION,
+ null,
+ options,
+ options[0]);
+ optionPane.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent e) {
+ String prop = e.getPropertyName();
+
+ if (isVisible() && (e.getSource() == optionPane) &&
+ (prop.equals(JOptionPane.VALUE_PROPERTY) || prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
+ Object value = optionPane.getValue();
+ if (value == JOptionPane.UNINITIALIZED_VALUE) return;
+ optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE);
+
+ if (value.equals(btnString1)) {
+ // boolean[] quantizers = {quantize, location, duration};
+ Track track = tracks[trackListA.getSelectedIndex() + 1];
+ int channel = Moosique.getGUI().getView().getTrackView(track).getTitle().getChannel();
+ boolean[] quantizers = {false, false, false};
+ int resolution = Moosique.SIXTEENTH_NOTE;
+ Moosique.record(track, channel, quantizers, resolution);
+ }
+ setVisible(false);
+ }
+ }
+ });
+ setContentPane(optionPane);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+
+ setResizable(false);
+ pack();
+ setLocationRelativeTo(Moosique.getGUI());
+ setVisible(true);
+ }
+
private MooNote note;
private JOptionPane optionPane;
private JTextField pitch;
* @param mn the note that will be graphically represented
*/
public MooDialog(MooNote mn) {
- super(Moosique.getGUI(), "Note properties", false);
+ super(Moosique.getGUI(), "Note properties", true);
+
note = mn;
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new GridLayout(3,2));
+
pitch = new JTextField(new Integer(note.getPitch()).toString(),3);
- JPanel pitchpanel = new JPanel();
- pitchpanel.add(new Label("Pitch: "));
- pitchpanel.add(pitch);
+ panel.add(new Label("Pitch: "));
+ panel.add(pitch);
velocity = new JTextField(new Integer(note.getVelocity()).toString(),3);
- JPanel velocitypanel = new JPanel();
- velocitypanel.add(new Label("Velocity: "));
- velocitypanel.add(velocity);
+ panel.add(new Label("Velocity: "));
+ panel.add(velocity);
length = new JTextField(new Integer(note.getDuration()).toString(),5);
- JPanel lengthpanel = new JPanel();
- lengthpanel.add(new Label("Length: "));
- lengthpanel.add(length);
+ panel.add(new Label("Length: "));
+ panel.add(length);
Object[] array = {"Set the note properties",
- pitchpanel,
- velocitypanel,
- lengthpanel};
+ panel};
final String btnString1 = "Apply changes";
final String btnString2 = "Cancel";
}
});
pack();
+ setLocationRelativeTo(Moosique.getGUI());
setVisible(true);
}
}