Node
abstract class Node
Implements: INode
Known subtypes: ChartNode, RadarChartNode, BaseCheckboxNode, BaseChoiceNode, FieldNode, BaseScrollbarNode, BaseToggleNode, DevNode, ContainerNode, FlexNode, GridNode, BaseModelNode, ProgressNode, ResourceNode, ResourcePlayerNode, CircleNode, RectNode, TextNode
Package: dev.joid.lib.ui.node · Module: core · Source: Node.java
Base class of every element of a UI, a box in design pixels with children, fluent properties, input, hover, scroll, drag and effects.
Description
Section titled “Description”Every shape, text, image, control and container of a UI extends Node.
You use it through its subclasses: create a node with the factory of its class, chain its setters, build its children in body(...), react with onX(...) listeners, and end the chain with attach(...):
RectNode.create(760, 390, 400, 300).color(selected.map(value -> value ? CardUI.ELEMENT : CardUI.SURFACE)).effect(RoundedNodeEffect.create(12F)).effect(BorderNodeEffect.create(CardUI.ELEMENT, 1.5F)).body(card -> { CircleNode.create(40, 40, 120).color(CardUI.ACCENT).attach(card); RectNode.create(190, 70, 170, 30).color(CardUI.ACCENT).attach(card);}).onClick(event -> selected.toggle()).attach(this);A node is placed relative to its parent, in design pixels; its children are drawn in the order of their zindex, over it, except those of negative zindex, drawn behind it; the children in front receive the input before it.
Most setters also take a Supplier or a signal, so that the property follows a value that changes.
To draw a node of your own, extend a node class and override the hooks of INode.
JOID calls every hook and every listener of a node on the render thread.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| Node(double x, double y) protected | Creates a node at x, y with a size of 0, for a subclass whose size comes from its content. | |
| Node(double x, double y, double width, double height) protected | Creates a node at x, y with this width and height, in design pixels. |
Properties
Section titled “Properties”Position and size
Section titled “Position and size”| Property | Type | Default | Summary |
|---|---|---|---|
| x signal | double | set at creation | Horizontal position of the anchor point of the node, in design pixels, from the left edge of its parent (or of the canvas for a root or ABSOLUTE node). |
| y signal | double | set at creation | Vertical position of the anchor point of the node, in design pixels, from the top edge of its parent (or of the canvas for a root or ABSOLUTE node). |
| width signal | double | set at creation | Width of the node, in design pixels. |
| height signal | double | set at creation | Height of the node, in design pixels. |
| position signal | PositionProperty | PositionProperty.RELATIVE | RELATIVE places the node inside its parent; ABSOLUTE places it on the canvas whatever its parents, out of their layout, their scroll and their content size. |
| anchor signal | Align | Align.START | Sets anchorX and anchorY to the same value. |
| anchorX signal | Align | Align.START | Which point of the node sits at x and stays in place when the width changes: START the left edge, CENTER the middle, END the right edge. |
| anchorY signal | Align | Align.START | Which point of the node sits at y and stays in place when the height changes: START the top edge, CENTER the middle, END the bottom edge. |
| aspectRatio signal | double | none, the width and the height stay free | Width divided by height that the node keeps on every frame: JOID computes the height from the width, or the width from the height when the width is 0. |
| zindex signal | int | 0 | Order of the node among its siblings: a higher value is drawn above and receives the input first. |
| zlevel signal | double | 0D | Depth of the node along the Z axis, added to the depth of its parent. |
Visibility
Section titled “Visibility”| Property | Type | Default | Summary |
|---|---|---|---|
| skeleton | Function<T,Node> | null | Placeholder node drawn instead of this node and its children while one of its wait conditions fails; the function receives the node and returns the placeholder, or null for the default skeleton. |
| visible signal | boolean | true | If false, the node and its children are neither drawn nor sent any input, and a layout node leaves them out. |
| enabled signal | boolean | true | If false, the node and its children are drawn but ignore the input and show no hover progress. |
| interactive signal | boolean | true | If false, the node and its children let the mouse through to what is under them and are never hovered. |
Hover and tooltips
Section titled “Hover and tooltips”| Property | Type | Default | Summary |
|---|---|---|---|
| cursor signal | Cursor | null: the cursor of the closest parent that sets one, Cursor.DEFAULT when none does | Cursor shown while the mouse is over the node; null uses the cursor of the closest parent that has one. |
| hoverDuration signal | long | 200L | Time, in ms, that the hover progress takes to go from 0 to 1 and back. |
| hoverEquation signal | TweenEquation | TweenEquations.LINEAR | Easing of the hover progress. |
| hover signal | IHoverElement | Adds a tooltip shown while the node is hovered: a IHoverElement, a HoverSupplier that gives one line (null for none), or a Supplier of lines (null for none) drawn by UI.drawHover. |
Scrolling
Section titled “Scrolling”| Property | Type | Default | Summary |
|---|---|---|---|
| overflow signal | OverflowProperty | OverflowProperty.NONE | What the node does with children that go past its bounds: NONE draws them, HIDDEN clips them, SCROLL clips them and lets the wheel scroll them. |
| scrollSpeed signal | double | 1D | Factor applied to the wheel: one notch scrolls 30 design pixels times this factor, twice as far with Control down. |
| scrollbar | BaseScrollbarNode | null | Scrollbar that scrolls this node; it is drawn when the overflow is SCROLL and the content goes past the node. |
Other properties
Section titled “Other properties”| Property | Type | Default | Summary |
|---|---|---|---|
| label signal | Text | null: no label | Text drawn centered over the node, after the node itself and before its children; null draws none. |
| draggable signal | DraggableProperty | null: the node cannot be dragged | Lets the user drag the node with the left button, inside the area and with the movement and the snapping of the DraggableProperty; null means the node cannot be dragged. |
Methods
Section titled “Methods”Lifecycle
Section titled “Lifecycle”| Returns | Signature | Summary |
|---|---|---|
void | load(UI ui) | Attaches the node to the UI: loads its children, its scrollbar, its skeleton and its effects, runs init and fires onInit. |
void | render(double mouseX, double mouseY) | Draws the node for this frame: applies its layout, its hover and its scroll, then draws its children behind it, itself, its label, its children in front and its layers, through its effects. |
boolean | renderHover(double mouseX, double mouseY) | Draws the tooltips of the node at the mouse and returns true when it has one. |
this | updateScroll() fluent | Moves the shown scroll to its target at once, on both axes, without the smooth movement. |
this | updateScrollX() fluent | Moves the shown horizontal scroll to its target at once. |
this | updateScrollY() fluent | Moves the shown vertical scroll to its target at once. |
Children
Section titled “Children”| Returns | Signature | Summary |
|---|---|---|
this | append(Node… nodes) fluent | Adds children to the node, in front of their siblings of the same zindex. |
this | attach(UI ui) fluent | Attaches the node at the root of the UI, as UI.add does. |
this | attach(Node node) fluent | Adds the node to the children of this parent, as Node.append does. |
this | body(Runnable runnable) fluent | Runs the code at once, to create the children where the node is created. |
this | body(Consumer | Runs the code at once with the node, to create its children; JOID keeps it to run it again when a watch rebuilds the node. |
this | clearChildren() fluent | Detaches every child of the node. |
T | getChild(int index, Class | The child at this index among the children of this class, or null when there is none at that index. |
List<Node> | getChildren() | The children of the node, in the order they were added; a read-only view. |
List<T> | getChildren(Class | The children of the node that are of this class, in the order they were added. |
List<Node> | getNodeListAt(double x, double y) | The node and every visible child under this point of the canvas, from the front-most to the back-most. |
Node | getParent() | The parent of the node, or null for a root. |
boolean | isAttached() | If true, the node is loaded in a UI. |
Position and size
Section titled “Position and size”| Returns | Signature | Summary |
|---|---|---|
double | getAbsoluteX() | Horizontal position of the top-left corner of the node on the canvas, with the positions of its parents, their layout and their scroll. |
double | getAbsoluteY() | Vertical position of the top-left corner of the node on the canvas. |
double | getAbsoluteDefaultX() | Position on the canvas of the declared x of the node, before its layout and its anchor. |
double | getAbsoluteDefaultY() | Position on the canvas of the declared y of the node, before its layout and its anchor. |
double | toDrawX(double x) | Converts a horizontal position of the canvas to the coordinates in which the node draws, where its left edge is getX(). |
double | toDrawY(double y) | Converts a vertical position of the canvas to the coordinates in which the node draws. |
double | w() | The current width of the node. |
double | h() | The current height of the node. |
double | dw(double value) | The width divided by the value: dw(2D) is half the width. |
double | dh(double value) | The height divided by the value. |
double | mw(double value) | The width multiplied by the value: mw(0.25D) is a quarter of the width. |
double | mh(double value) | The height multiplied by the value. |
double | aw(double value) | The width plus the value. |
double | ah(double value) | The height plus the value. |
double | ax(double value) | The current x plus the value. |
double | ay(double value) | The current y plus the value. |
double | getDefaultWidth() | The width declared by the constructor or by width(...); 0 when the width comes from the content. |
double | getDefaultHeight() | The height declared by the constructor or by height(...); 0 when the height comes from the content. |
Hover and tooltips
Section titled “Hover and tooltips”| Returns | Signature | Summary |
|---|---|---|
this | removeHover(IHoverElement element) fluent | Removes a tooltip element added with hover(...). |
this | clearHover() fluent | Removes every tooltip of the node. |
void | refreshHover(double mouseX, double mouseY) | Reads again whether the node is hovered, from the hovered path of its UI, and starts its hover animation and fires onHoverStart or onHoverEnd when that changed; the mouse is at this point of the design canvas. |
Cursor | getResolvedCursor() | The cursor shown over the node: its own, the one of its closest parent that has one, or the default arrow. |
float | hoverValue(float value) | The value multiplied by the hover progress, from 0 when the mouse is away to the value when the hover has fully faded in. |
TweenAnimator | getHoverAnimator() | The animator that holds the hover progress, from 0 to 1. |
boolean | isHovered() | If true, the mouse is over the node or one of its children, and its UI is on top. |
| Returns | Signature | Summary |
|---|---|---|
this | handleMousePressed(EventListener<NodeMouseEvent | Adds a listener that hears every mouse press of the UI, wherever the pointer is, after the children of the node in front and before its children behind; check isHovered() to react only over the node. |
this | handleMouseReleased(EventListener<NodeMouseEvent | Adds a listener that hears a mouse release, wherever the mouse is. |
this | handleMouseDragged(EventListener<NodeMouseEvent | Adds a listener that hears a mouse move while a button is held. |
this | handleMouseScroll(EventListener<NodeMouseScrollEvent | Adds a listener that hears every wheel turn of the UI, wherever the pointer is, before the node scrolls; check isHovered() to react only over the node. |
this | handleCharTyped(EventListener<NodeCharEvent | Adds a listener that hears a typed character, as a Unicode code point. |
this | handleKeyPressed(EventListener<NodeKeyEvent | Adds a listener that hears a key press. |
this | handleKeyReleased(EventListener<NodeKeyEvent | Adds a listener that hears a key release. |
long | getLastClickTime() | Time of the last mouse press the node received, in ms of the clock bridge. |
MouseButton | getLastClickButton() | Button of the last mouse press the node received, or null. |
Key | getLastKey() | The last key pressed while the node received the keyboard, or null. |
long | getLastKeyTime() | Time of the last key press the node received, in ms of the clock bridge. |
Scrolling
Section titled “Scrolling”| Returns | Signature | Summary |
|---|---|---|
T | scrollX(double scrollX) | Sets the horizontal scroll, in design pixels: 0 shows the start, a negative value moves the content to the left. |
T | scrollX(Signal | Binds the horizontal scroll to a signal: the node follows it, and a scroll by the user writes back to it. |
T | scrollY(double scrollY) | Sets the vertical scroll, in design pixels: 0 shows the top, a negative value moves the content up. |
T | scrollY(Signal | Binds the vertical scroll to a signal, both ways. |
this | scrollTo(double x, double y) fluent | Scrolls to these offsets as a change: the beforeScroll listeners can refuse it, and the content moves there smoothly. |
this | beforeScroll(EventListener<NodeScrollEvent.Pre | Adds a listener that runs before the scroll changes, by the wheel, a scrollbar or scrollTo; cancelling the event refuses the change. |
boolean | hasOverflowX() | If true, the overflow is SCROLL and the content is wider than the node. |
boolean | hasOverflowY() | If true, the overflow is SCROLL and the content is taller than the node. |
Node | getOverflowArea() | The node whose HIDDEN or SCROLL overflow clips this one, or null when nothing clips it. |
double | getScrollX() | Horizontal scroll shown on this frame, moving toward the target. |
double | getScrollY() | Vertical scroll shown on this frame, moving toward the target. |
double | getTargetScrollX() | Horizontal scroll that the content moves to. |
double | getTargetScrollY() | Vertical scroll that the content moves to. |
double | getMaxScrollX() | How far the content can scroll horizontally, in design pixels. |
double | getMaxScrollY() | How far the content can scroll vertically, in design pixels. |
boolean | isScrollEndX() | If true, a horizontal scroll toward the end has not reached it yet. |
boolean | isScrollEndY() | If true, a vertical scroll toward the end has not reached it yet. |
Drag and drop
Section titled “Drag and drop”| Returns | Signature | Summary |
|---|---|---|
this | startDragging(double mouseX, double mouseY) fluent | Starts a drag as if the user had pressed the left button at this point of the canvas; the beforeDragStart listeners can refuse it. |
this | stopDragging() fluent | Drops the node as if the user had released the button: it snaps to a target, or goes back to its start when it has targets and none fits or a beforeDragDrop listener refused. |
this | beforeDragStart(EventListener<NodeDragEvent.Pre | Adds a listener that runs before a drag starts; cancelling the event keeps the node in place. |
this | beforeDragDrop(EventListener<NodeDragEvent.Pre | Adds a listener that runs when the user releases the node; cancelling the event sends the node back to where the drag started. |
boolean | isDragging() | If true, the user holds the node, or a reorderable list drags it. |
double | getDragX() | Horizontal distance between the left edge of the node and the point where it was grabbed. |
double | getDragY() | Vertical distance between the top edge of the node and the point where it was grabbed. |
boolean | isDragged() | If true, the node is held or is still moving to where it was dropped. |
Node | getDragSource() | For the copy shown by a COPY drag, the node it copies; null for any other node. |
Node | getDraggedNode() | The copy that follows the mouse during a COPY drag, or null. |
double | getStartDragX() | Horizontal position of the node on the canvas when the drag started. |
double | getStartDragY() | Vertical position of the node on the canvas when the drag started. |
double | getTargetDragX() | Horizontal position on the canvas that the dragged node moves to. |
double | getTargetDragY() | Vertical position on the canvas that the dragged node moves to. |
Effects
Section titled “Effects”| Returns | Signature | Summary |
|---|---|---|
this | effect(NodeEffect<? super T> effect) fluent | Adds an effect to the node; an effect of the same class takes the place of the previous one. |
this | removeEffect(Class<?> effect) fluent | Removes the effects of this class and of its subclasses. |
this | clearEffects() fluent | Removes every effect of the node. |
boolean | hasEffect(Class<?> clazz) | If true, the node has an effect of this class or of a subclass. |
T | getEffect(Class | The effect of this class or of a subclass, or null. |
Drawing
Section titled “Drawing”| Returns | Signature | Summary |
|---|---|---|
this | layer(NodeLayer layer) fluent | Adds a drawing done after the children, in the coordinates of the node: (0, 0) is its top-left corner. |
this | layer(int index, NodeLayer layer) fluent | Inserts a drawing at this place among the layers of the node. |
this | clearLayers() fluent | Removes every layer of the node. |
Animation
Section titled “Animation”| Returns | Signature | Summary |
|---|---|---|
this | animate(TweenAnimator animator) fluent | Follows an animator: onAnimate fires on every frame where its value changes. |
this | removeAnimator(TweenAnimator animator) fluent | Stops following an animator. |
Reactivity
Section titled “Reactivity”| Returns | Signature | Summary |
|---|---|---|
this | wait(Predicate | Adds a condition that the node needs before it is mounted: until every condition holds, the skeleton is drawn instead of the node and its children. |
T | watch(Signal<?> signal, WatchProperty… properties) | Applies these properties each time the signal changes, such as running the body again to rebuild the children. |
T | watch(Signal<?> signal, Supplier | Applies these properties each time the signal changes while the condition gives true. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
boolean | hasListener(EventType<?> type) | If true, the node has a listener for this event type. |
boolean | isVisibleProperty() | If true, the node itself is set visible, whatever its parents and its clipping. |
boolean | isMounted() | If true, every wait condition of the node and of its parents holds. |
int | getIndex() | The zindex of the node, or the highest value while it is dragged with DraggableType.MOVE so that it is drawn above its siblings. |
T | getUi() | The UI of the node, or the UI whose code is running (UI.getCurrent) when the node is not attached yet. |
String | getHierarchy() | The class names from the root down to the node, such as FlexNode - RectNode. |
String | getMappedIndex() | The path of the node in the tree, its index at each level, such as 0.2.1; N/A when it is not attached. |
List<Task> | getTaskList() | The tasks attached to the node; a read-only view. |
List<Shortcut> | getShortcutList() | The shortcuts attached to the node; a read-only view. |
String | toJson() | The position and the size of the node as JSON, with its state in dev mode. |
String | toString() | The JSON of toJson(), indented in dev mode. |
EventBus | getEventBus() | The listeners of the node. |
Consumer<Node> | getBodyConsumer() | The code given to body(Consumer), or null. |
double | getDefaultX() | The x declared by the constructor, x(...), move or a drag. |
double | getDefaultY() | The y declared by the constructor, y(...), move or a drag. |
double | getLayoutX() | Horizontal offset that the layout of the parent adds to the declared position. |
double | getLayoutY() | Vertical offset that the layout of the parent adds to the declared position. |
double | getShiftX() | Horizontal offset that the scroll of the parent adds. |
double | getShiftY() | Vertical offset that the scroll of the parent adds. |
boolean | isStepping() | If true, the drag animation is moving the node during this frame. |
int | getLastCodepoint() | The last character the node received, as a Unicode code point. |
long | getLoadCount() | How many times the node has been loaded into a UI. |
long | getRenderTime() | Time that the last frame of the node took to draw, children included, in nanoseconds. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
this | remove(Node… nodes) fluent | Detaches these children from the node; a node that is not its child is ignored. |
this | self(Consumer | Runs the code at once with the node, to set it up without breaking the chain. |
T | copy() | Returns an unattached copy of the node and of its children, with their properties, listeners and effects. |
this | useStore(Class | Returns the store of this class from the UI of the node, as UI.useStore does. |
this | addTask(Task task) fluent | Attaches a task to the node; it runs while the node belongs to an open UI. |
this | removeTask(Task task) fluent | Detaches a task from the node. |
this | addShortcut(Shortcut shortcut) fluent | Attaches a shortcut to the node; it fires while the node is visible and enabled. |
this | removeShortcut(Shortcut shortcut) fluent | Detaches a shortcut from the node. |
this | layoutPosition(double layoutX, double layoutY) fluent | Sets the offset that a layout adds to the declared position of the node. |
this | layoutSize(double width, double height) fluent | Sets the size of the node for this frame without changing its declared size. |
this | fit(double contentWidth, double contentHeight) fluent | Gives the node the size of its content on each axis whose declared size is 0, and keeps the current size on the other. |
this | move(double x, double y) fluent | Moves the node to this declared position as a change: the beforeMove listeners can refuse it, bound signals are written, and a running drop animation stops there. |
this | beforeMove(EventListener<NodeChangeEvent.Pre<T,Point>> listener) fluent | Adds a listener that runs before the node moves, by a drag or move; cancelling the event keeps the node in place. |
Color | hoverColor(Color color, Color hoveredColor) | The first color blended toward the second by the hover progress; a null second color returns the first. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
void | drawSkeleton(double mouseX, double mouseY) hook | Draws the default skeleton, a rectangle of the loading color on the bounds of the node. |
void | fireUpdate() | Updates the node and its children for this frame: pulls its reactive values, runs update and fires onUpdate. |
void | fireDetach() | Detaches the node and its children from their UI: runs detach, ends the drag and the hover, detaches the effects and fires onDetach. |
boolean | fireMousePressed(double mouseX, double mouseY, MouseButton button) | Sends a mouse press at this point to the node and its children, as the UI does, and returns true when something consumed it; use it to simulate an input. |
void | fireMousePressed(double mouseX, double mouseY, MouseButton button, IConsumableEvent source) | Sends a mouse press that belongs to this source event: consuming it consumes the source. |
boolean | fireMouseReleased(double mouseX, double mouseY, MouseButton button, long deltaTime) | Sends a mouse release of this button, pressed deltaTime ms before, to the node and its children and returns true when something consumed it. |
void | fireMouseReleased(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source) | Sends a mouse release that belongs to this source event. |
boolean | fireMouseDragged(double mouseX, double mouseY, MouseButton button, long deltaTime) | Sends a mouse move with this button held for deltaTime ms and returns true when something consumed it. |
void | fireMouseDragged(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source) | Sends a mouse move that belongs to this source event. |
boolean | fireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY) | Sends a wheel turn, in notches, and returns true when something consumed it. |
void | fireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY, IConsumableEvent source) | Sends a wheel turn that belongs to this source event. |
boolean | fireCharTyped(int codepoint) | Sends a typed character and returns true when something consumed it. |
void | fireCharTyped(int codepoint, IConsumableEvent source) | Sends a typed character that belongs to this source event. |
boolean | fireKeyPressed(Key physicalKey, Key key) | Sends a key press, its position on the keyboard then the key that the layout gives, and returns true when something consumed it. |
void | fireKeyPressed(Key physicalKey, Key key, IConsumableEvent source) | Sends a key press that belongs to this source event. |
boolean | fireKeyReleased(Key physicalKey, Key key) | Sends a key release and returns true when something consumed it. |
void | fireKeyReleased(Key physicalKey, Key key, IConsumableEvent source) | Sends a key release that belongs to this source event. |
boolean | fireDragStart(Runnable start) | Runs the beforeDragStart listeners, then the start and the onDragStart listeners unless a listener cancelled; returns false when it was cancelled. |
void | fireDrag(Runnable drag) | Runs the move of the drag, then the onDrag listeners. |
boolean | fireDragDrop(Node target, Runnable drop) | Runs the beforeDragDrop listeners, then the drop and the onDragDrop listeners unless a listener cancelled; returns false when it was cancelled. |
T | listen(EventType type, EventListener listener) protected | Adds a listener for an event type of the subclass; the onX methods of a node of your own call it. |
E | fire(EventType<? super E> type, Supplier | Fires an event of the subclass to its listeners and returns it, or null when no listener exists, in which case the event is never built. |
T | start(String property, V value, Consumer | Sets a property to a plain value and applies it, replacing a previous follow or bind of the same property. |
T | follow(String property, Supplier | Makes a property follow a Supplier: the applier receives each new value, when the signals it reads change or on every frame for a lambda. |
T | bind(String property, Signal | Binds a property to a signal: the applier receives each value of the signal. |
T | bind(String property, Signal | Binds a property to a signal both ways: sync writes the value back through the writer. |
T | bindNullable(String property, Signal | Binds a property to a signal both ways, accepting null values. |
void | sync(String property, Object value) protected | Writes the value applied to a bound property back to its signal. |
void | require(String setting, String advice, Predicate | Declares a setting that the node needs: when the node loads without it, it throws an IllegalStateException that names the setting and gives the advice. |
N | part(Node previous, N next) protected | Replaces a part of the node, a child that the subclass places itself, by another one at the same place among the children, and returns it. |
void | reorderChildren(List | Puts the children in this order, for drawing and for the layout. |
Node | instantiate() hook protected | Creates the instance that copy() fills: it tries the constructors (x, y, width, height), (x, y) and without argument. |
boolean | holdsInput() hook protected | If true, the node keeps receiving the input while it is scrolled out of the area of its container; false by default. |
boolean | isDraggingChild(Node child) hook protected | If true, the parent raises this child above its siblings because it is being dragged; a layout node that drags its children overrides it. |
NodeBindings | getBindings() protected | The reactive bindings of the node’s properties, for a subclass. |
Events
Section titled “Events”Lifecycle
Section titled “Lifecycle”| Event | Listener | Summary |
|---|---|---|
| onUpdate | EventListener<NodeEvent<T>> | Adds a listener that runs on every frame, after the children and the update hook. |
| onDetach | EventListener<NodeEvent<T>> | Adds a listener that runs when the node leaves its UI, after its children and its own detach. |
| onInit | EventListener<NodeEvent<T>> | Adds a listener that runs when the node is loaded into a UI, after init. |
| onRender | EventListener<NodeDrawEvent<T>> | Adds a listener that runs at the end of the drawing of the node, after its children and its layers. |
| onDraw | EventListener<NodeDrawEvent<T>> | Adds a listener that runs after the node has drawn itself, before its label and its children in front. |
| onMount | EventListener<NodeEvent<T>> | Adds a listener that runs on each frame where the node becomes mounted: the first frame where it is drawn mounted, then again after a detach or after a wait condition stopped holding. |
Hover and tooltips
Section titled “Hover and tooltips”| Event | Listener | Summary |
|---|---|---|
| onHoverStart | EventListener<NodeHoverEvent<T>> | Adds a listener that runs when the mouse enters the node. |
| onHover | EventListener<NodeHoverEvent<T>> | Adds a listener that runs on every frame while the node is hovered. |
| onHoverEnd | EventListener<NodeHoverEvent<T>> | Adds a listener that runs when the mouse leaves the node, or when the node is hidden or detached while hovered. |
Scrolling
Section titled “Scrolling”| Event | Listener | Summary |
|---|---|---|
| onScroll | EventListener<NodeScrollEvent.Post<T>> | Adds a listener that runs after the scroll has changed. |
| onScrollToEnd | EventListener<NodeScrollEvent.Post<T>> | Adds a listener that runs when a scroll heads for the end of the content, before the content gets there: the moment to load more. |
| onScrollEndReached | EventListener<NodeScrollEvent.Post<T>> | Adds a listener that runs when the shown content has reached the end after a scroll toward it. |
Drag and drop
Section titled “Drag and drop”| Event | Listener | Summary |
|---|---|---|
| onDragStart | EventListener<NodeDragEvent.Post<T>> | Adds a listener that runs once a drag has started. |
| onDrag | EventListener<NodeDragEvent.Post<T>> | Adds a listener that runs at every mouse move of the drag. |
| onDragDrop | EventListener<NodeDragEvent.Post<T>> | Adds a listener that runs once the node has been dropped; the event holds the snap target, or null. |
| onDragSnap | EventListener<NodeDragEvent.Post<T>> | Adds a listener that runs when the node is dropped on one of its snap targets, before onDragDrop; a beforeDragDrop listener that cancels skips it. |
Other events
Section titled “Other events”| Event | Listener | Summary |
|---|---|---|
| onMove | EventListener<NodeChangeEvent.Post<T,Point>> | Adds a listener that runs after the node has moved. |
| onChildAppend | EventListener<NodeChildEvent<T>> | Adds a listener that runs when a child is added to the node; moving an existing child to the front does not fire it. |
| onClick | EventListener<NodeMouseEvent<T>> | Adds a listener that runs when the left button is pressed on the hovered node, unless a node in front consumed the press; the press is then consumed. |
| onAnimate | EventListener<NodeAnimateEvent<T>> | Adds a listener that runs when the value of a followed animator changes, during the update of the node. |
| onWatch | EventListener<NodeWatchEvent<T>> | Adds a listener that runs after a watch of the node has applied its properties. |
Creation details
Section titled “Creation details”Node(double x, double y) protected
Creates a node at x, y with a size of 0, for a subclass whose size comes from its content.
Node(double x, double y, double width, double height) protected
Creates a node at x, y with this width and height, in design pixels.
A subclass calls it from its own constructor; Node.copy calls a constructor with these four arguments.
Property details
Section titled “Property details”this x(double x)fluentthis x(Signal<Double> x)fluentthis x(Supplier<Double> x)fluent signaldouble getX()
Default: set at creation
Horizontal position of the anchor point of the node, in design pixels, from the left edge of its parent (or of the canvas for a root or ABSOLUTE node).
A writable signal is bound both ways: a drag or move writes the new position to it; a lambda or a read-only signal cannot be combined with a MOVE drag and throws an IllegalStateException.
this y(double y)fluentthis y(Signal<Double> y)fluentthis y(Supplier<Double> y)fluent signaldouble getY()
Default: set at creation
Vertical position of the anchor point of the node, in design pixels, from the top edge of its parent (or of the canvas for a root or ABSOLUTE node).
It binds to a signal like x.
this width(double width)fluentthis width(Supplier<Double> width)fluent signaldouble getWidth()
Default: set at creation
Width of the node, in design pixels.
0 lets a node that measures its content (text, image, flex, grid) take the width of its content.
height
Section titled “height”this height(double height)fluentthis height(Supplier<Double> height)fluent signaldouble getHeight()
Default: set at creation
Height of the node, in design pixels.
0 lets a node that measures its content take the height of its content.
position
Section titled “position”this position(PositionProperty position)fluentthis position(Supplier<PositionProperty> position)fluent signalPositionProperty getPosition()
Default: PositionProperty.RELATIVE
RELATIVE places the node inside its parent; ABSOLUTE places it on the canvas whatever its parents, out of their layout, their scroll and their content size.
anchor
Section titled “anchor”this anchor(Align anchor)fluentthis anchor(Supplier<Align> anchor)fluent signal
Default: Align.START
Sets anchorX and anchorY to the same value.
anchorX
Section titled “anchorX”this anchorX(Align anchorX)fluentthis anchorX(Supplier<Align> anchorX)fluent signalAlign getAnchorX()
Default: Align.START
Which point of the node sits at x and stays in place when the width changes: START the left edge, CENTER the middle, END the right edge.
anchorY
Section titled “anchorY”this anchorY(Align anchorY)fluentthis anchorY(Supplier<Align> anchorY)fluent signalAlign getAnchorY()
Default: Align.START
Which point of the node sits at y and stays in place when the height changes: START the top edge, CENTER the middle, END the bottom edge.
aspectRatio
Section titled “aspectRatio”this aspectRatio(double aspectRatio)fluentthis aspectRatio(Supplier<Double> aspectRatio)fluent signaldouble getAspectRatio()
Default: none, the width and the height stay free
Width divided by height that the node keeps on every frame: JOID computes the height from the width, or the width from the height when the width is 0.
A value of 0 or below turns it off.
zindex
Section titled “zindex”this zindex(int zindex)fluentthis zindex(Supplier<Integer> zindex)fluent signalint getZindex()
Default: 0
Order of the node among its siblings: a higher value is drawn above and receives the input first. A negative value draws the child behind its parent.
zlevel
Section titled “zlevel”this zlevel(double zlevel)fluentthis zlevel(Supplier<Double> zlevel)fluent signaldouble getZlevel()
Default: 0D
Depth of the node along the Z axis, added to the depth of its parent.
skeleton
Section titled “skeleton”this skeleton(Function<T,Node> skeleton)fluentNode getSkeleton()
Default: null
Placeholder node drawn instead of this node and its children while one of its wait conditions fails; the function receives the node and returns the placeholder, or null for the default skeleton.
visible
Section titled “visible”this visible(boolean visible)fluentthis visible(Supplier<Boolean> visible)fluent signalboolean isVisible()
Default: true
If false, the node and its children are neither drawn nor sent any input, and a layout node leaves them out.
enabled
Section titled “enabled”this enabled(boolean enabled)fluentthis enabled(Supplier<Boolean> enabled)fluent signalboolean isEnabled()
Default: true
If false, the node and its children are drawn but ignore the input and show no hover progress.
interactive
Section titled “interactive”this interactive(boolean interactive)fluentthis interactive(Supplier<Boolean> interactive)fluent signalboolean isInteractive()
Default: true
If false, the node and its children let the mouse through to what is under them and are never hovered.
cursor
Section titled “cursor”this cursor(Cursor cursor)fluentthis cursor(Supplier<Cursor> cursor)fluent signalCursor getCursor()
Default: null: the cursor of the closest parent that sets one, Cursor.DEFAULT when none does
Cursor shown while the mouse is over the node; null uses the cursor of the closest parent that has one.
hoverDuration
Section titled “hoverDuration”this hoverDuration(long hoverDuration)fluentthis hoverDuration(Supplier<Long> hoverDuration)fluent signallong getHoverDuration()
Default: 200L
Time, in ms, that the hover progress takes to go from 0 to 1 and back.
hoverEquation
Section titled “hoverEquation”this hoverEquation(TweenEquation hoverEquation)fluentthis hoverEquation(Supplier<TweenEquation> hoverEquation)fluent signalTweenEquation getHoverEquation()
Default: TweenEquations.LINEAR
Easing of the hover progress.
this hover(IHoverElement element)fluentthis hover(HoverSupplier supplier)fluentthis hover(Supplier<List<String>> supplier)fluent signal
Adds a tooltip shown while the node is hovered: a IHoverElement, a HoverSupplier that gives one line (null for none), or a Supplier of lines (null for none) drawn by UI.drawHover.
Each call adds one more element.
overflow
Section titled “overflow”this overflow(OverflowProperty overflow)fluentthis overflow(Supplier<OverflowProperty> overflow)fluent signalOverflowProperty getOverflow()
Default: OverflowProperty.NONE
What the node does with children that go past its bounds: NONE draws them, HIDDEN clips them, SCROLL clips them and lets the wheel scroll them.
scrollSpeed
Section titled “scrollSpeed”this scrollSpeed(double scrollSpeed)fluentthis scrollSpeed(Supplier<Double> scrollSpeed)fluent signaldouble getScrollSpeed()
Default: 1D
Factor applied to the wheel: one notch scrolls 30 design pixels times this factor, twice as far with Control down.
scrollbar
Section titled “scrollbar”this scrollbar(BaseScrollbarNode scrollbar)fluentBaseScrollbarNode getScrollbar()
Default: null
Scrollbar that scrolls this node; it is drawn when the overflow is SCROLL and the content goes past the node.
this label(Text label)fluentthis label(Supplier<Text> label)fluent signalText getLabel()
Default: null: no label
Text drawn centered over the node, after the node itself and before its children; null draws none.
draggable
Section titled “draggable”this draggable(DraggableProperty draggable)fluentthis draggable(Supplier<DraggableProperty> draggable)fluent signalDraggableProperty getDraggable()
Default: null: the node cannot be dragged
Lets the user drag the node with the left button, inside the area and with the movement and the snapping of the DraggableProperty; null means the node cannot be dragged.
Method details
Section titled “Method details”void load(UI ui)
Attaches the node to the UI: loads its children, its scrollbar, its skeleton and its effects, runs init and fires onInit.
Throws an IllegalStateException when a required part or setting is missing; JOID calls it for you when the node joins an open UI.
render
Section titled “render”void render(double mouseX, double mouseY)
Draws the node for this frame: applies its layout, its hover and its scroll, then draws its children behind it, itself, its label, its children in front and its layers, through its effects. Its parent or its UI calls it; you never call it.
renderHover
Section titled “renderHover”boolean renderHover(double mouseX, double mouseY)
Draws the tooltips of the node at the mouse and returns true when it has one.
The UI calls it on the hovered node, then on its parents until one draws.
updateScroll
Section titled “updateScroll”this updateScroll() fluent
Moves the shown scroll to its target at once, on both axes, without the smooth movement.
updateScrollX
Section titled “updateScrollX”this updateScrollX() fluent
Moves the shown horizontal scroll to its target at once.
updateScrollY
Section titled “updateScrollY”this updateScrollY() fluent
Moves the shown vertical scroll to its target at once.
append
Section titled “append”this append(Node... nodes) fluent
Adds children to the node, in front of their siblings of the same zindex.
A node that has another parent or that is a root of a UI leaves it first; a child of this node moves to the front without being loaded again.
The children are loaded at once when the node is attached, and when it joins a UI otherwise; onChildAppend fires for each new child.
attach
Section titled “attach”this attach(UI ui) fluent
Attaches the node at the root of the UI, as UI.add does.
this attach(Node node) fluent
Adds the node to the children of this parent, as Node.append does.
this body(Runnable runnable) fluent
Runs the code at once, to create the children where the node is created.
this body(Consumer<T> consumer) fluent
Runs the code at once with the node, to create its children; JOID keeps it to run it again when a watch rebuilds the node.
clearChildren
Section titled “clearChildren”this clearChildren() fluent
Detaches every child of the node.
getChild
Section titled “getChild”<T extends Node> T getChild(int index, Class<T> clazz)
The child at this index among the children of this class, or null when there is none at that index.
getChildren
Section titled “getChildren”List<Node> getChildren()
The children of the node, in the order they were added; a read-only view.
<T extends Node> List<T> getChildren(Class<T> clazz)
The children of the node that are of this class, in the order they were added.
getNodeListAt
Section titled “getNodeListAt”List<Node> getNodeListAt(double x, double y)
The node and every visible child under this point of the canvas, from the front-most to the back-most.
getParent
Section titled “getParent”Node getParent()
The parent of the node, or null for a root.
isAttached
Section titled “isAttached”boolean isAttached()
If true, the node is loaded in a UI.
getAbsoluteX
Section titled “getAbsoluteX”double getAbsoluteX()
Horizontal position of the top-left corner of the node on the canvas, with the positions of its parents, their layout and their scroll.
getAbsoluteY
Section titled “getAbsoluteY”double getAbsoluteY()
Vertical position of the top-left corner of the node on the canvas.
getAbsoluteDefaultX
Section titled “getAbsoluteDefaultX”double getAbsoluteDefaultX()
Position on the canvas of the declared x of the node, before its layout and its anchor.
getAbsoluteDefaultY
Section titled “getAbsoluteDefaultY”double getAbsoluteDefaultY()
Position on the canvas of the declared y of the node, before its layout and its anchor.
toDrawX
Section titled “toDrawX”double toDrawX(double x)
Converts a horizontal position of the canvas to the coordinates in which the node draws, where its left edge is getX().
toDrawY
Section titled “toDrawY”double toDrawY(double y)
Converts a vertical position of the canvas to the coordinates in which the node draws.
double w()
The current width of the node.
double h()
The current height of the node.
double dw(double value)
The width divided by the value: dw(2D) is half the width.
double dh(double value)
The height divided by the value.
double mw(double value)
The width multiplied by the value: mw(0.25D) is a quarter of the width.
double mh(double value)
The height multiplied by the value.
double aw(double value)
The width plus the value.
double ah(double value)
The height plus the value.
double ax(double value)
The current x plus the value.
double ay(double value)
The current y plus the value.
getDefaultWidth
Section titled “getDefaultWidth”double getDefaultWidth()
The width declared by the constructor or by width(...); 0 when the width comes from the content.
getDefaultHeight
Section titled “getDefaultHeight”double getDefaultHeight()
The height declared by the constructor or by height(...); 0 when the height comes from the content.
removeHover
Section titled “removeHover”this removeHover(IHoverElement element) fluent
Removes a tooltip element added with hover(...).
clearHover
Section titled “clearHover”this clearHover() fluent
Removes every tooltip of the node.
refreshHover
Section titled “refreshHover”void refreshHover(double mouseX, double mouseY)
Reads again whether the node is hovered, from the hovered path of its UI, and starts its hover animation and fires onHoverStart or onHoverEnd when that changed; the mouse is at this point of the design canvas.
The node calls it while it draws, and UI.moveMouse at every mouse event.
getResolvedCursor
Section titled “getResolvedCursor”Cursor getResolvedCursor()
The cursor shown over the node: its own, the one of its closest parent that has one, or the default arrow.
hoverValue
Section titled “hoverValue”float hoverValue(float value)
The value multiplied by the hover progress, from 0 when the mouse is away to the value when the hover has fully faded in.
getHoverAnimator
Section titled “getHoverAnimator”TweenAnimator getHoverAnimator()
The animator that holds the hover progress, from 0 to 1.
isHovered
Section titled “isHovered”boolean isHovered()
If true, the mouse is over the node or one of its children, and its UI is on top.
handleMousePressed
Section titled “handleMousePressed”this handleMousePressed(EventListener<NodeMouseEvent<T>> listener) fluent
Adds a listener that hears every mouse press of the UI, wherever the pointer is, after the children of the node in front and before its children behind; check isHovered() to react only over the node.
It does not run while the node is hidden, disabled or not interactive.
Consuming the event stops the nodes behind, the UI and the host; a MONITOR listener always hears it.
handleMouseReleased
Section titled “handleMouseReleased”this handleMouseReleased(EventListener<NodeMouseEvent<T>> listener) fluent
Adds a listener that hears a mouse release, wherever the mouse is. It runs even on a hidden or disabled node, so that a gesture always ends.
handleMouseDragged
Section titled “handleMouseDragged”this handleMouseDragged(EventListener<NodeMouseEvent<T>> listener) fluent
Adds a listener that hears a mouse move while a button is held. It does not run while the node is hidden, disabled or not interactive.
handleMouseScroll
Section titled “handleMouseScroll”this handleMouseScroll(EventListener<NodeMouseScrollEvent<T>> listener) fluent
Adds a listener that hears every wheel turn of the UI, wherever the pointer is, before the node scrolls; check isHovered() to react only over the node.
It does not run while the node is hidden, disabled or not interactive.
handleCharTyped
Section titled “handleCharTyped”this handleCharTyped(EventListener<NodeCharEvent<T>> listener) fluent
Adds a listener that hears a typed character, as a Unicode code point. It does not run while the node is hidden or disabled, nor while it is scrolled out of view unless it holds the input.
handleKeyPressed
Section titled “handleKeyPressed”this handleKeyPressed(EventListener<NodeKeyEvent<T>> listener) fluent
Adds a listener that hears a key press. It does not run while the node is hidden or disabled, nor while it is scrolled out of view unless it holds the input.
handleKeyReleased
Section titled “handleKeyReleased”this handleKeyReleased(EventListener<NodeKeyEvent<T>> listener) fluent
Adds a listener that hears a key release. It runs even on a hidden or disabled node, so that a held key always ends.
getLastClickTime
Section titled “getLastClickTime”long getLastClickTime()
Time of the last mouse press the node received, in ms of the clock bridge.
getLastClickButton
Section titled “getLastClickButton”MouseButton getLastClickButton()
Button of the last mouse press the node received, or null.
getLastKey
Section titled “getLastKey”Key getLastKey()
The last key pressed while the node received the keyboard, or null.
getLastKeyTime
Section titled “getLastKeyTime”long getLastKeyTime()
Time of the last key press the node received, in ms of the clock bridge.
scrollX
Section titled “scrollX”<T extends Node> T scrollX(double scrollX)
Sets the horizontal scroll, in design pixels: 0 shows the start, a negative value moves the content to the left.
The value is kept between the end of the content and 0; a positive value warns once in dev mode.
<T extends Node> T scrollX(Signal<Double> scrollX)
Binds the horizontal scroll to a signal: the node follows it, and a scroll by the user writes back to it.
scrollY
Section titled “scrollY”<T extends Node> T scrollY(double scrollY)
Sets the vertical scroll, in design pixels: 0 shows the top, a negative value moves the content up.
The value is kept between the end of the content and 0; a positive value warns once in dev mode.
<T extends Node> T scrollY(Signal<Double> scrollY)
Binds the vertical scroll to a signal, both ways.
scrollTo
Section titled “scrollTo”this scrollTo(double x, double y) fluent
Scrolls to these offsets as a change: the beforeScroll listeners can refuse it, and the content moves there smoothly.
beforeScroll
Section titled “beforeScroll”this beforeScroll(EventListener<NodeScrollEvent.Pre<T>> listener) fluent
Adds a listener that runs before the scroll changes, by the wheel, a scrollbar or scrollTo; cancelling the event refuses the change.
hasOverflowX
Section titled “hasOverflowX”boolean hasOverflowX()
If true, the overflow is SCROLL and the content is wider than the node.
hasOverflowY
Section titled “hasOverflowY”boolean hasOverflowY()
If true, the overflow is SCROLL and the content is taller than the node.
getOverflowArea
Section titled “getOverflowArea”Node getOverflowArea()
The node whose HIDDEN or SCROLL overflow clips this one, or null when nothing clips it.
getScrollX
Section titled “getScrollX”double getScrollX()
Horizontal scroll shown on this frame, moving toward the target.
getScrollY
Section titled “getScrollY”double getScrollY()
Vertical scroll shown on this frame, moving toward the target.
getTargetScrollX
Section titled “getTargetScrollX”double getTargetScrollX()
Horizontal scroll that the content moves to.
getTargetScrollY
Section titled “getTargetScrollY”double getTargetScrollY()
Vertical scroll that the content moves to.
getMaxScrollX
Section titled “getMaxScrollX”double getMaxScrollX()
How far the content can scroll horizontally, in design pixels.
getMaxScrollY
Section titled “getMaxScrollY”double getMaxScrollY()
How far the content can scroll vertically, in design pixels.
isScrollEndX
Section titled “isScrollEndX”boolean isScrollEndX()
If true, a horizontal scroll toward the end has not reached it yet.
isScrollEndY
Section titled “isScrollEndY”boolean isScrollEndY()
If true, a vertical scroll toward the end has not reached it yet.
startDragging
Section titled “startDragging”this startDragging(double mouseX, double mouseY) fluent
Starts a drag as if the user had pressed the left button at this point of the canvas; the beforeDragStart listeners can refuse it.
Throws an IllegalStateException when the node has no draggable property, when it is disabled, or when the area is PARENT and the node has no parent.
stopDragging
Section titled “stopDragging”this stopDragging() fluent
Drops the node as if the user had released the button: it snaps to a target, or goes back to its start when it has targets and none fits or a beforeDragDrop listener refused.
beforeDragStart
Section titled “beforeDragStart”this beforeDragStart(EventListener<NodeDragEvent.Pre<T>> listener) fluent
Adds a listener that runs before a drag starts; cancelling the event keeps the node in place.
beforeDragDrop
Section titled “beforeDragDrop”this beforeDragDrop(EventListener<NodeDragEvent.Pre<T>> listener) fluent
Adds a listener that runs when the user releases the node; cancelling the event sends the node back to where the drag started.
isDragging
Section titled “isDragging”boolean isDragging()
If true, the user holds the node, or a reorderable list drags it.
getDragX
Section titled “getDragX”double getDragX()
Horizontal distance between the left edge of the node and the point where it was grabbed.
getDragY
Section titled “getDragY”double getDragY()
Vertical distance between the top edge of the node and the point where it was grabbed.
isDragged
Section titled “isDragged”boolean isDragged()
If true, the node is held or is still moving to where it was dropped.
getDragSource
Section titled “getDragSource”Node getDragSource()
For the copy shown by a COPY drag, the node it copies; null for any other node.
getDraggedNode
Section titled “getDraggedNode”Node getDraggedNode()
The copy that follows the mouse during a COPY drag, or null.
getStartDragX
Section titled “getStartDragX”double getStartDragX()
Horizontal position of the node on the canvas when the drag started.
getStartDragY
Section titled “getStartDragY”double getStartDragY()
Vertical position of the node on the canvas when the drag started.
getTargetDragX
Section titled “getTargetDragX”double getTargetDragX()
Horizontal position on the canvas that the dragged node moves to.
getTargetDragY
Section titled “getTargetDragY”double getTargetDragY()
Vertical position on the canvas that the dragged node moves to.
effect
Section titled “effect”this effect(NodeEffect<? super T> effect) fluent
Adds an effect to the node; an effect of the same class takes the place of the previous one.
removeEffect
Section titled “removeEffect”this removeEffect(Class<?> effect) fluent
Removes the effects of this class and of its subclasses.
clearEffects
Section titled “clearEffects”this clearEffects() fluent
Removes every effect of the node.
hasEffect
Section titled “hasEffect”boolean hasEffect(Class<?> clazz)
If true, the node has an effect of this class or of a subclass.
getEffect
Section titled “getEffect”<T extends NodeEffect<?>> T getEffect(Class<T> clazz)
The effect of this class or of a subclass, or null.
this layer(NodeLayer layer) fluent
Adds a drawing done after the children, in the coordinates of the node: (0, 0) is its top-left corner.
this layer(int index, NodeLayer layer) fluent
Inserts a drawing at this place among the layers of the node.
clearLayers
Section titled “clearLayers”this clearLayers() fluent
Removes every layer of the node.
animate
Section titled “animate”this animate(TweenAnimator animator) fluent
Follows an animator: onAnimate fires on every frame where its value changes.
removeAnimator
Section titled “removeAnimator”this removeAnimator(TweenAnimator animator) fluent
Stops following an animator.
this wait(Predicate<T> predicate) fluent
Adds a condition that the node needs before it is mounted: until every condition holds, the skeleton is drawn instead of the node and its children.
<T extends Node> T watch(Signal<?> signal, WatchProperty... properties)
Applies these properties each time the signal changes, such as running the body again to rebuild the children.
<T extends Node> T watch(Signal<?> signal, Supplier<Boolean> condition, WatchProperty... properties)
Applies these properties each time the signal changes while the condition gives true.
hasListener
Section titled “hasListener”boolean hasListener(EventType<?> type)
If true, the node has a listener for this event type.
isVisibleProperty
Section titled “isVisibleProperty”boolean isVisibleProperty()
If true, the node itself is set visible, whatever its parents and its clipping.
isMounted
Section titled “isMounted”boolean isMounted()
If true, every wait condition of the node and of its parents holds.
getIndex
Section titled “getIndex”int getIndex()
The zindex of the node, or the highest value while it is dragged with DraggableType.MOVE so that it is drawn above its siblings.
<T extends UI> T getUi()
The UI of the node, or the UI whose code is running (UI.getCurrent) when the node is not attached yet.
getHierarchy
Section titled “getHierarchy”String getHierarchy()
The class names from the root down to the node, such as FlexNode - RectNode.
getMappedIndex
Section titled “getMappedIndex”String getMappedIndex()
The path of the node in the tree, its index at each level, such as 0.2.1; N/A when it is not attached.
getTaskList
Section titled “getTaskList”List<Task> getTaskList()
The tasks attached to the node; a read-only view.
getShortcutList
Section titled “getShortcutList”List<Shortcut> getShortcutList()
The shortcuts attached to the node; a read-only view.
toJson
Section titled “toJson”String toJson()
The position and the size of the node as JSON, with its state in dev mode.
toString
Section titled “toString”String toString()
The JSON of toJson(), indented in dev mode.
getEventBus
Section titled “getEventBus”EventBus getEventBus()
The listeners of the node.
getBodyConsumer
Section titled “getBodyConsumer”Consumer<Node> getBodyConsumer()
The code given to body(Consumer), or null.
getDefaultX
Section titled “getDefaultX”double getDefaultX()
The x declared by the constructor, x(...), move or a drag.
getDefaultY
Section titled “getDefaultY”double getDefaultY()
The y declared by the constructor, y(...), move or a drag.
getLayoutX
Section titled “getLayoutX”double getLayoutX()
Horizontal offset that the layout of the parent adds to the declared position.
getLayoutY
Section titled “getLayoutY”double getLayoutY()
Vertical offset that the layout of the parent adds to the declared position.
getShiftX
Section titled “getShiftX”double getShiftX()
Horizontal offset that the scroll of the parent adds.
getShiftY
Section titled “getShiftY”double getShiftY()
Vertical offset that the scroll of the parent adds.
isStepping
Section titled “isStepping”boolean isStepping()
If true, the drag animation is moving the node during this frame.
getLastCodepoint
Section titled “getLastCodepoint”int getLastCodepoint()
The last character the node received, as a Unicode code point.
getLoadCount
Section titled “getLoadCount”long getLoadCount()
How many times the node has been loaded into a UI.
getRenderTime
Section titled “getRenderTime”long getRenderTime()
Time that the last frame of the node took to draw, children included, in nanoseconds.
remove
Section titled “remove”this remove(Node... nodes) fluent
Detaches these children from the node; a node that is not its child is ignored.
this self(Consumer<T> consumer) fluent
Runs the code at once with the node, to set it up without breaking the chain.
<T extends Node> T copy()
Returns an unattached copy of the node and of its children, with their properties, listeners and effects.
A field that holds a node of the copied tree holds its copy; transient fields are left out.
Throws an IllegalStateException when the class has no constructor (x, y, width, height), (x, y) or without argument and does not override instantiate().
useStore
Section titled “useStore”this useStore(Class<T> clazz, Supplier<T> factory) fluent
Returns the store of this class from the UI of the node, as UI.useStore does.
addTask
Section titled “addTask”this addTask(Task task) fluent
Attaches a task to the node; it runs while the node belongs to an open UI.
removeTask
Section titled “removeTask”this removeTask(Task task) fluent
Detaches a task from the node.
addShortcut
Section titled “addShortcut”this addShortcut(Shortcut shortcut) fluent
Attaches a shortcut to the node; it fires while the node is visible and enabled.
removeShortcut
Section titled “removeShortcut”this removeShortcut(Shortcut shortcut) fluent
Detaches a shortcut from the node.
layoutPosition
Section titled “layoutPosition”this layoutPosition(double layoutX, double layoutY) fluent
Sets the offset that a layout adds to the declared position of the node.
A layout node or a control calls it on its children in layout().
layoutSize
Section titled “layoutSize”this layoutSize(double width, double height) fluent
Sets the size of the node for this frame without changing its declared size.
this fit(double contentWidth, double contentHeight) fluent
Gives the node the size of its content on each axis whose declared size is 0, and keeps the current size on the other.
this move(double x, double y) fluent
Moves the node to this declared position as a change: the beforeMove listeners can refuse it, bound signals are written, and a running drop animation stops there.
beforeMove
Section titled “beforeMove”this beforeMove(EventListener<NodeChangeEvent.Pre<T,Point>> listener) fluent
Adds a listener that runs before the node moves, by a drag or move; cancelling the event keeps the node in place.
hoverColor
Section titled “hoverColor”Color hoverColor(Color color, Color hoveredColor)
The first color blended toward the second by the hover progress; a null second color returns the first.
drawSkeleton
Section titled “drawSkeleton”void drawSkeleton(double mouseX, double mouseY) hook
Draws the default skeleton, a rectangle of the loading color on the bounds of the node.
fireUpdate
Section titled “fireUpdate”void fireUpdate()
Updates the node and its children for this frame: pulls its reactive values, runs update and fires onUpdate.
Its UI calls it once per frame; an update that throws prints a warning once.
fireDetach
Section titled “fireDetach”void fireDetach()
Detaches the node and its children from their UI: runs detach, ends the drag and the hover, detaches the effects and fires onDetach.
fireMousePressed
Section titled “fireMousePressed”boolean fireMousePressed(double mouseX, double mouseY, MouseButton button)
Sends a mouse press at this point to the node and its children, as the UI does, and returns true when something consumed it; use it to simulate an input.
void fireMousePressed(double mouseX, double mouseY, MouseButton button, IConsumableEvent source)
Sends a mouse press that belongs to this source event: consuming it consumes the source.
fireMouseReleased
Section titled “fireMouseReleased”boolean fireMouseReleased(double mouseX, double mouseY, MouseButton button, long deltaTime)
Sends a mouse release of this button, pressed deltaTime ms before, to the node and its children and returns true when something consumed it.
void fireMouseReleased(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source)
Sends a mouse release that belongs to this source event.
fireMouseDragged
Section titled “fireMouseDragged”boolean fireMouseDragged(double mouseX, double mouseY, MouseButton button, long deltaTime)
Sends a mouse move with this button held for deltaTime ms and returns true when something consumed it.
void fireMouseDragged(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source)
Sends a mouse move that belongs to this source event.
fireMouseScroll
Section titled “fireMouseScroll”boolean fireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY)
Sends a wheel turn, in notches, and returns true when something consumed it.
void fireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY, IConsumableEvent source)
Sends a wheel turn that belongs to this source event.
fireCharTyped
Section titled “fireCharTyped”boolean fireCharTyped(int codepoint)
Sends a typed character and returns true when something consumed it.
void fireCharTyped(int codepoint, IConsumableEvent source)
Sends a typed character that belongs to this source event.
fireKeyPressed
Section titled “fireKeyPressed”boolean fireKeyPressed(Key physicalKey, Key key)
Sends a key press, its position on the keyboard then the key that the layout gives, and returns true when something consumed it.
void fireKeyPressed(Key physicalKey, Key key, IConsumableEvent source)
Sends a key press that belongs to this source event.
fireKeyReleased
Section titled “fireKeyReleased”boolean fireKeyReleased(Key physicalKey, Key key)
Sends a key release and returns true when something consumed it.
void fireKeyReleased(Key physicalKey, Key key, IConsumableEvent source)
Sends a key release that belongs to this source event.
fireDragStart
Section titled “fireDragStart”boolean fireDragStart(Runnable start)
Runs the beforeDragStart listeners, then the start and the onDragStart listeners unless a listener cancelled; returns false when it was cancelled.
A node that runs a drag of its own, such as a reorderable list, calls it.
fireDrag
Section titled “fireDrag”void fireDrag(Runnable drag)
Runs the move of the drag, then the onDrag listeners.
fireDragDrop
Section titled “fireDragDrop”boolean fireDragDrop(Node target, Runnable drop)
Runs the beforeDragDrop listeners, then the drop and the onDragDrop listeners unless a listener cancelled; returns false when it was cancelled.
target is the snap target, or null.
listen
Section titled “listen”<T extends Node> T listen(EventType<?> type, EventListener<?> listener) protected
Adds a listener for an event type of the subclass; the onX methods of a node of your own call it.
<E extends Event> E fire(EventType<? super E> type, Supplier<E> event) protected
Fires an event of the subclass to its listeners and returns it, or null when no listener exists, in which case the event is never built.
<T extends Node, V> T start(String property, V value, Consumer<V> applier) protected
Sets a property to a plain value and applies it, replacing a previous follow or bind of the same property.
follow
Section titled “follow”<T extends Node, V> T follow(String property, Supplier<V> supplier, Consumer<V> applier) protected
Makes a property follow a Supplier: the applier receives each new value, when the signals it reads change or on every frame for a lambda.
<T extends Node, V> T bind(String property, Signal<V> signal, Consumer<V> applier) protected
Binds a property to a signal: the applier receives each value of the signal.
<T extends Node, V, M> T bind(String property, Signal<V> signal, Consumer<V> applier, Function<M,V> writer) protected
Binds a property to a signal both ways: sync writes the value back through the writer.
bindNullable
Section titled “bindNullable”<T extends Node, V, M> T bindNullable(String property, Signal<V> signal, Consumer<V> applier, Function<M,V> writer) protected
Binds a property to a signal both ways, accepting null values.
void sync(String property, Object value) protected
Writes the value applied to a bound property back to its signal.
require
Section titled “require”<N extends Node> void require(String setting, String advice, Predicate<N> present) protected
Throws:
IllegalStateException: The … has no …, …
Declares a setting that the node needs: when the node loads without it, it throws an IllegalStateException that names the setting and gives the advice.
<N extends Node> N part(Node previous, N next) protected
Replaces a part of the node, a child that the subclass places itself, by another one at the same place among the children, and returns it.
reorderChildren
Section titled “reorderChildren”void reorderChildren(List<Node> order) protected
Puts the children in this order, for drawing and for the layout.
instantiate
Section titled “instantiate”Node instantiate() hook protected
Throws:
IllegalStateException: The node … cannot be copied: its constructor … failed (…)IllegalStateException: The node … cannot be copied: declare a constructor (x, y, width, height) or override instantiate()
Creates the instance that copy() fills: it tries the constructors (x, y, width, height), (x, y) and without argument.
Override it when the class has none of them.
holdsInput
Section titled “holdsInput”boolean holdsInput() hook protected
If true, the node keeps receiving the input while it is scrolled out of the area of its container; false by default.
FieldNode holds it while it has the focus or a selection goes on, BaseSelectorNode while it is open.
isDraggingChild
Section titled “isDraggingChild”boolean isDraggingChild(Node child) hook protected
If true, the parent raises this child above its siblings because it is being dragged; a layout node that drags its children overrides it.
getBindings
Section titled “getBindings”NodeBindings getBindings() protected
The reactive bindings of the node’s properties, for a subclass.
Event details
Section titled “Event details”onUpdate
Section titled “onUpdate”this onUpdate(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs on every frame, after the children and the update hook.
onDetach
Section titled “onDetach”this onDetach(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when the node leaves its UI, after its children and its own detach.
onInit
Section titled “onInit”this onInit(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs when the node is loaded into a UI, after init.
onRender
Section titled “onRender”this onRender(EventListener<NodeDrawEvent<T>> listener) fluent
Adds a listener that runs at the end of the drawing of the node, after its children and its layers.
onDraw
Section titled “onDraw”this onDraw(EventListener<NodeDrawEvent<T>> listener) fluent
Adds a listener that runs after the node has drawn itself, before its label and its children in front.
onMount
Section titled “onMount”this onMount(EventListener<NodeEvent<T>> listener) fluent
Adds a listener that runs on each frame where the node becomes mounted: the first frame where it is drawn mounted, then again after a detach or after a wait condition stopped holding.
onHoverStart
Section titled “onHoverStart”this onHoverStart(EventListener<NodeHoverEvent<T>> listener) fluent
Adds a listener that runs when the mouse enters the node.
onHover
Section titled “onHover”this onHover(EventListener<NodeHoverEvent<T>> listener) fluent
Adds a listener that runs on every frame while the node is hovered.
onHoverEnd
Section titled “onHoverEnd”this onHoverEnd(EventListener<NodeHoverEvent<T>> listener) fluent
Adds a listener that runs when the mouse leaves the node, or when the node is hidden or detached while hovered.
onScroll
Section titled “onScroll”this onScroll(EventListener<NodeScrollEvent.Post<T>> listener) fluent
Adds a listener that runs after the scroll has changed.
onScrollToEnd
Section titled “onScrollToEnd”this onScrollToEnd(EventListener<NodeScrollEvent.Post<T>> listener) fluent
Adds a listener that runs when a scroll heads for the end of the content, before the content gets there: the moment to load more.
onScrollEndReached
Section titled “onScrollEndReached”this onScrollEndReached(EventListener<NodeScrollEvent.Post<T>> listener) fluent
Adds a listener that runs when the shown content has reached the end after a scroll toward it.
onDragStart
Section titled “onDragStart”this onDragStart(EventListener<NodeDragEvent.Post<T>> listener) fluent
Adds a listener that runs once a drag has started.
onDrag
Section titled “onDrag”this onDrag(EventListener<NodeDragEvent.Post<T>> listener) fluent
Adds a listener that runs at every mouse move of the drag.
onDragDrop
Section titled “onDragDrop”this onDragDrop(EventListener<NodeDragEvent.Post<T>> listener) fluent
Adds a listener that runs once the node has been dropped; the event holds the snap target, or null.
onDragSnap
Section titled “onDragSnap”this onDragSnap(EventListener<NodeDragEvent.Post<T>> listener) fluent
Adds a listener that runs when the node is dropped on one of its snap targets, before onDragDrop; a beforeDragDrop listener that cancels skips it.
onMove
Section titled “onMove”this onMove(EventListener<NodeChangeEvent.Post<T,Point>> listener) fluent
Adds a listener that runs after the node has moved.
onChildAppend
Section titled “onChildAppend”this onChildAppend(EventListener<NodeChildEvent<T>> listener) fluent
Adds a listener that runs when a child is added to the node; moving an existing child to the front does not fire it.
onClick
Section titled “onClick”this onClick(EventListener<NodeMouseEvent<T>> listener) fluent
Adds a listener that runs when the left button is pressed on the hovered node, unless a node in front consumed the press; the press is then consumed.
onAnimate
Section titled “onAnimate”this onAnimate(EventListener<NodeAnimateEvent<T>> listener) fluent
Adds a listener that runs when the value of a followed animator changes, during the update of the node.
onWatch
Section titled “onWatch”this onWatch(EventListener<NodeWatchEvent<T>> listener) fluent
Adds a listener that runs after a watch of the node has applied its properties.
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
