Class PianoRollEditorTopComponent

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.openide.windows.TopComponent
org.jjazz.pianoroll.api.PianoRollEditorTopComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Externalizable, Serializable, EventListener, Accessible, SgsChangeListener, org.openide.util.HelpCtx.Provider, org.openide.util.Lookup.Provider

public final class PianoRollEditorTopComponent extends org.openide.windows.TopComponent implements PropertyChangeListener, SgsChangeListener
A TopComponent to use a PianoRollEditor for a song phrase.

The TopComponent closes itself when song is closed and listen to SongStructure changes to update the edited range.

See Also:
  • Field Details

  • Constructor Details

    • PianoRollEditorTopComponent

      public PianoRollEditorTopComponent(Song sg, PianoRollEditorSettings settings)
      Create a TopComponent editor for the specified song.

      Parameters:
      sg - The TopComponent listens to song structure changes to update the edited range.
      settings -
  • Method Details

    • setModelForSongPartCustomPhrase

      public void setModelForSongPartCustomPhrase(SongPart spt, Phrase p, int channel, DrumKit.KeyMap keyMap)
      Configure the TopComponent to edit a custom phrase of a song part.

      This can be used to edit a RP_SYS_CustomPhrase value.

      Parameters:
      spt - Must belong to the song
      p - The phrase must start at bar/beat 0 (independently of spt start position)
      channel - The Midi channel of the edited phrase (p.getChannel() is ignored). Must correspond to a RhythmVoice of the song part rhythm.
      keyMap - Null for melodic phrase
    • setModelForUserPhrase

      public void setModelForUserPhrase(Phrase p, int channel, DrumKit.KeyMap keyMap)
      Configure the TopComponent to edit a user phrase on the whole song.

      Parameters:
      p -
      channel - The Midi channel of the edited Phrase (p.getChannel() is ignored). Must correspond to a UserRhythmVoice in the song's MidiMix.
      keyMap - Null for melodic phrase
    • getTitle

      public String getTitle()
      The title used within the editor.
      Returns:
    • setTitle

      public void setTitle(String title)
      Set the title base used within the editor.
      Parameters:
      title -
    • getSong

      public Song getSong()
      The song associated to this TopComponent.
      Returns:
    • getMidiMix

      public MidiMix getMidiMix()
      The MidiMix associated to the song.
      Returns:
    • getRhythmVoice

      public RhythmVoice getRhythmVoice()
      The RhythmVoice associated to the
      Returns:
    • getSongPart

      public SongPart getSongPart()
      The edited SongPart, or null if the whole song is edited.
      Returns:
    • getBeatRange

      public FloatRange getBeatRange()
      The edited beat range.
      Returns:
    • getBarRange

      public IntRange getBarRange()
      The edited bar range.
      Returns:
    • isRP_SYS_CustomPhraseMode

      public boolean isRP_SYS_CustomPhraseMode()
      Check if TopComponent was last configured via setModelForSongPartCustomPhrase().
      Returns:
    • preferredID

      public String preferredID()
      Returns:
      For example "PianoRollEditorTopComponent-MySongName"
    • getEditor

      public PianoRollEditor getEditor()
    • getUndoRedo

      public org.openide.awt.UndoRedo getUndoRedo()
      Overrides:
      getUndoRedo in class org.openide.windows.TopComponent
    • getActions

      public Action[] getActions()
      Overridden to insert possible new actions from path "Actions/PianoRollEditorTopComponent".
      Overrides:
      getActions in class org.openide.windows.TopComponent
      Returns:
      The actions to be shown in the TopComponent popup menu.
    • getLookup

      public org.openide.util.Lookup getLookup()
      Return the PianoRollEditor lookup.
      Specified by:
      getLookup in interface org.openide.util.Lookup.Provider
      Overrides:
      getLookup in class org.openide.windows.TopComponent
      Returns:
    • getPersistenceType

      public int getPersistenceType()
      Overrides:
      getPersistenceType in class org.openide.windows.TopComponent
    • canClose

      public boolean canClose()
      Overrides:
      canClose in class org.openide.windows.TopComponent
    • componentOpened

      public void componentOpened()
    • componentClosed

      public void componentClosed()
    • getActive

      public static PianoRollEditorTopComponent getActive()
      Return the active (i.e. focused or ancestor of the focused component) PianoRollEditorTopComponent.
      Returns:
      Can be null
    • get

      public static PianoRollEditorTopComponent get(Song song)
      Search for the PianoRollEditorTopComponent associated to song.
      Parameters:
      song -
      Returns:
      Can be null
    • getDefaultTabName

      public static String getDefaultTabName(Song song)
      The default tab name for a song.
      Parameters:
      song -
      Returns:
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • authorizeChange

      public void authorizeChange(SgsChangeEvent e) throws UnsupportedEditException
      Description copied from interface: SgsChangeListener
      Some change events might need to be authorized by all listeners before being processed by songStructureChanged().
      Specified by:
      authorizeChange in interface SgsChangeListener
      Parameters:
      e - The change to authorize.
      Throws:
      UnsupportedEditException - Listener shall throw this exception if change is not acceptable. Exception message might be shown to user to explain the problem.
    • songStructureChanged

      public void songStructureChanged(SgsChangeEvent e)
      Description copied from interface: SgsChangeListener
      Process the change.

      Note that this method might be called outside of the EDT.

      Specified by:
      songStructureChanged in interface SgsChangeListener