BaseToggleNode
abstract class BaseToggleNode<F, S>
Extends: Node
Known subtypes: ToggleNode
Package: dev.joid.lib.ui.node.impl.control.toggle · Module: core · Source: BaseToggleNode.java
The behavior of a toggle without its look: a boolean that a left press switches, and the two values it stands for.
Description
Section titled “Description”Extend ToggleNode for a look made of a track and a knob; extend BaseToggleNode only to build the look entirely yourself.
F is the type of the value when the toggle is on, S when it is off.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| BaseToggleNode(double x, double y, double width, double height) protected | Creates the toggle at x, y with a width and a height in design pixels, from the constructor of a skin. |
Properties
Section titled “Properties”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 |
|---|---|---|
T | getValue() | Returns the value that the toggle stands for: the first value of state(...) while it is on, the second one while it is off, or a Boolean without a state. |
this | state(F toggle, S back) fluent | Gives the two values that getValue() returns, such as "Night" and "Day"; it does not change whether the toggle is on. |
T | toggle(boolean toggle) | Gives the toggle its start value: true is on; a toggle attached already fires onChange when it differs. |
T | toggle(Signal | Binds the on state to a signal both ways: the toggle shows the signal, and a press writes the new state into it. |
this | change(boolean toggle) fluent | Sets the state as if the user pressed the toggle: beforeChange can refuse it, then onChange fires. |
T | beforeChange(EventListener<NodeChangeEvent.Pre<T,Boolean>> listener) | Adds a listener that runs before a change that a press or change(...) asks for; cancel() refuses it. |
boolean | isToggle() | If true, the toggle is on. |
ToggleState<F,S> | getState() | Returns the pair given to state(...), or null before it. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | mousePressed(NodeMouseEvent<?> event) hook | Switches the state on a left press over the toggle that no one consumed, and consumes the press. |
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,Boolean>> | Adds a listener that runs after each real change of the state, 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”BaseToggleNode
Section titled “BaseToggleNode”BaseToggleNode(double x, double y, double width, double height) protected
Creates the toggle at x, y with a width and a height in design pixels, from the constructor of a skin.
Method details
Section titled “Method details”getValue
Section titled “getValue”<T> T getValue()
Returns the value that the toggle stands for: the first value of state(...) while it is on, the second one while it is off, or a Boolean without a state.
this state(F toggle, S back) fluent
Gives the two values that getValue() returns, such as "Night" and "Day"; it does not change whether the toggle is on.
toggle
Section titled “toggle”<T extends BaseToggleNode<F,S>> T toggle(boolean toggle)
Gives the toggle its start value: true is on; a toggle attached already fires onChange when it differs.
A setter is never refused.
<T extends BaseToggleNode<F,S>> T toggle(Signal<Boolean> toggle)
Binds the on state to a signal both ways: the toggle shows the signal, and a press writes the new state into it.
Throws an IllegalArgumentException for a signal that cannot be written.
change
Section titled “change”this change(boolean toggle) fluent
Sets the state as if the user pressed the toggle: beforeChange can refuse it, then onChange fires.
beforeChange
Section titled “beforeChange”<T extends BaseToggleNode<F,S>> T beforeChange(EventListener<NodeChangeEvent.Pre<T,Boolean>> listener)
Adds a listener that runs before a change that a press or change(...) asks for; cancel() refuses it.
isToggle
Section titled “isToggle”boolean isToggle()
If true, the toggle is on.
getState
Section titled “getState”ToggleState<F,S> getState()
Returns the pair given to state(...), or null before it.
mousePressed
Section titled “mousePressed”void mousePressed(NodeMouseEvent<?> event) hook
Switches the state on a left press over the toggle that no one consumed, and consumes the press.
Event details
Section titled “Event details”onChange
Section titled “onChange”<T extends BaseToggleNode<F,S>> T onChange(EventListener<NodeChangeEvent.Post<T,Boolean>> listener)
Adds a listener that runs after each real change of the state, 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
