# Class Node

java.lang.Object
com.codename1.ui.scene.Node

public class Node extends Object
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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final Property<Bounds,Node>`
  `boundsInLocal`
  The local bounds of the node (without any of the transforms applied to it).
  `final Property<Double,Node>`
  `layoutX`
  X-coordinate in the Scene-graph where node should be rendered.
  `final Property<Double,Node>`
  `layoutY`
  Y-coordinate in the scene graph where node should be rendered.
  `final Property<Double,Node>`
  `layoutZ`
  Z-coordinate in the scene graph where node should be rendered.
  `final Property<Double,Node>`
  `localCanvasZ`
  The depth of the coordinate at which the renderer should paint itself.
  `final Property<Double,Node>`
  `opacity`
  `final Property<Rectangle, Node>`
  `paintingRect`
  The painting rectangle, into which the renderer should be painted inside the node's local bounds.
  `final Property<Double,Node>`
  `rotate`
  Rotation to apply to the node.
  `final Property<Point3D,Node>`
  `rotationAxis`
  The rotation axis around which rotations should be performed.
  `final Property<Double,Node>`
  `scaleX`
  The scale to apply to the node, along the x-axis.
  `final Property<Double,Node>`
  `scaleY`
  The scale to apply to the node along the y-axis.
  `final Property<Double,Node>`
  `scaleZ`
  The scale to apply to the node along the z-axis.
  `final Property<Double,Node>`
  `translateX`
  X-translation to apply to the node.
  `final Property<Double,Node>`
  `translateY`
  Y-translation to apply to the node.
  `final Property<Double,Node>`
  `translateZ`
  Z-translation to apply to the node.
  `final Property<Boolean,Node>`
  `visible`
  Flag to indicate whether the node should be visible or not.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Node()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(Node child)`
  Adds a child node.
  `void`
  `addTags(String... tags)`
  Adds tags to this node.
  `boolean`
  `contains(int x, int y)`
  This can be used to hit test pointer events against this node.
  `Collection<Node>`
  `findNodesWithTag(String tag)`
  `Rectangle2D`
  `getBoundsInScene(Rectangle2D out)`
  `Node`
  `getChildAt(int index)`
  Gets child node at index.
  `int`
  `getChildCount()`
  Gets number of children in this node.
  `Iterable<Node>`
  `getChildNodes()`
  Gets the child nodes of this node.
  `Transform`
  `getLocalToParentTransform()`
  Gets the transform to use to transform the Node into its parent node's space.
  `Transform`
  `getLocalToSceneTransform()`
  Gets the transform to use to go from the local coordinates to scene coordinates.
  `Transform`
  `getLocalToScreenTransform()`
  `NodePainter`
  `getRenderer()`
  Gets the renderer component for this node.
  `Scene`
  `getScene()`
  Gets the scene that this node is attached to.
  `Style`
  `getStyle()`

  ###### Returns

  `boolean`
  `hasChildren()`
  Checks if node has children.
  `boolean`
  `hasTag(String tag)`
  Check if this node has a tag.
  `boolean`
  `isNeedsLayout()`
  Returns true if this node needs to have its children re-laid out before rendering
  `protected void`
  `layoutChildren()`
  Can be overridden by subclasses to layout children.
  `void`
  `remove(Node child)`
  Removes a child node.
  `void`
  `removeAll()`
  Removes all child nodes.
  `void`
  `removeTags(String... tags)`
  Removes tags from this node.
  `void`
  `render(Graphics g)`
  Renders the node onto a graphics context.
  `void`
  `renderChildren(Graphics g)`
  Renders the node's children.
  `void`
  `setNeedsLayout(boolean needsLayout)`

  ###### Parameters

  `void`
  `setRenderAsImage(boolean t)`
  Sets the render as image flag.
  `void`
  `setRenderer(NodePainter comp)`
  Sets the component that should be used to render the node's contents.
  `void`
  `setStyle(Style style)`

  ###### Parameters

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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.

    ###### Parameters

    - `t`

  - ### addTags

    public void addTags(String... tags)

    Adds tags to this node.

    ###### Parameters

    - `tags`

  - ### getBoundsInScene

    public Rectangle2D getBoundsInScene(Rectangle2D out)

  - ### removeTags

    public void removeTags(String... tags)

    Removes tags from this node.

    ###### Parameters

    - `tags`

  - ### hasTag

    public boolean hasTag(String tag)

    Check if this node has a tag.

    ###### Parameters

    - `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`: the needsLayout to set

  - ### getStyle

    public Style getStyle()

    ###### Returns

    the style

  - ### setStyle

    public void setStyle(Style style)

    ###### Parameters

    - `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.

    ###### Parameters

    - `x`

    - `y`

  - ### findNodesWithTag

    public Collection<Node> findNodesWithTag(String tag)

  - ### getLocalToScreenTransform

    public Transform getLocalToScreenTransform()

  - ### render

    public void render(Graphics g)

    Renders the node onto a graphics context.

    ###### Parameters

    - `g`

  - ### renderChildren

    public void renderChildren(Graphics g)

    Renders the node's children.

    ###### Parameters

    - `g`

  - ### 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.

    ###### Parameters

    - `comp`

  - ### add

    public void add(Node child)

    Adds a child node.

    ###### Parameters

    - `child`

  - ### remove

    public void remove(Node child)

    Removes a child node.

    ###### Parameters

    - `child`

  - ### 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.

    ###### Parameters

    - `index`

  - ### hasChildren

    public boolean hasChildren()
    Checks if node has children.

  - ### removeAll

    public void removeAll()
    Removes all child nodes.