Skip to content

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.

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);

Full file: CardUI.java

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.

ReturnsSignatureSummary
Node(double x, double y) protectedCreates 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) protectedCreates a node at x, y with this width and height, in design pixels.

PropertyTypeDefaultSummary
x signaldoubleset at creationHorizontal 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 signaldoubleset at creationVertical 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 signaldoubleset at creationWidth of the node, in design pixels.
height signaldoubleset at creationHeight of the node, in design pixels.
position signalPositionPropertyPositionProperty.RELATIVERELATIVE 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 signalAlignAlign.STARTSets anchorX and anchorY to the same value.
anchorX signalAlignAlign.STARTWhich 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 signalAlignAlign.STARTWhich 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 signaldoublenone, the width and the height stay freeWidth 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 signalint0Order of the node among its siblings: a higher value is drawn above and receives the input first.
zlevel signaldouble0DDepth of the node along the Z axis, added to the depth of its parent.
PropertyTypeDefaultSummary
skeletonFunction<T,Node>nullPlaceholder 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 signalbooleantrueIf false, the node and its children are neither drawn nor sent any input, and a layout node leaves them out.
enabled signalbooleantrueIf false, the node and its children are drawn but ignore the input and show no hover progress.
interactive signalbooleantrueIf false, the node and its children let the mouse through to what is under them and are never hovered.
PropertyTypeDefaultSummary
cursor signalCursornull: the cursor of the closest parent that sets one, Cursor.DEFAULT when none doesCursor shown while the mouse is over the node; null uses the cursor of the closest parent that has one.
hoverDuration signallong200LTime, in ms, that the hover progress takes to go from 0 to 1 and back.
hoverEquation signalTweenEquationTweenEquations.LINEAREasing of the hover progress.
hover signalIHoverElementAdds 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.
PropertyTypeDefaultSummary
overflow signalOverflowPropertyOverflowProperty.NONEWhat 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 signaldouble1DFactor applied to the wheel: one notch scrolls 30 design pixels times this factor, twice as far with Control down.
scrollbarBaseScrollbarNodenullScrollbar that scrolls this node; it is drawn when the overflow is SCROLL and the content goes past the node.
PropertyTypeDefaultSummary
label signalTextnull: no labelText drawn centered over the node, after the node itself and before its children; null draws none.
draggable signalDraggablePropertynull: the node cannot be draggedLets 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.

ReturnsSignatureSummary
voidload(UI ui)Attaches the node to the UI: loads its children, its scrollbar, its skeleton and its effects, runs init and fires onInit.
voidrender(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.
booleanrenderHover(double mouseX, double mouseY)Draws the tooltips of the node at the mouse and returns true when it has one.
thisupdateScroll() fluentMoves the shown scroll to its target at once, on both axes, without the smooth movement.
thisupdateScrollX() fluentMoves the shown horizontal scroll to its target at once.
thisupdateScrollY() fluentMoves the shown vertical scroll to its target at once.
ReturnsSignatureSummary
thisappend(Node… nodes) fluentAdds children to the node, in front of their siblings of the same zindex.
thisattach(UI ui) fluentAttaches the node at the root of the UI, as UI.add does.
thisattach(Node node) fluentAdds the node to the children of this parent, as Node.append does.
thisbody(Runnable runnable) fluentRuns the code at once, to create the children where the node is created.
thisbody(Consumer consumer) fluentRuns the code at once with the node, to create its children; JOID keeps it to run it again when a watch rebuilds the node.
thisclearChildren() fluentDetaches every child of the node.
TgetChild(int index, Class clazz)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 clazz)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.
NodegetParent()The parent of the node, or null for a root.
booleanisAttached()If true, the node is loaded in a UI.
ReturnsSignatureSummary
doublegetAbsoluteX()Horizontal position of the top-left corner of the node on the canvas, with the positions of its parents, their layout and their scroll.
doublegetAbsoluteY()Vertical position of the top-left corner of the node on the canvas.
doublegetAbsoluteDefaultX()Position on the canvas of the declared x of the node, before its layout and its anchor.
doublegetAbsoluteDefaultY()Position on the canvas of the declared y of the node, before its layout and its anchor.
doubletoDrawX(double x)Converts a horizontal position of the canvas to the coordinates in which the node draws, where its left edge is getX().
doubletoDrawY(double y)Converts a vertical position of the canvas to the coordinates in which the node draws.
doublew()The current width of the node.
doubleh()The current height of the node.
doubledw(double value)The width divided by the value: dw(2D) is half the width.
doubledh(double value)The height divided by the value.
doublemw(double value)The width multiplied by the value: mw(0.25D) is a quarter of the width.
doublemh(double value)The height multiplied by the value.
doubleaw(double value)The width plus the value.
doubleah(double value)The height plus the value.
doubleax(double value)The current x plus the value.
doubleay(double value)The current y plus the value.
doublegetDefaultWidth()The width declared by the constructor or by width(...); 0 when the width comes from the content.
doublegetDefaultHeight()The height declared by the constructor or by height(...); 0 when the height comes from the content.
ReturnsSignatureSummary
thisremoveHover(IHoverElement element) fluentRemoves a tooltip element added with hover(...).
thisclearHover() fluentRemoves every tooltip of the node.
voidrefreshHover(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.
CursorgetResolvedCursor()The cursor shown over the node: its own, the one of its closest parent that has one, or the default arrow.
floathoverValue(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.
TweenAnimatorgetHoverAnimator()The animator that holds the hover progress, from 0 to 1.
booleanisHovered()If true, the mouse is over the node or one of its children, and its UI is on top.
ReturnsSignatureSummary
thishandleMousePressed(EventListener<NodeMouseEvent> listener) fluentAdds 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.
thishandleMouseReleased(EventListener<NodeMouseEvent> listener) fluentAdds a listener that hears a mouse release, wherever the mouse is.
thishandleMouseDragged(EventListener<NodeMouseEvent> listener) fluentAdds a listener that hears a mouse move while a button is held.
thishandleMouseScroll(EventListener<NodeMouseScrollEvent> listener) fluentAdds 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.
thishandleCharTyped(EventListener<NodeCharEvent> listener) fluentAdds a listener that hears a typed character, as a Unicode code point.
thishandleKeyPressed(EventListener<NodeKeyEvent> listener) fluentAdds a listener that hears a key press.
thishandleKeyReleased(EventListener<NodeKeyEvent> listener) fluentAdds a listener that hears a key release.
longgetLastClickTime()Time of the last mouse press the node received, in ms of the clock bridge.
MouseButtongetLastClickButton()Button of the last mouse press the node received, or null.
KeygetLastKey()The last key pressed while the node received the keyboard, or null.
longgetLastKeyTime()Time of the last key press the node received, in ms of the clock bridge.
ReturnsSignatureSummary
TscrollX(double scrollX)Sets the horizontal scroll, in design pixels: 0 shows the start, a negative value moves the content to the left.
TscrollX(Signal scrollX)Binds the horizontal scroll to a signal: the node follows it, and a scroll by the user writes back to it.
TscrollY(double scrollY)Sets the vertical scroll, in design pixels: 0 shows the top, a negative value moves the content up.
TscrollY(Signal scrollY)Binds the vertical scroll to a signal, both ways.
thisscrollTo(double x, double y) fluentScrolls to these offsets as a change: the beforeScroll listeners can refuse it, and the content moves there smoothly.
thisbeforeScroll(EventListener<NodeScrollEvent.Pre> listener) fluentAdds a listener that runs before the scroll changes, by the wheel, a scrollbar or scrollTo; cancelling the event refuses the change.
booleanhasOverflowX()If true, the overflow is SCROLL and the content is wider than the node.
booleanhasOverflowY()If true, the overflow is SCROLL and the content is taller than the node.
NodegetOverflowArea()The node whose HIDDEN or SCROLL overflow clips this one, or null when nothing clips it.
doublegetScrollX()Horizontal scroll shown on this frame, moving toward the target.
doublegetScrollY()Vertical scroll shown on this frame, moving toward the target.
doublegetTargetScrollX()Horizontal scroll that the content moves to.
doublegetTargetScrollY()Vertical scroll that the content moves to.
doublegetMaxScrollX()How far the content can scroll horizontally, in design pixels.
doublegetMaxScrollY()How far the content can scroll vertically, in design pixels.
booleanisScrollEndX()If true, a horizontal scroll toward the end has not reached it yet.
booleanisScrollEndY()If true, a vertical scroll toward the end has not reached it yet.
ReturnsSignatureSummary
thisstartDragging(double mouseX, double mouseY) fluentStarts a drag as if the user had pressed the left button at this point of the canvas; the beforeDragStart listeners can refuse it.
thisstopDragging() fluentDrops 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.
thisbeforeDragStart(EventListener<NodeDragEvent.Pre> listener) fluentAdds a listener that runs before a drag starts; cancelling the event keeps the node in place.
thisbeforeDragDrop(EventListener<NodeDragEvent.Pre> listener) fluentAdds a listener that runs when the user releases the node; cancelling the event sends the node back to where the drag started.
booleanisDragging()If true, the user holds the node, or a reorderable list drags it.
doublegetDragX()Horizontal distance between the left edge of the node and the point where it was grabbed.
doublegetDragY()Vertical distance between the top edge of the node and the point where it was grabbed.
booleanisDragged()If true, the node is held or is still moving to where it was dropped.
NodegetDragSource()For the copy shown by a COPY drag, the node it copies; null for any other node.
NodegetDraggedNode()The copy that follows the mouse during a COPY drag, or null.
doublegetStartDragX()Horizontal position of the node on the canvas when the drag started.
doublegetStartDragY()Vertical position of the node on the canvas when the drag started.
doublegetTargetDragX()Horizontal position on the canvas that the dragged node moves to.
doublegetTargetDragY()Vertical position on the canvas that the dragged node moves to.
ReturnsSignatureSummary
thiseffect(NodeEffect<? super T> effect) fluentAdds an effect to the node; an effect of the same class takes the place of the previous one.
thisremoveEffect(Class<?> effect) fluentRemoves the effects of this class and of its subclasses.
thisclearEffects() fluentRemoves every effect of the node.
booleanhasEffect(Class<?> clazz)If true, the node has an effect of this class or of a subclass.
TgetEffect(Class clazz)The effect of this class or of a subclass, or null.
ReturnsSignatureSummary
thislayer(NodeLayer layer) fluentAdds a drawing done after the children, in the coordinates of the node: (0, 0) is its top-left corner.
thislayer(int index, NodeLayer layer) fluentInserts a drawing at this place among the layers of the node.
thisclearLayers() fluentRemoves every layer of the node.
ReturnsSignatureSummary
thisanimate(TweenAnimator animator) fluentFollows an animator: onAnimate fires on every frame where its value changes.
thisremoveAnimator(TweenAnimator animator) fluentStops following an animator.
ReturnsSignatureSummary
thiswait(Predicate predicate) fluentAdds 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.
Twatch(Signal<?> signal, WatchProperty… properties)Applies these properties each time the signal changes, such as running the body again to rebuild the children.
Twatch(Signal<?> signal, Supplier condition, WatchProperty… properties)Applies these properties each time the signal changes while the condition gives true.
ReturnsSignatureSummary
booleanhasListener(EventType<?> type)If true, the node has a listener for this event type.
booleanisVisibleProperty()If true, the node itself is set visible, whatever its parents and its clipping.
booleanisMounted()If true, every wait condition of the node and of its parents holds.
intgetIndex()The zindex of the node, or the highest value while it is dragged with DraggableType.MOVE so that it is drawn above its siblings.
TgetUi()The UI of the node, or the UI whose code is running (UI.getCurrent) when the node is not attached yet.
StringgetHierarchy()The class names from the root down to the node, such as FlexNode - RectNode.
StringgetMappedIndex()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.
StringtoJson()The position and the size of the node as JSON, with its state in dev mode.
StringtoString()The JSON of toJson(), indented in dev mode.
EventBusgetEventBus()The listeners of the node.
Consumer<Node>getBodyConsumer()The code given to body(Consumer), or null.
doublegetDefaultX()The x declared by the constructor, x(...), move or a drag.
doublegetDefaultY()The y declared by the constructor, y(...), move or a drag.
doublegetLayoutX()Horizontal offset that the layout of the parent adds to the declared position.
doublegetLayoutY()Vertical offset that the layout of the parent adds to the declared position.
doublegetShiftX()Horizontal offset that the scroll of the parent adds.
doublegetShiftY()Vertical offset that the scroll of the parent adds.
booleanisStepping()If true, the drag animation is moving the node during this frame.
intgetLastCodepoint()The last character the node received, as a Unicode code point.
longgetLoadCount()How many times the node has been loaded into a UI.
longgetRenderTime()Time that the last frame of the node took to draw, children included, in nanoseconds.
ReturnsSignatureSummary
thisremove(Node… nodes) fluentDetaches these children from the node; a node that is not its child is ignored.
thisself(Consumer consumer) fluentRuns the code at once with the node, to set it up without breaking the chain.
Tcopy()Returns an unattached copy of the node and of its children, with their properties, listeners and effects.
thisuseStore(Class clazz, Supplier factory) fluentReturns the store of this class from the UI of the node, as UI.useStore does.
thisaddTask(Task task) fluentAttaches a task to the node; it runs while the node belongs to an open UI.
thisremoveTask(Task task) fluentDetaches a task from the node.
thisaddShortcut(Shortcut shortcut) fluentAttaches a shortcut to the node; it fires while the node is visible and enabled.
thisremoveShortcut(Shortcut shortcut) fluentDetaches a shortcut from the node.
thislayoutPosition(double layoutX, double layoutY) fluentSets the offset that a layout adds to the declared position of the node.
thislayoutSize(double width, double height) fluentSets the size of the node for this frame without changing its declared size.
thisfit(double contentWidth, double contentHeight) fluentGives the node the size of its content on each axis whose declared size is 0, and keeps the current size on the other.
thismove(double x, double y) fluentMoves 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.
thisbeforeMove(EventListener<NodeChangeEvent.Pre<T,Point>> listener) fluentAdds a listener that runs before the node moves, by a drag or move; cancelling the event keeps the node in place.
ColorhoverColor(Color color, Color hoveredColor)The first color blended toward the second by the hover progress; a null second color returns the first.
ReturnsSignatureSummary
voiddrawSkeleton(double mouseX, double mouseY) hookDraws the default skeleton, a rectangle of the loading color on the bounds of the node.
voidfireUpdate()Updates the node and its children for this frame: pulls its reactive values, runs update and fires onUpdate.
voidfireDetach()Detaches the node and its children from their UI: runs detach, ends the drag and the hover, detaches the effects and fires onDetach.
booleanfireMousePressed(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.
voidfireMousePressed(double mouseX, double mouseY, MouseButton button, IConsumableEvent source)Sends a mouse press that belongs to this source event: consuming it consumes the source.
booleanfireMouseReleased(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.
voidfireMouseReleased(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source)Sends a mouse release that belongs to this source event.
booleanfireMouseDragged(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.
voidfireMouseDragged(double mouseX, double mouseY, MouseButton button, long deltaTime, IConsumableEvent source)Sends a mouse move that belongs to this source event.
booleanfireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY)Sends a wheel turn, in notches, and returns true when something consumed it.
voidfireMouseScroll(double mouseX, double mouseY, double notchesX, double notchesY, IConsumableEvent source)Sends a wheel turn that belongs to this source event.
booleanfireCharTyped(int codepoint)Sends a typed character and returns true when something consumed it.
voidfireCharTyped(int codepoint, IConsumableEvent source)Sends a typed character that belongs to this source event.
booleanfireKeyPressed(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.
voidfireKeyPressed(Key physicalKey, Key key, IConsumableEvent source)Sends a key press that belongs to this source event.
booleanfireKeyReleased(Key physicalKey, Key key)Sends a key release and returns true when something consumed it.
voidfireKeyReleased(Key physicalKey, Key key, IConsumableEvent source)Sends a key release that belongs to this source event.
booleanfireDragStart(Runnable start)Runs the beforeDragStart listeners, then the start and the onDragStart listeners unless a listener cancelled; returns false when it was cancelled.
voidfireDrag(Runnable drag)Runs the move of the drag, then the onDrag listeners.
booleanfireDragDrop(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.
Tlisten(EventType type, EventListener listener) protectedAdds a listener for an event type of the subclass; the onX methods of a node of your own call it.
Efire(EventType<? super E> type, Supplier event) protectedFires 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.
Tstart(String property, V value, Consumer applier) protectedSets a property to a plain value and applies it, replacing a previous follow or bind of the same property.
Tfollow(String property, Supplier supplier, Consumer applier) protectedMakes a property follow a Supplier: the applier receives each new value, when the signals it reads change or on every frame for a lambda.
Tbind(String property, Signal signal, Consumer applier) protectedBinds a property to a signal: the applier receives each value of the signal.
Tbind(String property, Signal signal, Consumer applier, Function<M,V> writer) protectedBinds a property to a signal both ways: sync writes the value back through the writer.
TbindNullable(String property, Signal signal, Consumer applier, Function<M,V> writer) protectedBinds a property to a signal both ways, accepting null values.
voidsync(String property, Object value) protectedWrites the value applied to a bound property back to its signal.
voidrequire(String setting, String advice, Predicate present) protectedDeclares a setting that the node needs: when the node loads without it, it throws an IllegalStateException that names the setting and gives the advice.
Npart(Node previous, N next) protectedReplaces 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.
voidreorderChildren(List order) protectedPuts the children in this order, for drawing and for the layout.
Nodeinstantiate() hook protectedCreates the instance that copy() fills: it tries the constructors (x, y, width, height), (x, y) and without argument.
booleanholdsInput() hook protectedIf true, the node keeps receiving the input while it is scrolled out of the area of its container; false by default.
booleanisDraggingChild(Node child) hook protectedIf true, the parent raises this child above its siblings because it is being dragged; a layout node that drags its children overrides it.
NodeBindingsgetBindings() protectedThe reactive bindings of the node’s properties, for a subclass.

EventListenerSummary
onUpdateEventListener<NodeEvent<T>>Adds a listener that runs on every frame, after the children and the update hook.
onDetachEventListener<NodeEvent<T>>Adds a listener that runs when the node leaves its UI, after its children and its own detach.
onInitEventListener<NodeEvent<T>>Adds a listener that runs when the node is loaded into a UI, after init.
onRenderEventListener<NodeDrawEvent<T>>Adds a listener that runs at the end of the drawing of the node, after its children and its layers.
onDrawEventListener<NodeDrawEvent<T>>Adds a listener that runs after the node has drawn itself, before its label and its children in front.
onMountEventListener<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.
EventListenerSummary
onHoverStartEventListener<NodeHoverEvent<T>>Adds a listener that runs when the mouse enters the node.
onHoverEventListener<NodeHoverEvent<T>>Adds a listener that runs on every frame while the node is hovered.
onHoverEndEventListener<NodeHoverEvent<T>>Adds a listener that runs when the mouse leaves the node, or when the node is hidden or detached while hovered.
EventListenerSummary
onScrollEventListener<NodeScrollEvent.Post<T>>Adds a listener that runs after the scroll has changed.
onScrollToEndEventListener<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.
onScrollEndReachedEventListener<NodeScrollEvent.Post<T>>Adds a listener that runs when the shown content has reached the end after a scroll toward it.
EventListenerSummary
onDragStartEventListener<NodeDragEvent.Post<T>>Adds a listener that runs once a drag has started.
onDragEventListener<NodeDragEvent.Post<T>>Adds a listener that runs at every mouse move of the drag.
onDragDropEventListener<NodeDragEvent.Post<T>>Adds a listener that runs once the node has been dropped; the event holds the snap target, or null.
onDragSnapEventListener<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.
EventListenerSummary
onMoveEventListener<NodeChangeEvent.Post<T,Point>>Adds a listener that runs after the node has moved.
onChildAppendEventListener<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.
onClickEventListener<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.
onAnimateEventListener<NodeAnimateEvent<T>>Adds a listener that runs when the value of a followed animator changes, during the update of the node.
onWatchEventListener<NodeWatchEvent<T>>Adds a listener that runs after a watch of the node has applied its properties.

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.

  • this x(double x) fluent
  • this x(Signal<Double> x) fluent
  • this x(Supplier<Double> x) fluent signal
  • double 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) fluent
  • this y(Signal<Double> y) fluent
  • this y(Supplier<Double> y) fluent signal
  • double 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) fluent
  • this width(Supplier<Double> width) fluent signal
  • double 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.

  • this height(double height) fluent
  • this height(Supplier<Double> height) fluent signal
  • double 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.

  • this position(PositionProperty position) fluent
  • this position(Supplier<PositionProperty> position) fluent signal
  • PositionProperty 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.

  • this anchor(Align anchor) fluent
  • this anchor(Supplier<Align> anchor) fluent signal

Default: Align.START

Sets anchorX and anchorY to the same value.

  • this anchorX(Align anchorX) fluent
  • this anchorX(Supplier<Align> anchorX) fluent signal
  • Align 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.

  • this anchorY(Align anchorY) fluent
  • this anchorY(Supplier<Align> anchorY) fluent signal
  • Align 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.

  • this aspectRatio(double aspectRatio) fluent
  • this aspectRatio(Supplier<Double> aspectRatio) fluent signal
  • double 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.

  • this zindex(int zindex) fluent
  • this zindex(Supplier<Integer> zindex) fluent signal
  • int 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.

  • this zlevel(double zlevel) fluent
  • this zlevel(Supplier<Double> zlevel) fluent signal
  • double getZlevel()

Default: 0D

Depth of the node along the Z axis, added to the depth of its parent.

  • this skeleton(Function<T,Node> skeleton) fluent
  • Node 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.

  • this visible(boolean visible) fluent
  • this visible(Supplier<Boolean> visible) fluent signal
  • boolean isVisible()

Default: true

If false, the node and its children are neither drawn nor sent any input, and a layout node leaves them out.

  • this enabled(boolean enabled) fluent
  • this enabled(Supplier<Boolean> enabled) fluent signal
  • boolean isEnabled()

Default: true

If false, the node and its children are drawn but ignore the input and show no hover progress.

  • this interactive(boolean interactive) fluent
  • this interactive(Supplier<Boolean> interactive) fluent signal
  • boolean isInteractive()

Default: true

If false, the node and its children let the mouse through to what is under them and are never hovered.

  • this cursor(Cursor cursor) fluent
  • this cursor(Supplier<Cursor> cursor) fluent signal
  • Cursor 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.

  • this hoverDuration(long hoverDuration) fluent
  • this hoverDuration(Supplier<Long> hoverDuration) fluent signal
  • long getHoverDuration()

Default: 200L

Time, in ms, that the hover progress takes to go from 0 to 1 and back.

  • this hoverEquation(TweenEquation hoverEquation) fluent
  • this hoverEquation(Supplier<TweenEquation> hoverEquation) fluent signal
  • TweenEquation getHoverEquation()

Default: TweenEquations.LINEAR

Easing of the hover progress.

  • this hover(IHoverElement element) fluent
  • this hover(HoverSupplier supplier) fluent
  • this 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.

  • this overflow(OverflowProperty overflow) fluent
  • this overflow(Supplier<OverflowProperty> overflow) fluent signal
  • OverflowProperty 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.

  • this scrollSpeed(double scrollSpeed) fluent
  • this scrollSpeed(Supplier<Double> scrollSpeed) fluent signal
  • double getScrollSpeed()

Default: 1D

Factor applied to the wheel: one notch scrolls 30 design pixels times this factor, twice as far with Control down.

  • this scrollbar(BaseScrollbarNode scrollbar) fluent
  • BaseScrollbarNode 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) fluent
  • this label(Supplier<Text> label) fluent signal
  • Text getLabel()

Default: null: no label

Text drawn centered over the node, after the node itself and before its children; null draws none.

  • this draggable(DraggableProperty draggable) fluent
  • this draggable(Supplier<DraggableProperty> draggable) fluent signal
  • DraggableProperty 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.

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.

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.

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.

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.

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.

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.

this clearChildren() fluent

Detaches every child of the node.

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

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.

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.

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.

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. The node calls it while it draws, and UI.moveMouse at every mouse event.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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

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

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

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.

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.

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<T>> listener) fluent

Adds a listener that runs before a drag starts; cancelling the event keeps the node in place.

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.

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.

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

this clearLayers() fluent

Removes every layer of the node.

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.

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.

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

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.

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

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.

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. A layout node or a control calls it on its children in layout().

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.

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. Its UI calls it once per frame; an update that throws prints a warning once.

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. A node that runs a drag of its own, such as a reorderable list, calls it.

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. target is the snap target, or null.

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

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

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

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

void reorderChildren(List<Node> order) protected

Puts the children in this order, for drawing and for the layout.

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.

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.

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.

this onUpdate(EventListener<NodeEvent<T>> listener) fluent

Adds a listener that runs on every frame, after the children and the update hook.

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.

this onInit(EventListener<NodeEvent<T>> listener) fluent

Adds a listener that runs when the node is loaded into a UI, after init.

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.

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.

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.

this onHoverStart(EventListener<NodeHoverEvent<T>> listener) fluent

Adds a listener that runs when the mouse enters the node.

this onHover(EventListener<NodeHoverEvent<T>> listener) fluent

Adds a listener that runs on every frame while the node is hovered.

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.

this onScroll(EventListener<NodeScrollEvent.Post<T>> listener) fluent

Adds a listener that runs after the scroll has changed.

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.

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.

this onDragStart(EventListener<NodeDragEvent.Post<T>> listener) fluent

Adds a listener that runs once a drag has started.

this onDrag(EventListener<NodeDragEvent.Post<T>> listener) fluent

Adds a listener that runs at every mouse move of the drag.

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.

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.

this onMove(EventListener<NodeChangeEvent.Post<T,Point>> listener) fluent

Adds a listener that runs after the node has moved.

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.

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.

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.

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

Report a problem with this page