BaseChoiceNode
abstract class BaseChoiceNode<V>
Extends: Node
Known subtypes: SwitchNode, BaseSelectorNode, BaseSliderNode
Package: dev.joid.lib.ui.node.impl.control.choice · Module: core · Source: BaseChoiceNode.java
The behavior shared by the controls that select one value among options: the switch, the selector and the sliders.
Description
Section titled “Description”A choice holds a list of options and the selected one.
New options keep the selected value when it is still one of them; otherwise the choice shows the value of fallback(...).
A value given by a bound signal that is not an option yet waits until the options hold it; a plain value must be one of the options.
The order of values(...) and value(...) does not matter.
Attaching a choice without options throws an IllegalStateException.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| BaseChoiceNode(double x, double y, double width, double height) protected | Creates the choice at x, y with a width and a height in design pixels, from the constructor of a subclass. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| values signal | V... | none, values(...) is required before the attach | The options, at least one, in their order on screen. |
| value | V | the first option | The selected option. |
| valueIndex | int | 0, the first option | The index of the selected option in the options. |
Inherited from Node (24)
x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
List<V> | getValueList() | Returns the options, as a read-only view that follows the options set later. |
this | change(V value) fluent | Selects an option as if the user picked it: beforeChange can refuse it, then onChange fires. |
T | beforeChange(EventListener<NodeChangeEvent.Pre<T,V>> listener) | Adds a listener that runs before a change that a gesture or change(...) asks for; cancel() refuses it. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | createOptions() hook protected | Hook that JOID calls each time the options change, after the choice stored them. |
V | fallback(V value) hook protected | Hook that picks the value to show when the value asked for is not one of the options. |
Inherited from Node (128)
load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · isDragging · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onChange | EventListener<NodeChangeEvent.Post<T,V>> | Adds a listener that runs after each real change of the selected value, whatever its source. |
Inherited from Node (21)
onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch
Creation details
Section titled “Creation details”BaseChoiceNode
Section titled “BaseChoiceNode”BaseChoiceNode(double x, double y, double width, double height) protected
Creates the choice at x, y with a width and a height in design pixels, from the constructor of a subclass.
Property details
Section titled “Property details”values
Section titled “values”this values(V... values)fluentthis values(Supplier<List<V>> values)fluent signal
Default: none, values(...) is required before the attach
The options, at least one, in their order on screen.
The reactive setter takes a Supplier of a list, and the choice builds its options again each time the list changes.
An empty list throws an IllegalArgumentException.
this value(V value)fluentthis value(Signal<V> value)fluentV getValue()
Default: the first option
Throws:
IllegalStateException: The … has no values, call values(…) before getValue()
The selected option.
A plain value is the start value, and throws an IllegalArgumentException when it is not one of the options; a signal binds the selection both ways.
valueIndex
Section titled “valueIndex”this valueIndex(int valueIndex)fluentthis valueIndex(Signal<Integer> valueIndex)fluentint getValueIndex()
Default: 0, the first option
The index of the selected option in the options.
A plain index is the start value, and throws an IllegalArgumentException when it is out of the options; an IntegerSignal binds the index both ways.
Method details
Section titled “Method details”getValueList
Section titled “getValueList”List<V> getValueList()
Returns the options, as a read-only view that follows the options set later.
change
Section titled “change”this change(V value) fluent
Selects an option as if the user picked it: beforeChange can refuse it, then onChange fires.
Throws an IllegalArgumentException for a value that is not an option.
beforeChange
Section titled “beforeChange”<T extends BaseChoiceNode<V>> T beforeChange(EventListener<NodeChangeEvent.Pre<T,V>> listener)
Adds a listener that runs before a change that a gesture or change(...) asks for; cancel() refuses it.
createOptions
Section titled “createOptions”void createOptions() hook protected
Hook that JOID calls each time the options change, after the choice stored them. The switch and the selector build one node per option there; the default does nothing.
fallback
Section titled “fallback”V fallback(V value) hook protected
Hook that picks the value to show when the value asked for is not one of the options. The default keeps the current value when it is still an option, else the first option; the sliders of numbers return the nearest option.
Event details
Section titled “Event details”onChange
Section titled “onChange”<T extends BaseChoiceNode<V>> T onChange(EventListener<NodeChangeEvent.Post<T,V>> listener)
Adds a listener that runs after each real change of the selected value, whatever its source.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
