Class PNode

java.lang.Object
edu.umd.cs.piccolo.PNode
All Implemented Interfaces:
Printable, Serializable, Cloneable
Direct Known Subclasses:
PCamera, PHtmlView, PImage, PLayer, PPath, PRoot, PText

public class PNode extends Object implements Cloneable, Serializable, Printable
PNode is the central abstraction in Piccolo. All objects that are visible on the screen are instances of the node class. All nodes may have other "child" nodes added to them.

See edu.umd.piccolo.examples.NodeExample.java for demonstrations of how nodes can be used and how new types of nodes can be created.

Version:
1.0
Author:
Jesse Grosjean
See Also:
  • Field Details

    • PROPERTY_CLIENT_PROPERTIES

      public static final String PROPERTY_CLIENT_PROPERTIES
      The property name that identifies a change in this node's client propertie (see getClientProperty). In an property change event the new value will be a reference to the map of client properties but old value will always be null.
      See Also:
    • PROPERTY_CODE_CLIENT_PROPERTIES

      public static final int PROPERTY_CODE_CLIENT_PROPERTIES
      The property code that identifies a change in this node's client propertie (see getClientProperty). In an property change event the new value will be a reference to the map of client properties but old value will always be null.
      See Also:
    • PROPERTY_BOUNDS

      public static final String PROPERTY_BOUNDS
      The property name that identifies a change of this node's bounds (see getBounds, getBoundsReference). In any property change event the new value will be a reference to this node's bounds, but old value will always be null.
      See Also:
    • PROPERTY_CODE_BOUNDS

      public static final int PROPERTY_CODE_BOUNDS
      The property code that identifies a change of this node's bounds (see getBounds, getBoundsReference). In any property change event the new value will be a reference to this node's bounds, but old value will always be null.
      See Also:
    • PROPERTY_FULL_BOUNDS

      public static final String PROPERTY_FULL_BOUNDS
      The property name that identifies a change of this node's full bounds (see getFullBounds, getFullBoundsReference). In any property change event the new value will be a reference to this node's full bounds cache, but old value will always be null.
      See Also:
    • PROPERTY_CODE_FULL_BOUNDS

      public static final int PROPERTY_CODE_FULL_BOUNDS
      The property code that identifies a change of this node's full bounds (see getFullBounds, getFullBoundsReference). In any property change event the new value will be a reference to this node's full bounds cache, but old value will always be null.
      See Also:
    • PROPERTY_TRANSFORM

      public static final String PROPERTY_TRANSFORM
      The property name that identifies a change of this node's transform (see getTransform, getTransformReference). In any property change event the new value will be a reference to this node's transform, but old value will always be null.
      See Also:
    • PROPERTY_CODE_TRANSFORM

      public static final int PROPERTY_CODE_TRANSFORM
      The property code that identifies a change of this node's transform (see getTransform, getTransformReference). In any property change event the new value will be a reference to this node's transform, but old value will always be null.
      See Also:
    • PROPERTY_VISIBLE

      public static final String PROPERTY_VISIBLE
      The property name that identifies a change of this node's visibility (see getVisible). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CODE_VISIBLE

      public static final int PROPERTY_CODE_VISIBLE
      The property code that identifies a change of this node's visibility (see getVisible). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_PAINT

      public static final String PROPERTY_PAINT
      The property name that identifies a change of this node's paint (see getPaint). Both old value and new value will be set correctly in any property change event.
      See Also:
    • PROPERTY_CODE_PAINT

      public static final int PROPERTY_CODE_PAINT
      The property code that identifies a change of this node's paint (see getPaint). Both old value and new value will be set correctly in any property change event.
      See Also:
    • PROPERTY_TRANSPARENCY

      public static final String PROPERTY_TRANSPARENCY
      The property name that identifies a change of this node's transparency (see getTransparency). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CODE_TRANSPARENCY

      public static final int PROPERTY_CODE_TRANSPARENCY
      The property code that identifies a change of this node's transparency (see getTransparency). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_PICKABLE

      public static final String PROPERTY_PICKABLE
      The property name that identifies a change of this node's pickable status (see getPickable). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CODE_PICKABLE

      public static final int PROPERTY_CODE_PICKABLE
      The property code that identifies a change of this node's pickable status (see getPickable). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CHILDREN_PICKABLE

      public static final String PROPERTY_CHILDREN_PICKABLE
      The property name that identifies a change of this node's children pickable status (see getChildrenPickable). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CODE_CHILDREN_PICKABLE

      public static final int PROPERTY_CODE_CHILDREN_PICKABLE
      The property code that identifies a change of this node's children pickable status (see getChildrenPickable). Both old value and new value will be null in any property change event.
      See Also:
    • PROPERTY_CHILDREN

      public static final String PROPERTY_CHILDREN
      The property name that identifies a change in the set of this node's direct children (see getChildrenReference, getChildrenIterator). In any property change event the new value will be a reference to this node's children, but old value will always be null.
      See Also:
    • PROPERTY_CODE_CHILDREN

      public static final int PROPERTY_CODE_CHILDREN
      The property code that identifies a change in the set of this node's direct children (see getChildrenReference, getChildrenIterator). In any property change event the new value will be a reference to this node's children, but old value will always be null.
      See Also:
    • PROPERTY_PARENT

      public static final String PROPERTY_PARENT
      The property name that identifies a change of this node's parent (see getParent). Both old value and new value will be set correctly in any property change event.
      See Also:
    • PROPERTY_CODE_PARENT

      public static final int PROPERTY_CODE_PARENT
      The property code that identifies a change of this node's parent (see getParent). Both old value and new value will be set correctly in any property change event.
      See Also:
    • SCENE_GRAPH_DELEGATE

      public static PNode.PSceneGraphDelegate SCENE_GRAPH_DELEGATE
      The single scene graph delegate that receives low level node events.
    • FILL_STRATEGY_ASPECT_FIT

      public static final int FILL_STRATEGY_ASPECT_FIT
      toImage fill strategy that stretches the node be as large as possible while still retaining its aspect ratio.
      Since:
      1.3
      See Also:
    • FILL_STRATEGY_ASPECT_COVER

      public static final int FILL_STRATEGY_ASPECT_COVER
      toImage fill strategy that stretches the node be large enough to cover the image, and centers it.
      Since:
      1.3
      See Also:
    • FILL_STRATEGY_EXACT_FIT

      public static final int FILL_STRATEGY_EXACT_FIT
      toImage fill strategy that stretches the node to be exactly the dimensions of the image. Will result in distortion if the aspect ratios are different.
      Since:
      1.3
      See Also:
  • Constructor Details

    • PNode

      public PNode(String newName)
      Creates a new PNode with the given name.
      Parameters:
      newName - name to assign to node
      Since:
      1.3
    • PNode

      public PNode()
      Constructs a new PNode.

      By default a node's paint is null, and bounds are empty. These values must be set for the node to show up on the screen once it's added to a scene graph.

  • Method Details

    • animateToBounds

      public PInterpolatingActivity animateToBounds(double x, double y, double width, double height, long duration)
      Animate this node's bounds from their current location when the activity starts to the specified bounds. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transform activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that. Note this method animates the node's bounds, but does not change the node's transform. Use animateTransformToBounds() to animate the node's transform instead.
      Parameters:
      x - left of target bounds
      y - top of target bounds
      width - width of target bounds
      height - height of target bounds
      duration - amount of time that the animation should take
      Returns:
      the newly scheduled activity
    • animateTransformToBounds

      public PTransformActivity animateTransformToBounds(double x, double y, double width, double height, long duration)
      Animate this node from it's current transform when the activity starts a new transform that will fit the node into the given bounds. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transform activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that. Note this method animates the node's transform, but does not directly change the node's bounds rectangle. Use animateToBounds() to animate the node's bounds rectangle instead.
      Parameters:
      x - left of target bounds
      y - top of target bounds
      width - width of target bounds
      height - height of target bounds
      duration - amount of time that the animation should take
      Returns:
      the newly scheduled activity
    • animateToPositionScaleRotation

      public PTransformActivity animateToPositionScaleRotation(double x, double y, double scale, double theta, long duration)
      Animate this node's transform from its current location when the activity starts to the specified location, scale, and rotation. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transform activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that.
      Parameters:
      x - the final target x position of node
      y - the final target y position of node
      duration - amount of time that the animation should take
      scale - the final scale for the duration
      theta - final theta value (in radians) for the animation
      Returns:
      the newly scheduled activity
    • animateToTransform

      public PTransformActivity animateToTransform(AffineTransform destTransform, long duration)
      Animate this node's transform from its current values when the activity starts to the new values specified in the given transform. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transform activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that.
      Parameters:
      destTransform - the final transform value
      duration - amount of time that the animation should take
      Returns:
      the newly scheduled activity
    • animateToColor

      public PInterpolatingActivity animateToColor(Color destColor, long duration)
      Animate this node's color from its current value to the new value specified. This meathod assumes that this nodes paint property is of type color. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different color activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that.
      Parameters:
      destColor - final color value.
      duration - amount of time that the animation should take
      Returns:
      the newly scheduled activity
    • animateToTransparency

      public PInterpolatingActivity animateToTransparency(float zeroToOne, long duration)
      Animate this node's transparency from its current value to the new value specified. Transparency values must range from zero to one. If this node descends from the root then the activity will be scheduled, else the returned activity should be scheduled manually. If two different transparency activities are scheduled for the same node at the same time, they will both be applied to the node, but the last one scheduled will be applied last on each frame, so it will appear to have replaced the original. Generally you will not want to do that.
      Parameters:
      zeroToOne - final transparency value.
      duration - amount of time that the animation should take
      Returns:
      the newly scheduled activity
    • addActivity

      public boolean addActivity(PActivity activity)
      Schedule the given activity with the root, note that only scheduled activities will be stepped. If the activity is successfully added true is returned, else false.
      Parameters:
      activity - new activity to schedule
      Returns:
      true if the activity is successfully scheduled.
    • getClientProperties

      public MutableAttributeSet getClientProperties()
      Return mutable attributed set of client properties associated with this node.
      Returns:
      the client properties associated to this node
    • getAttribute

      public Object getAttribute(Object key)
      Returns the value of the client attribute with the specified key. Only attributes added with addAttribute will return a non-null value.
      Parameters:
      key - key to use while fetching client attribute
      Returns:
      the value of this attribute or null
    • addAttribute

      public void addAttribute(Object key, Object value)
      Add an arbitrary key/value to this node.

      The get/add attribute methods provide access to a small per-instance attribute set. Callers can use get/add attribute to annotate nodes that were created by another module.

      If value is null this method will remove the attribute.

      Parameters:
      key - to use when adding the attribute
      value - value to associate to the new attribute
    • getClientPropertyKeysEnumeration

      public Enumeration getClientPropertyKeysEnumeration()
      Returns an enumeration of all keys maped to attribute values values.
      Returns:
      an Enumeration over attribute keys
    • getAttribute

      public Object getAttribute(Object key, Object defaultValue)
      Fetches the value of the requested attribute, returning defaultValue is not found.
      Parameters:
      key - attribute to search for
      defaultValue - value to return if attribute is not found
      Returns:
      value of attribute or defaultValue if not found
    • getBooleanAttribute

      public boolean getBooleanAttribute(Object key, boolean defaultValue)
      Fetches the boolean value of the requested attribute, returning defaultValue is not found.
      Parameters:
      key - attribute to search for
      defaultValue - value to return if attribute is not found
      Returns:
      value of attribute or defaultValue if not found
    • getIntegerAttribute

      public int getIntegerAttribute(Object key, int defaultValue)
      Fetches the integer value of the requested attribute, returning defaultValue is not found.
      Parameters:
      key - attribute to search for
      defaultValue - value to return if attribute is not found
      Returns:
      value of attribute or defaultValue if not found
    • getDoubleAttribute

      public double getDoubleAttribute(Object key, double defaultValue)
      Fetches the double value of the requested attribute, returning defaultValue is not found.
      Parameters:
      key - attribute to search for
      defaultValue - value to return if attribute is not found
      Returns:
      value of attribute or defaultValue if not found
    • getClientProperty

      public Object getClientProperty(Object key)
      Deprecated.
      use getAttribute(Object key)instead.
      Parameters:
      key - name of property to search for
      Returns:
      value of matching client property
    • addClientProperty

      public void addClientProperty(Object key, Object value)
      Deprecated.
      use addAttribute(Object key, Object value)instead.
      Parameters:
      key - name of property to add
      value - value or new attribute
    • getClientPropertyKeysIterator

      public Iterator getClientPropertyKeysIterator()
      Deprecated.
      use getClientPropertyKeysEnumerator() instead.
      Returns:
      iterator for client property keys
    • clone

      public Object clone()
      The copy method copies this node and all of its descendants. Note that copying is implemented in terms of java serialization. See the serialization notes for more information.
      Overrides:
      clone in class Object
      Returns:
      new copy of this node or null if the node was not serializable
    • localToParent

      public Point2D localToParent(Point2D localPoint)
      Transform the given point from this node's local coordinate system to its parent's local coordinate system. Note that this will modify the point parameter.
      Parameters:
      localPoint - point in local coordinate system to be transformed.
      Returns:
      point in parent's local coordinate system
    • localToParent

      public Dimension2D localToParent(Dimension2D localDimension)
      Transform the given dimension from this node's local coordinate system to its parent's local coordinate system. Note that this will modify the dimension parameter.
      Parameters:
      localDimension - dimension in local coordinate system to be transformed.
      Returns:
      dimension in parent's local coordinate system
    • localToParent

      public Rectangle2D localToParent(Rectangle2D localRectangle)
      Transform the given rectangle from this node's local coordinate system to its parent's local coordinate system. Note that this will modify the rectangle parameter.
      Parameters:
      localRectangle - rectangle in local coordinate system to be transformed.
      Returns:
      rectangle in parent's local coordinate system
    • parentToLocal

      public Point2D parentToLocal(Point2D parentPoint)
      Transform the given point from this node's parent's local coordinate system to the local coordinate system of this node. Note that this will modify the point parameter.
      Parameters:
      parentPoint - point in parent's coordinate system to be transformed.
      Returns:
      point in this node's local coordinate system
    • parentToLocal

      public Dimension2D parentToLocal(Dimension2D parentDimension)
      Transform the given dimension from this node's parent's local coordinate system to the local coordinate system of this node. Note that this will modify the dimension parameter.
      Parameters:
      parentDimension - dimension in parent's coordinate system to be transformed.
      Returns:
      dimension in this node's local coordinate system
    • parentToLocal

      public Rectangle2D parentToLocal(Rectangle2D parentRectangle)
      Transform the given rectangle from this node's parent's local coordinate system to the local coordinate system of this node. Note that this will modify the rectangle parameter.
      Parameters:
      parentRectangle - rectangle in parent's coordinate system to be transformed.
      Returns:
      rectangle in this node's local coordinate system
    • localToGlobal

      public Point2D localToGlobal(Point2D localPoint)
      Transform the given point from this node's local coordinate system to the global coordinate system. Note that this will modify the point parameter.
      Parameters:
      localPoint - point in local coordinate system to be transformed.
      Returns:
      point in global coordinates
    • localToGlobal

      public Dimension2D localToGlobal(Dimension2D localDimension)
      Transform the given dimension from this node's local coordinate system to the global coordinate system. Note that this will modify the dimension parameter.
      Parameters:
      localDimension - dimension in local coordinate system to be transformed.
      Returns:
      dimension in global coordinates
    • localToGlobal

      public Rectangle2D localToGlobal(Rectangle2D localRectangle)
      Transform the given rectangle from this node's local coordinate system to the global coordinate system. Note that this will modify the rectangle parameter.
      Parameters:
      localRectangle - rectangle in local coordinate system to be transformed.
      Returns:
      rectangle in global coordinates
    • globalToLocal

      public Point2D globalToLocal(Point2D globalPoint)
      Transform the given point from global coordinates to this node's local coordinate system. Note that this will modify the point parameter.
      Parameters:
      globalPoint - point in global coordinates to be transformed.
      Returns:
      point in this node's local coordinate system.
    • globalToLocal

      public Dimension2D globalToLocal(Dimension2D globalDimension)
      Transform the given dimension from global coordinates to this node's local coordinate system. Note that this will modify the dimension parameter.
      Parameters:
      globalDimension - dimension in global coordinates to be transformed.
      Returns:
      dimension in this node's local coordinate system.
    • globalToLocal

      public Rectangle2D globalToLocal(Rectangle2D globalRectangle)
      Transform the given rectangle from global coordinates to this node's local coordinate system. Note that this will modify the rectangle parameter.
      Parameters:
      globalRectangle - rectangle in global coordinates to be transformed.
      Returns:
      rectangle in this node's local coordinate system.
    • getLocalToGlobalTransform

      public PAffineTransform getLocalToGlobalTransform(PAffineTransform dest)
      Return the transform that converts local coordinates at this node to the global coordinate system.
      Parameters:
      dest - PAffineTransform to transform to global coordinates
      Returns:
      The concatenation of transforms from the top node down to this node.
    • getGlobalToLocalTransform

      public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest)
      Return the transform that converts global coordinates to local coordinates of this node.
      Parameters:
      dest - PAffineTransform to transform from global to local
      Returns:
      The inverse of the concatenation of transforms from the root down to this node.
    • getListenerList

      public EventListenerList getListenerList()
      Return the list of event listeners associated with this node.
      Returns:
      event listener list or null
    • addInputEventListener

      public void addInputEventListener(PInputEventListener listener)
      Adds the specified input event listener to receive input events from this node.
      Parameters:
      listener - the new input listener
    • removeInputEventListener

      public void removeInputEventListener(PInputEventListener listener)
      Removes the specified input event listener so that it no longer receives input events from this node.
      Parameters:
      listener - the input listener to remove
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a PropertyChangeListener to the listener list. The listener is registered for all properties. See the fields in PNode and subclasses that start with PROPERTY_ to find out which properties exist.
      Parameters:
      listener - The PropertyChangeListener to be added
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. See the fields in PNode and subclasses that start with PROPERTY_ to find out which properties are supported.
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The PropertyChangeListener to be added
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
      Parameters:
      listener - The PropertyChangeListener to be removed
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Remove a PropertyChangeListener for a specific property.
      Parameters:
      propertyName - The name of the property that was listened on.
      listener - The PropertyChangeListener to be removed
    • getPropertyChangeParentMask

      public int getPropertyChangeParentMask()
      Return the propertyChangeParentMask that determines which property change events are forwared to this nodes parent so that its property change listeners will also be notified.
      Returns:
      mask used for deciding whether to bubble property changes up to parent
    • setPropertyChangeParentMask

      public void setPropertyChangeParentMask(int propertyChangeParentMask)
      Set the propertyChangeParentMask that determines which property change events are forwared to this nodes parent so that its property change listeners will also be notified.
      Parameters:
      propertyChangeParentMask - new mask for property change bubble up
    • firePropertyChange

      public void firePropertyChange(int propertyCode, String propertyName, Object oldValue, Object newValue)
      Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null. If the propertyCode exists in this node's propertyChangeParentMask then a property change event will also be fired on this nodes parent.
      Parameters:
      propertyCode - The code of the property changed.
      propertyName - The name of the property that was changed.
      oldValue - The old value of the property.
      newValue - The new value of the property.
    • fireChildPropertyChange

      protected void fireChildPropertyChange(PropertyChangeEvent event, int propertyCode)
      Called by child node to forward property change events up the node tree so that property change listeners registered with this node will be notified of property changes of its children nodes. For performance reason only propertyCodes listed in the propertyChangeParentMask are forwarded.
      Parameters:
      event - The property change event containing source node and changed values.
      propertyCode - The code of the property changed.
    • getBounds

      public PBounds getBounds()
      Return a copy of this node's bounds. These bounds are stored in the local coordinate system of this node and do not include the bounds of any of this node's children.
      Returns:
      copy of this node's local bounds
    • getBoundsReference

      public PBounds getBoundsReference()
      Return a direct reference to this node's bounds. These bounds are stored in the local coordinate system of this node and do not include the bounds of any of this node's children. The value returned should not be modified.
      Returns:
      direct reference to local bounds
    • startResizeBounds

      public void startResizeBounds()
      Notify this node that you will begin to repeatedly call setBounds . When you are done call endResizeBounds to let the node know that you are done.
    • endResizeBounds

      public void endResizeBounds()
      Notify this node that you have finished a resize bounds sequence.
    • setX

      public boolean setX(double x)
      Set's this node's bounds left position, leaving y, width, and height unchanged.
      Parameters:
      x - new x position of bounds
      Returns:
      whether the change was successful
    • setY

      public boolean setY(double y)
      Set's this node's bounds top position, leaving x, width, and height unchanged.
      Parameters:
      y - new y position of bounds
      Returns:
      whether the change was successful
    • setWidth

      public boolean setWidth(double width)
      Set's this node's bounds width, leaving x, y, and height unchanged.
      Parameters:
      width - new width position of bounds
      Returns:
      whether the change was successful
    • setHeight

      public boolean setHeight(double height)
      Set's this node's bounds height, leaving x, y, and width unchanged.
      Parameters:
      height - new height position of bounds
      Returns:
      whether the change was successful
    • setBounds

      public boolean setBounds(Rectangle2D newBounds)
      Set the bounds of this node to the given value. These bounds are stored in the local coordinate system of this node.
      Parameters:
      newBounds - bounds to apply to this node
      Returns:
      true if the bounds changed.
    • setBounds

      public boolean setBounds(double x, double y, double width, double height)
      Set the bounds of this node to the given position and size. These bounds are stored in the local coordinate system of this node. If the width or height is less then or equal to zero then the bound's empty bit will be set to true. Subclasses must call the super.setBounds() method.
      Parameters:
      x - x position of bounds
      y - y position of bounds
      width - width to apply to the bounds
      height - height to apply to the bounds
      Returns:
      true if the bounds changed.
    • internalUpdateBounds

      protected void internalUpdateBounds(double x, double y, double width, double height)
      Gives nodes a chance to update their internal structure before bounds changed notifications are sent. When this message is recived the nodes bounds field will contain the new value. See PPath for an example that uses this method.
      Parameters:
      x - x position of bounds
      y - y position of bounds
      width - width to apply to the bounds
      height - height to apply to the bounds
    • resetBounds

      public void resetBounds()
      Set the empty bit of this bounds to true.
    • getX

      public double getX()
      Return the x position (in local coords) of this node's bounds.
      Returns:
      local x position of bounds
    • getY

      public double getY()
      Return the y position (in local coords) of this node's bounds.
      Returns:
      local y position of bounds
    • getWidth

      public double getWidth()
      Return the width (in local coords) of this node's bounds.
      Returns:
      local width of bounds
    • getHeight

      public double getHeight()
      Return the height (in local coords) of this node's bounds.
      Returns:
      local width of bounds
    • getGlobalBounds

      public PBounds getGlobalBounds()
      Return a copy of the bounds of this node in the global coordinate system.
      Returns:
      the bounds in global coordinate system.
    • centerBoundsOnPoint

      public boolean centerBoundsOnPoint(double localX, double localY)
      Center the bounds of this node so that they are centered on the given point specified on the local coordinates of this node. Note that this method will modify the nodes bounds, while centerFullBoundsOnPoint will modify the nodes transform.
      Parameters:
      localX - x position of point around which to center bounds
      localY - y position of point around which to center bounds
      Returns:
      true if the bounds changed.
    • centerFullBoundsOnPoint

      public void centerFullBoundsOnPoint(double parentX, double parentY)
      Center the full bounds of this node so that they are centered on the given point specified on the local coordinates of this nodes parent. Note that this method will modify the nodes transform, while centerBoundsOnPoint will modify the nodes bounds.
      Parameters:
      parentX - x position around which to center full bounds
      parentY - y position around which to center full bounds
    • intersects

      public boolean intersects(Rectangle2D localBounds)
      Return true if this node intersects the given rectangle specified in local bounds. If the geometry of this node is complex this method can become expensive, it is therefore recommended that fullIntersects is used for quick rejects before calling this method.
      Parameters:
      localBounds - the bounds to test for intersection against
      Returns:
      true if the given rectangle intersects this nodes geometry.
    • getFullBounds

      public PBounds getFullBounds()
      Return a copy of this node's full bounds. These bounds are stored in the parent coordinate system of this node and they include the union of this node's bounds and all the bounds of it's descendants.
      Returns:
      a copy of this node's full bounds.
    • getFullBoundsReference

      public PBounds getFullBoundsReference()
      Return a reference to this node's full bounds cache. These bounds are stored in the parent coordinate system of this node and they include the union of this node's bounds and all the bounds of it's descendants. The bounds returned by this method should not be modified.
      Returns:
      a reference to this node's full bounds cache.
    • computeFullBounds

      public PBounds computeFullBounds(PBounds dstBounds)
      Compute and return the full bounds of this node. If the dstBounds parameter is not null then it will be used to return the results instead of creating a new PBounds.
      Parameters:
      dstBounds - if not null the new bounds will be stored here
      Returns:
      the full bounds in the parent coordinate system of this node
    • getUnionOfChildrenBounds

      public PBounds getUnionOfChildrenBounds(PBounds dstBounds)
      Compute and return the union of the full bounds of all the children of this node. If the dstBounds parameter is not null then it will be used to return the results instead of creating a new PBounds.
      Parameters:
      dstBounds - if not null the new bounds will be stored here
      Returns:
      union of children bounds
    • getGlobalFullBounds

      public PBounds getGlobalFullBounds()
      Return a copy of the full bounds of this node in the global coordinate system.
      Returns:
      the full bounds in global coordinate system.
    • fullIntersects

      public boolean fullIntersects(Rectangle2D parentBounds)
      Return true if the full bounds of this node intersects with the specified bounds.
      Parameters:
      parentBounds - the bounds to test for intersection against (specified in parent's coordinate system)
      Returns:
      true if this nodes full bounds intersect the given bounds.
    • getBoundsVolatile

      protected boolean getBoundsVolatile()
      Return true if this nodes bounds may change at any time. The default behavior is to return false, subclasses that override this method to return true should also override getBoundsReference() and compute their volatile bounds there before returning the reference.
      Returns:
      true if this node has volatile bounds
    • getChildBoundsVolatile

      protected boolean getChildBoundsVolatile()
      Return true if this node has a child with volatile bounds.
      Returns:
      true if this node has a child with volatile bounds
    • setChildBoundsVolatile

      protected void setChildBoundsVolatile(boolean childBoundsVolatile)
      Set if this node has a child with volatile bounds. This should normally be managed automatically by the bounds validation process.
      Parameters:
      childBoundsVolatile - true if this node has a descendant with volatile bounds
    • getBoundsChanged

      protected boolean getBoundsChanged()
      Return true if this node's bounds have recently changed. This flag will be reset on the next call of validateFullBounds.
      Returns:
      true if this node's bounds have changed.
    • setBoundsChanged

      protected void setBoundsChanged(boolean boundsChanged)
      Set the bounds chnaged flag. This flag will be reset on the next call of validateFullBounds.
      Parameters:
      boundsChanged - true if this nodes bounds have changed.
    • getFullBoundsInvalid

      protected boolean getFullBoundsInvalid()
      Return true if the full bounds of this node are invalid. This means that the full bounds of this node have changed and need to be recomputed.
      Returns:
      true if the full bounds of this node are invalid
    • setFullBoundsInvalid

      protected void setFullBoundsInvalid(boolean fullBoundsInvalid)
      Set the full bounds invalid flag. This flag is set when the full bounds of this node need to be recomputed as is the case when this node is transformed or when one of this node's children changes geometry.
      Parameters:
      fullBoundsInvalid - true=invalid, false=valid
    • getChildBoundsInvalid

      protected boolean getChildBoundsInvalid()
      Return true if one of this node's descendants has invalid bounds.
      Returns:
      whether child bounds are invalid
    • setChildBoundsInvalid

      protected void setChildBoundsInvalid(boolean childBoundsInvalid)
      Set the flag indicating that one of this node's descendants has invalid bounds.
      Parameters:
      childBoundsInvalid - true=invalid, false=valid
    • signalBoundsChanged

      public void signalBoundsChanged()
      This method should be called when the bounds of this node are changed. It invalidates the full bounds of this node, and also notifies each of this nodes children that their parent's bounds have changed. As a result of this method getting called this nodes layoutChildren will be called.
    • invalidateLayout

      public void invalidateLayout()
      Invalidate this node's layout, so that later layoutChildren will get called.
    • parentBoundsChanged

      protected void parentBoundsChanged()
      A notification that the bounds of this node's parent have changed.
    • invalidateFullBounds

      public void invalidateFullBounds()
      Invalidates the full bounds of this node, and sets the child bounds invalid flag on each of this node's ancestors.
    • validateFullBounds

      protected boolean validateFullBounds()
      This method is called to validate the bounds of this node and all of its descendants. It returns true if this nodes bounds or the bounds of any of its descendants are marked as volatile.
      Returns:
      true if this node or any of its descendants have volatile bounds
    • layoutChildren

      protected void layoutChildren()
      Nodes that apply layout constraints to their children should override this method and do the layout there.
    • getRotation

      public double getRotation()
      Returns the rotation applied by this node's transform in radians. This rotation affects this node and all its descendants. The value returned will be between 0 and 2pi radians.
      Returns:
      rotation in radians.
    • setRotation

      public void setRotation(double theta)
      Sets the rotation of this nodes transform in radians. This will affect this node and all its descendents.
      Parameters:
      theta - rotation in radians
    • rotate

      public void rotate(double theta)
      Rotates this node by theta (in radians) about the 0,0 point. This will affect this node and all its descendants.
      Parameters:
      theta - the amount to rotate by in radians
    • rotateInPlace

      public void rotateInPlace(double theta)
      Rotates this node by theta (in radians), and then translates the node so that the x, y position of its fullBounds stays constant.
      Parameters:
      theta - the amount to rotate by in radians
    • rotateAboutPoint

      public void rotateAboutPoint(double theta, Point2D point)
      Rotates this node by theta (in radians) about the given point. This will affect this node and all its descendants.
      Parameters:
      theta - the amount to rotate by in radians
      point - the point about which to rotate
    • rotateAboutPoint

      public void rotateAboutPoint(double theta, double x, double y)
      Rotates this node by theta (in radians) about the given point. This will affect this node and all its descendants.
      Parameters:
      theta - the amount to rotate by in radians
      x - the x coordinate of the point around which to rotate
      y - the y coordinate of the point around which to rotate
    • getGlobalRotation

      public double getGlobalRotation()
      Return the total amount of rotation applied to this node by its own transform together with the transforms of all its ancestors. The value returned will be between 0 and 2pi radians.
      Returns:
      the total amount of rotation applied to this node in radians
    • setGlobalRotation

      public void setGlobalRotation(double theta)
      Set the global rotation (in radians) of this node. This is implemented by rotating this nodes transform the required amount so that the nodes global rotation is as requested.
      Parameters:
      theta - the amount to rotate by in radians relative to the global coordinate system.
    • getScale

      public double getScale()
      Return the scale applied by this node's transform. The scale is effecting this node and all its descendants.
      Returns:
      scale applied by this nodes transform.
    • setScale

      public void setScale(double scale)
      Set the scale of this node's transform. The scale will affect this node and all its descendants.
      Parameters:
      scale - the scale to set the transform to
    • scale

      public void scale(double scale)
      Scale this nodes transform by the given amount. This will affect this node and all of its descendants.
      Parameters:
      scale - the amount to scale by
    • scaleAboutPoint

      public void scaleAboutPoint(double scale, Point2D point)
      Scale this nodes transform by the given amount about the specified point. This will affect this node and all of its descendants.
      Parameters:
      scale - the amount to scale by
      point - the point to scale about
    • scaleAboutPoint

      public void scaleAboutPoint(double scale, double x, double y)
      Scale this nodes transform by the given amount about the specified point. This will affect this node and all of its descendants.
      Parameters:
      scale - the amount to scale by
      x - the x coordinate of the point around which to scale
      y - the y coordinate of the point around which to scale
    • getGlobalScale

      public double getGlobalScale()
      Return the global scale that is being applied to this node by its transform together with the transforms of all its ancestors.
      Returns:
      global scale of this node
    • setGlobalScale

      public void setGlobalScale(double scale)
      Set the global scale of this node. This is implemented by scaling this nodes transform the required amount so that the nodes global scale is as requested.
      Parameters:
      scale - the desired global scale
    • getXOffset

      public double getXOffset()
      Returns the x offset of this node as applied by its transform.
      Returns:
      x offset of this node as applied by its transform
    • getYOffset

      public double getYOffset()
      Returns the y offset of this node as applied by its transform.
      Returns:
      y offset of this node as applied by its transform
    • getOffset

      public Point2D getOffset()
      Return the offset that is being applied to this node by its transform. This offset effects this node and all of its descendants and is specified in the parent coordinate system. This returns the values that are in the m02 and m12 positions in the affine transform.
      Returns:
      a point representing the x and y offset
    • setOffset

      public void setOffset(Point2D point)
      Set the offset that is being applied to this node by its transform. This offset effects this node and all of its descendants and is specified in the nodes parent coordinate system. This directly sets the values of the m02 and m12 positions in the affine transform. Unlike "PNode.translate()" it is not effected by the transforms scale.
      Parameters:
      point - value of new offset
    • setOffset

      public void setOffset(double x, double y)
      Set the offset that is being applied to this node by its transform. This offset effects this node and all of its descendants and is specified in the nodes parent coordinate system. This directly sets the values of the m02 and m12 positions in the affine transform. Unlike "PNode.translate()" it is not effected by the transforms scale.
      Parameters:
      x - amount of x offset
      y - amount of y offset
    • offset

      public void offset(double dx, double dy)
      Offset this node relative to the parents coordinate system, and is NOT effected by this nodes current scale or rotation. This is implemented by directly adding dx to the m02 position and dy to the m12 position in the affine transform.
      Parameters:
      dx - amount to add to this nodes current x Offset
      dy - amount to add to this nodes current y Offset
    • translate

      public void translate(double dx, double dy)
      Translate this node's transform by the given amount, using the standard affine transform translate method. This translation effects this node and all of its descendants.
      Parameters:
      dx - amount to add to this nodes current x translation
      dy - amount to add to this nodes current y translation
    • getGlobalTranslation

      public Point2D getGlobalTranslation()
      Return the global translation that is being applied to this node by its transform together with the transforms of all its ancestors.
      Returns:
      the global translation applied to this node
    • setGlobalTranslation

      public void setGlobalTranslation(Point2D globalPoint)
      Set the global translation of this node. This is implemented by translating this nodes transform the required amount so that the nodes global scale is as requested.
      Parameters:
      globalPoint - the desired global translation
    • transformBy

      public void transformBy(AffineTransform aTransform)
      Transform this nodes transform by the given transform.
      Parameters:
      aTransform - the transform to apply.
    • lerp

      public static double lerp(double t, double a, double b)
      Linearly interpolates between a and b, based on t. Specifically, it computes lerp(a, b, t) = a + t*(b - a). This produces a result that changes from a (when t = 0) to b (when t = 1).
      Parameters:
      t - variable 'time' parameter
      a - from point
      b - to Point
      Returns:
      linear interpolation between and b at time interval t (given as # between 0f and 1f)
    • animateToRelativePosition

      public PActivity animateToRelativePosition(Point2D srcPt, Point2D destPt, Rectangle2D destBounds, int millis)
      This will calculate the necessary transform in order to make this node appear at a particular position relative to the specified bounding box. The source point specifies a point in the unit square (0, 0) - (1, 1) that represents an anchor point on the corresponding node to this transform. The destination point specifies an anchor point on the reference node. The position method then computes the transform that results in transforming this node so that the source anchor point coincides with the reference anchor point. This can be useful for layout algorithms as it is straightforward to position one object relative to another.

      For example, If you have two nodes, A and B, and you call

       Point2D srcPt = new Point2D.Double(1.0, 0.0);
       Point2D destPt = new Point2D.Double(0.0, 0.0);
       A.position(srcPt, destPt, B.getGlobalBounds(), 750, null);
       
      The result is that A will move so that its upper-right corner is at the same place as the upper-left corner of B, and the transition will be smoothly animated over a period of 750 milliseconds.
      Parameters:
      srcPt - The anchor point on this transform's node (normalized to a unit square)
      destPt - The anchor point on destination bounds (normalized to a unit square)
      destBounds - The bounds (in global coordinates) used to calculate this transform's node
      millis - Number of milliseconds over which to perform the animation
      Returns:
      newly scheduled activity or node if activity could not be scheduled
      Since:
      1.3
    • position

      public void position(Point2D srcPt, Point2D destPt, Rectangle2D destBounds, int millis)
      Deprecated.
      in favor of animateToRelativePosition It will calculate the necessary transform in order to make this node appear at a particular position relative to the specified bounding box. The source point specifies a point in the unit square (0, 0) - (1, 1) that represents an anchor point on the corresponding node to this transform. The destination point specifies an anchor point on the reference node. The position method then computes the transform that results in transforming this node so that the source anchor point coincides with the reference anchor point. This can be useful for layout algorithms as it is straightforward to position one object relative to another.

      For example, If you have two nodes, A and B, and you call

       Point2D srcPt = new Point2D.Double(1.0, 0.0);
       Point2D destPt = new Point2D.Double(0.0, 0.0);
       A.position(srcPt, destPt, B.getGlobalBounds(), 750, null);
       
      The result is that A will move so that its upper-right corner is at the same place as the upper-left corner of B, and the transition will be smoothly animated over a period of 750 milliseconds.
      Parameters:
      srcPt - The anchor point on this transform's node (normalized to a unit square)
      destPt - The anchor point on destination bounds (normalized to a unit square)
      destBounds - The bounds (in global coordinates) used to calculate this transform's node
      millis - Number of milliseconds over which to perform the animation
    • getTransform

      public PAffineTransform getTransform()
      Return a copy of the transform associated with this node.
      Returns:
      copy of this node's transform
    • getTransformReference

      public PAffineTransform getTransformReference(boolean createNewTransformIfNull)
      Return a reference to the transform associated with this node. This returned transform should not be modified. PNode transforms are created lazily when needed. If you access the transform reference before the transform has been created it may return null. The createNewTransformIfNull parameter is used to specify that the PNode should create a new transform (and assign that transform to the nodes local transform variable) instead of returning null.
      Parameters:
      createNewTransformIfNull - if the transform has not been initialised, should it be?
      Returns:
      reference to this node's transform
    • getInverseTransform

      public PAffineTransform getInverseTransform()
      Return an inverted copy of the transform associated with this node.
      Returns:
      inverted copy of this node's transform
    • setTransform

      public void setTransform(AffineTransform transform)
      Set the transform applied to this node.
      Parameters:
      transform - the new transform value
    • getPaintInvalid

      public boolean getPaintInvalid()
      Return true if this nodes paint is invalid, in which case the node needs to be repainted.
      Returns:
      true if this node needs to be repainted
    • setPaintInvalid

      public void setPaintInvalid(boolean paintInvalid)
      Mark this node as having invalid paint. If this is set the node will later be repainted. Node this method is most often used internally.
      Parameters:
      paintInvalid - true if this node should be repainted
    • getChildPaintInvalid

      public boolean getChildPaintInvalid()
      Return true if this node has a child with invalid paint.
      Returns:
      true if this node has a child with invalid paint
    • setChildPaintInvalid

      public void setChildPaintInvalid(boolean childPaintInvalid)
      Mark this node as having a child with invalid paint.
      Parameters:
      childPaintInvalid - true if this node has a child with invalid paint
    • invalidatePaint

      public void invalidatePaint()
      Invalidate this node's paint, and mark all of its ancestors as having a node with invalid paint.
    • validateFullPaint

      public void validateFullPaint()
      Repaint this node and any of its descendants if they have invalid paint.
    • repaint

      public void repaint()
      Mark the area on the screen represented by this nodes full bounds as needing a repaint.
    • repaintFrom

      public void repaintFrom(PBounds localBounds, PNode childOrThis)
      Pass the given repaint request up the tree, so that any cameras can invalidate that region on their associated canvas.
      Parameters:
      localBounds - the bounds to repaint
      childOrThis - if childOrThis does not equal this then this nodes transform will be applied to the localBounds param
    • isOpaque

      public boolean isOpaque(Rectangle2D boundary)
      Returns whether this node is Opaque.
      Parameters:
      boundary - boundary to check and see if this node covers completely.
      Returns:
      true if opaque
    • getOccluded

      public boolean getOccluded()
      Returns whether this node has been flagged as occluded.
      Returns:
      true if occluded
    • setOccluded

      public void setOccluded(boolean occluded)
      Flags this node as occluded.
      Parameters:
      occluded - new value for occluded
    • getVisible

      public boolean getVisible()
      Return true if this node is visible, that is if it will paint itself and descendants.
      Returns:
      true if this node and its descendants are visible.
    • setVisible

      public void setVisible(boolean isVisible)
      Set the visibility of this node and its descendants.
      Parameters:
      isVisible - true if this node and its descendants are visible
    • getPaint

      public Paint getPaint()
      Return the paint used while painting this node. This value may be null.
      Returns:
      the paint used while painting this node.
    • setPaint

      public void setPaint(Paint newPaint)
      Set the paint used to paint this node, which may be null.
      Parameters:
      newPaint - paint that this node should use when painting itself.
    • getTransparency

      public float getTransparency()
      Return the transparency used when painting this node. Note that this transparency is also applied to all of the node's descendants.
      Returns:
      how transparent this node is 0f = completely transparent, 1f = completely opaque
    • setTransparency

      public void setTransparency(float newTransparency)
      Set the transparency used to paint this node. Note that this transparency applies to this node and all of its descendants.
      Parameters:
      newTransparency - transparency value for this node. 0f = fully transparent, 1f = fully opaque
    • paint

      protected void paint(PPaintContext paintContext)
      Paint this node behind any of its children nodes. Subclasses that define a different appearance should override this method and paint themselves there.
      Parameters:
      paintContext - the paint context to use for painting the node
    • fullPaint

      public void fullPaint(PPaintContext paintContext)
      Paint this node and all of its descendants. Most subclasses do not need to override this method, they should override paint or paintAfterChildren instead.
      Parameters:
      paintContext - the paint context to use for painting this node and its children
    • paintAfterChildren

      protected void paintAfterChildren(PPaintContext paintContext)
      Subclasses that wish to do additional painting after their children are painted should override this method and do that painting here.
      Parameters:
      paintContext - the paint context to sue for painting after the children are painted
    • toImage

      public Image toImage()
      Return a new Image representing this node and all of its children. The image size will be equal to the size of this nodes full bounds.
      Returns:
      a new image representing this node and its descendants
    • toImage

      public Image toImage(int width, int height, Paint backgroundPaint)
      Return a new Image of the requested size representing this node and all of its children. If backGroundPaint is null the resulting image will have transparent regions, otherwise those regions will be filled with the backgroundPaint.
      Parameters:
      width - pixel width of the resulting image
      height - pixel height of the resulting image
      backgroundPaint - paint to fill the image with before drawing this node, may be null
      Returns:
      a new image representing this node and its descendants
    • toImage

      public Image toImage(BufferedImage image, Paint backGroundPaint)
      Paint a representation of this node into the specified buffered image. If background, paint is null, then the image will not be filled with a color prior to rendering
      Parameters:
      image - Image onto which this node will be painted
      backGroundPaint - will fill background of image with this. May be null.
      Returns:
      a rendering of this image and its descendants onto the specified image
    • toImage

      public Image toImage(BufferedImage image, Paint backGroundPaint, int fillStrategy)
      Paint a representation of this node into the specified buffered image. If background, paint is null, then the image will not be filled with a color prior to rendering
      Parameters:
      image - Image onto which this node will be painted
      backGroundPaint - will fill background of image with this. May be null.
      fillStrategy - strategy to use regarding how node will cover the image
      Returns:
      a rendering of this image and its descendants onto the specified image
      Since:
      1.3
    • print

      public void print()
      Constructs a new PrinterJob, allows the user to select which printer to print to, And then prints the node.
    • print

      public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
      Prints the node into the given Graphics context using the specified format. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. If the printable object aborts the print job then it throws a PrinterException.
      Specified by:
      print in interface Printable
      Parameters:
      graphics - the context into which the node is drawn
      pageFormat - the size and orientation of the page
      pageIndex - the zero based index of the page to be drawn
      Returns:
      Either NO_SUCH_PAGE or PAGE_EXISTS
    • getPickable

      public boolean getPickable()
      Return true if this node is pickable. Only pickable nodes can receive input events. Nodes are pickable by default.
      Returns:
      true if this node is pickable
    • setPickable

      public void setPickable(boolean isPickable)
      Set the pickable flag for this node. Only pickable nodes can receive input events. Nodes are pickable by default.
      Parameters:
      isPickable - true if this node is pickable
    • getChildrenPickable

      public boolean getChildrenPickable()
      Return true if the children of this node should be picked. If this flag is false then this node will not try to pick its children. Children are pickable by default.
      Returns:
      true if this node tries to pick its children
    • setChildrenPickable

      public void setChildrenPickable(boolean areChildrenPickable)
      Set the children pickable flag. If this flag is false then this node will not try to pick its children. Children are pickable by default.
      Parameters:
      areChildrenPickable - true if this node tries to pick its children
    • pick

      protected boolean pick(PPickPath pickPath)
      Try to pick this node before its children have had a chance to be picked. Nodes that paint on top of their children may want to override this method to if the pick path intersects that paint.
      Parameters:
      pickPath - the pick path used for the pick operation
      Returns:
      true if this node was picked
    • fullPick

      public boolean fullPick(PPickPath pickPath)
      Try to pick this node and all of its descendants. Most subclasses should not need to override this method. Instead they should override pick or pickAfterChildren.
      Parameters:
      pickPath - the pick path to add the node to if its picked
      Returns:
      true if this node or one of its descendants was picked.
    • findIntersectingNodes

      public void findIntersectingNodes(Rectangle2D fullBounds, ArrayList results)
      Finds all descendants of this node that intersect with the given bounds and adds them to the results array.
      Parameters:
      fullBounds - bounds to compare against
      results - array into which to add matches
    • pickAfterChildren

      protected boolean pickAfterChildren(PPickPath pickPath)
      Try to pick this node after its children have had a chance to be picked. Most subclasses the define a different geometry will need to override this method.
      Parameters:
      pickPath - the pick path used for the pick operation
      Returns:
      true if this node was picked
    • addChild

      public void addChild(PNode child)
      Add a node to be a new child of this node. The new node is added to the end of the list of this node's children. If child was previously a child of another node, it is removed from that first.
      Parameters:
      child - the new child to add to this node
    • addChild

      public void addChild(int index, PNode child)
      Add a node to be a new child of this node at the specified index. If child was previously a child of another node, it is removed from that node first.
      Parameters:
      index - where in the children list to insert the child
      child - the new child to add to this node
    • addChildren

      public void addChildren(Collection nodes)
      Add a collection of nodes to be children of this node. If these nodes already have parents they will first be removed from those parents.
      Parameters:
      nodes - a collection of nodes to be added to this node
    • isAncestorOf

      public boolean isAncestorOf(PNode node)
      Return true if this node is an ancestor of the parameter node.
      Parameters:
      node - a possible descendant node
      Returns:
      true if this node is an ancestor of the given node
    • isDescendentOf

      public boolean isDescendentOf(PNode node)
      Return true if this node is a descendant of the parameter node.
      Parameters:
      node - a possible ancestor node
      Returns:
      true if this nodes descends from the given node
    • isDescendentOfRoot

      public boolean isDescendentOfRoot()
      Return true if this node descends from the root.
      Returns:
      whether this node descends from root node
    • moveToBack

      public void moveToBack()
      Change the order of this node in its parent's children list so that it will draw in back of all of its other sibling nodes.
    • moveInBackOf

      public void moveInBackOf(PNode sibling)
      Change the order of this node in its parent's children list so that it will draw in back of the specified sibling node.
      Parameters:
      sibling - sibling to move in back of
    • moveToFront

      public void moveToFront()
      Change the order of this node in its parent's children list so that it will draw in front of all of its other sibling nodes.
    • moveInFrontOf

      public void moveInFrontOf(PNode sibling)
      Change the order of this node in its parent's children list so that it will draw in front of the specified sibling node.
      Parameters:
      sibling - sibling to move in front of
    • getParent

      public PNode getParent()
      Return the parent of this node. This will be null if this node has not been added to a parent yet.
      Returns:
      this nodes parent or null
    • setParent

      public void setParent(PNode newParent)
      Set the parent of this node. Note this is set automatically when adding and removing children.
      Parameters:
      newParent - the parent to which this node should be added
    • indexOfChild

      public int indexOfChild(PNode child)
      Return the index where the given child is stored.
      Parameters:
      child - child so search for
      Returns:
      index of child or -1 if not found
    • removeChild

      public PNode removeChild(PNode child)
      Remove the given child from this node's children list. Any subsequent children are shifted to the left (one is subtracted from their indices). The removed child's parent is set to null.
      Parameters:
      child - the child to remove
      Returns:
      the removed child
    • removeChild

      public PNode removeChild(int index)
      Remove the child at the specified position of this group node's children. Any subsequent children are shifted to the left (one is subtracted from their indices). The removed child's parent is set to null.
      Parameters:
      index - the index of the child to remove
      Returns:
      the removed child
    • removeChildren

      public void removeChildren(Collection childrenNodes)
      Remove all the children in the given collection from this node's list of children. All removed nodes will have their parent set to null.
      Parameters:
      childrenNodes - the collection of children to remove
    • removeAllChildren

      public void removeAllChildren()
      Remove all the children from this node. Node this method is more efficient then removing each child individually.
    • removeFromParent

      public void removeFromParent()
      Delete this node by removing it from its parent's list of children.
    • reparent

      public void reparent(PNode newParent)
      Set the parent of this node, and transform the node in such a way that it doesn't move in global coordinates.
      Parameters:
      newParent - The new parent of this node.
    • replaceWith

      public void replaceWith(PNode replacementNode)
      Swaps this node out of the scene graph tree, and replaces it with the specified replacement node. This node is left dangling, and it is up to the caller to manage it. The replacement node will be added to this node's parent in the same position as this was. That is, if this was the 3rd child of its parent, then after calling replaceWith(), the replacement node will also be the 3rd child of its parent. If this node has no parent when replace is called, then nothing will be done at all.
      Parameters:
      replacementNode - the new node that replaces the current node in the scene graph tree.
    • setName

      public void setName(String name)
      Sets the name of this null, may be null.
      Parameters:
      name - new name for this node
      Since:
      1.3
    • getName

      public String getName()
      Returns the name given to this node.
      Returns:
      name given to this node, may be null
      Since:
      1.3
    • getChildrenCount

      public int getChildrenCount()
      Return the number of children that this node has.
      Returns:
      the number of children
    • getChild

      public PNode getChild(int index)
      Return the child node at the specified index.
      Parameters:
      index - a child index
      Returns:
      the child node at the specified index
    • getChildrenReference

      public List getChildrenReference()
      Return a reference to the list used to manage this node's children. This list should not be modified.
      Returns:
      reference to the children list
    • getChildrenIterator

      public ListIterator getChildrenIterator()
      Return an iterator over this node's direct descendant children.
      Returns:
      iterator over this nodes children
    • getRoot

      public PRoot getRoot()
      Return the root node (instance of PRoot). If this node does not descend from a PRoot then null will be returned.
      Returns:
      root element of this node, or null if this node does not descend from a PRoot
    • getAllNodes

      public Collection getAllNodes()
      Return a collection containing this node and all of its descendant nodes.
      Returns:
      a new collection containing this node and all descendants
    • getAllNodes

      public Collection getAllNodes(PNodeFilter filter, Collection resultantNodes)
      Return a collection containing the subset of this node and all of its descendant nodes that are accepted by the given node filter. If the filter is null then all nodes will be accepted. If the results parameter is not null then it will be used to collect this subset instead of creating a new collection.
      Parameters:
      filter - the filter used to determine the subset
      resultantNodes - where matching nodes should be added
      Returns:
      a collection containing this node and all descendants
    • paramString

      protected String paramString()
      Deprecated.
      see http://code.google.com/p/piccolo2d/issues/detail?id=99
      Returns:
      a string representation of this node's state
    • getInputEventListeners

      public PInputEventListener[] getInputEventListeners()
      Returns an array of input event listeners that are attached to this node.
      Returns:
      event listeners attached to this node
      Since:
      1.3