Skip to content

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.

Create one with the factory of its area, then give it to Node.draggable.

ReturnsSignatureSummary
DraggablePropertyfree() factoryA drag anywhere, with no area.
DraggablePropertycustom(double x, double y, double width, double height) factoryA drag inside this rectangle of the canvas.
DraggablePropertyparent() factoryA drag inside the bounds of the parent of the node.
DraggablePropertynode(Node node) factoryA drag inside the bounds of this node.
DraggablePropertyui() factoryA drag inside the design canvas, 1920 × 1080.
DraggablePropertyscreen() factoryA drag inside the window, which can show more than the canvas.
DraggablePropertydisabled() factoryA property that never lets the node be dragged.

PropertyTypeDefaultSummary
enabledPredicate<Node>node -> truePredicate that decides, for the node, whether a drag can start now; a drag that started goes to its end whatever it returns.
typeDraggableTypeDraggableType.MOVEMOVE drags the node itself; COPY drags a copy and leaves the node in place.
snapTypeDraggableSnapTypeDraggableSnapType.NEARESTHow the target is chosen when the node is dropped.

ReturnsSignatureSummary
NodegetSnapping(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.
BoundingBoxgetBounds(Node node)The area that the node stays in, on the canvas.
booleanhasSnapping()If true, the property has targets.
booleanisEnabled(Node node)If true, the node can be dragged now.
thissnap(Node… snapNodes) fluentAdds targets: on drop, the node snaps to the center of one of them, or goes back where it started when none fits.
DraggablePropertycopy()A copy of the property with the same area, type, predicate and targets.
NodegetAreaNode()The node whose bounds are the area of a NODE drag, or null.
DraggableAreaTypegetAreaType()The kind of area of the drag.

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.

  • this enabled(Predicate<Node> enabled) fluent
  • Predicate<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) fluent
  • DraggableType getType()

Default: DraggableType.MOVE

MOVE drags the node itself; COPY drags a copy and leaves the node in place.

  • this snapType(DraggableSnapType snapType) fluent
  • DraggableSnapType getSnapType()

Default: DraggableSnapType.NEAREST

How the target is chosen when the node is dropped.

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)

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.

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.


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