Class EditManager

java.lang.Object
com.softsynth.jmsl.score.EditManager
All Implemented Interfaces:
ScoreCanvasListener

public class EditManager
extends java.lang.Object
implements ScoreCanvasListener
This class makes decisions about things like cursor placement, note selection, based on mouse clicks.
JMSL Notation Project
Author:
Nick Didkovsky, copyright 2000 Nick Didkovsky
  • Field Details

    • CURSOR_MODE

      public static final int CURSOR_MODE
      This mode treats mouse pointer like a cursor, used to select notes
      See Also:
      Constant Field Values
    • INSERT_MODE

      public static final int INSERT_MODE
      This mode treats mouse pointer like an insertion cursor, used to insert notes
      See Also:
      Constant Field Values
  • Constructor Details

  • Method Details

    • addSelectionBufferListener

      public void addSelectionBufferListener​(SelectionBufferListener listener)
    • removeSelectionBufferListener

      public void removeSelectionBufferListener​(SelectionBufferListener listener)
    • removeAllSelectionBufferListeners

      public void removeAllSelectionBufferListeners()
    • setAccPref

      public void setAccPref​(int accPref)
      Defaults to Note.ACC_NO_PREFERENCE. When set to this, the key signature of the staff into which a new note is inserted will determine the accidental preferences of the new Note. When set to Note.ACC_PREFER_SHARP or Note.ACC_PREFER_FLAT, this preference will override context and set the preference for the new Note. Currently the EditManager's preference is set by menu items in ScoreFrame
    • getAccPref

      public int getAccPref()
      see comment for setAccPref()
    • setSilentEdit

      public static void setSilentEdit​(boolean b)
      Turn note sound on/off in response to note click
    • sound

      public static boolean sound​(Note note)
      In response to a Note being clicked or inserted, sound the Note. Only make a sound if !silentEdit. Clips hold time to 1.0 sec. Does not retrigger if within 0.2 seconds of last sounding of same pitch
    • sound

      public static boolean sound​(Note note, boolean onlyIfDifferent)
      in response to a note being clicked, inserted, or dragged. onlyIfDifferent flag forces pitch to be different before sounding returns flag if pitch was different
      Parameters:
      note -
      onlyIfDifferent -
      Returns:
    • setAutoBeam

      public static void setAutoBeam​(boolean flag)
    • getAutoBeam

      public static boolean getAutoBeam()
    • scoreCanvasClicked

      public void scoreCanvasClicked​(ScoreCanvas canvas, java.awt.Point location, java.awt.event.MouseEvent ev)
      ScoreCanvasListener interface
      Specified by:
      scoreCanvasClicked in interface ScoreCanvasListener
    • scoreCanvasPressed

      public void scoreCanvasPressed​(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent ev)
      Description copied from interface: ScoreCanvasListener
      executes when mouse button is pressed down
      Specified by:
      scoreCanvasPressed in interface ScoreCanvasListener
    • scoreCanvasDragged

      public void scoreCanvasDragged​(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
      Description copied from interface: ScoreCanvasListener
      executes when mouse is dragged (moved while mousedown)
      Specified by:
      scoreCanvasDragged in interface ScoreCanvasListener
    • selectExtendedRange

      public void selectExtendedRange​(Note firstNote, Note lastNote, boolean maximizeEndTimeLimit)
      Parameters:
      maximizeEndTimeLimit -
      lastNote -
    • isAutoAddMeasure

      public boolean isAutoAddMeasure()
      when true, adds an empty measure to a score if notes are added or pasted into the very last measure
      Returns:
      the autoAddMeasure
    • setAutoAddMeasure

      public void setAutoAddMeasure​(boolean autoAddMeasure)
      when true, adds an empty measure to a score if notes are added or pasted into the very last measure
      Parameters:
      autoAddMeasure - the autoAddMeasure to set
    • selectAll

      public void selectAll()
      Selects all note in score, staff by staff beginning to end . Afterwards, score.getSelectionBuffer() contains selected material
    • selectAllInStaff

      public void selectAllInStaff()
      Selects all notes in score.getSelectedStaff() Does this for each measure beginning to end. Afterwards, score.getSelectionBuffer() contains selected material
    • selectStaff

      public void selectStaff​(int staffNum)
      enumerate through indicated staff of each measure and select all notes in it.
      Parameters:
      staffNum -
    • selectAllNotesInRange

      public void selectAllNotesInRange​(int fromMeasureIndex, int toMeasureIndex, int fromStaffIndex, int toStaffIndex, int fromTrackIndex, int toTrackIndex)
      select all notes in indicated range. End index values are EXCLUDED
    • selectAllNotesInRange

      public void selectAllNotesInRange​(int fromMeasureIndex, int toMeasureIndex, int fromStaffIndex, int toStaffIndex, int fromTrackIndex, int toTrackIndex, int pitchClass, int modulus)
      select all notes in indicated range. End index values are EXCLUDED
    • getNote

      public Note getNote​(int measureIndex, int staffIndex, int trackIndex, int noteIndex, int intervalIndex, int graceNoteIndex, int graceNoteIntervalIndex)
      to support indexed selection in MaxScore but might have other uses too *
      Parameters:
      measureIndex -
      staffIndex -
      trackIndex -
      noteIndex -
      intervalIndex - or -1
      graceNoteIndex - or -1
      graceNoteIntervalIndex - or -1
      Returns:
    • addNoteToSelectionBuffer

      public void addNoteToSelectionBuffer​(Note note)
    • scoreCanvasKeyTyped

      public void scoreCanvasKeyTyped​(ScoreCanvas canvas, java.awt.event.KeyEvent keyEvent)
      ScoreCanvasListener interface
      Specified by:
      scoreCanvasKeyTyped in interface ScoreCanvasListener
    • addUndoRedoStackListener

      public void addUndoRedoStackListener​(UndoRedoStackListener listener)
    • removeUndoRedoStackListener

      public void removeUndoRedoStackListener​(UndoRedoStackListener listener)
    • getUndoRedoStackListeners

      public java.util.Vector getUndoRedoStackListeners()
    • notifyUndoRedoStackListeners

      public void notifyUndoRedoStackListeners​(java.lang.String msg)
    • undo

      public void undo()
    • redo

      public void redo()
      Redo ScoreCommand on top of redo stack. notify Alterables if stack is empty . Notifies UndoRedoStackListeners. Moves ScoreCommand off redo stack and onto undo stack
    • executeScoreCommand

      public void executeScoreCommand​(ScoreCommand scoreCommand)
      Execute ScoreCommand.
    • scoreCanvasKeyReleased

      public void scoreCanvasKeyReleased​(ScoreCanvas canvas, java.awt.event.KeyEvent keyEvent)
      ScoreCanvasListener interface
      Specified by:
      scoreCanvasKeyReleased in interface ScoreCanvasListener
    • scoreCanvasRectangleSelected

      public void scoreCanvasRectangleSelected​(ScoreCanvas canvas, java.awt.Point p1, java.awt.Point p2)
      ScoreCanvasListener interface
      Specified by:
      scoreCanvasRectangleSelected in interface ScoreCanvasListener
    • scoreCanvasReady

      public void scoreCanvasReady​(ScoreCanvas canvas)
      ScoreCanvasListener interface
      Specified by:
      scoreCanvasReady in interface ScoreCanvasListener
    • setProximityFactor

      public static void setProximityFactor​(double d)
    • getProximityFactor

      public static double getProximityFactor()
    • openProximityControlFrame

      public static void openProximityControlFrame()
    • findClosestNote

      public Note findClosestNote​(java.awt.geom.Point2D location, int editMode)
    • findClosestNote

      public Note findClosestNote​(java.awt.geom.Point2D location, int editMode, double radiusFactor)
    • findSelectedStaff

      public Staff findSelectedStaff​(java.awt.Point location)
      Enumerate through all staffs of all measures in this layout, and return the staff within which Point lies
    • copy

      public void copy()
      Copy from selection buffer to Score.copyBuffer
    • copy

      public void copy​(CopyBuffer copyBuffer)
      Copy from selection buffer to specified copy buffer
    • cut

      public void cut()
      Copy from selection buffer to Score.copyBuffer, delete selected notes
    • removeNotes

      public java.util.Vector removeNotes​(int startMeasure, int endMeasure)
      same as removeNotes(startMeasure, endMeasure, -1, -1);
      Returns:
      Vector of Notes removed, in order of measure, staff, track
    • removeNotes

      public java.util.Vector removeNotes​(int startMeasure, int endMeasure, int staffIndex)
      same as removeNotes(startMeasure, endMeasure, staffIndex, -1);
      Returns:
      Vector of Notes removed, in order of measure, staff, track
    • removeNotes

      public java.util.Vector removeNotes​(int startMeasure, int endMeasure, int staffIndex, int trackIndex)
      Remove Notes from range of measures (inclusive)
      Parameters:
      startMeasure - , first measure from which to remove notes
      endMeasure - , last measure from which to remove notes, inclusive
      staffIndex - 0.. measure.size()-1, value of -1 signals all staves
      trackIndex - 0.. staff.size()-1, value of -1 signals all tracks
      Returns:
      Vector of Notes removed
    • removeNotesFromStaff

      public java.util.Vector removeNotesFromStaff​(Staff s, int trackIndex)
      Remove all notes from specified trackIndex of Staff. trackIndex -1 signals remove from all Tracks *
      Returns:
      Vector of Notes removed, in order of measure, staff, track
    • paste

      public void paste()
      Paste from Score.copyBuffer to score, do not copy measure info
    • pasteWithMeasureInfo

      public void pasteWithMeasureInfo()
      Paste from Score.copyBuffer to score, copy over tempo and timesignatures of source measures
    • setStaffInsertionIndex

      public void setStaffInsertionIndex​(int insertionIndex)
      This is usually set by a mouse click, but you can set it with this method
    • paste

      public void paste​(CopyBuffer copyBuffer, boolean copyMeasureInfo)
      Paste from specified CopyBuffer to score
    • freeflowPaste

      public void freeflowPaste()
      Paste from Score.copyBuffer to score, ignore track and measure info of notes in copy buffer, just unroll them and paste in series using addNote(), which inserts measures if no room, or adds them at the end.
    • freeflowPaste

      public void freeflowPaste​(CopyBuffer copyBuffer)
      Paste from specified copy buffer to score, ignore track and measure info of notes in copy buffer, just unroll them and paste in series using addNote(), which inserts measures if no room, or adds them at the end.
    • deleteMeasure

      public void deleteMeasure()
    • deleteMeasureRange

      public void deleteMeasureRange​(int numMeasures)
      delete numMeasures starting at score.getSelectedMeasure()
    • insertMeasure

      public void insertMeasure()
    • insertMeasureRange

      public void insertMeasureRange​(int numMeasures)
      insert numMeasures starting at score.getSelectedMeasure()
    • realignMeasure

      public void realignMeasure()
    • insertNewStaff

      public void insertNewStaff()
    • deleteStaff

      public void deleteStaff()
    • addAlertable

      public void addAlertable​(Alertable alertable)
    • removeAlertable

      public void removeAlertable​(Alertable alertable)
    • scoreCanvasDisplayedImageReady

      public void scoreCanvasDisplayedImageReady​(Score score, ScoreCanvas canvas, java.awt.Image displayedImage)
      Description copied from interface: ScoreCanvasListener
      Called immediately before ScoreCanvas draws the completed offscreen display image to the canvas's graphics context in paint() (awt) or paintComponent() (Swing). You may do additional drawing on top of the rendered score by retrieving displayedImage.getGraphics() and drawing with it.
      Specified by:
      scoreCanvasDisplayedImageReady in interface ScoreCanvasListener
    • scoreCanvasReleased

      public void scoreCanvasReleased​(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
      Description copied from interface: ScoreCanvasListener
      executes when mouse button is released
      Specified by:
      scoreCanvasReleased in interface ScoreCanvasListener
    • addScoreEditManagerListener

      public static void addScoreEditManagerListener​(EditManagerListener listener)
    • removeScoreEditManagerListener

      public static void removeScoreEditManagerListener​(EditManagerListener listener)
    • getEditStateProvider

      public EditStateProvider getEditStateProvider()
      Returns:
      Returns the editStateProvider.
    • setEditStateProvider

      public void setEditStateProvider​(EditStateProvider editStateProvider)
      Parameters:
      editStateProvider - The editStateProvider to set.