Class SS_SelectionUtilities

java.lang.Object
org.jjazz.ss_editor.api.SS_SelectionUtilities

public final class SS_SelectionUtilities extends Object
Provide convenience methods to get information about a selection in a lookup.

Selected items can be either SongPart or RhythmParameters, but not both in the same time. Returned SongParts or SongPartParameters are ordered by startBarIndex.

  • Constructor Details

    • SS_SelectionUtilities

      public SS_SelectionUtilities(List<SongPart> spts)
    • SS_SelectionUtilities

      public SS_SelectionUtilities(List<SongPartParameter> sptps, Object not_used)
      Parameters:
      sptps -
      not_used - Not used, just to avoid name clash with other constructor !
    • SS_SelectionUtilities

      public SS_SelectionUtilities(org.openide.util.Lookup lookup)
      Refresh the selection with selected objects in the lookup.
      Parameters:
      lookup -
      Throws:
      IllegalStateException - If lookup contains both SongParts and RhythmParameters
  • Method Details

    • unselectAll

      public void unselectAll(SS_Editor editor)
      Convenience function.

      Unselect everything in specified editor.

      Parameters:
      editor -
    • isSameRhythm

      public boolean isSameRhythm()
      True if all selected Song Parts or Rhythm Parameters share the same rhythm.
      Returns:
    • isRhythmParameterCompatible

      public boolean isRhythmParameterCompatible()
      True if all selected Rhythm Parameters are compatible.
      Returns:
    • isContiguousSptSelection

      public boolean isContiguousSptSelection()
      True if the selected song parts are contiguous (valid whatever the selection type, SongParts or RhythmParameters)
      Returns:
    • isEmpty

      public boolean isEmpty()
    • isSongPartSelected

      public boolean isSongPartSelected()
    • isRhythmParameterSelected

      public boolean isRhythmParameterSelected()
    • isEnumerableRhythmParameterSelected

      public boolean isEnumerableRhythmParameterSelected()
      True if the first selected RhythmParameter is an instanceof RP_Enumerabl.
      Returns:
    • getMinStartSptIndex

      public int getMinStartSptIndex()
      Get the first SongPart of the selection.

      Works independently of the selection mode (SongParts or RhythmParameters). Return a meaningful value only if selection is not empty.

      Returns:
      The index of the SongPart in the SongStructure.
    • getMaxStartSptIndex

      public int getMaxStartSptIndex()
      Get the last SongPart of the selection.

      Works independently of the selection mode (SongParts or RhythmParameters). Return a meaningful value only if selection is not empty.

      Returns:
      The index of the SongPart in the SongStructure.
    • isSongPartSelected

      public boolean isSongPartSelected(SongPart spt)
    • isRhythmParameterSelected

      public boolean isRhythmParameterSelected(SongPart spt, RhythmParameter<?> rp)
    • getSelectedSongPartParameter

      public RhythmParameter<?> getSelectedSongPartParameter(SongPart spt)
      Parameters:
      spt -
      Returns:
      The selected rp belonging to spt (only one RhythmParameter can be selected for one spt). Null if no rp selected in spt.
    • getSelectedSongParts

      public List<SongPart> getSelectedSongParts()
      Returns:
      The returned list is ordered by SongPart startBarIndex.
    • getSelectedSongPartParameters

      public List<SongPartParameter> getSelectedSongPartParameters()
      Returns:
      The returned list is ordered by SongPart startBarIndex.
    • getIndirectlySelectedSongParts

      public List<SongPart> getIndirectlySelectedSongParts()
      The list of selected SongParts (ordered by startBarIndex), or corresponding to the selected RhythmParameters if RhythmParameters are selected.
      Returns:
    • getModel

      public SongStructure getModel()
      Returns:
      Can be null if isEmpty() is true.
    • toString

      public String toString()
      Overrides:
      toString in class Object