edu.umd.cs.piccolo
Class PRoot

java.lang.Object
  extended byedu.umd.cs.piccolo.PNode
      extended byedu.umd.cs.piccolo.PRoot
All Implemented Interfaces:
java.lang.Cloneable, java.awt.print.Printable, java.io.Serializable
Direct Known Subclasses:
PSWTRoot

public class PRoot
extends PNode

PRoot serves as the top node in Piccolo's runtime structure. The PRoot responsible for running the main UI loop that processes input from activities and external events.

Version:
1.1
Author:
Jesse Grosjean
See Also:
Serialized Form

Nested Class Summary
static interface PRoot.InputSource
          This interfaces is for advanced use only.
 
Field Summary
protected  boolean processingInputs
           
protected  boolean processInputsScheduled
           
static java.lang.String PROPERTY_INPUT_SOURCES
          The property name that identifies a change in the set of this root's input sources (see InputSource).
 
Fields inherited from class edu.umd.cs.piccolo.PNode
PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PRoot()
          Construct a new PRoot().
 
Method Summary
 boolean addActivity(PActivity activity)
          Add an activity to the activity scheduler associated with this root.
 void addInputSource(PRoot.InputSource inputSource)
          Advanced.
 javax.swing.Timer createTimer(int delay, java.awt.event.ActionListener listener)
          Returns a new timer.
 PActivityScheduler getActivityScheduler()
          Get the activity scheduler associated with this root.
 PInputManager getDefaultInputManager()
          Get the default input manager to be used when processing input events.
 long getGlobalTime()
          Get the global Piccolo time.
 PRoot getRoot()
          Return this.
 void processInputs()
          This is the heartbeat of the Piccolo framework.
 void removeInputSource(PRoot.InputSource inputSource)
          Advanced.
 void scheduleProcessInputsIfNeeded()
           
 void setChildBoundsInvalid(boolean childLayoutInvalid)
          Set the flag indicating that one of this node's descendents has invalid bounds.
 void setChildPaintInvalid(boolean childPaintInvalid)
          Mark this node as having a child with invalid paint.
 void setFullBoundsInvalid(boolean fullLayoutInvalid)
          Set the full bounds invalid flag.
 void setPaintInvalid(boolean paintInvalid)
          Mark this node as having invalid paint.
 void waitForActivities()
          Wait for all scheduled activities to finish before returning from this method.
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToTransform, animateToTransparency, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperty, getClientPropertyKeysIterator, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInverseTransform, getListenerList, getLocalToGlobalTransform, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paint, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBounds, setBoundsChanged, setChildBoundsVolatile, setChildrenPickable, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setOccluded, setOffset, setOffset, setPaint, setParent, setPickable, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toString, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_INPUT_SOURCES

public static final java.lang.String PROPERTY_INPUT_SOURCES
The property name that identifies a change in the set of this root's input sources (see InputSource). In any property change event the new value will be a reference to the list of this root's input sources, but old value will always be null.

See Also:
Constant Field Values

processingInputs

protected transient boolean processingInputs

processInputsScheduled

protected transient boolean processInputsScheduled
Constructor Detail

PRoot

public PRoot()
Construct a new PRoot(). Note the PCanvas already creates a basic scene graph for you so often you will not need to construct your own roots.

Method Detail

addActivity

public boolean addActivity(PActivity activity)
Add an activity to the activity scheduler associated with this root. Activities are given a chance to run during each call to the roots processInputs method. When the activity has finished running it will automatically get removed.

Overrides:
addActivity in class PNode
Parameters:
activity - new activity to schedule
Returns:
true if the activity is successfully scheduled.

getActivityScheduler

public PActivityScheduler getActivityScheduler()
Get the activity scheduler associated with this root.


waitForActivities

public void waitForActivities()
Wait for all scheduled activities to finish before returning from this method. This will freeze out user input, and so it is generally recommended that you use PActivities.setTriggerTime() to offset activities instead of using this method.


getRoot

public PRoot getRoot()
Return this.

Overrides:
getRoot in class PNode

getDefaultInputManager

public PInputManager getDefaultInputManager()
Get the default input manager to be used when processing input events. PCanvas's use this method when they forward new swing input events to the PInputManager.


addInputSource

public void addInputSource(PRoot.InputSource inputSource)
Advanced. If you want to add additional input sources to the roots UI process you can do that here. You will seldom do this unless you are making additions to the piccolo framework.


removeInputSource

public void removeInputSource(PRoot.InputSource inputSource)
Advanced. If you want to remove the default input source from the roots UI process you can do that here. You will seldom do this unless you are making additions to the piccolo framework.


createTimer

public javax.swing.Timer createTimer(int delay,
                                     java.awt.event.ActionListener listener)
Returns a new timer. This method allows subclasses, such as PSWTRoot to create custom timers that will be used transparently by the Piccolo framework.


getGlobalTime

public long getGlobalTime()
Get the global Piccolo time. This is set to System.currentTimeMillis() at the beginning of the roots processInputs method. Activities should usually use this global time instead of System. currentTimeMillis() so that multiple activities will be synchronized.


processInputs

public void processInputs()
This is the heartbeat of the Piccolo framework. Pending input events are processed. Activities are given a chance to run, and the bounds caches and any paint damage is validated.


setFullBoundsInvalid

public void setFullBoundsInvalid(boolean fullLayoutInvalid)
Description copied from class: PNode
Set the full bounds invalid flag. This flag is set when the full bounds of this node need to be recomputed as is the case when this node is transformed or when one of this node's children changes geometry.

Overrides:
setFullBoundsInvalid in class PNode

setChildBoundsInvalid

public void setChildBoundsInvalid(boolean childLayoutInvalid)
Description copied from class: PNode
Set the flag indicating that one of this node's descendents has invalid bounds.

Overrides:
setChildBoundsInvalid in class PNode

setPaintInvalid

public void setPaintInvalid(boolean paintInvalid)
Description copied from class: PNode
Mark this node as having invalid paint. If this is set the node will later be repainted. Node this method is most often used internally.

Overrides:
setPaintInvalid in class PNode
Parameters:
paintInvalid - true if this node should be repainted

setChildPaintInvalid

public void setChildPaintInvalid(boolean childPaintInvalid)
Description copied from class: PNode
Mark this node as having a child with invalid paint.

Overrides:
setChildPaintInvalid in class PNode
Parameters:
childPaintInvalid - true if this node has a child with invalid paint

scheduleProcessInputsIfNeeded

public void scheduleProcessInputsIfNeeded()


Copyright 2004 by University of Maryland, College Park, MD 20742, USA All rights reserved.