|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.PNode
public class PNode
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.
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 |
---|
public static final java.lang.String PROPERTY_CLIENT_PROPERTIES
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.
public static final int PROPERTY_CODE_CLIENT_PROPERTIES
public static final java.lang.String PROPERTY_BOUNDS
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.
public static final int PROPERTY_CODE_BOUNDS
public static final java.lang.String PROPERTY_FULL_BOUNDS
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.
public static final int PROPERTY_CODE_FULL_BOUNDS
public static final java.lang.String PROPERTY_TRANSFORM
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.
public static final int PROPERTY_CODE_TRANSFORM
public static final java.lang.String PROPERTY_VISIBLE
getVisible
). Both old value and new value will be
null in any property change event.
public static final int PROPERTY_CODE_VISIBLE
public static final java.lang.String PROPERTY_PAINT
getPaint
). Both old value and new value will be set
correctly in any property change event.
public static final int PROPERTY_CODE_PAINT
public static final java.lang.String PROPERTY_TRANSPARENCY
getTransparency
). Both old value and new
value will be null in any property change event.
public static final int PROPERTY_CODE_TRANSPARENCY
public static final java.lang.String PROPERTY_PICKABLE
getPickable
). Both old value and new value will
be null in any property change event.
public static final int PROPERTY_CODE_PICKABLE
public static final java.lang.String PROPERTY_CHILDREN_PICKABLE
getChildrenPickable
).
Both old value and new value will be null in any property change event.
public static final int PROPERTY_CODE_CHILDREN_PICKABLE
public static final java.lang.String PROPERTY_CHILDREN
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.
public static final int PROPERTY_CODE_CHILDREN
public static final java.lang.String PROPERTY_PARENT
getParent
).
Both old value and new value will be set correctly in any property change event.
public static final int PROPERTY_CODE_PARENT
public static PNode.PSceneGraphDelegate SCENE_GRAPH_DELEGATE
Constructor Detail |
---|
public 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 |
---|
public PInterpolatingActivity animateToBounds(double x, double y, double width, double height, long duration)
duration
- amount of time that the animation should take
public PTransformActivity animateTransformToBounds(double x, double y, double width, double height, long duration)
duration
- amount of time that the animation should take
public PTransformActivity animateToPositionScaleRotation(double x, double y, double scale, double theta, long duration)
duration
- amount of time that the animation should taketheta
- final theta value (in radians) for the animation
public PTransformActivity animateToTransform(java.awt.geom.AffineTransform destTransform, long duration)
destTransform
- the final transform valueduration
- amount of time that the animation should take
public PInterpolatingActivity animateToColor(java.awt.Color destColor, long duration)
destColor
- final color value.duration
- amount of time that the animation should take
public PInterpolatingActivity animateToTransparency(float zeroToOne, long duration)
zeroToOne
- final transparency value.duration
- amount of time that the animation should take
public boolean addActivity(PActivity activity)
activity
- new activity to schedule
public javax.swing.text.MutableAttributeSet getClientProperties()
public java.lang.Object getAttribute(java.lang.Object key)
addAttribute
will return
a non-null value.
public void addAttribute(java.lang.Object key, java.lang.Object value)
The
If value is null this method will remove the attribute.
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.
public java.util.Enumeration getClientPropertyKeysEnumeration()
public java.lang.Object getAttribute(java.lang.Object key, java.lang.Object def)
public boolean getBooleanAttribute(java.lang.Object key, boolean def)
public int getIntegerAttribute(java.lang.Object key, int def)
public double getDoubleAttribute(java.lang.Object key, double def)
public java.lang.Object getClientProperty(java.lang.Object key)
public void addClientProperty(java.lang.Object key, java.lang.Object value)
public java.util.Iterator getClientPropertyKeysIterator()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.awt.geom.Point2D localToParent(java.awt.geom.Point2D localPoint)
localPoint
- point in local coordinate system to be transformed.
public java.awt.geom.Dimension2D localToParent(java.awt.geom.Dimension2D localDimension)
localDimension
- dimension in local coordinate system to be transformed.
public java.awt.geom.Rectangle2D localToParent(java.awt.geom.Rectangle2D localRectangle)
localRectangle
- rectangle in local coordinate system to be transformed.
public java.awt.geom.Point2D parentToLocal(java.awt.geom.Point2D parentPoint)
parentPoint
- point in parent's coordinate system to be transformed.
public java.awt.geom.Dimension2D parentToLocal(java.awt.geom.Dimension2D parentDimension)
parentDimension
- dimension in parent's coordinate system to be transformed.
public java.awt.geom.Rectangle2D parentToLocal(java.awt.geom.Rectangle2D parentRectangle)
parentRectangle
- rectangle in parent's coordinate system to be transformed.
public java.awt.geom.Point2D localToGlobal(java.awt.geom.Point2D localPoint)
localPoint
- point in local coordinate system to be transformed.
public java.awt.geom.Dimension2D localToGlobal(java.awt.geom.Dimension2D localDimension)
localDimension
- dimension in local coordinate system to be transformed.
public java.awt.geom.Rectangle2D localToGlobal(java.awt.geom.Rectangle2D localRectangle)
localRectangle
- rectangle in local coordinate system to be transformed.
public java.awt.geom.Point2D globalToLocal(java.awt.geom.Point2D globalPoint)
globalPoint
- point in global coordinates to be transformed.
public java.awt.geom.Dimension2D globalToLocal(java.awt.geom.Dimension2D globalDimension)
globalDimension
- dimension in global coordinates to be transformed.
public java.awt.geom.Rectangle2D globalToLocal(java.awt.geom.Rectangle2D globalRectangle)
globalRectangle
- rectangle in global coordinates to be transformed.
public PAffineTransform getLocalToGlobalTransform(PAffineTransform dest)
public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest)
public javax.swing.event.EventListenerList getListenerList()
public void addInputEventListener(PInputEventListener listener)
listener
- the new input listenerpublic void removeInputEventListener(PInputEventListener listener)
listener
- the input listener to removepublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be addedpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- The name of the property that was listened on.listener
- The PropertyChangeListener to be removedpublic int getPropertyChangeParentMask()
public void setPropertyChangeParentMask(int propertyChangeParentMask)
protected void firePropertyChange(int propertyCode, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyCode
- The code of the property changed.propertyName
- The programmatic name of the property that was changed.oldValue
- The old value of the property.newValue
- The new value of the property.protected void fireChildPropertyChange(java.beans.PropertyChangeEvent event, int propertyCode)
event
- The property change event containing source node and changed values.propertyCode
- The code of the property changed.public PBounds getBounds()
public PBounds getBoundsReference()
public void startResizeBounds()
setBounds
.
When you are done call endResizeBounds
to let the node know that
you are done.
public void endResizeBounds()
public boolean setX(double x)
public boolean setY(double y)
public boolean setWidth(double width)
public boolean setHeight(double height)
public boolean setBounds(java.awt.geom.Rectangle2D newBounds)
public boolean setBounds(double x, double y, double width, double height)
protected void internalUpdateBounds(double x, double y, double width, double height)
public void resetBounds()
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public PBounds getGlobalBounds()
public boolean centerBoundsOnPoint(double localX, double localY)
public void centerFullBoundsOnPoint(double parentX, double parentY)
public boolean intersects(java.awt.geom.Rectangle2D localBounds)
fullIntersects
is used
for quick rejects before calling this method.
localBounds
- the bounds to test for intersection against
public PBounds getFullBounds()
public PBounds getFullBoundsReference()
public PBounds computeFullBounds(PBounds dstBounds)
dstBounds
- if not null the new bounds will be stored here
public PBounds getUnionOfChildrenBounds(PBounds dstBounds)
dstBounds
- if not null the new bounds will be stored herepublic PBounds getGlobalFullBounds()
public boolean fullIntersects(java.awt.geom.Rectangle2D parentBounds)
parentBounds
- the bounds to test for intersection against (specified in parent's coordinate system)
protected boolean getBoundsVolatile()
protected boolean getChildBoundsVolatile()
protected void setChildBoundsVolatile(boolean childBoundsVolatile)
childBoundsVolatile
- true if this node has a descendent with volatile boundsprotected boolean getBoundsChanged()
protected void setBoundsChanged(boolean boundsChanged)
boundsChanged
- true if this nodes bounds have changed.protected boolean getFullBoundsInvalid()
protected void setFullBoundsInvalid(boolean fullBoundsInvalid)
protected boolean getChildBoundsInvalid()
protected void setChildBoundsInvalid(boolean childBoundsInvalid)
public void signalBoundsChanged()
public void invalidateLayout()
protected void parentBoundsChanged()
public void invalidateFullBounds()
protected boolean validateFullBounds()
protected void layoutChildren()
public double getRotation()
public void setRotation(double theta)
theta
- rotation in radianspublic void rotate(double theta)
theta
- the amount to rotate by in radianspublic void rotateInPlace(double theta)
theta
- the amount to rotate by in radianspublic void rotateAboutPoint(double theta, java.awt.geom.Point2D point)
theta
- the amount to rotate by in radianspublic void rotateAboutPoint(double theta, double x, double y)
theta
- the amount to rotate by in radianspublic double getGlobalRotation()
public void setGlobalRotation(double theta)
theta
- the amount to rotate by in radians relative to the global coord system.public double getScale()
public void setScale(double scale)
scale
- the scale to set the transform topublic void scale(double scale)
scale
- the amount to scale bypublic void scaleAboutPoint(double scale, java.awt.geom.Point2D point)
scale
- the amount to scale bypoint
- the point to scale aboutpublic void scaleAboutPoint(double scale, double x, double y)
scale
- the amount to scale bypublic double getGlobalScale()
public void setGlobalScale(double scale)
scale
- the desired global scalepublic double getXOffset()
public double getYOffset()
public java.awt.geom.Point2D getOffset()
public void setOffset(java.awt.geom.Point2D point)
point
- a point representing the x and y offsetpublic void setOffset(double x, double y)
x
- amount of x offsety
- amount of y offsetpublic void offset(double dx, double dy)
public void translate(double dx, double dy)
public java.awt.geom.Point2D getGlobalTranslation()
public void setGlobalTranslation(java.awt.geom.Point2D globalPoint)
globalPoint
- the desired global translationpublic void transformBy(java.awt.geom.AffineTransform aTransform)
aTransform
- the transform to apply.public static double lerp(double t, double a, double b)
a
- from pointb
- to Pointt
- variable 'time' parameterpublic void position(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D destPt, java.awt.geom.Rectangle2D destBounds, int millis)
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.
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 nodemillis
- Number of milliseconds over which to perform the animationpublic PAffineTransform getTransform()
public PAffineTransform getTransformReference(boolean createNewTransformIfNull)
public PAffineTransform getInverseTransform()
public void setTransform(java.awt.geom.AffineTransform newTransform)
newTransform
- the new transform valuepublic boolean getPaintInvalid()
public void setPaintInvalid(boolean paintInvalid)
paintInvalid
- true if this node should be repaintedpublic boolean getChildPaintInvalid()
public void setChildPaintInvalid(boolean childPaintInvalid)
childPaintInvalid
- true if this node has a child with invalid paintpublic void invalidatePaint()
public void validateFullPaint()
public void repaint()
public void repaintFrom(PBounds localBounds, PNode childOrThis)
localBounds
- the bounds to repaintchildOrThis
- if childOrThis does not equal this then this nodes transform will be applied to the localBounds parampublic boolean isOpaque(java.awt.geom.Rectangle2D boundary)
public boolean getOccluded()
public void setOccluded(boolean isOccluded)
public boolean getVisible()
public void setVisible(boolean isVisible)
isVisible
- true if this node and its descendents are visiblepublic java.awt.Paint getPaint()
public void setPaint(java.awt.Paint newPaint)
public float getTransparency()
public void setTransparency(float zeroToOne)
protected void paint(PPaintContext paintContext)
paintContext
- the paint context to use for painting the nodepublic void fullPaint(PPaintContext paintContext)
paint
or
paintAfterChildren
instead.
paintContext
- the paint context to use for painting this node and its childrenprotected void paintAfterChildren(PPaintContext paintContext)
paintContext
- the paint context to sue for painting after the children are paintedpublic java.awt.Image toImage()
public java.awt.Image toImage(int width, int height, java.awt.Paint backGroundPaint)
width
- pixel width of the resulting imageheight
- pixel height of the resulting image
public java.awt.Image toImage(java.awt.image.BufferedImage image, java.awt.Paint backGroundPaint)
public void print()
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
print
in interface java.awt.print.Printable
graphics
- the context into which the node is drawnpageFormat
- the size and orientation of the pagepageIndex
- the zero based index of the page to be drawnpublic boolean getPickable()
public void setPickable(boolean isPickable)
isPickable
- true if this node is pickablepublic boolean getChildrenPickable()
public void setChildrenPickable(boolean areChildrenPickable)
areChildrenPickable
- true if this node tries to pick its childrenprotected boolean pick(PPickPath pickPath)
pickPath
- the pick path used for the pick operation
public boolean fullPick(PPickPath pickPath)
pick
or
pickAfterChildren
.
pickPath
- the pick path to add the node to if its picked
public void findIntersectingNodes(java.awt.geom.Rectangle2D fullBounds, java.util.ArrayList results)
protected boolean pickAfterChildren(PPickPath pickPath)
pickPath
- the pick path used for the pick operation
public void addChild(PNode child)
child
- the new child to add to this nodepublic void addChild(int index, PNode child)
child
- the new child to add to this nodepublic void addChildren(java.util.Collection nodes)
nodes
- a collection of nodes to be added to this nodepublic boolean isAncestorOf(PNode node)
node
- a possible descendent node
public boolean isDescendentOf(PNode node)
node
- a possible ancestor node
public boolean isDescendentOfRoot()
public void moveToBack()
public void moveInBackOf(PNode sibling)
public void moveToFront()
public void moveInFrontOf(PNode sibling)
public PNode getParent()
public void setParent(PNode newParent)
public int indexOfChild(PNode child)
public PNode removeChild(PNode child)
child
- the child to remove
public PNode removeChild(int index)
index
- the index of the child to remove
public void removeChildren(java.util.Collection childrenNodes)
childrenNodes
- the collection of children to removepublic void removeAllChildren()
public void removeFromParent()
public void reparent(PNode newParent)
newParent
- The new parent of this node.public void replaceWith(PNode replacementNode)
replacementNode
- the new node that replaces the current node in the scene graph tree.public int getChildrenCount()
public PNode getChild(int index)
index
- a child index
public java.util.List getChildrenReference()
public java.util.ListIterator getChildrenIterator()
public PRoot getRoot()
public java.util.Collection getAllNodes()
public java.util.Collection getAllNodes(PNodeFilter filter, java.util.Collection results)
filter
- the filter used to determine the subset
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String paramString()
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |