edu.umd.cs.piccolo
Class PNode

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
All Implemented Interfaces:
java.awt.print.Printable, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
P3DRect, PCamera, PComposite, PImage, PLayer, PLens, PLine, PNodeCache, PPath, PRoot, PStickyHandleManager, PStyledText, PSWTImage, PSWTPath, PSWTStickyHandleManager, PSWTText, PText

public class PNode
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, java.awt.print.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:
Serialized Form

Nested Class Summary
static interface PNode.PSceneGraphDelegate
          PSceneGraphDelegate is an interface to recive low level node events.
 
Field Summary
static java.lang.String PROPERTY_BOUNDS
          The property name that identifies a change of this node's bounds (see getBounds, getBoundsReference).
static java.lang.String PROPERTY_CHILDREN
          The property name that identifies a change in the set of this node's direct children (see getChildrenReference, getChildrenIterator).
static java.lang.String PROPERTY_CHILDREN_PICKABLE
          The property name that identifies a change of this node's children pickable status (see getChildrenPickable).
static java.lang.String PROPERTY_CLIENT_PROPERTIES
          The property name that identifies a change in this node's client propertie (see getClientProperty).
static int PROPERTY_CODE_BOUNDS
           
static int PROPERTY_CODE_CHILDREN
           
static int PROPERTY_CODE_CHILDREN_PICKABLE
           
static int PROPERTY_CODE_CLIENT_PROPERTIES
           
static int PROPERTY_CODE_FULL_BOUNDS
           
static int PROPERTY_CODE_PAINT
           
static int PROPERTY_CODE_PARENT
           
static int PROPERTY_CODE_PICKABLE
           
static int PROPERTY_CODE_TRANSFORM
           
static int PROPERTY_CODE_TRANSPARENCY
           
static int PROPERTY_CODE_VISIBLE
           
static java.lang.String PROPERTY_FULL_BOUNDS
          The property name that identifies a change of this node's full bounds (see getFullBounds, getFullBoundsReference).
static java.lang.String PROPERTY_PAINT
          The property name that identifies a change of this node's paint (see getPaint).
static java.lang.String PROPERTY_PARENT
          The property name that identifies a change of this node's parent (see getParent).
static java.lang.String PROPERTY_PICKABLE
          The property name that identifies a change of this node's pickable status (see getPickable).
static java.lang.String PROPERTY_TRANSFORM
          The property name that identifies a change of this node's transform (see getTransform, getTransformReference).
static java.lang.String PROPERTY_TRANSPARENCY
          The property name that identifies a change of this node's transparency (see getTransparency).
static java.lang.String PROPERTY_VISIBLE
          The property name that identifies a change of this node's visibility (see getVisible).
static PNode.PSceneGraphDelegate SCENE_GRAPH_DELEGATE
          The single scene graph delegate that recives low level node events.
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PNode()
          Constructs a new PNode.
 
Method Summary
 boolean addActivity(PActivity activity)
          Schedule the given activity with the root, note that only scheduled activities will be stepped.
 void addAttribute(java.lang.Object key, java.lang.Object value)
          Add an arbitrary key/value to this node.
 void addChild(int index, PNode child)
          Add a node to be a new child of this node at the specified index.
 void addChild(PNode child)
          Add a node to be a new child of this node.
 void addChildren(java.util.Collection nodes)
          Add a collection of nodes to be children of this node.
 void addClientProperty(java.lang.Object key, java.lang.Object value)
          Deprecated. use addAttribute(Object key, Object value)instead.
 void addInputEventListener(PInputEventListener listener)
          Adds the specified input event listener to receive input events from this node.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 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.
 PInterpolatingActivity animateToColor(java.awt.Color destColor, long duration)
          Animate this node's color from its current value to the new value specified.
 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.
 PTransformActivity animateToTransform(java.awt.geom.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.
 PInterpolatingActivity animateToTransparency(float zeroToOne, long duration)
          Animate this node's transparency from its current value to the new value specified.
 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.
 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 coords of this node.
 void centerFullBoundsOnPoint(double parentX, double parentY)
          Center the ffull bounds of this node so that they are centered on the given point specified on the local coords of this nodes parent.
 java.lang.Object clone()
          The copy method copies this node and all of its descendents.
 PBounds computeFullBounds(PBounds dstBounds)
          Compute and return the full bounds of this node.
 void endResizeBounds()
          Notify this node that you have finished a resize bounds sequence.
 void findIntersectingNodes(java.awt.geom.Rectangle2D fullBounds, java.util.ArrayList results)
           
protected  void fireChildPropertyChange(java.beans.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.
protected  void firePropertyChange(int propertyCode, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Report a bound property update to any registered listeners.
 boolean fullIntersects(java.awt.geom.Rectangle2D parentBounds)
          Return true if the full bounds of this node intersects with the specified bounds.
 void fullPaint(PPaintContext paintContext)
          Paint this node and all of its descendents.
 boolean fullPick(PPickPath pickPath)
          Try to pick this node and all of its descendents.
 java.util.Collection getAllNodes()
          Return a collection containing this node and all of its descendent nodes.
 java.util.Collection getAllNodes(PNodeFilter filter, java.util.Collection results)
          Return a collection containing the subset of this node and all of its descendent nodes that are accepted by the given node filter.
 java.lang.Object getAttribute(java.lang.Object key)
          Returns the value of the client attribute with the specified key.
 java.lang.Object getAttribute(java.lang.Object key, java.lang.Object def)
           
 boolean getBooleanAttribute(java.lang.Object key, boolean def)
           
 PBounds getBounds()
          Return a copy of this node's bounds.
protected  boolean getBoundsChanged()
          Return true if this node's bounds have recently changed.
 PBounds getBoundsReference()
          Return a direct reference to this node's bounds.
protected  boolean getBoundsVolatile()
          Return true if this nodes bounds may change at any time.
 PNode getChild(int index)
          Return the child node at the specified index.
protected  boolean getChildBoundsInvalid()
          Return true if one of this node's descendents has invalid bounds.
protected  boolean getChildBoundsVolatile()
          Return true if this node has a child with volatile bounds.
 boolean getChildPaintInvalid()
          Return true if this node has a child with invalid paint.
 int getChildrenCount()
          Return the number of children that this node has.
 java.util.ListIterator getChildrenIterator()
          Return an iterator over this node's direct descendent children.
 boolean getChildrenPickable()
          Return true if the children of this node should be picked.
 java.util.List getChildrenReference()
          Return a reference to the list used to manage this node's children.
 javax.swing.text.MutableAttributeSet getClientProperties()
          Return mutable attributed set of client properites associated with this node.
 java.lang.Object getClientProperty(java.lang.Object key)
          Deprecated. use getAttribute(Object key)instead.
 java.util.Enumeration getClientPropertyKeysEnumeration()
          Returns an enumeration of all keys maped to attribute values values.
 java.util.Iterator getClientPropertyKeysIterator()
          Deprecated. use getClientPropertyKeysEnumerator() instead.
 double getDoubleAttribute(java.lang.Object key, double def)
           
 PBounds getFullBounds()
          Return a copy of this node's full bounds.
protected  boolean getFullBoundsInvalid()
          Return true if the full bounds of this node are invalid.
 PBounds getFullBoundsReference()
          Return a reference to this node's full bounds cache.
 PBounds getGlobalBounds()
          Return a copy of the bounds of this node in the global coordinate system.
 PBounds getGlobalFullBounds()
          Return a copy of the full bounds of this node in the global coordinate system.
 double getGlobalRotation()
          Return the total amount of rotation applied to this node by its own transform together with the transforms of all its ancestors.
 double getGlobalScale()
          Return the global scale that is being applied to this node by its transform together with the transforms of all its ancestors.
 PAffineTransform getGlobalToLocalTransform(PAffineTransform dest)
          Return the transform that converts global coordinates to local coordinates of this node.
 java.awt.geom.Point2D getGlobalTranslation()
          Return the global translation that is being applied to this node by its transform together with the transforms of all its ancestors.
 double getHeight()
          Return the height (in local coords) of this node's bounds.
 int getIntegerAttribute(java.lang.Object key, int def)
           
 PAffineTransform getInverseTransform()
          Return an inverted copy of the transform associated with this node.
 javax.swing.event.EventListenerList getListenerList()
          Return the list of event listeners associated with this node.
 PAffineTransform getLocalToGlobalTransform(PAffineTransform dest)
          Return the transform that converts local coordinates at this node to the global coordinate system.
 boolean getOccluded()
           
 java.awt.geom.Point2D getOffset()
          Return the offset that is being applied to this node by its transform.
 java.awt.Paint getPaint()
          Return the paint used to paint this node.
 boolean getPaintInvalid()
          Return true if this nodes paint is invalid, in which case the node needs to be repainted.
 PNode getParent()
          Return the parent of this node.
 boolean getPickable()
          Return true if this node is pickable.
 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.
 PRoot getRoot()
          Return the root node (instance of PRoot).
 double getRotation()
          Returns the rotation applied by this node's transform in radians.
 double getScale()
          Return the scale applied by this node's transform.
 PAffineTransform getTransform()
          Return a copy of the transform associated with this node.
 PAffineTransform getTransformReference(boolean createNewTransformIfNull)
          Return a reference to the transform associated with this node.
 float getTransparency()
          Return the transparency used when painting this node.
 PBounds getUnionOfChildrenBounds(PBounds dstBounds)
          Compute and return the union of the full bounds of all the children of this node.
 boolean getVisible()
          Return true if this node is visible, that is if it will paint itself and descendents.
 double getWidth()
          Return the width (in local coords) of this node's bounds.
 double getX()
          Return the x position (in local coords) of this node's bounds.
 double getXOffset()
           
 double getY()
          Return the y position (in local coords) of this node's bounds.
 double getYOffset()
           
 java.awt.geom.Dimension2D globalToLocal(java.awt.geom.Dimension2D globalDimension)
          Transform the given dimension from global coordinates to this node's local coordinate system.
 java.awt.geom.Point2D globalToLocal(java.awt.geom.Point2D globalPoint)
          Transform the given point from global coordinates to this node's local coordinate system.
 java.awt.geom.Rectangle2D globalToLocal(java.awt.geom.Rectangle2D globalRectangle)
          Transform the given rectangle from global coordinates to this node's local coordinate system.
 int indexOfChild(PNode child)
          Return the index where the given child is stored.
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.
 boolean intersects(java.awt.geom.Rectangle2D localBounds)
          Return true if this node intersects the given rectangle specified in local bounds.
 void invalidateFullBounds()
          Invalidates the full bounds of this node, and sets the child bounds invalid flag on each of this node's ancestors.
 void invalidateLayout()
          Invalidate this node's layout, so that later layoutChildren will get called.
 void invalidatePaint()
          Invalidate this node's paint, and mark all of its ancestors as having a node with invalid paint.
 boolean isAncestorOf(PNode node)
          Return true if this node is an ancestor of the parameter node.
 boolean isDescendentOf(PNode node)
          Return true if this node is a descendent of the parameter node.
 boolean isDescendentOfRoot()
          Return true if this node descends from the root.
 boolean isOpaque(java.awt.geom.Rectangle2D boundary)
           
protected  void layoutChildren()
          Nodes that apply layout constraints to their children should override this method and do the layout there.
static double lerp(double t, double a, double b)
          Linearly interpolates between a and b, based on t.
 java.awt.geom.Dimension2D localToGlobal(java.awt.geom.Dimension2D localDimension)
          Transform the given dimension from this node's local coordinate system to the global coordinate system.
 java.awt.geom.Point2D localToGlobal(java.awt.geom.Point2D localPoint)
          Transform the given point from this node's local coordinate system to the global coordinate system.
 java.awt.geom.Rectangle2D localToGlobal(java.awt.geom.Rectangle2D localRectangle)
          Transform the given rectangle from this node's local coordinate system to the global coordinate system.
 java.awt.geom.Dimension2D localToParent(java.awt.geom.Dimension2D localDimension)
          Transform the given dimension from this node's local coordinate system to its parent's local coordinate system.
 java.awt.geom.Point2D localToParent(java.awt.geom.Point2D localPoint)
          Transform the given point from this node's local coordinate system to its parent's local coordinate system.
 java.awt.geom.Rectangle2D localToParent(java.awt.geom.Rectangle2D localRectangle)
          Transform the given rectangle from this node's local coordinate system to its parent's local coordinate system.
 void moveInBackOf(PNode sibling)
          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.
 void moveInFrontOf(PNode sibling)
          Change the order of this node in its parent's children list so that it will draw before the given sibling node.
 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.
 void moveToFront()
          Change the order of this node in its parent's children list so that it will draw after the given sibling node.
 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.
protected  void paint(PPaintContext paintContext)
          Paint this node behind any of its children nodes.
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.
protected  java.lang.String paramString()
          Returns a string representing the state of this node.
protected  void parentBoundsChanged()
          A notification that the bounds of this node's parent have changed.
 java.awt.geom.Dimension2D parentToLocal(java.awt.geom.Dimension2D parentDimension)
          Transform the given dimension from this node's parent's local coordinate system to the local coordinate system of this node.
 java.awt.geom.Point2D parentToLocal(java.awt.geom.Point2D parentPoint)
          Transform the given point from this node's parent's local coordinate system to the local coordinate system of this node.
 java.awt.geom.Rectangle2D parentToLocal(java.awt.geom.Rectangle2D parentRectangle)
          Transform the given rectangle from this node's parent's local coordinate system to the local coordinate system of this node.
protected  boolean pick(PPickPath pickPath)
          Try to pick this node before its children have had a chance to be picked.
protected  boolean pickAfterChildren(PPickPath pickPath)
          Try to pick this node after its children have had a chance to be picked.
 void position(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D destPt, java.awt.geom.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.
 void print()
          Constructs a new PrinterJob, allows the user to select which printer to print to, And then prints the node.
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
          Prints the node into the given Graphics context using the specified format.
 void removeAllChildren()
          Remove all the children from this node.
 PNode removeChild(int index)
          Remove the child at the specified position of this group node's children.
 PNode removeChild(PNode child)
          Remove the given child from this node's children list.
 void removeChildren(java.util.Collection childrenNodes)
          Remove all the children in the given collection from this node's list of children.
 void removeFromParent()
          Delete this node by removing it from its parent's list of children.
 void removeInputEventListener(PInputEventListener listener)
          Removes the specified input event listener so that it no longer receives input events from this node.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void repaint()
          Mark the area on the screen represented by this nodes full bounds as needing a repaint.
 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.
 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.
 void replaceWith(PNode replacementNode)
          Swaps this node out of the scene graph tree, and replaces it with the specified replacement node.
 void resetBounds()
          Set the empty bit of this bounds to true.
 void rotate(double theta)
          Rotates this node by theta (in radians) about the 0,0 point.
 void rotateAboutPoint(double theta, double x, double y)
          Rotates this node by theta (in radians) about the given point.
 void rotateAboutPoint(double theta, java.awt.geom.Point2D point)
          Rotates this node by theta (in radians) about the given point.
 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.
 void scale(double scale)
          Scale this nodes transform by the given amount.
 void scaleAboutPoint(double scale, double x, double y)
          Scale this nodes transform by the given amount about the specified point.
 void scaleAboutPoint(double scale, java.awt.geom.Point2D point)
          Scale this nodes transform by the given amount about the specified point.
 boolean setBounds(double x, double y, double width, double height)
          Set the bounds of this node to the given value.
 boolean setBounds(java.awt.geom.Rectangle2D newBounds)
          Set the bounds of this node to the given value.
protected  void setBoundsChanged(boolean boundsChanged)
          Set the bounds chnaged flag.
protected  void setChildBoundsInvalid(boolean childBoundsInvalid)
          Set the flag indicating that one of this node's descendents has invalid bounds.
protected  void setChildBoundsVolatile(boolean childBoundsVolatile)
          Set if this node has a child with volatile bounds.
 void setChildPaintInvalid(boolean childPaintInvalid)
          Mark this node as having a child with invalid paint.
 void setChildrenPickable(boolean areChildrenPickable)
          Set the children pickable flag.
protected  void setFullBoundsInvalid(boolean fullBoundsInvalid)
          Set the full bounds invalid flag.
 void setGlobalRotation(double theta)
          Set the global rotation (in radians) of this node.
 void setGlobalScale(double scale)
          Set the global scale of this node.
 void setGlobalTranslation(java.awt.geom.Point2D globalPoint)
          Set the global translation of this node.
 boolean setHeight(double height)
           
 void setOccluded(boolean isOccluded)
           
 void setOffset(double x, double y)
          Set the offset that is being applied to this node by its transform.
 void setOffset(java.awt.geom.Point2D point)
          Set the offset that is being applied to this node by its transform.
 void setPaint(java.awt.Paint newPaint)
          Set the paint used to paint this node.
 void setPaintInvalid(boolean paintInvalid)
          Mark this node as having invalid paint.
 void setParent(PNode newParent)
          Set the parent of this node.
 void setPickable(boolean isPickable)
          Set the pickable flag for this node.
 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.
 void setRotation(double theta)
          Sets the rotation of this nodes transform in radians.
 void setScale(double scale)
          Set the scale of this node's transform.
 void setTransform(java.awt.geom.AffineTransform newTransform)
          Set the transform applied to this node.
 void setTransparency(float zeroToOne)
          Set the transparency used to paint this node.
 void setVisible(boolean isVisible)
          Set the visibility of this node and its descendents.
 boolean setWidth(double width)
           
 boolean setX(double x)
           
 boolean setY(double y)
           
 void signalBoundsChanged()
          This method should be called when the bounds of this node are changed.
 void startResizeBounds()
          Notify this node that you will beging to repeadily call setBounds.
 java.awt.Image toImage()
          Return a new Image representing this node and all of its children.
 java.awt.Image toImage(java.awt.image.BufferedImage image, java.awt.Paint backGroundPaint)
          Paint a representation of this node into the specified buffered image.
 java.awt.Image toImage(int width, int height, java.awt.Paint backGroundPaint)
          Return a new Image of the requested size representing this node and all of its children.
 java.lang.String toString()
          Returns a string representation of this object for debugging purposes.
 void transformBy(java.awt.geom.AffineTransform aTransform)
          Transform this nodes transform by the given transform.
 void translate(double dx, double dy)
          Translate this node's transform by the given amount, using the standard affine transform translate method.
protected  boolean validateFullBounds()
          This method is called to validate the bounds of this node and all of its descendents.
 void validateFullPaint()
          Repaint this node and any of its descendents if they have invalid paint.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_CLIENT_PROPERTIES

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_CLIENT_PROPERTIES

public static final int PROPERTY_CODE_CLIENT_PROPERTIES
See Also:
Constant Field Values

PROPERTY_BOUNDS

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_BOUNDS

public static final int PROPERTY_CODE_BOUNDS
See Also:
Constant Field Values

PROPERTY_FULL_BOUNDS

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_FULL_BOUNDS

public static final int PROPERTY_CODE_FULL_BOUNDS
See Also:
Constant Field Values

PROPERTY_TRANSFORM

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_TRANSFORM

public static final int PROPERTY_CODE_TRANSFORM
See Also:
Constant Field Values

PROPERTY_VISIBLE

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_VISIBLE

public static final int PROPERTY_CODE_VISIBLE
See Also:
Constant Field Values

PROPERTY_PAINT

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_PAINT

public static final int PROPERTY_CODE_PAINT
See Also:
Constant Field Values

PROPERTY_TRANSPARENCY

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_TRANSPARENCY

public static final int PROPERTY_CODE_TRANSPARENCY
See Also:
Constant Field Values

PROPERTY_PICKABLE

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_PICKABLE

public static final int PROPERTY_CODE_PICKABLE
See Also:
Constant Field Values

PROPERTY_CHILDREN_PICKABLE

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_CHILDREN_PICKABLE

public static final int PROPERTY_CODE_CHILDREN_PICKABLE
See Also:
Constant Field Values

PROPERTY_CHILDREN

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_CHILDREN

public static final int PROPERTY_CODE_CHILDREN
See Also:
Constant Field Values

PROPERTY_PARENT

public static final java.lang.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:
Constant Field Values

PROPERTY_CODE_PARENT

public static final int PROPERTY_CODE_PARENT
See Also:
Constant Field Values

SCENE_GRAPH_DELEGATE

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

Constructor Detail

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 Detail

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:
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:
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:
duration - amount of time that the animation should take
theta - final theta value (in radians) for the animation
Returns:
the newly scheduled activity

animateToTransform

public PTransformActivity animateToTransform(java.awt.geom.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(java.awt.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 javax.swing.text.MutableAttributeSet getClientProperties()
Return mutable attributed set of client properites associated with this node.


getAttribute

public java.lang.Object getAttribute(java.lang.Object key)
Returns the value of the client attribute with the specified key. Only attributes added with addAttribute will return a non-null value.

Returns:
the value of this attribute or null

addAttribute

public void addAttribute(java.lang.Object key,
                         java.lang.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.