Class SelectionProperty<I,S>
java.lang.Object
dev.prozilla.pine.common.property.VariableProperty<S>
dev.prozilla.pine.common.property.MutableProperty<S>
dev.prozilla.pine.common.property.observable.ObservableProperty<S>
dev.prozilla.pine.common.property.selection.SelectionProperty<I,S>
- Type Parameters:
I
- The type of selectable items.S
- The type of the selection.
- Direct Known Subclasses:
SingleSelectionProperty
Represents a selection of items from a list.
-
Field Summary
FieldsFields inherited from class dev.prozilla.pine.common.property.observable.ObservableProperty
logger
Fields inherited from class dev.prozilla.pine.common.property.VariableProperty
random
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
getItem
(int index) Returns the item at the given index based on the wrap mode.int
getItems()
Returns an unmodifiable clone of the list of items.boolean
removeItem
(I item) void
Selects the first item.abstract boolean
selectIndex
(int index) Selects an item from the list of items at a given index.boolean
selectItem
(I item) Selects an item from the list of items.void
Selects the last item.abstract void
Selects the next item.abstract void
Selects the previous item.void
setWrapMode
(WrapMode wrapMode) int
transformIndex
(int index) Transforms an index based on the wrap mode.Methods inherited from class dev.prozilla.pine.common.property.observable.ObservableProperty
addObserver, onValueChange, read, removeObserver, setLogger
Methods inherited from class dev.prozilla.pine.common.property.MutableProperty
exists, getValue, setValue
-
Field Details
-
items
-
wrapMode
-
-
Constructor Details
-
SelectionProperty
-
-
Method Details
-
getItems
Returns an unmodifiable clone of the list of items.- Returns:
- A clone of the list of items.
-
getItemCount
public int getItemCount() -
addItem
-
removeItem
-
selectItem
Selects an item from the list of items.- Parameters:
item
- The item to select- Returns:
false
if the item was already selected.- Throws:
IllegalArgumentException
- If the item is not in the list of items.
-
selectIndex
public abstract boolean selectIndex(int index) Selects an item from the list of items at a given index.- Parameters:
index
- The index of the item to select- Returns:
false
if the item was already selected.
-
selectFirst
public void selectFirst()Selects the first item. -
selectLast
public void selectLast()Selects the last item. -
selectPrevious
public abstract void selectPrevious()Selects the previous item. -
selectNext
public abstract void selectNext()Selects the next item. -
getItem
Returns the item at the given index based on the wrap mode.- Parameters:
index
- The index of the item- Returns:
- The item at the given index or
null
if there is no corresponding item.
-
transformIndex
public int transformIndex(int index) Transforms an index based on the wrap mode.- Parameters:
index
- The index to transform- Returns:
- The transformed index.
-
setWrapMode
-