Class PianoRollEditor
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,PropertyChangeListener
,Serializable
,EventListener
,Accessible
It can edit whole or part of a Phrase.
Its Lookup must contain :
- editor's ActionMap
- editor's Zoomable instance
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
oldValue=old tool, newValue=new toolstatic final String
newValue=false.static final String
oldValue=old channel, newValue=new channel model.static final String
oldValue=old Phrase model, newValue=new Phrase model.static final String
newValue=playback point position in beatsstatic final String
oldValue=old quantization value, newValue=new quantization valuestatic final String
oldValue=sorted list of NoteViews whose state has changeds, newValue=selected statestatic final String
newValue=booleanFields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionPianoRollEditor
(PianoRollEditorSettings settings) Create a piano roll editor for a dummy phrase model. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Clean up everything so component can be garbaged.Get the actived EditTool.int
Get the channel of the editor.The drum key map used by the edited phrase.The available EditTools.Get the optional view-only phrases shown faded in the background of the editor.org.openide.util.Lookup
Get the lookup of this editor.getModel()
Get the Phrase edited by this editor.getNoteView
(NoteEvent ne) Get the NoteView associated to the specified NoteEvent.Get all the NoteViews sorted by NoteEvent natural order.int
Get the bar index corresponding to getPhraseBeatRange().from.int
getPitchFromPoint
(Point notesPanelPoint) Return the pitch that correspond to a graphical point in the editor.float
Get the playback point position.float
getPositionFromPoint
(Point editorPoint) Return the phrase position in beats that corresponds to a graphical point in the editor.Get the display quantization.Get the ruler bar range.int
Get the bar index displayed on the ruler corresponding to getBeatRange().from.Get the currently selected NoteViews sorted by NoteEvent natural order.Get the graphical settings of this editor.getSong()
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 notes which are currently visible.int
getXFromPosition
(float pos) Return the X editor position that corresponds to a beat position of the Phrase model.getZoom()
Get the editor zoom value.boolean
isDrums()
Convenience method which returns true if getDrumKeyMap() is non null.boolean
boolean
boolean
isReady()
Check is editor is ready, ie painted and layouted at the correct size, so all editor methods can be called.boolean
Check if the snap to quantization feature is enabled.void
void
scrollToCenter
(float posInBeats) Scroll so that specified position is shown in the center of the editor, if possible.void
scrollToCenter
(int pitch) Scroll so that specified pitch is shown in the center of the editor, if possible.void
selectNote
(NoteEvent ne, boolean b) void
selectNotes
(Collection<NoteEvent> notes, boolean b) Select or unselect NoteViews.void
setActiveTool
(EditTool tool) Set the active EditTool.void
setGhostPhases
(Map<Integer, Phrase> mapChannelPhrases) Optional view-only phrases shown faded in the background of the editor.void
setModel
(Phrase p, FloatRange beatRange, int phraseStartBar, int rulerStartBar, int channel, NavigableMap<Float, TimeSignature> mapPosTs, DrumKit.KeyMap kMap) Set the edited model.void
setPlaybackAutoScrollEnabled
(boolean playbackAutoScrollEnabled) void
Set the display quantization.void
setSnapEnabled
(boolean b) Enable or disable the snap to quantization feature.void
Associate an optional song to the editor.final void
Set the UndoManager used by this editor.void
Set the editor zoom value.void
showPlaybackPoint
(float pos) Show (or hide) a playback point in the editor at specified phrase position.toPosition
(float posInBeats) Convert a phrase position in beats into a Position.float
Convert a phrase Position into a phrase position in beats.toString()
void
Unselect all notes.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
Methods 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, update
Methods 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, validate
Methods 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 changeds, newValue=selected state- See Also:
-
PROP_ACTIVE_TOOL
oldValue=old tool, newValue=new tool- See Also:
-
PROP_SNAP_ENABLED
newValue=boolean- See Also:
-
PROP_QUANTIZATION
oldValue=old quantization value, newValue=new quantization value- See Also:
-
PROP_PLAYBACK_POINT_POSITION
newValue=playback point position in beats- See Also:
-
-
Constructor Details
-
PianoRollEditor
Create a piano roll editor for a dummy phrase model.- Parameters:
settings
- Can't be null
-
-
Method Details
-
setSong
Associate an optional song to the editor.Put the song in the editor's lookup. Song undo manager is used. The ruler can show the chord symbols and listen to chord symbols changes.
This method can be called only once.
- Parameters:
song
- Can't be null
-
getSong
-
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:
-
#setModel(int, org.jjazz.util.api.FloatRange, org.jjazz.phrase.api.Phrase, int, java.util.NavigableMap, org.jjazz.midi.api.DrumKit.KeyMap)
-
getEditTools
The available EditTools.- Returns:
-
setGhostPhases
Optional view-only phrases shown faded in the background of the editor.The specified phrases are shown faded in the background in order to facilite the editing of the Phrase model. E.g. if the edited phrase is a bass line, you can use this method to make the corresponding drums phrase also visible.
- Parameters:
mapChannelPhrases
- A name associated to a Phrase.
-
getGhostPhrases
Get the optional view-only phrases shown faded in the background of the editor.- Returns:
- Can be empty
-
getModel
Get the Phrase edited by this editor.- Returns:
-
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:
-
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
-
getPhraseStartBar
public int getPhraseStartBar()Get the bar index corresponding to getPhraseBeatRange().from.- Returns:
-
getPhraseBarRange
-
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
Get the graphical settings of this editor.- Returns:
-
cleanup
public void cleanup()Clean up everything so component can be garbaged.Fire a PROP_EDITOR_ALIVE with value=false.
-
setZoom
Set the editor zoom value.- Parameters:
zoom
-
-
getZoom
Get the editor zoom value.- Returns:
-
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
Get the display quantization.- Returns:
- Can't be null
-
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
Get the NoteView associated to the specified NoteEvent.- Parameters:
ne
-- Returns:
- Can be null
-
getNoteViews
Get all the NoteViews sorted by NoteEvent natural order.- Returns:
-
unselectAll
public void unselectAll()Unselect all notes. -
getSelectedNoteViews
Get the currently selected NoteViews sorted by NoteEvent natural order.- Returns:
-
setActiveTool
Set the active EditTool.Fire a PROP_ACTIVE_TOOL change event.
- Parameters:
tool
-
-
getActiveTool
Get the actived EditTool.- Returns:
- Can't be null
-
isPlaybackAutoScrollEnabled
public boolean isPlaybackAutoScrollEnabled() -
setPlaybackAutoScrollEnabled
public void setPlaybackAutoScrollEnabled(boolean playbackAutoScrollEnabled) -
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 editor.- Parameters:
editorPoint
- A point in the editor's coordinates. -1 if point is not valid.- Returns:
-
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:
-
toPosition
Convert a phrase position in beats into a Position.- Parameters:
posInBeats
- Must be in the beat range.- Returns:
- See Also:
-
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 notes which are currently visible.- Returns:
-
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:
-
getUndoManager
- Returns:
- The UndoManager used by this editor.
-
setUndoManager
Set the UndoManager used by this editor.- Parameters:
um
-
-
toString
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-