Skip to content

ModelViewerNode

class ModelViewerNode
Extends: BaseModelNode
Package: dev.joid.lib.ui.node.impl.model · Module: core · Source: ModelViewerNode.java

Draws a 3D model that the user turns by dragging and zooms with the wheel, within ranges.

A drag with the left button turns the model, one degree per 5 design pixels; one wheel notch zooms by 0.04D. The model moves smoothly toward the requested zoom and rotation. A requested value outside its range is kept and applied again when the range changes.

ReturnsSignatureSummary
ModelViewerNodecreate(double x, double y, double width, double height) factoryCreates a model viewer at x, y with this width and height.
ModelViewerNode(double x, double y, double width, double height) protectedCalled by a subclass with the same arguments as create.

PropertyTypeDefaultSummary
rotationYawdouble0DRotation around the vertical axis, in degrees, kept within its range; a signal is bound both ways.
rotationPitchdouble0DRotation around the horizontal axis, in degrees, kept within its range; a signal is bound both ways.
Inherited from BaseModelNode (1)

model

Inherited from Node (24)

x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable

ReturnsSignatureSummary
doublegetDrawnZoom()The zoom drawn on this frame, moving toward the zoom.
doublegetDrawnRotationYaw()The vertical-axis rotation drawn on this frame.
doublegetDrawnRotationPitch()The horizontal-axis rotation drawn on this frame.
ReturnsSignatureSummary
doublegetZoom()The zoom the model moves to.
doublegetMinZoom()The smallest zoom.
doublegetMaxZoom()The largest zoom.
doublegetMinRotationYaw()The smallest rotation around the vertical axis.
doublegetMaxRotationYaw()The largest rotation around the vertical axis.
doublegetMinRotationPitch()The smallest rotation around the horizontal axis.
doublegetMaxRotationPitch()The largest rotation around the horizontal axis.
ReturnsSignatureSummary
Tzoom(double zoom)Sets the zoom of the model, kept within the zoom range.
Tzoom(Signal zoom)Binds the zoom to a signal: the viewer follows it, and a wheel zoom writes back to it.
thiszoomRange(double min, double max) fluentSmallest and largest zoom.
thiszoomRange(Supplier min, Supplier max) fluentSmallest and largest zoom, following the suppliers.
thisrotationYawRange(double min, double max) fluentSmallest and largest rotation around the vertical axis, in degrees.
thisrotationYawRange(Supplier min, Supplier max) fluentRange of the rotation around the vertical axis, following the suppliers.
thisrotationPitchRange(double min, double max) fluentSmallest and largest rotation around the horizontal axis, in degrees.
thisrotationPitchRange(Supplier min, Supplier max) fluentRange of the rotation around the horizontal axis, following the suppliers.
thiszoomTo(double zoom) fluentZooms to this value as a change: the beforeZoom listeners can refuse it and onZoom fires.
thisrotate(double rotationYaw, double rotationPitch) fluentTurns the model to these angles as a change: the beforeRotate listeners can refuse it and onRotate fires.
TbeforeZoom(EventListener<NodeChangeEvent.Pre<T,Double>> listener)Adds a listener that runs before the zoom changes; cancelling the event refuses the change.
TbeforeRotate(EventListener<NodeChangeEvent.Pre<T,Point>> listener)Adds a listener that runs before the rotation changes; the value is a point of yaw and pitch.
ReturnsSignatureSummary
voidinit(UI ui) hookDraws the model at its requested zoom and rotation from the first frame, without moving toward them.
voiddraw(double mouseX, double mouseY) hookMoves the drawn zoom and rotation toward the requested ones, then draws the model.
voidmousePressed(NodeMouseEvent<?> event) hookStarts turning the model on a left press over the node and consumes the press.
voidmouseReleased(NodeMouseEvent<?> event) hookStops turning the model when the left button is released.
voidmouseDragged(NodeMouseEvent<?> event) hookTurns the model with the mouse move.
voidmouseScroll(NodeMouseScrollEvent<?> event) hookZooms on a wheel turn over the node and consumes it.
voiddetach() hookStops a turn in progress.
Inherited from Node (128)

load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · isDragging · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor

EventListenerSummary
onZoomEventListener<NodeChangeEvent.Post<T,Double>>Adds a listener that runs after the zoom has changed.
onRotateEventListener<NodeChangeEvent.Post<T,Point>>Adds a listener that runs after the rotation has changed.
Inherited from Node (21)

onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch

ModelViewerNode create(double x, double y, double width, double height) factory

Creates a model viewer at x, y with this width and height.

ModelViewerNode(double x, double y, double width, double height) protected

Called by a subclass with the same arguments as create.

  • this rotationYaw(double rotationYaw) fluent
  • this rotationYaw(Signal<Double> rotationYaw) fluent
  • double getRotationYaw()

Default: 0D

Rotation around the vertical axis, in degrees, kept within its range; a signal is bound both ways.

  • this rotationPitch(double rotationPitch) fluent
  • this rotationPitch(Signal<Double> rotationPitch) fluent
  • double getRotationPitch()

Default: 0D

Rotation around the horizontal axis, in degrees, kept within its range; a signal is bound both ways.

double getDrawnZoom()

The zoom drawn on this frame, moving toward the zoom.

double getDrawnRotationYaw()

The vertical-axis rotation drawn on this frame.

double getDrawnRotationPitch()

The horizontal-axis rotation drawn on this frame.

double getZoom()

The zoom the model moves to.

double getMinZoom()

The smallest zoom.

double getMaxZoom()

The largest zoom.

double getMinRotationYaw()

The smallest rotation around the vertical axis.

double getMaxRotationYaw()

The largest rotation around the vertical axis.

double getMinRotationPitch()

The smallest rotation around the horizontal axis.

double getMaxRotationPitch()

The largest rotation around the horizontal axis.

<T extends ModelViewerNode> T zoom(double zoom)

Sets the zoom of the model, kept within the zoom range.

<T extends ModelViewerNode> T zoom(Signal<Double> zoom)

Binds the zoom to a signal: the viewer follows it, and a wheel zoom writes back to it.

this zoomRange(double min, double max) fluent

Smallest and largest zoom. Throws an IllegalArgumentException when the minimum is above the maximum.

this zoomRange(Supplier<Double> min, Supplier<Double> max) fluent

Throws:

  • IllegalArgumentException: The min … of the zoom range is above its max …, pass a min of at most …

Smallest and largest zoom, following the suppliers.

this rotationYawRange(double min, double max) fluent

Smallest and largest rotation around the vertical axis, in degrees. Throws an IllegalArgumentException when the minimum is above the maximum.

this rotationYawRange(Supplier<Double> min, Supplier<Double> max) fluent

Throws:

  • IllegalArgumentException: The min … of the rotation yaw range is above its max …, pass a min of at most …

Range of the rotation around the vertical axis, following the suppliers.

this rotationPitchRange(double min, double max) fluent

Smallest and largest rotation around the horizontal axis, in degrees. Throws an IllegalArgumentException when the minimum is above the maximum.

this rotationPitchRange(Supplier<Double> min, Supplier<Double> max) fluent

Throws:

  • IllegalArgumentException: The min … of the rotation pitch range is above its max …, pass a min of at most …

Range of the rotation around the horizontal axis, following the suppliers.

this zoomTo(double zoom) fluent

Zooms to this value as a change: the beforeZoom listeners can refuse it and onZoom fires.

this rotate(double rotationYaw, double rotationPitch) fluent

Turns the model to these angles as a change: the beforeRotate listeners can refuse it and onRotate fires.

<T extends ModelViewerNode> T beforeZoom(EventListener<NodeChangeEvent.Pre<T,Double>> listener)

Adds a listener that runs before the zoom changes; cancelling the event refuses the change.

<T extends ModelViewerNode> T beforeRotate(EventListener<NodeChangeEvent.Pre<T,Point>> listener)

Adds a listener that runs before the rotation changes; the value is a point of yaw and pitch.

void init(UI ui) hook

Draws the model at its requested zoom and rotation from the first frame, without moving toward them.

void draw(double mouseX, double mouseY) hook

Moves the drawn zoom and rotation toward the requested ones, then draws the model.

void mousePressed(NodeMouseEvent<?> event) hook

Starts turning the model on a left press over the node and consumes the press.

void mouseReleased(NodeMouseEvent<?> event) hook

Stops turning the model when the left button is released.

void mouseDragged(NodeMouseEvent<?> event) hook

Turns the model with the mouse move.

void mouseScroll(NodeMouseScrollEvent<?> event) hook

Zooms on a wheel turn over the node and consumes it.

void detach() hook

Stops a turn in progress.

<T extends ModelViewerNode> T onZoom(EventListener<NodeChangeEvent.Post<T,Double>> listener)

Adds a listener that runs after the zoom has changed.

<T extends ModelViewerNode> T onRotate(EventListener<NodeChangeEvent.Post<T,Point>> listener)

Adds a listener that runs after the rotation has changed.


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