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);


    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 Details

  • 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

      public static void toBuffer​(MusicShape s)
      adds a copy of MusicShape to static buffer
    • fromBuffer

      public static MusicShape fromBuffer​(int n)
      Returns:
      MusicShape in static buffer's nth position
      Throws:
      java.lang.IndexOutOfBoundsException - if n>= buffer.size()
    • toBuffer

      public static void toBuffer​(MusicShape s, int n)
      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

      public void notifyPlayLurker​(double playTime, MusicJob list, int index)
      Specified by:
      notifyPlayLurker in interface PlayLurker
    • getEditMode

      public int getEditMode()
    • addMusicShapeEditorOperator

      public void addMusicShapeEditorOperator​(MusicShapeEditorOperator op)
    • removeMusicShapeRangeOperator

      public void removeMusicShapeRangeOperator​(MusicShapeEditorOperator op)
    • addMusicShape

      public void addMusicShape​(MusicShape s)
      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

      public MusicShape 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 interface java.awt.event.ItemListener
    • setZoom

      public void setZoom​(double zoom)
    • actionPerformed

      public void actionPerformed​(java.awt.event.ActionEvent ev)
      Specified by:
      actionPerformed in interface java.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 interface PVComponent
      Overrides:
      getFont in class PVPanelAdapter
    • setFont

      public void setFont​(java.awt.Font font)
      Specified by:
      setFont in interface PVComponent
      Overrides:
      setFont in class PVPanelAdapter
    • getUserPanel

      public PVPanel 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)