Class CL_Selection
java.lang.Object
org.jjazz.cl_editor.api.CL_Selection
Represent the selection of a CL_Editor, built from its Lookup.
Selected items can be either SelectedCLI or SelectedBar, but not both in the same time. Furthermore, a selection can not contain SelectedCLIs with incompatible ChordLeadSheetItem classes (eg CLI_ChordSymbol and CLI_Section).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCL_Selection(org.openide.util.Lookup lookup) Create a selection with items or bars.CL_Selection(org.openide.util.Lookup lookup, boolean searchItems, boolean searchBars) Create an instance with only the searched types. -
Method Summary
Modifier and TypeMethodDescriptionThe selected bar range within the chord leadsheet.The selected bar range within the chord leadsheet.Can be null if selection is empty.intThe first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.intSame as getMaxBarIndex but limited to bars within the chordleadsheet's range.intThe first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.intSame as getMinBarIndex but limited to bars within the chordleadsheet's range.Get only the selected chord symbols sorted by position.The bar indexes of the SelectedBars (sorted by position).Same as getSelectedBarsIndexes() but limited to bars within the chordleadsheet's range.Get the selected bars sorted by position.Same as getSelectedBars() but limited to bars within the chordleadsheet's range.Get only the selected chord symbols sorted by position.Get all the SelectedCLIs, unsorted.Get all the selected items sections, chord symbols, etc. sorted by position.Get only the selected sections sorted by position.booleanbooleanTrue if a BarBox is selected.booleanisBarSelected(int bbIndex) static booleanisBarSelected(org.openide.util.Lookup lookup) Utility method to quickly check if selection contains at least one SelectedBar.booleanTrue if at least one selected BarBox is within the chordleadsheet range.booleanbooleanSame as isContiguousBarSelection but limited to bars within the chordleadsheet's range.booleanTrue if all selectedBars are contiguous.booleanisEmpty()booleanbooleanisItemSelected(ChordLeadSheetItem<?> item) static booleanisItemSelected(org.openide.util.Lookup lookup) Utility method to quickly check if selection contains at least one SelectedCLI.booleanisItemTypeSelected(Class<? extends ChordLeadSheetItem> itemClass) Check if the selected ChordLeadSheet items are compatible with itemClass.booleantoString()
-
Constructor Details
-
CL_Selection
public CL_Selection(org.openide.util.Lookup lookup) Create a selection with items or bars.- Parameters:
lookup-- Throws:
IllegalStateException- If lookup contains both SelectedBars and SelectedCLIs
-
CL_Selection
public CL_Selection(org.openide.util.Lookup lookup, boolean searchItems, boolean searchBars) Create an instance with only the searched types.- Parameters:
lookup-searchItems- If false SelectedCLIs are ignoredsearchBars- If false SelectedBars are ignored- Throws:
IllegalStateException- If lookup contains both SelectedBars and SelectedCLIs, or incompatible SelectedCLIs
-
-
Method Details
-
isItemSelected
public static boolean isItemSelected(org.openide.util.Lookup lookup) Utility method to quickly check if selection contains at least one SelectedCLI.This is faster than new CL_Selection(Lookup).isItemSelected().
- Parameters:
lookup-- Returns:
-
isBarSelected
public static boolean isBarSelected(org.openide.util.Lookup lookup) Utility method to quickly check if selection contains at least one SelectedBar.This is faster than new CL_Selection(Lookup).isBarSelected().
- Parameters:
lookup-- Returns:
-
isContiguousBarSelection
public boolean isContiguousBarSelection()True if all selectedBars are contiguous.- Returns:
-
isContiguousBarboxSelectionWithinCls
public boolean isContiguousBarboxSelectionWithinCls()Same as isContiguousBarSelection but limited to bars within the chordleadsheet's range.- Returns:
-
isEmpty
public boolean isEmpty() -
isChordSymbolSelected
public boolean isChordSymbolSelected() -
isSectionSelected
public boolean isSectionSelected() -
isBarAnnotationSelected
public boolean isBarAnnotationSelected() -
isItemSelected
public boolean isItemSelected() -
isBarSelected
public boolean isBarSelected()True if a BarBox is selected.- Returns:
-
isBarSelectedWithinCls
public boolean isBarSelectedWithinCls()True if at least one selected BarBox is within the chordleadsheet range.- Returns:
-
getMinBarIndexWithinCls
public int getMinBarIndexWithinCls()Same as getMinBarIndex but limited to bars within the chordleadsheet's range.- Returns:
- -1 if selection is empty or first selected bar is after chordleadsheet's end.
-
getMaxBarIndexWithinCls
public int getMaxBarIndexWithinCls()Same as getMaxBarIndex but limited to bars within the chordleadsheet's range.- Returns:
- -1 if selection is empty or selected bars are after chordleadsheet's end.
-
getBarRangeWithinCls
The selected bar range within the chord leadsheet.- Returns:
- Can be null if selection empty or outside the chord leadsheet.
-
getBarRange
The selected bar range within the chord leadsheet.- Returns:
- Can be null if selection empty
-
getMaxBarIndex
public int getMaxBarIndex()The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.- Returns:
- -1 if selection is empty.
-
getMinBarIndex
public int getMinBarIndex()The first selected bar index if bars are selected, or the barIndex of the first item selected if items are selected.- Returns:
- -1 if selection is empty.
-
getChordLeadSheet
-
isItemSelected
-
isItemTypeSelected
Check if the selected ChordLeadSheet items are compatible with itemClass.- Parameters:
itemClass-- Returns:
-
isBarSelected
public boolean isBarSelected(int bbIndex) -
getSelectedCLIs
Get all the SelectedCLIs, unsorted.- Returns:
- Can be empty.
-
getSelectedItems
Get all the selected items sections, chord symbols, etc. sorted by position.- Returns:
- Can be empty.
-
getSelectedSections
Get only the selected sections sorted by position.- Returns:
- Can be empty.
-
getSelectedChordSymbols
Get only the selected chord symbols sorted by position.- Returns:
- Can be empty.
-
getSelectedBarAnnotations
Get only the selected chord symbols sorted by position.- Returns:
- Can be empty.
-
getSelectedBars
Get the selected bars sorted by position.- Returns:
- Can be empty if isItemSelected() returns true.
-
getSelectedBarIndexes
-
getSelectedBarsWithinCls
Same as getSelectedBars() but limited to bars within the chordleadsheet's range.- Returns:
- Can be empty if isItemSelected() returns true.
-
getSelectedBarIndexesWithinCls
-
toString
-