|
||||||||||
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 receive low level node events. |
Field Summary | |
---|---|
static int |
FILL_STRATEGY_ASPECT_COVER
toImage fill strategy that stretches the node be large enough to cover the image, and centers it. |
static int |
FILL_STRATEGY_ASPECT_FIT
toImage fill strategy that stretches the node be as large as possible while still retaining its aspect ratio. |
static int |
FILL_STRATEGY_EXACT_FIT
toImage fill strategy that stretches the node to be exactly the dimensions of the image. |
static String |
PROPERTY_BOUNDS
The property name that identifies a change of this node's bounds (see getBounds , getBoundsReference ). |
static String |
PROPERTY_CHILDREN
The property name that identifies a change in the set of this node's direct children (see getChildrenReference ,
getChildrenIterator ). |
static String |
PROPERTY_CHILDREN_PICKABLE
The property name that identifies a change of this node's children pickable status (see getChildrenPickable ). |
static String |
PROPERTY_CLIENT_PROPERTIES
The property name that identifies a change in this node's client propertie (see getClientProperty ). |
static int |
PROPERTY_CODE_BOUNDS
The property code that identifies a change of this node's bounds (see getBounds , getBoundsReference ). |
static int |
PROPERTY_CODE_CHILDREN
The property code that identifies a change in the set of this node's direct children (see getChildrenReference ,
getChildrenIterator ). |
static int |
PROPERTY_CODE_CHILDREN_PICKABLE
The property code that identifies a change of this node's children pickable status (see getChildrenPickable ). |
static int |
PROPERTY_CODE_CLIENT_PROPERTIES
The property code that identifies a change in this node's client propertie (see getClientProperty ). |
static int |
PROPERTY_CODE_FULL_BOUNDS
The property code that identifies a change of this node's full bounds (see getFullBounds ,
getFullBoundsReference ). |
static int |
PROPERTY_CODE_PAINT
The property code that identifies a change of this node's paint (see getPaint ). |
static int |
PROPERTY_CODE_PARENT
The property code that identifies a change of this node's parent (see getParent ). |
static int |
PROPERTY_CODE_PICKABLE
The property code that identifies a change of this node's pickable status (see getPickable ). |
static int |
PROPERTY_CODE_TRANSFORM
The property code that identifies a change of this node's transform (see getTransform , getTransformReference ). |
static int |
PROPERTY_CODE_TRANSPARENCY
The property code that identifies a change of this node's transparency (see getTransparency ). |
static int |
PROPERTY_CODE_VISIBLE
The property code that identifies a change of this node's visibility (see getVisible ). |
static String |
PROPERTY_FULL_BOUNDS
The property name that identifies a change of this node's full bounds (see getFullBounds ,
getFullBoundsReference ). |
static String |
PROPERTY_PAINT
The property name that identifies a change of this node's paint (see getPaint ). |
static String |
PROPERTY_PARENT
The property name that identifies a change of this node's parent (see getParent ). |
static String |
PROPERTY_PICKABLE
The property name that identifies a change of this node's pickable status (see getPickable ). |
static String |
PROPERTY_TRANSFORM
The property name that identifies a change of this node's transform (see getTransform , getTransformReference ). |
static String |
PROPERTY_TRANSPARENCY
The property name that identifies a change of this node's transparency (see getTransparency ). |
static 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 receives low level node events. |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PNode()
Constructs a new PNode. |
|
PNode(String newName)
Creates a new PNode with the given name. |
Method Summary | |
---|---|
boolean |
addActivity(PActivity activity)
Schedule the given activity with the root, note that only scheduled activities will be stepped. |
void |
addAttribute(Object key,
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(Collection nodes)
Add a collection of nodes to be children of this node. |
void |
addClientProperty(Object key,
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(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(String propertyName,
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(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. |
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. |
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. |
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 coordinates of this node. |
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. |
Object |
clone()
The copy method copies this node and all of its descendants. |
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(Rectangle2D fullBounds,
ArrayList results)
Finds all descendants of this node that intersect with the given bounds and adds them to the results array. |
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. |
protected void |
firePropertyChange(int propertyCode,
String propertyName,
Object oldValue,
Object newValue)
Report a bound property update to any registered listeners. |
boolean |
fullIntersects(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 descendants. |
boolean |
fullPick(PPickPath pickPath)
Try to pick this node and all of its descendants. |
Collection |
getAllNodes()
Return a collection containing this node and all of its descendant nodes. |
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. |
Object |
getAttribute(Object key)
Returns the value of the client attribute with the specified key. |
Object |
getAttribute(Object key,
Object defaultValue)
Fetches the value of the requested attribute, returning defaultValue is not found. |
boolean |
getBooleanAttribute(Object key,
boolean defaultValue)
Fetches the boolean value of the requested attribute, returning defaultValue is not found. |
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 descendants 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. |
ListIterator |
getChildrenIterator()
Return an iterator over this node's direct descendant children. |
boolean |
getChildrenPickable()
Return true if the children of this node should be picked. |
List |
getChildrenReference()
Return a reference to the list used to manage this node's children. |
MutableAttributeSet |
getClientProperties()
Return mutable attributed set of client properties associated with this node. |
Object |
getClientProperty(Object key)
Deprecated. use getAttribute(Object key)instead. |
Enumeration |
getClientPropertyKeysEnumeration()
Returns an enumeration of all keys maped to attribute values values. |
Iterator |
getClientPropertyKeysIterator()
Deprecated. use getClientPropertyKeysEnumerator() instead. |
double |
getDoubleAttribute(Object key,
double defaultValue)
Fetches the double value of the requested attribute, returning defaultValue is not found. |
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. |
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. |
PInputEventListener[] |
getInputEventListeners()
Returns an array of input event listeners that are attached to this node. |
int |
getIntegerAttribute(Object key,
int defaultValue)
Fetches the integer value of the requested attribute, returning defaultValue is not found. |
PAffineTransform |
getInverseTransform()
Return an inverted copy of the transform associated with this node. |
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. |
String |
getName()
Returns the name given to this node. |
boolean |
getOccluded()
Returns whether this node has been flagged as occluded. |
Point2D |
getOffset()
Return the offset that is being applied to this node by its transform. |
Paint |
getPaint()
Return the paint used while painting 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 descendants. |
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()
Returns the x offset of this node as applied by its transform. |
double |
getY()
Return the y position (in local coords) of this node's bounds. |
double |
getYOffset()
Returns the y offset of this node as applied by its transform. |
Dimension2D |
globalToLocal(Dimension2D globalDimension)
Transform the given dimension from global coordinates to this node's local coordinate system. |
Point2D |
globalToLocal(Point2D globalPoint)
Transform the given point from global coordinates to this node's local coordinate system. |
Rectangle2D |
globalToLocal(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(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 descendant of the parameter node. |
boolean |
isDescendentOfRoot()
Return true if this node descends from the root. |
boolean |
isOpaque(Rectangle2D boundary)
Returns whether this node is Opaque. |
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. |
Dimension2D |
localToGlobal(Dimension2D localDimension)
Transform the given dimension from this node's local coordinate system to the global coordinate system. |
Point2D |
localToGlobal(Point2D localPoint)
Transform the given point from this node's local coordinate system to the global coordinate system. |
Rectangle2D |
localToGlobal(Rectangle2D localRectangle)
Transform the given rectangle from this node's local coordinate system to the global coordinate system. |
Dimension2D |
localToParent(Dimension2D localDimension)
Transform the given dimension from this node's local coordinate system to its parent's local coordinate system. |
Point2D |
localToParent(Point2D localPoint)
Transform the given point from this node's local coordinate system to its parent's local coordinate system. |
Rectangle2D |
localToParent(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 back of the specified sibling node. |
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. |
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 in front of all of its other sibling nodes. |
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 String |
paramString()
Deprecated. see http://code.google.com/p/piccolo2d/issues/detail?id=99 |
protected void |
parentBoundsChanged()
A notification that the bounds of this node's parent have changed. |
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. |
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. |
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. |
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(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. |
void |
print()
Constructs a new PrinterJob, allows the user to select which printer to print to, And then prints the node. |
int |
print(Graphics graphics,
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(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(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(String propertyName,
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,
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,
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 position and size. |
boolean |
setBounds(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 descendants 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(Point2D globalPoint)
Set the global translation of this node. |
boolean |
setHeight(double height)
Set's this node's bounds height, leaving x, y, and width unchanged. |
void |
setName(String name)
Sets the name of this null, may be null. |
void |
setOccluded(boolean occluded)
Flags this node as occluded. |
void |
setOffset(double x,
double y)
Set the offset that is being applied to this node by its transform. |
void |
setOffset(Point2D point)
Set the offset that is being applied to this node by its transform. |
void |
setPaint(Paint newPaint)
Set the paint used to paint this node, which may be null. |
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(AffineTransform transform)
Set the transform applied to this node. |
void |
setTransparency(float newTransparency)
Set the transparency used to paint this node. |
void |
setVisible(boolean isVisible)
Set the visibility of this node and its descendants. |
boolean |
setWidth(double width)
Set's this node's bounds width, leaving x, y, and height unchanged. |
boolean |
setX(double x)
Set's this node's bounds left position, leaving y, width, and height unchanged. |
boolean |
setY(double y)
Set's this node's bounds top position, leaving x, width, and height unchanged. |
void |
signalBoundsChanged()
This method should be called when the bounds of this node are changed. |
void |
startResizeBounds()
Notify this node that you will begin to repeatedly call setBounds
. |
Image |
toImage()
Return a new Image representing this node and all of its children. |
Image |
toImage(BufferedImage image,
Paint backGroundPaint)
Paint a representation of this node into the specified buffered image. |
Image |
toImage(BufferedImage image,
Paint backGroundPaint,
int fillStrategy)
Paint a representation of this node into the specified buffered image. |
Image |
toImage(int width,
int height,
Paint backgroundPaint)
Return a new Image of the requested size representing this node and all of its children. |
void |
transformBy(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 descendants. |
void |
validateFullPaint()
Repaint this node and any of its descendants if they have invalid paint. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final 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
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 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
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 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
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 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
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 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
getVisible
). Both old value and new value will be
null in any property change event.
public static final 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
getPaint
). Both old value and new value will be set
correctly in any property change event.
public static final 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
getTransparency
). Both old value and new
value will be null in any property change event.
public static final 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
getPickable
). Both old value and new value will
be null in any property change event.
public static final 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
getChildrenPickable
).
Both old value and new value will be null in any property change event.
public static final 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
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 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
getParent
). Both old value and new value will be set
correctly in any property change event.
public static PNode.PSceneGraphDelegate SCENE_GRAPH_DELEGATE
public static final int FILL_STRATEGY_ASPECT_FIT
public static final int FILL_STRATEGY_ASPECT_COVER
public static final int FILL_STRATEGY_EXACT_FIT
Constructor Detail |
---|
public PNode(String newName)
newName
- name to assign to nodepublic 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)
x
- left of target boundsy
- top of target boundswidth
- width of target boundsheight
- height of target boundsduration
- amount of time that the animation should take
public PTransformActivity animateTransformToBounds(double x, double y, double width, double height, long duration)
x
- left of target boundsy
- top of target boundswidth
- width of target boundsheight
- height of target boundsduration
- amount of time that the animation should take
public PTransformActivity animateToPositionScaleRotation(double x, double y, double scale, double theta, long duration)
x
- the final target x position of nodey
- the final target y position of nodeduration
- amount of time that the animation should takescale
- the final scale for the durationtheta
- final theta value (in radians) for the animation
public PTransformActivity animateToTransform(AffineTransform destTransform, long duration)
destTransform
- the final transform valueduration
- amount of time that the animation should take
public PInterpolatingActivity animateToColor(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 MutableAttributeSet getClientProperties()
public Object getAttribute(Object key)
addAttribute
will return a non-null
value.
key
- key to use while fetching client attribute
public void addAttribute(Object key, Object value)
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.
key
- to use when adding the attributevalue
- value to associate to the new attributepublic Enumeration getClientPropertyKeysEnumeration()
public Object getAttribute(Object key, Object defaultValue)
key
- attribute to search fordefaultValue
- value to return if attribute is not found
public boolean getBooleanAttribute(Object key, boolean defaultValue)
key
- attribute to search fordefaultValue
- value to return if attribute is not found
public int getIntegerAttribute(Object key, int defaultValue)
key
- attribute to search fordefaultValue
- value to return if attribute is not found
public double getDoubleAttribute(Object key, double defaultValue)
key
- attribute to search fordefaultValue
- value to return if attribute is not found
public Object getClientProperty(Object key)
key
- name of property to search for
public void addClientProperty(Object key, Object value)
key
- name of property to addvalue
- value or new attributepublic Iterator getClientPropertyKeysIterator()
public Object clone()
clone
in class Object
public Point2D localToParent(Point2D localPoint)
localPoint
- point in local coordinate system to be transformed.
public Dimension2D localToParent(Dimension2D localDimension)
localDimension
- dimension in local coordinate system to be
transformed.
public Rectangle2D localToParent(Rectangle2D localRectangle)
localRectangle
- rectangle in local coordinate system to be
transformed.
public Point2D parentToLocal(Point2D parentPoint)
parentPoint
- point in parent's coordinate system to be transformed.
public Dimension2D parentToLocal(Dimension2D parentDimension)
parentDimension
- dimension in parent's coordinate system to be
transformed.
public Rectangle2D parentToLocal(Rectangle2D parentRectangle)
parentRectangle
- rectangle in parent's coordinate system to be
transformed.
public Point2D localToGlobal(Point2D localPoint)
localPoint
- point in local coordinate system to be transformed.
public Dimension2D localToGlobal(Dimension2D localDimension)
localDimension
- dimension in local coordinate system to be
transformed.
public Rectangle2D localToGlobal(Rectangle2D localRectangle)
localRectangle
- rectangle in local coordinate system to be
transformed.
public Point2D globalToLocal(Point2D globalPoint)
globalPoint
- point in global coordinates to be transformed.
public Dimension2D globalToLocal(Dimension2D globalDimension)
globalDimension
- dimension in global coordinates to be transformed.
public Rectangle2D globalToLocal(Rectangle2D globalRectangle)
globalRectangle
- rectangle in global coordinates to be transformed.
public PAffineTransform getLocalToGlobalTransform(PAffineTransform dest)
dest
- PAffineTransform to transform to global coordinates
public PAffineTransform getGlobalToLocalTransform(PAffineTransform dest)
dest
- PAffineTransform to transform from global to local
public EventListenerList getListenerList()
public void addInputEventListener(PInputEventListener listener)
listener
- the new input listenerpublic void removeInputEventListener(PInputEventListener listener)
listener
- the input listener to removepublic void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be addedpublic void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedpublic void removePropertyChangeListener(String propertyName, 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)
propertyChangeParentMask
- new mask for property change bubble upprotected void firePropertyChange(int propertyCode, String propertyName, Object oldValue, Object newValue)
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.protected void fireChildPropertyChange(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)
x
- new x position of bounds
public boolean setY(double y)
y
- new y position of bounds
public boolean setWidth(double width)
width
- new width position of bounds
public boolean setHeight(double height)
height
- new height position of bounds
public boolean setBounds(Rectangle2D newBounds)
newBounds
- bounds to apply to this node
public boolean setBounds(double x, double y, double width, double height)
x
- x position of boundsy
- y position of boundswidth
- width to apply to the boundsheight
- height to apply to the bounds
protected void internalUpdateBounds(double x, double y, double width, double height)
x
- x position of boundsy
- y position of boundswidth
- width to apply to the boundsheight
- height to apply to the boundspublic void resetBounds()
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public PBounds getGlobalBounds()
public boolean centerBoundsOnPoint(double localX, double localY)
localX
- x position of point around which to center boundslocalY
- y position of point around which to center bounds
public void centerFullBoundsOnPoint(double parentX, double parentY)
parentX
- x position around which to center full boundsparentY
- y position around which to center full boundspublic boolean intersects(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 here
public PBounds getGlobalFullBounds()
public boolean fullIntersects(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 descendant 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)
fullBoundsInvalid
- true=invalid, false=validprotected boolean getChildBoundsInvalid()
protected void setChildBoundsInvalid(boolean childBoundsInvalid)
childBoundsInvalid
- true=invalid, false=validpublic 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, Point2D point)
theta
- the amount to rotate by in radianspoint
- the point about which to rotatepublic void rotateAboutPoint(double theta, double x, double y)
theta
- the amount to rotate by in radiansx
- the x coordinate of the point around which to rotatey
- the y coordinate of the point around which to rotatepublic double getGlobalRotation()
public void setGlobalRotation(double theta)
theta
- the amount to rotate by in radians relative to the global
coordinate 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, 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 byx
- the x coordinate of the point around which to scaley
- the y coordinate of the point around which to scalepublic double getGlobalScale()
public void setGlobalScale(double scale)
scale
- the desired global scalepublic double getXOffset()
public double getYOffset()
public Point2D getOffset()
public void setOffset(Point2D point)
point
- value of new offsetpublic void setOffset(double x, double y)
x
- amount of x offsety
- amount of y offsetpublic void offset(double dx, double dy)
dx
- amount to add to this nodes current x Offsetdy
- amount to add to this nodes current y Offsetpublic void translate(double dx, double dy)
dx
- amount to add to this nodes current x translationdy
- amount to add to this nodes current y translationpublic Point2D getGlobalTranslation()
public void setGlobalTranslation(Point2D globalPoint)
globalPoint
- the desired global translationpublic void transformBy(AffineTransform aTransform)
aTransform
- the transform to apply.public static double lerp(double t, double a, double b)
t
- variable 'time' parametera
- from pointb
- to Point
public PActivity animateToRelativePosition(Point2D srcPt, Point2D destPt, 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 animation
public void position(Point2D srcPt, Point2D destPt, 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)
createNewTransformIfNull
- if the transform has not been
initialised, should it be?
public PAffineTransform getInverseTransform()
public void setTransform(AffineTransform transform)
transform
- 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(Rectangle2D boundary)
boundary
- boundary to check and see if this node covers completely.
public boolean getOccluded()
public void setOccluded(boolean occluded)
occluded
- new value for occludedpublic boolean getVisible()
public void setVisible(boolean isVisible)
isVisible
- true if this node and its descendants are visiblepublic Paint getPaint()
public void setPaint(Paint newPaint)
newPaint
- paint that this node should use when painting itself.public float getTransparency()
public void setTransparency(float newTransparency)
newTransparency
- transparency value for this node. 0f = fully
transparent, 1f = fully opaqueprotected 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 Image toImage()
public Image toImage(int width, int height, Paint backgroundPaint)
width
- pixel width of the resulting imageheight
- pixel height of the resulting imagebackgroundPaint
- paint to fill the image with before drawing this
node, may be null
public Image toImage(BufferedImage image, Paint backGroundPaint)
image
- Image onto which this node will be paintedbackGroundPaint
- will fill background of image with this. May be
null.
public Image toImage(BufferedImage image, Paint backGroundPaint, int fillStrategy)
image
- Image onto which this node will be paintedbackGroundPaint
- will fill background of image with this. May be
null.fillStrategy
- strategy to use regarding how node will cover the
image
public void print()
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
print
in interface 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 drawn
public 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(Rectangle2D fullBounds, ArrayList results)
fullBounds
- bounds to compare againstresults
- array into which to add matchesprotected 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)
index
- where in the children list to insert the childchild
- the new child to add to this nodepublic void addChildren(Collection nodes)
nodes
- a collection of nodes to be added to this nodepublic boolean isAncestorOf(PNode node)
node
- a possible descendant node
public boolean isDescendentOf(PNode node)
node
- a possible ancestor node
public boolean isDescendentOfRoot()
public void moveToBack()
public void moveInBackOf(PNode sibling)
sibling
- sibling to move in back ofpublic void moveToFront()
public void moveInFrontOf(PNode sibling)
sibling
- sibling to move in front ofpublic PNode getParent()
public void setParent(PNode newParent)
newParent
- the parent to which this node should be addedpublic int indexOfChild(PNode child)
child
- child so search for
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(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 void setName(String name)
name
- new name for this nodepublic String getName()
public int getChildrenCount()
public PNode getChild(int index)
index
- a child index
public List getChildrenReference()
public ListIterator getChildrenIterator()
public PRoot getRoot()
public Collection getAllNodes()
public Collection getAllNodes(PNodeFilter filter, Collection resultantNodes)
filter
- the filter used to determine the subsetresultantNodes
- where matching nodes should be added
protected String paramString()
public PInputEventListener[] getInputEventListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |