com.softsynth.jmsl.score
Class EditManager

java.lang.Object
  extended by 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 Summary
static java.lang.String copyright
           
static int CURSOR_MODE
          This mode treats mouse pointer like a cursor, used to select notes
static int INSERT_MODE
          This mode treats mouse pointer like an insertion cursor, used to insert notes
 
Constructor Summary
EditManager(Score score, EditStateProvider editStateProvider)
           
 
Method Summary
 void addAlertable(Alertable alertable)
           
 void addUndoRedoStackListener(UndoRedoStackListener listener)
           
 void copy()
          Copy from selection buffer to Score.copyBuffer
 void copy(CopyBuffer copyBuffer)
          Copy from selection buffer to specified copy buffer
 void cut()
          Copy from selection buffer to Score.copyBuffer, delete selected notes
 void deleteMeasure()
           
 void deleteMeasureRange(int numMeasures)
          delete numMeasures starting at score.getSelectedMeasure()
 void deleteStaff()
           
 void executeScoreCommand(ScoreCommand scoreCommand)
          Execute ScoreCommand.
 Note findClosestNote(java.awt.Point location, int editMode)
           
 Staff findSelectedStaff(java.awt.Point location)
          Enumerate through all staffs of all measures in this layout, and return the staff within which Point lies
 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.
 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.
 int getAccPref()
          see comment for setAccPref()
static double getProximityFactor()
           
 void insertMeasure()
           
 void insertMeasureRange(int numMeasures)
          insert numMeasures starting at score.getSelectedMeasure()
 void insertNewStaff()
           
 void notifyUndoRedoStackListeners()
           
static void openProximityControlFrame()
           
 void paste()
          Paste from Score.copyBuffer to score, do not copy measure info
 void paste(CopyBuffer copyBuffer, boolean copyMeasureInfo)
          Paste from specified CopyBuffer to score
 void pasteWithMeasureInfo()
          Paste from Score.copyBuffer to score, copy over tempo and timesignatures of source measures
 void realignMeasure()
           
 void redo()
          Redo ScoreCommand on top of redo stack.
 void removeAlertable(Alertable alertable)
           
 java.util.Vector removeNotes(int startMeasure, int endMeasure)
          same as removeNotes(startMeasure, endMeasure, -1, -1);
 java.util.Vector removeNotes(int startMeasure, int endMeasure, int staffIndex)
          same as removeNotes(startMeasure, endMeasure, staffIndex, -1);
 java.util.Vector removeNotes(int startMeasure, int endMeasure, int staffIndex, int trackIndex)
          Remove Notes from range of measures (inclusive)
 java.util.Vector removeNotesFromStaff(Staff s, int trackIndex)
          Remove all notes from specified trackIndex of Staff.
 void removeUndoRedoStackListener(UndoRedoStackListener listener)
           
 void scoreCanvasClicked(ScoreCanvas canvas, java.awt.Point location, java.awt.event.MouseEvent ev)
          ScoreCanvasListener interface
 void scoreCanvasDisplayedImageReady(Score score, ScoreCanvas canvas, java.awt.Image displayedImage)
          Called immediately before ScoreCanvas draws the completed offscreen display image to the canvas's graphics context in paint() (awt) or paintComponent() (Swing).
 void scoreCanvasDragged(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
          executes when mouse is dragged (moved while mousedown)
 void scoreCanvasKeyReleased(ScoreCanvas canvas, java.awt.event.KeyEvent keyEvent)
          ScoreCanvasListener interface
 void scoreCanvasKeyTyped(ScoreCanvas canvas, java.awt.event.KeyEvent keyEvent)
          ScoreCanvasListener interface
 void scoreCanvasPressed(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
          executes when mouse button is pressed down
 void scoreCanvasReady(ScoreCanvas canvas)
          ScoreCanvasListener interface
 void scoreCanvasRectangleSelected(ScoreCanvas canvas, java.awt.Point p1, java.awt.Point p2)
          ScoreCanvasListener interface
 void scoreCanvasReleased(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
          executes when mouse button is released
 void selectAll()
          Selects all note in score, staff by staff beginning to end .
 void selectAllInStaff()
          Selects all notes in score.getSelectedStaff() Does this for each measure beginning to end.
 void setAccPref(int accPref)
          Defaults to Note.ACC_NO_PREFERENCE.
static void setProximityFactor(double d)
           
static void setSilentEdit(boolean b)
          Turn note sound on/off in response to note click
 void setStaffInsertionIndex(int insertionIndex)
          This is usually set by a mouse click, but you can set it with this method
static void sound(Note note)
          In response to a Note being clicked or inserted, sound the Note.
 void undo()
          Undo ScoreCommand on top of undo stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

copyright

public static final java.lang.String copyright
See Also:
Constant Field Values
Constructor Detail

EditManager

public EditManager(Score score,
                   EditStateProvider editStateProvider)
Method Detail

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 void 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


scoreCanvasClicked

public void scoreCanvasClicked(ScoreCanvas canvas,
                               java.awt.Point location,
                               java.awt.event.MouseEvent ev)
ScoreCanvasListener interface

Specified by:
scoreCanvasClicked in interface ScoreCanvasListener

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


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)

notifyUndoRedoStackListeners

public void notifyUndoRedoStackListeners()

undo

public void undo()
Undo ScoreCommand on top of undo stack. notify Alterables if stack is empty and returns. Notifies UndoRedoStackListeners moves ScoreCommand off undo stack and onto redo stack


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. If scoreCommand.isUndoable(), adds to undo stack and notifies UndoRedoStackListeners


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.Point location,
                            int editMode)

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

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

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

scoreCanvasPressed

public void scoreCanvasPressed(ScoreCanvas canvas,
                               java.awt.Point p,
                               java.awt.event.MouseEvent e)
Description copied from interface: ScoreCanvasListener
executes when mouse button is pressed down

Specified by:
scoreCanvasPressed in interface ScoreCanvasListener