[Bluemusic-commits] SF.net SVN: bluemusic:[4200] blue/trunk/blue-ui-core/src/blue/soundObject/ edit
Brought to you by:
kunstmusik
|
From: <kun...@us...> - 2010-04-07 02:48:57
|
Revision: 4200
http://bluemusic.svn.sourceforge.net/bluemusic/?rev=4200&view=rev
Author: kunstmusik
Date: 2010-04-07 02:48:51 +0000 (Wed, 07 Apr 2010)
Log Message:
-----------
made scale selection panel not have a dependency on PianoRoll so that it can be used by other parts of application
Modified Paths:
--------------
blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/PianoRollPropertiesEditor.java
blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/ScaleSelectionPanel.java
Modified: blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/PianoRollPropertiesEditor.java
===================================================================
--- blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/PianoRollPropertiesEditor.java 2010-04-07 02:42:46 UTC (rev 4199)
+++ blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/PianoRollPropertiesEditor.java 2010-04-07 02:48:51 UTC (rev 4200)
@@ -223,6 +223,15 @@
this.setViewportView(mainPanel);
this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.setBorder(null);
+
+ scalePanel.addChangeListener(new ChangeListener() {
+
+ public void stateChanged(ChangeEvent e) {
+ if (p != null) {
+ p.setScale(scalePanel.getScale());
+ }
+ }
+ });
}
/**
@@ -294,7 +303,7 @@
instrumentIDText.setText(p.getInstrumentId());
baseFrequencyText.setText(Float.toString(p.getScale()
.getBaseFrequency()));
- scalePanel.editPianoRoll(p);
+ scalePanel.setScale(p.getScale());
if (p.getPchGenerationMethod() == PianoRoll.GENERATE_FREQUENCY) {
frequencyOption.setSelected(true);
Modified: blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/ScaleSelectionPanel.java
===================================================================
--- blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/ScaleSelectionPanel.java 2010-04-07 02:42:46 UTC (rev 4199)
+++ blue/trunk/blue-ui-core/src/blue/soundObject/editor/pianoRoll/ScaleSelectionPanel.java 2010-04-07 02:48:51 UTC (rev 4200)
@@ -30,24 +30,24 @@
import javax.swing.JTextField;
import blue.BlueSystem;
-import blue.soundObject.PianoRoll;
import blue.soundObject.pianoRoll.Scale;
import blue.ui.utilities.FileChooserManager;
+import java.util.Vector;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
-/**
- * @author steven
- *
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
- */
public class ScaleSelectionPanel extends JComponent {
public static String FILE_CHOOSER_ID = "scaleSelectionPanel";
JTextField fileNameField = new JTextField();
- PianoRoll p = null;
+ Scale scale = null;
+ Vector<ChangeListener> changeListeners = null;
+
+ ChangeEvent c = null;
+
public ScaleSelectionPanel() {
this.setLayout(new BorderLayout());
@@ -58,28 +58,24 @@
public void actionPerformed(ActionEvent e) {
- int rValue = FileChooserManager.getDefault().showOpenDialog(FILE_CHOOSER_ID,
+ int rValue = FileChooserManager.getDefault().showOpenDialog(
+ FILE_CHOOSER_ID,
null);
if (rValue == JFileChooser.APPROVE_OPTION) {
- File f = FileChooserManager.getDefault()
- .getSelectedFile(FILE_CHOOSER_ID);
+ File f = FileChooserManager.getDefault().getSelectedFile(
+ FILE_CHOOSER_ID);
if (!f.exists()) {
return;
}
- Scale scale = Scale.loadScale(f);
+ scale = Scale.loadScale(f);
- // TODO - clear notes if new scale
-
- p.setScale(scale);
-
updateDisplay();
-
+ fireChangeEvent();
}
}
-
});
fileNameField.setEditable(false);
@@ -95,8 +91,8 @@
return;
}
- fcm.setDialogTitle(FILE_CHOOSER_ID, BlueSystem
- .getString("pianoRoll.selectScalaFile"));
+ fcm.setDialogTitle(FILE_CHOOSER_ID, BlueSystem.getString(
+ "pianoRoll.selectScalaFile"));
fcm.addFilter(FILE_CHOOSER_ID, new ScalaFileFilter());
// SET DEFAULT DIR
@@ -110,13 +106,48 @@
}
}
- public void editPianoRoll(PianoRoll p) {
- this.p = p;
- updateDisplay();
+ public void setScale(Scale scale) {
+ this.scale = scale;
}
+ public Scale getScale() {
+ return this.scale;
+ }
+
private void updateDisplay() {
- fileNameField.setText(p.getScale().getScaleName());
+ if (scale == null) {
+ fileNameField.setText("");
+ } else {
+ fileNameField.setText(scale.getScaleName());
+ }
}
+ // change listener methods
+ public void addChangeListener(ChangeListener cl) {
+ if (changeListeners == null) {
+ changeListeners = new Vector<ChangeListener>();
+ }
+ changeListeners.add(cl);
+ }
+
+ public void removeChangeListener(ChangeListener cl) {
+ if (changeListeners != null) {
+ changeListeners.remove(cl);
+ }
+ }
+
+ protected void fireChangeEvent() {
+
+ if (changeListeners == null) {
+ return;
+ }
+
+ if (c == null) {
+ c = new ChangeEvent(this);
+ }
+
+ for (ChangeListener cl : changeListeners) {
+ cl.stateChanged(c);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|