Class PianoRollEditor
- All Implemented Interfaces:
ImageObserver,MenuContainer,PropertyChangeListener,Serializable,EventListener,Accessible,ClsChangeListener
Optional view-only "ghost phrases" can be shown faded in the background of the editor, based on the ghostPhrasesModel state.
Editor's lookup must contain :
- its ActionMap instance
- a Zoomable instance
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringoldValue=old tool, newValue=new toolstatic final StringoldValue=old ChordSequence newValue=new ChordSequencestatic final StringnewValue=false.static final StringoldValue=old loop zone, newValue=new loop zonestatic final StringoldValue=old channel, newValue=new channel model.static final StringoldValue=old phrase model, newValue=new Phrase model.static final StringnewValue=playback point position in beatsstatic final StringoldValue=old quantization value, newValue=new quantization valuestatic final StringoldValue=sorted list of NoteViews whose state has changed, newValue=selected statestatic final StringnewValue=booleanFields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionPianoRollEditor(PianoRollEditorSettings settings, GhostPhrasesModel ghostPhrasesModel) Create a piano roll editor for a dummy phrase model. -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess the change.voidcleanup()Clean up everything so component can be garbaged.Get the actived EditTool.intGet the channel of the editor.The chord sequence associated to the edited phrase.The drum key map used by the edited phrase.The available EditTools.org.openide.util.LookupGet the lookup of this editor.Get the loop zone.getModel()Get the Phrase edited by this editor.getNoteView(NoteEvent ne) Get the NoteView from the main EditorPanel associated to the specified NoteEvent.Get all the NoteViews from the main EditorPanel sorted by NoteEvent natural order.Get the bar range of the edited phrase.Get the phase beat range of the edited phrase.intgetPitchFromPoint(Point notesPanelPoint) Return the pitch that correspond to a graphical point in the editor.floatGet the playback point position.floatgetPositionFromPoint(Point notesPanelPoint) Return the phrase position in beats that corresponds to a graphical point in the NotesPanel.Get the display quantization.Get the ruler bar range.intGet the bar index displayed on the ruler corresponding to getBeatRange().from.Get the currently selected NoteEvents sorted by NoteEvent natural order.Get the currently selected NoteViews sorted by NoteEvent natural order.Get the graphical settings of this editor.getSong()Get the song the edited phrase belongs to.getTimeSignature(float posInBeats) The time signature at the specified beat position.Get all the time signatures with their position.Get the min/max bar indexes which are visible.Get the min/max beat positions which are visible.Get the min/max phrase notes which are currently visible.intgetXFromPosition(float pos) Return the X editor position that corresponds to a beat position of the Phrase model.getZoom()Get the editor zoom value.booleanisDrums()Convenience method which returns true if getDrumKeyMap() is non null.booleanbooleanbooleanisReady()Check is editor is ready, ie painted and layouted at the correct size, so all editor methods can be called.booleanCheck if the snap to quantization feature is enabled.voidvoidscrollToCenter(float posInBeats) Scroll so that specified position is shown in the center of the editor, if possible.voidscrollToCenter(int pitch) Scroll so that specified pitch is shown in the center of the editor, if possible.voidselectNote(NoteEvent ne, boolean b) voidselectNotes(Collection<NoteEvent> notes, boolean b) Select or unselect NoteViews.voidsetActiveTool(EditTool tool) Set the active EditTool.voidsetLoopZone(IntRange barRange) Set the loop zone.voidsetModel(Phrase p, FloatRange beatRange, int rulerStartBar, int channel, NavigableMap<Float, TimeSignature> mapPosTs, DrumKit.KeyMap kMap) Set the phrase model.voidsetPlaybackAutoScrollEnabled(boolean playbackAutoScrollEnabled) voidSet the display quantization.voidsetSnapEnabled(boolean b) Enable or disable the snap to quantization feature.voidAssociate an optional song to the editor -this method can be called only once.final voidSet the UndoManager used by this editor.voidshowPlaybackPoint(float pos) Show (or hide) a playback point in the editor at specified phrase position.toNotesPanelPoint(Point editorPoint) Convert a point in this editor coordinates into NotesPanel's coordinates.floatCompute the phrase-based beat position of a CLI_ChordSymbol obtained via getChordSequence().toPosition(float posInBeats) Convert a phrase position in beats into a Position.floatConvert a phrase Position into a phrase position in beats.toString()voidUnselect all notes.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PROP_EDITOR_ALIVE
newValue=false. This property change event is fired ONLY once, when the editor is destroyed (cleanup() is called).- See Also:
-
PROP_MODEL_PHRASE
oldValue=old phrase model, newValue=new Phrase model.- See Also:
-
PROP_MODEL_CHANNEL
oldValue=old channel, newValue=new channel model.- See Also:
-
PROP_SELECTED_NOTE_VIEWS
oldValue=sorted list of NoteViews whose state has changed, newValue=selected state- See Also:
-
PROP_ACTIVE_TOOL
-
PROP_LOOP_ZONE
-
PROP_SNAP_ENABLED
-
PROP_QUANTIZATION
oldValue=old quantization value, newValue=new quantization value- See Also:
-
PROP_PLAYBACK_POINT_POSITION
newValue=playback point position in beats- See Also:
-
PROP_CHORD_SEQUENCE
oldValue=old ChordSequence newValue=new ChordSequence- See Also:
-
-
Constructor Details
-
PianoRollEditor
Create a piano roll editor for a dummy phrase model.- Parameters:
settings- Can't be nullghostPhrasesModel- Can't be null
-
-
Method Details
-
getKeyboard
-
setSong
Associate an optional song to the editor -this method can be called only once.- Song isput in the editor's lookup
- Song undo manager is used for undo/redo
- Song can be used by subpanels to show e.g. chord symbols.
- The Chord sequence associated to the edited phrase is kept uptodate.- Parameters:
song- Can't be null- See Also:
-
getSong
-
getGhostPhrasesModel
-
getChannel
public int getChannel()Get the channel of the editor.The channel is used e.g. when "hear preview" or "solo mode" is activated, or when notes are imported from a dragged Midi file.
- Returns:
- See Also:
-
getEditTools
-
getModel
Get the Phrase edited by this editor.- Returns:
- Can not be null but can be empty. Starts at bar/beat=0.
-
getRulerStartBar
public int getRulerStartBar()Get the bar index displayed on the ruler corresponding to getBeatRange().from.Usually identical to getPhraseStartBar(), but it can be different to make the edited range appear at a different bar in the ruler.
- Returns:
-
getRulerBarRange
Get the ruler bar range.An IntRange starting at getRulerStartbar() with size equals to getPhraseBarRange().
- Returns:
-
getChordSequence
The chord sequence associated to the edited phrase.Important: Chord sequence first bar is equals to getRulerStartBar().
- Returns:
- Can be null if song is not set.
- See Also:
-
toPhraseRelativeBeatPosition
Compute the phrase-based beat position of a CLI_ChordSymbol obtained via getChordSequence().- Parameters:
cliCs-- Returns:
- See Also:
-
getTimeSignature
The time signature at the specified beat position.- Parameters:
posInBeats- Must be in the beat range- Returns:
- Can't be null
-
getTimeSignatures
Get all the time signatures with their position.- Returns:
- Can't be empty.
-
getPhraseBeatRange
Get the phase beat range of the edited phrase.- Returns:
- A FloatRange with from=0.
-
getPhraseBarRange
Get the bar range of the edited phrase.- Returns:
- An IntRange with from=0.
-
getLookup
public org.openide.util.Lookup getLookup()Get the lookup of this editor.Lookup contains
- Returns:
-
isDrums
public boolean isDrums()Convenience method which returns true if getDrumKeyMap() is non null.- Returns:
-
getDrumKeyMap
The drum key map used by the edited phrase.- Returns:
- Null if it's a melodic phrase.
-
getSettings
-
cleanup
public void cleanup()Clean up everything so component can be garbaged.Fire a PROP_EDITOR_ALIVE with value=false.
-
getZoom
-
setQuantization
Set the display quantization.Fire a PROP_QUANTIZATION change event.
- Parameters:
q- Accepted values are BEAT, HALF_BEAT, ONE_THIRD_BEAT, ONE_QUARTER_BEAT, ONE_SIXTH_BEAT.
-
getQuantization
-
isNoteSelected
-
selectNote
-
selectNotes
Select or unselect NoteViews.Fire a PROP_SELECTED_NOTE_VIEWS change event.
- Parameters:
notes-b-
-
setSnapEnabled
public void setSnapEnabled(boolean b) Enable or disable the snap to quantization feature.Fire a PROP_SNAP_ENABLED change event.
- Parameters:
b-
-
isSnapEnabled
public boolean isSnapEnabled()Check if the snap to quantization feature is enabled.- Returns:
-
getNoteView
-
getNoteViews
-
unselectAll
public void unselectAll()Unselect all notes. -
getSelectedNoteViews
-
getSelectedNoteEvents
-
setActiveTool
Set the active EditTool.Fire a PROP_ACTIVE_TOOL change event.
- Parameters:
tool-
-
getActiveTool
-
isPlaybackAutoScrollEnabled
public boolean isPlaybackAutoScrollEnabled() -
setPlaybackAutoScrollEnabled
public void setPlaybackAutoScrollEnabled(boolean playbackAutoScrollEnabled) -
setLoopZone
Set the loop zone.- Parameters:
barRange- If null there is no loop zone. If not null must be contained in the phrase bar range.
-
getLoopZone
-
showPlaybackPoint
public void showPlaybackPoint(float pos) Show (or hide) a playback point in the editor at specified phrase position.If pos is < 0 or out of the editor bounds, nothing is shown. Fire a PROP_PLAYBACK_POINT_POSITION change event.
- Parameters:
pos- The phrase position in beats.
-
getPlaybackPointPosition
public float getPlaybackPointPosition()Get the playback point position.- Returns:
- If < 0 no playback point is shown.
-
getPositionFromPoint
Return the phrase position in beats that corresponds to a graphical point in the NotesPanel.- Parameters:
notesPanelPoint- A point in NotesPanel's coordinates. -1 if point is not valid.- Returns:
- See Also:
-
toNotesPanelPoint
-
getXFromPosition
public int getXFromPosition(float pos) Return the X editor position that corresponds to a beat position of the Phrase model.- Parameters:
pos-- Returns:
- -1 If pos is outside the Phrase
-
toPositionInBeats
Convert a phrase Position into a phrase position in beats.- Parameters:
pos- Must be in the bar range.- Returns:
- A beat positino relative to the edited phrase (starts at beat 0)
-
toPosition
Convert a phrase position in beats into a Position.- Parameters:
posInBeats- Must be in the beat range.- Returns:
- A position relative to the edited phrase (starts at bar 0)
-
getPitchFromPoint
Return the pitch that correspond to a graphical point in the editor.- Parameters:
notesPanelPoint- A point in the editor's coordinates. -1 if point is not valid.- Returns:
-
scrollToCenter
public void scrollToCenter(int pitch) Scroll so that specified pitch is shown in the center of the editor, if possible.- Parameters:
pitch-
-
scrollToCenter
public void scrollToCenter(float posInBeats) Scroll so that specified position is shown in the center of the editor, if possible.- Parameters:
posInBeats-
-
getVisiblePitchRange
Get the min/max phrase notes which are currently visible.- Returns:
- Might be empty
-
getVisibleBeatRange
Get the min/max beat positions which are visible.- Returns:
- Can be EMPTY_FLOAT_RANGE
-
isReady
public boolean isReady()Check is editor is ready, ie painted and layouted at the correct size, so all editor methods can be called.- Returns:
-
getVisibleBarRange
Get the min/max bar indexes which are visible.- Returns:
- Can be IntRange.EMPTY_RANGE
-
getUndoManager
- Returns:
- The UndoManager used by this editor.
-
setUndoManager
Set the UndoManager used by this editor.- Parameters:
um-
-
toString
-
chordLeadSheetChanged
Description copied from interface:ClsChangeListenerProcess the change.Note that this method might be called outside of the EDT.
- Specified by:
chordLeadSheetChangedin interfaceClsChangeListener- Parameters:
e-- Throws:
UnsupportedEditException- If a ClsVetoableChangeEvent is not authorized by a listener.
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-