Skip to content

ToggleNode

abstract class ToggleNode<F, S>
Extends: BaseToggleNode<F,S>
Package: dev.joid.lib.ui.node.impl.control.toggle · Module: core · Source: ToggleNode.java

A toggle made of two parts: a track that covers the control and a knob that slides from the left (off) to the right (on).

A skin extends it and gives its parts in its constructor; the toggle places them on every frame. A knob of size 0 takes half the width and the whole height of the toggle. Attaching a toggle without a knob throws an IllegalStateException.

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

PropertyTypeDefaultSummary
trackNodenullThe node drawn behind the knob, over the whole toggle, with a zindex of -1; optional.
knobNodenullThe node that slides along the track and shows the state; required.
speed signalfloat0.25FHow fast the knob reaches its new place: the part of the remaining way that it covers in 1/60 s, at any frame rate.
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
floatgetKnobProgress()Returns the place of the knob on this frame, from 0F at the left (off) to 1F at the right (on).
ReturnsSignatureSummary
voidlayout() hookPlaces the track over the toggle and moves the knob one step toward the side of the state.
voiddetach() hookForgets the place of the knob, so that the toggle shows its state at once when it comes back.
Inherited from BaseToggleNode (7)

getValue · state · toggle · change · beforeChange · isToggle · getState

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 BaseToggleNode (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

ToggleNode(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.

  • this track(Node track) fluent
  • Node getTrack()

Default: null

The node drawn behind the knob, over the whole toggle, with a zindex of -1; optional.

  • this knob(Node knob) fluent
  • Node getKnob()

Default: null

The node that slides along the track and shows the state; required.

  • this speed(float speed) fluent
  • this speed(Supplier<Float> speed) fluent signal
  • float getSpeed()

Default: 0.25F

How fast the knob reaches its new place: the part of the remaining way that it covers in 1/60 s, at any frame rate. 1F moves it at once.

float getKnobProgress()

Returns the place of the knob on this frame, from 0F at the left (off) to 1F at the right (on). A skin reads it to make another part follow the knob.

void layout() hook

Places the track over the toggle and moves the knob one step toward the side of the state.

void detach() hook

Forgets the place of the knob, so that the toggle shows its state at once when it comes back.


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