Package com.softsynth.jmsl.view
Class MusicShapeEditor
java.lang.Object
com.softsynth.jmsl.view.PVPanelAdapter
com.softsynth.jmsl.view.MusicShapeEditor
- All Implemented Interfaces:
PVComponent
,PVPanel
,PlayLurker
,java.awt.event.ActionListener
,java.awt.event.ItemListener
,java.util.EventListener
- Direct Known Subclasses:
ScoreMusicShapeEditor
public class MusicShapeEditor extends PVPanelAdapter implements java.awt.event.ItemListener, java.awt.event.ActionListener, PlayLurker
View MusicShapes and manipulate their data with the mouse.
NOTE: Since JMSL v103, MusicShapeEditor adds the getComponent() method. Use this to access component panel for layout.
OLD: myContainer.add(myMusicShapeEditor); // broken since v103
NEW: myContainer.add(myMusicShapeEditor.getComponent);
NOTE: Since JMSL v103, MusicShapeEditor adds the getComponent() method. Use this to access component panel for layout.
OLD: myContainer.add(myMusicShapeEditor); // broken since v103
NEW: myContainer.add(myMusicShapeEditor.getComponent);
-
New features 11/30/06
- Additional constructors permit the specification of startup values font, zoom, lock to int, show grid
- Non-modal editing
- Add your own MusicShapeEditorOperators to a MusicShapeEditor. These be used to modify MusicShape data.
- Hold ALT key down and drag mouse left of the left margin or right of the right margin and new elements will be inserted or appended
- getUserPanel() allows you to populate a panel with your own components. Example shown below:
// user panel example final MusicShapeEditor se2 = new MusicShapeEditor("I am another MusicShapeEditor", 600, 100, Color.cyan, new Font( "Times-Roman", Font.ITALIC, 16), DRAW_EDIT, 4.0, false, true); final PVButton launcherButton = JMSL.getViewFactory().createButton("Launch"); final PVButton finisherButton = JMSL.getViewFactory().createButton("Finish"); finisherButton.setEnabled(false); launcherButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { MusicShape shapeToLaunch = se2.getMusicShape(); System.out.println("Launching " + shapeToLaunch.getName()); shapeToLaunch.launch(JMSL.now()); launcherButton.setEnabled(false); finisherButton.setEnabled(true); } }); finisherButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { MusicShape shapeToLaunch = se2.getMusicShape(); System.out.println("Finishing " + shapeToLaunch.getName()); shapeToLaunch.finish(); launcherButton.setEnabled(true); finisherButton.setEnabled(false); } }); PVPanel myUserPanel = se2.getUserPanel(); myUserPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); myUserPanel.add(new PVLabelAdapter("My User Panel").getComponent()); myUserPanel.add(launcherButton.getComponent()); myUserPanel.add(finisherButton.getComponent());
- Author:
- Nick Didkovsky and Phil Burk
(C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom. - See Also:
RetrogradeMusicShapeEditorOperator
,ScrambleMusicShapeEditorOperator
,RandomizeMusicShapeEditorOperator
-
Field Summary
Fields Modifier and Type Field Description static int
DRAW_EDIT
static int
RANGE_SELECT
static int
SAFE
static int
ZOOMING
-
Constructor Summary
Constructors Constructor Description MusicShapeEditor()
Construct a new Music Shape Editor with default title, width, height, and colorMusicShapeEditor(java.lang.String title)
Construct a new Music Shape Editor with default width, height, and colorMusicShapeEditor(java.lang.String title, int w, int h)
Construct a new Music Shape Editor with default colorMusicShapeEditor(java.lang.String title, int w, int h, java.awt.Color color)
MusicShapeEditor(java.lang.String title, int w, int h, java.awt.Color color, java.awt.Font font, double zoom, boolean lockToInt, boolean showGrid)
Construct a new MusicShape Editor with specified startup values. -
Method Summary
Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent ev)
void
addMusicShape(MusicShape s)
Add a MusicShape to the MusicShape Editor's list of MusicShapesvoid
addMusicShapeEditorOperator(MusicShapeEditorOperator op)
static int
bufferSize()
void
buildUserPanel()
override this in subclass.void
clear()
Remove all MusicShapes from Editorstatic void
clearBuffer()
remove all MusicShapes from static buffervoid
elementEditedOrYChanged(int index, double value)
Respond to an element being editedstatic MusicShape
fromBuffer(int n)
double
getCeiling()
get the max threshold value set by the user, scaled to the values meaningful to currently displayed musicshape's currently dimension, clipped to current dimension's limitsint
getDimension()
int
getEditMode()
double
getFloor()
get the min threshold value set by the user, scaled to the values meaningful to currently displayed musicshape's currently dimension, clipped to current dimension's limitsjava.awt.Font
getFont()
double
getInvert()
get the inversion value set by the user (drawn in magenta), scaled to the values meaningful to currently displayed musicshape's currently displayed dimension.boolean
getLockedToInt()
MusicShape
getMusicShape()
java.util.Vector
getMusicShapes()
int
getRangeEndIndex()
int
getRangeStartIndex()
PVPanel
getUserPanel()
This is an empty PVPanel which is at the very bottom of the layout, below the musicshape and dimension choices.double
getV1()
double
getV2()
double
getV3()
void
itemStateChanged(java.awt.event.ItemEvent e)
static void
main(java.lang.String[] args)
Test MusicShapeEditor by adding a couple of them to a PortView Frame (PortView Frames can be either AWT or Swing
Source:void
notifyPlayLurker(double playTime, MusicJob list, int index)
void
refresh()
void
removeMusicShapeRangeOperator(MusicShapeEditorOperator op)
void
repackParent()
run up the parent component hierarchy until you get null or you get a Window, then pack() the Windowvoid
repaint()
void
reset()
force recalculation of MusicShape drawing parameters.void
setFont(java.awt.Font font)
void
setRange(int startIndex, int endIndex)
void
setZoom(double zoom)
void
showMessage(java.lang.String msg)
static void
toBuffer(MusicShape s)
adds a copy of MusicShape to static bufferstatic void
toBuffer(MusicShape s, int n)
puts copy of MusicShape into nth position of buffer vector.void
updateMinMaxLabels()
Methods inherited from class com.softsynth.jmsl.view.PVPanelAdapter
add, add, addKeyListener, equals, getBackground, getBounds, getComponent, getLocation, getParent, hashCode, isEnabled, remove, removeAll, removeKeyListener, setBackground, setEnabled, setLayout, setLocation, setVisible, toString, validate
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
SAFE
public static final int SAFE- See Also:
- Constant Field Values
-
DRAW_EDIT
public static final int DRAW_EDIT- See Also:
- Constant Field Values
-
RANGE_SELECT
public static final int RANGE_SELECT- See Also:
- Constant Field Values
-
ZOOMING
public static final int ZOOMING- See Also:
- Constant Field Values
-
-
Constructor Details
-
MusicShapeEditor
public MusicShapeEditor(java.lang.String title, int w, int h, java.awt.Color color, java.awt.Font font, double zoom, boolean lockToInt, boolean showGrid)Construct a new MusicShape Editor with specified startup values. Note that editMode is one of SAFE, POINT_EDIT, DRAW_EDIT -
MusicShapeEditor
public MusicShapeEditor(java.lang.String title, int w, int h, java.awt.Color color) -
MusicShapeEditor
public MusicShapeEditor(java.lang.String title, int w, int h)Construct a new Music Shape Editor with default color -
MusicShapeEditor
public MusicShapeEditor(java.lang.String title)Construct a new Music Shape Editor with default width, height, and color -
MusicShapeEditor
public MusicShapeEditor()Construct a new Music Shape Editor with default title, width, height, and color
-
-
Method Details
-
toBuffer
adds a copy of MusicShape to static buffer -
fromBuffer
- Returns:
- MusicShape in static buffer's nth position
- Throws:
java.lang.IndexOutOfBoundsException
- if n>= buffer.size()
-
toBuffer
puts copy of MusicShape into nth position of buffer vector.- Throws:
IndexOutpuBoundsException
- if n>= buffer.size()
-
clearBuffer
public static void clearBuffer()remove all MusicShapes from static buffer -
bufferSize
public static int bufferSize() -
repackParent
public void repackParent()run up the parent component hierarchy until you get null or you get a Window, then pack() the Window -
notifyPlayLurker
- Specified by:
notifyPlayLurker
in interfacePlayLurker
-
getEditMode
public int getEditMode() -
addMusicShapeEditorOperator
-
removeMusicShapeRangeOperator
-
addMusicShape
Add a MusicShape to the MusicShape Editor's list of MusicShapes -
getMusicShapes
public java.util.Vector getMusicShapes()- Returns:
- Vector of all MusicShapes in this MusicShapeEditor
-
getMusicShape
- Returns:
- MusicShape currently in editor
-
elementEditedOrYChanged
public void elementEditedOrYChanged(int index, double value)Respond to an element being edited -
clear
public void clear()Remove all MusicShapes from Editor -
repaint
public void repaint() -
updateMinMaxLabels
public void updateMinMaxLabels() -
refresh
public void refresh() -
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
-
setZoom
public void setZoom(double zoom) -
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent ev)- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
getLockedToInt
public boolean getLockedToInt()- Returns:
- lockedToIntCheckbox.getState(), causes new Y position to jump to nearest integer
-
getFont
public java.awt.Font getFont()- Specified by:
getFont
in interfacePVComponent
- Overrides:
getFont
in classPVPanelAdapter
-
setFont
public void setFont(java.awt.Font font)- Specified by:
setFont
in interfacePVComponent
- Overrides:
setFont
in classPVPanelAdapter
-
getUserPanel
This is an empty PVPanel which is at the very bottom of the layout, below the musicshape and dimension choices. Get this and add your own components to it.- Returns:
- PVPanel
-
buildUserPanel
public void buildUserPanel()override this in subclass. getUserPanel() is valid by the time this is called, and is an empty PVPanel -
getRangeStartIndex
public int getRangeStartIndex() -
getRangeEndIndex
public int getRangeEndIndex() -
getDimension
public int getDimension()- Returns:
- currently displayed dimension
-
getFloor
public double getFloor()get the min threshold value set by the user, scaled to the values meaningful to currently displayed musicshape's currently dimension, clipped to current dimension's limits- Returns:
- floor
-
getCeiling
public double getCeiling()get the max threshold value set by the user, scaled to the values meaningful to currently displayed musicshape's currently dimension, clipped to current dimension's limits- Returns:
- ceiling
-
getInvert
public double getInvert()get the inversion value set by the user (drawn in magenta), scaled to the values meaningful to currently displayed musicshape's currently displayed dimension.- Returns:
- values of megenta horizontal line representing a value about which you may invert
-
getV1
public double getV1()- Returns:
- value entered in v1 textfield
-
getV2
public double getV2()- Returns:
- value entered in v2 textfield
-
getV3
public double getV3()- Returns:
- value entered in v3 textfield
-
reset
public void reset()force recalculation of MusicShape drawing parameters. Use after adding or deleting elements, for example -
setRange
public void setRange(int startIndex, int endIndex) -
main
public static void main(java.lang.String[] args)Test MusicShapeEditor by adding a couple of them to a PortView Frame (PortView Frames can be either AWT or Swing
Source:
public static void main(String args[]) { boolean swing = false; if (swing) JMSL.setViewFactory(new com.didkovsky.portview.swing.ViewFactorySwing()); else JMSL.setViewFactory(new com.didkovsky.portview.awt.ViewFactoryAWT()); PVFrame f = new PVFrameAdapter("MusicShapeEditors are Panels for viewing/editing MusicShapes"); f.setFrameLayout(new GridLayout(0, 1, 10, 10)); f.setBackground(Color.black); MusicShapeEditor se1 = new MusicShapeEditor("I am a MusicShapeEditor", 600, 100); MusicShapeEditor se2 = new MusicShapeEditor("I am another MusicShapeEditor", 600, 100, Color.cyan); MusicShape s1 = new MusicShape(4); MusicShape s2 = new MusicShape(4); MusicShape s3 = new MusicShape(4); s1.prefab(); s2.prefab(); s3.prefab(); // s2.setDimensionName(2, "ampy"); se1.addMusicShape(s1); se1.addMusicShape(s2); se2.addMusicShape(s3); f.add(se1.getComponent()); f.add(se2.getComponent()); f.pack(); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }
-
showMessage
public void showMessage(java.lang.String msg)
-