DraggableProperty
final class DraggableProperty
Package: dev.joid.lib.ui.node.property · Module: core · Source: DraggableProperty.java
How a node is dragged: the area it stays in, whether it moves or leaves a copy, and the targets it snaps to.
Description
Section titled “Description”Create one with the factory of its area, then give it to Node.draggable.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
DraggableProperty | free() factory | A drag anywhere, with no area. |
DraggableProperty | custom(double x, double y, double width, double height) factory | A drag inside this rectangle of the canvas. |
DraggableProperty | parent() factory | A drag inside the bounds of the parent of the node. |
DraggableProperty | node(Node node) factory | A drag inside the bounds of this node. |
DraggableProperty | ui() factory | A drag inside the design canvas, 1920 × 1080. |
DraggableProperty | screen() factory | A drag inside the window, which can show more than the canvas. |
DraggableProperty | disabled() factory | A property that never lets the node be dragged. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| enabled | Predicate<Node> | node -> true | Predicate that decides, for the node, whether a drag can start now; a drag that started goes to its end whatever it returns. |
| type | DraggableType | DraggableType.MOVE | MOVE drags the node itself; COPY drags a copy and leaves the node in place. |
| snapType | DraggableSnapType | DraggableSnapType.NEAREST | How the target is chosen when the node is dropped. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
Node | getSnapping(Node node) | The target that the node at its current place would snap to, or null. |
List<Node> | getSnapNodes() | The targets; a read-only view, empty when the node has none. |
BoundingBox | getBounds(Node node) | The area that the node stays in, on the canvas. |
boolean | hasSnapping() | If true, the property has targets. |
boolean | isEnabled(Node node) | If true, the node can be dragged now. |
this | snap(Node… snapNodes) fluent | Adds targets: on drop, the node snaps to the center of one of them, or goes back where it started when none fits. |
DraggableProperty | copy() | A copy of the property with the same area, type, predicate and targets. |
Node | getAreaNode() | The node whose bounds are the area of a NODE drag, or null. |
DraggableAreaType | getAreaType() | The kind of area of the drag. |
Creation details
Section titled “Creation details”DraggableProperty free() factory
A drag anywhere, with no area.
custom
Section titled “custom”DraggableProperty custom(double x, double y, double width, double height) factory
A drag inside this rectangle of the canvas.
parent
Section titled “parent”DraggableProperty parent() factory
A drag inside the bounds of the parent of the node.
DraggableProperty node(Node node) factory
A drag inside the bounds of this node.
DraggableProperty ui() factory
A drag inside the design canvas, 1920 × 1080.
screen
Section titled “screen”DraggableProperty screen() factory
A drag inside the window, which can show more than the canvas.
disabled
Section titled “disabled”DraggableProperty disabled() factory
A property that never lets the node be dragged.
Property details
Section titled “Property details”enabled
Section titled “enabled”this enabled(Predicate<Node> enabled)fluentPredicate<Node> getEnabled()
Default: node -> true
Predicate that decides, for the node, whether a drag can start now; a drag that started goes to its end whatever it returns.
this type(DraggableType type)fluentDraggableType getType()
Default: DraggableType.MOVE
MOVE drags the node itself; COPY drags a copy and leaves the node in place.
snapType
Section titled “snapType”this snapType(DraggableSnapType snapType)fluentDraggableSnapType getSnapType()
Default: DraggableSnapType.NEAREST
How the target is chosen when the node is dropped.
Method details
Section titled “Method details”getSnapping
Section titled “getSnapping”Node getSnapping(Node node)
The target that the node at its current place would snap to, or null.
getSnapNodes
Section titled “getSnapNodes”List<Node> getSnapNodes()
The targets; a read-only view, empty when the node has none.
getBounds
Section titled “getBounds”BoundingBox getBounds(Node node)
Throws:
IllegalStateException: The node … is dragged inside its parent but sits at the top of its UI, attach it to a node or pick another area such as DraggableProperty.ui()IllegalStateException: A free draggable area has no bounds, check getAreaType() before calling getBounds() or pick a bounded area such as DraggableProperty.parent()
The area that the node stays in, on the canvas.
Throws an IllegalStateException for a free drag, or for a PARENT area when the node has no parent.
hasSnapping
Section titled “hasSnapping”boolean hasSnapping()
If true, the property has targets.
isEnabled
Section titled “isEnabled”boolean isEnabled(Node node)
If true, the node can be dragged now.
this snap(Node... snapNodes) fluent
Adds targets: on drop, the node snaps to the center of one of them, or goes back where it started when none fits.
DraggableProperty copy()
A copy of the property with the same area, type, predicate and targets.
getAreaNode
Section titled “getAreaNode”Node getAreaNode()
The node whose bounds are the area of a NODE drag, or null.
getAreaType
Section titled “getAreaType”DraggableAreaType getAreaType()
The kind of area of the drag.
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
