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.
Description
Section titled “Description”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.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
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. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| rotationYaw | double | 0D | Rotation around the vertical axis, in degrees, kept within its range; a signal is bound both ways. |
| rotationPitch | double | 0D | Rotation around the horizontal axis, in degrees, kept within its range; a signal is bound both ways. |
Inherited from BaseModelNode (1)
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
Methods
Section titled “Methods”Drawing
Section titled “Drawing”| Returns | Signature | Summary |
|---|---|---|
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. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
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. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
T | zoom(double zoom) | Sets the zoom of the model, kept within the zoom range. |
T | zoom(Signal | 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. |
this | zoomRange(Supplier | Smallest and largest zoom, following the suppliers. |
this | rotationYawRange(double min, double max) fluent | Smallest and largest rotation around the vertical axis, in degrees. |
this | rotationYawRange(Supplier | 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. |
this | rotationPitchRange(Supplier | 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 | beforeZoom(EventListener<NodeChangeEvent.Pre<T,Double>> listener) | Adds a listener that runs before the zoom changes; cancelling the event refuses the change. |
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. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
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. |
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
Events
Section titled “Events”| Event | Listener | Summary |
|---|---|---|
| onZoom | EventListener<NodeChangeEvent.Post<T,Double>> | Adds a listener that runs after the zoom has changed. |
| onRotate | EventListener<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
Creation details
Section titled “Creation details”create
Section titled “create”ModelViewerNode create(double x, double y, double width, double height) factory
Creates a model viewer at x, y with this width and height.
ModelViewerNode
Section titled “ModelViewerNode”ModelViewerNode(double x, double y, double width, double height) protected
Called by a subclass with the same arguments as create.
Property details
Section titled “Property details”rotationYaw
Section titled “rotationYaw”this rotationYaw(double rotationYaw)fluentthis rotationYaw(Signal<Double> rotationYaw)fluentdouble getRotationYaw()
Default: 0D
Rotation around the vertical axis, in degrees, kept within its range; a signal is bound both ways.
rotationPitch
Section titled “rotationPitch”this rotationPitch(double rotationPitch)fluentthis rotationPitch(Signal<Double> rotationPitch)fluentdouble getRotationPitch()
Default: 0D
Rotation around the horizontal axis, in degrees, kept within its range; a signal is bound both ways.
Method details
Section titled “Method details”getDrawnZoom
Section titled “getDrawnZoom”double getDrawnZoom()
The zoom drawn on this frame, moving toward the zoom.
getDrawnRotationYaw
Section titled “getDrawnRotationYaw”double getDrawnRotationYaw()
The vertical-axis rotation drawn on this frame.
getDrawnRotationPitch
Section titled “getDrawnRotationPitch”double getDrawnRotationPitch()
The horizontal-axis rotation drawn on this frame.
getZoom
Section titled “getZoom”double getZoom()
The zoom the model moves to.
getMinZoom
Section titled “getMinZoom”double getMinZoom()
The smallest zoom.
getMaxZoom
Section titled “getMaxZoom”double getMaxZoom()
The largest zoom.
getMinRotationYaw
Section titled “getMinRotationYaw”double getMinRotationYaw()
The smallest rotation around the vertical axis.
getMaxRotationYaw
Section titled “getMaxRotationYaw”double getMaxRotationYaw()
The largest rotation around the vertical axis.
getMinRotationPitch
Section titled “getMinRotationPitch”double getMinRotationPitch()
The smallest rotation around the horizontal axis.
getMaxRotationPitch
Section titled “getMaxRotationPitch”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.
zoomRange
Section titled “zoomRange”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.
rotationYawRange
Section titled “rotationYawRange”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.
rotationPitchRange
Section titled “rotationPitchRange”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.
zoomTo
Section titled “zoomTo”this zoomTo(double zoom) fluent
Zooms to this value as a change: the beforeZoom listeners can refuse it and onZoom fires.
rotate
Section titled “rotate”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.
beforeZoom
Section titled “beforeZoom”<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.
beforeRotate
Section titled “beforeRotate”<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.
mousePressed
Section titled “mousePressed”void mousePressed(NodeMouseEvent<?> event) hook
Starts turning the model on a left press over the node and consumes the press.
mouseReleased
Section titled “mouseReleased”void mouseReleased(NodeMouseEvent<?> event) hook
Stops turning the model when the left button is released.
mouseDragged
Section titled “mouseDragged”void mouseDragged(NodeMouseEvent<?> event) hook
Turns the model with the mouse move.
mouseScroll
Section titled “mouseScroll”void mouseScroll(NodeMouseScrollEvent<?> event) hook
Zooms on a wheel turn over the node and consumes it.
detach
Section titled “detach”void detach() hook
Stops a turn in progress.
Event details
Section titled “Event details”onZoom
Section titled “onZoom”<T extends ModelViewerNode> T onZoom(EventListener<NodeChangeEvent.Post<T,Double>> listener)
Adds a listener that runs after the zoom has changed.
onRotate
Section titled “onRotate”<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
