Skip to content

SwitchNode

abstract class SwitchNode<V>
Extends: BaseChoiceNode<V>
Package: dev.joid.lib.ui.node.impl.control.choice · Module: core · Source: SwitchNode.java

A choice that shows every option side by side, one node per option, and selects the option under a left press.

A skin extends it and gives option((value, index) -> node), which creates the node of each option. The switch splits its width equally between the options, in their order. Attaching a switch without an option function throws an IllegalStateException.

ReturnsSignatureSummary
SwitchNode(double x, double y, double width, double height) protectedCreates the switch at x, y with a width and a height in design pixels, from the constructor of a skin.

PropertyTypeDefaultSummary
optionBiFunction<V,Integer,Node>nullThe function that creates the node of an option from its value and its index.
Inherited from BaseChoiceNode (3)

values · value · valueIndex

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

ReturnsSignatureSummary
List<Node>getOptionList()Returns the nodes of the options, in the order of the options, as a read-only list.
ReturnsSignatureSummary
voidlayout() hookPlaces the nodes of the options side by side, each one as wide as the switch divided by the number of options.
voidmousePressed(NodeMouseEvent<?> event) hookSelects the option under a left press that no one consumed, through change(...), and consumes the press.
voidcreateOptions() hook protectedRemoves the nodes of the previous options and creates one node per option with the option function.
Inherited from BaseChoiceNode (3)

getValueList · change · beforeChange

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

Inherited from BaseChoiceNode (1)

onChange

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

SwitchNode(double x, double y, double width, double height) protected

Creates the switch at x, y with a width and a height in design pixels, from the constructor of a skin.

  • this option(BiFunction<V,Integer,Node> option) fluent

Default: null

The function that creates the node of an option from its value and its index. The switch calls it again for every option each time the options change.

List<Node> getOptionList()

Returns the nodes of the options, in the order of the options, as a read-only list.

void layout() hook

Places the nodes of the options side by side, each one as wide as the switch divided by the number of options.

void mousePressed(NodeMouseEvent<?> event) hook

Selects the option under a left press that no one consumed, through change(...), and consumes the press.

void createOptions() hook protected

Removes the nodes of the previous options and creates one node per option with the option function.


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

Report a problem with this page