public class Node

  1. Object
  2. Node
Encapsulates a Node in the scene-graph. This wraps a component (the “renderer” of the Node) and an associated transform that describes where, in the 3D space of the scene graph the component should be rendered.

Fields

public final Property<Double, Node> scaleXThe scale to apply to the node, along the x-axis.
public final Property<Double, Node> scaleYThe scale to apply to the node along the y-axis.
public final Property<Double, Node> scaleZThe scale to apply to the node along the z-axis.
public final Property<Double, Node> layoutXX-coordinate in the Scene-graph where node should be rendered.
public final Property<Double, Node> layoutYY-coordinate in the scene graph where node should be rendered.
public final Property<Double, Node> layoutZZ-coordinate in the scene graph where node should be rendered.
public final Property<Double, Node> translateXX-translation to apply to the node.
public final Property<Double, Node> translateYY-translation to apply to the node.
public final Property<Double, Node> translateZZ-translation to apply to the node.
public final Property<Double, Node> rotateRotation to apply to the node.
public final Property<Double, Node> localCanvasZThe depth of the coordinate at which the renderer should paint itself.
public final Property<Double, Node> opacity
public final Property<Point3D, Node> rotationAxisThe rotation axis around which rotations should be performed.
public final Property<Bounds, Node> boundsInLocalThe local bounds of the node (without any of the transforms applied to it).
public final Property<Boolean, Node> visibleFlag to indicate whether the node should be visible or not.
public final Property<Rectangle, Node> paintingRectThe painting rectangle, into which the renderer should be painted inside the node’s local bounds.

Constructors

public Node()

Methods

public void setRenderAsImage(boolean t)Sets the render as image flag.
public void addTags(String... tags)Adds tags to this node.
public Rectangle2D getBoundsInScene(Rectangle2D out)
public void removeTags(String... tags)Removes tags from this node.
public boolean hasTag(String tag)Check if this node has a tag.
public Transform getLocalToParentTransform()Gets the transform to use to transform the Node into its parent node’s space.
public Transform getLocalToSceneTransform()Gets the transform to use to go from the local coordinates to scene coordinates.
public Scene getScene()Gets the scene that this node is attached to.
public boolean isNeedsLayout()Returns true if this node needs to have its children re-laid out before rendering
public void setNeedsLayout(boolean needsLayout)
public Style getStyle()
public void setStyle(Style style)
public boolean contains(int x, int y)This can be used to hit test pointer events against this node.
public Collection<Node> findNodesWithTag(String tag)
public Transform getLocalToScreenTransform()
public void render(Graphics g)Renders the node onto a graphics context.
public void renderChildren(Graphics g)Renders the node’s children.
public NodePainter getRenderer()Gets the renderer component for this node.
public void setRenderer(NodePainter comp)Sets the component that should be used to render the node’s contents.
public void add(Node child)Adds a child node.
public void remove(Node child)Removes a child node.
protected void layoutChildren()Can be overridden by subclasses to layout children.
public Iterable<Node> getChildNodes()Gets the child nodes of this node.
public int getChildCount()Gets number of children in this node.
public Node getChildAt(int index)Gets child node at index.
public boolean hasChildren()Checks if node has children.
public void removeAll()Removes all child nodes.

Inherited methods

Field details

scaleX

public final Property<Double, Node> scaleX
The scale to apply to the node, along the x-axis.

scaleY

public final Property<Double, Node> scaleY
The scale to apply to the node along the y-axis.

scaleZ

public final Property<Double, Node> scaleZ
The scale to apply to the node along the z-axis.

layoutX

public final Property<Double, Node> layoutX
X-coordinate in the Scene-graph where node should be rendered.

layoutY

public final Property<Double, Node> layoutY
Y-coordinate in the scene graph where node should be rendered.

layoutZ

public final Property<Double, Node> layoutZ
Z-coordinate in the scene graph where node should be rendered.

translateX

public final Property<Double, Node> translateX
X-translation to apply to the node.

translateY

public final Property<Double, Node> translateY
Y-translation to apply to the node.

translateZ

public final Property<Double, Node> translateZ
Z-translation to apply to the node.

rotate

public final Property<Double, Node> rotate
Rotation to apply to the node. In degrees. Node is always rotated around its center.

localCanvasZ

public final Property<Double, Node> localCanvasZ
The depth of the coordinate at which the renderer should paint itself. By default nodes will have no depth, and renderer will be painted onto a rectangle on the Z=0 plane. If you need to perform 3D rotations, you may want to give the node depth by setting the depth of #boundsInLocal and changing the #localCanvasZ to something other than 0 since the node will be rotated at its center point.

opacity

public final Property<Double, Node> opacity

rotationAxis

public final Property<Point3D, Node> rotationAxis
The rotation axis around which rotations should be performed. (0, 0, 1) results in a rotation around the z-axis, (1, 0, 0) results in a rotation around the x-axis, and (0, 1, 0) a rotation around the y-axis.

boundsInLocal

public final Property<Bounds, Node> boundsInLocal
The local bounds of the node (without any of the transforms applied to it).

visible

public final Property<Boolean, Node> visible
Flag to indicate whether the node should be visible or not.

paintingRect

public final Property<Rectangle, Node> paintingRect
The painting rectangle, into which the renderer should be painted inside the node’s local bounds.

Constructor details

Node

public Node()

Method details

setRenderAsImage

public void setRenderAsImage(boolean t)
Sets the render as image flag. True to render this Node as an image.

addTags

public void addTags(String... tags)
Adds tags to this node.

getBoundsInScene

public Rectangle2D getBoundsInScene(Rectangle2D out)

removeTags

public void removeTags(String... tags)
Removes tags from this node.

hasTag

public boolean hasTag(String tag)
Check if this node has a tag.

getLocalToParentTransform

public Transform getLocalToParentTransform()
Gets the transform to use to transform the Node into its parent node’s space.

getLocalToSceneTransform

public Transform getLocalToSceneTransform()
Gets the transform to use to go from the local coordinates to scene coordinates.

getScene

public Scene getScene()
Gets the scene that this node is attached to.

Returns

the scene

isNeedsLayout

public boolean isNeedsLayout()
Returns true if this node needs to have its children re-laid out before rendering

Returns

the needsLayout

setNeedsLayout

public void setNeedsLayout(boolean needsLayout)

Parameters

needsLayout boolean
the needsLayout to set

getStyle

public Style getStyle()

Returns

the style

setStyle

public void setStyle(Style style)

Parameters

style Style
the style to set

contains

public boolean contains(int x, int y)
This can be used to hit test pointer events against this node. It checks whether a given absolute (x, y) coordinate hits the node.

findNodesWithTag

public Collection<Node> findNodesWithTag(String tag)

getLocalToScreenTransform

public Transform getLocalToScreenTransform()

render

public void render(Graphics g)
Renders the node onto a graphics context.

renderChildren

public void renderChildren(Graphics g)
Renders the node’s children.

getRenderer

public NodePainter getRenderer()
Gets the renderer component for this node.

setRenderer

public void setRenderer(NodePainter comp)
Sets the component that should be used to render the node’s contents.

add

public void add(Node child)
Adds a child node.

remove

public void remove(Node child)
Removes a child node.

layoutChildren

protected void layoutChildren()
Can be overridden by subclasses to layout children. Called before node is rendered.

getChildNodes

public Iterable<Node> getChildNodes()
Gets the child nodes of this node.

getChildCount

public int getChildCount()
Gets number of children in this node.

getChildAt

public Node getChildAt(int index)
Gets child node at index.

hasChildren

public boolean hasChildren()
Checks if node has children.

removeAll

public void removeAll()
Removes all child nodes.