Package com.softsynth.jmsl.score
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
JMSL Notation Project
- Author:
- Nick Didkovsky, copyright 2000 Nick Didkovsky
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
copyright
static int
CURSOR_MODE
This mode treats mouse pointer like a cursor, used to select notesstatic int
INSERT_MODE
This mode treats mouse pointer like an insertion cursor, used to insert notes -
Constructor Summary
Constructors Constructor Description EditManager(Score score, EditStateProvider editStateProvider)
-
Method Summary
Modifier and Type Method Description void
addAlertable(Alertable alertable)
void
addNoteToSelectionBuffer(Note note)
static void
addScoreEditManagerListener(EditManagerListener listener)
void
addSelectionBufferListener(SelectionBufferListener listener)
void
addUndoRedoStackListener(UndoRedoStackListener listener)
void
copy()
Copy from selection buffer to Score.copyBuffervoid
copy(CopyBuffer copyBuffer)
Copy from selection buffer to specified copy buffervoid
cut()
Copy from selection buffer to Score.copyBuffer, delete selected notesvoid
deleteMeasure()
void
deleteMeasureRange(int numMeasures)
delete numMeasures starting at score.getSelectedMeasure()void
deleteStaff()
void
executeScoreCommand(ScoreCommand scoreCommand)
Execute ScoreCommand.Note
findClosestNote(java.awt.geom.Point2D location, int editMode)
Note
findClosestNote(java.awt.geom.Point2D location, int editMode, double radiusFactor)
Staff
findSelectedStaff(java.awt.Point location)
Enumerate through all staffs of all measures in this layout, and return the staff within which Point liesvoid
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 boolean
getAutoBeam()
EditStateProvider
getEditStateProvider()
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 *static double
getProximityFactor()
java.util.Vector
getUndoRedoStackListeners()
void
insertMeasure()
void
insertMeasureRange(int numMeasures)
insert numMeasures starting at score.getSelectedMeasure()void
insertNewStaff()
boolean
isAutoAddMeasure()
when true, adds an empty measure to a score if notes are added or pasted into the very last measurevoid
notifyUndoRedoStackListeners(java.lang.String msg)
static void
openProximityControlFrame()
void
paste()
Paste from Score.copyBuffer to score, do not copy measure infovoid
paste(CopyBuffer copyBuffer, boolean copyMeasureInfo)
Paste from specified CopyBuffer to scorevoid
pasteWithMeasureInfo()
Paste from Score.copyBuffer to score, copy over tempo and timesignatures of source measuresvoid
realignMeasure()
void
redo()
Redo ScoreCommand on top of redo stack.void
removeAlertable(Alertable alertable)
void
removeAllSelectionBufferListeners()
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.static void
removeScoreEditManagerListener(EditManagerListener listener)
void
removeSelectionBufferListener(SelectionBufferListener listener)
void
removeUndoRedoStackListener(UndoRedoStackListener listener)
void
scoreCanvasClicked(ScoreCanvas canvas, java.awt.Point location, java.awt.event.MouseEvent ev)
ScoreCanvasListener interfacevoid
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 interfacevoid
scoreCanvasKeyTyped(ScoreCanvas canvas, java.awt.event.KeyEvent keyEvent)
ScoreCanvasListener interfacevoid
scoreCanvasPressed(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent ev)
executes when mouse button is pressed downvoid
scoreCanvasReady(ScoreCanvas canvas)
ScoreCanvasListener interfacevoid
scoreCanvasRectangleSelected(ScoreCanvas canvas, java.awt.Point p1, java.awt.Point p2)
ScoreCanvasListener interfacevoid
scoreCanvasReleased(ScoreCanvas canvas, java.awt.Point p, java.awt.event.MouseEvent e)
executes when mouse button is releasedvoid
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
selectAllNotesInRange(int fromMeasureIndex, int toMeasureIndex, int fromStaffIndex, int toStaffIndex, int fromTrackIndex, int toTrackIndex)
select all notes in indicated range.void
selectAllNotesInRange(int fromMeasureIndex, int toMeasureIndex, int fromStaffIndex, int toStaffIndex, int fromTrackIndex, int toTrackIndex, int pitchClass, int modulus)
select all notes in indicated range.void
selectExtendedRange(Note firstNote, Note lastNote, boolean maximizeEndTimeLimit)
void
selectStaff(int staffNum)
enumerate through indicated staff of each measure and select all notes in it.void
setAccPref(int accPref)
Defaults to Note.ACC_NO_PREFERENCE.void
setAutoAddMeasure(boolean autoAddMeasure)
when true, adds an empty measure to a score if notes are added or pasted into the very last measurestatic void
setAutoBeam(boolean flag)
void
setEditStateProvider(EditStateProvider editStateProvider)
static void
setProximityFactor(double d)
static void
setSilentEdit(boolean b)
Turn note sound on/off in response to note clickvoid
setStaffInsertionIndex(int insertionIndex)
This is usually set by a mouse click, but you can set it with this methodstatic boolean
sound(Note note)
In response to a Note being clicked or inserted, sound the Note.static boolean
sound(Note note, boolean onlyIfDifferent)
in response to a note being clicked, inserted, or dragged.void
undo()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
CURSOR_MODE
public static final int CURSOR_MODEThis mode treats mouse pointer like a cursor, used to select notes- See Also:
- Constant Field Values
-
INSERT_MODE
public static final int INSERT_MODEThis 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 Details
-
EditManager
-
-
Method Details
-
addSelectionBufferListener
-
removeSelectionBufferListener
-
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
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
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 interfaceScoreCanvasListener
-
scoreCanvasPressed
Description copied from interface:ScoreCanvasListener
executes when mouse button is pressed down- Specified by:
scoreCanvasPressed
in interfaceScoreCanvasListener
-
scoreCanvasDragged
Description copied from interface:ScoreCanvasListener
executes when mouse is dragged (moved while mousedown)- Specified by:
scoreCanvasDragged
in interfaceScoreCanvasListener
-
selectExtendedRange
- 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 -1graceNoteIndex
- or -1graceNoteIntervalIndex
- or -1- Returns:
-
addNoteToSelectionBuffer
-
scoreCanvasKeyTyped
ScoreCanvasListener interface- Specified by:
scoreCanvasKeyTyped
in interfaceScoreCanvasListener
-
addUndoRedoStackListener
-
removeUndoRedoStackListener
-
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
Execute ScoreCommand. -
scoreCanvasKeyReleased
ScoreCanvasListener interface- Specified by:
scoreCanvasKeyReleased
in interfaceScoreCanvasListener
-
scoreCanvasRectangleSelected
ScoreCanvasListener interface- Specified by:
scoreCanvasRectangleSelected
in interfaceScoreCanvasListener
-
scoreCanvasReady
ScoreCanvasListener interface- Specified by:
scoreCanvasReady
in interfaceScoreCanvasListener
-
setProximityFactor
public static void setProximityFactor(double d) -
getProximityFactor
public static double getProximityFactor() -
openProximityControlFrame
public static void openProximityControlFrame() -
findClosestNote
-
findClosestNote
-
findSelectedStaff
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
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 notesendMeasure
- , last measure from which to remove notes, inclusivestaffIndex
- 0.. measure.size()-1, value of -1 signals all stavestrackIndex
- 0.. staff.size()-1, value of -1 signals all tracks- Returns:
- Vector of Notes removed
-
removeNotesFromStaff
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
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
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
-
removeAlertable
-
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 interfaceScoreCanvasListener
-
scoreCanvasReleased
Description copied from interface:ScoreCanvasListener
executes when mouse button is released- Specified by:
scoreCanvasReleased
in interfaceScoreCanvasListener
-
addScoreEditManagerListener
-
removeScoreEditManagerListener
-
getEditStateProvider
- Returns:
- Returns the editStateProvider.
-
setEditStateProvider
- Parameters:
editStateProvider
- The editStateProvider to set.
-