Package edu.umd.cs.piccolo
Class PRoot
java.lang.Object
edu.umd.cs.piccolo.PNode
edu.umd.cs.piccolo.PRoot
- All Implemented Interfaces:
Printable,Serializable,Cloneable
PRoot serves as the top node in Piccolo2D'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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interfaces is for advanced use only.Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode
PNode.PSceneGraphDelegate -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether this not is currently processing inputs.protected booleanWhether this node needs to have its inputs processed.static final intThe property code that identifies a change in the set of this root's input sources (seeInputSource).static final intThe property code that identifies a change in this node's interacting state.static final StringThe property name that identifies a change in the set of this root's input sources (seeInputSource).static final StringThe property name that identifies a change in this node's interacting state.Fields inherited from class edu.umd.cs.piccolo.PNode
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATEFields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddActivity(PActivity activity) Add an activity to the activity scheduler associated with this root.voidaddInputSource(PRoot.InputSource inputSource) Advanced.createTimer(int delay, ActionListener listener) Returns a new timer.Get the activity scheduler associated with this root.Get the default input manager to be used when processing input events.longGet the global Piccolo2D time.booleanReturn true if this root has been marked as interacting.getRoot()Since getRoot is handled recursively, and root is the lowest point in the hierarchy, simply returns itself.voidThis is the heartbeat of the Piccolo2D framework.voidremoveInputSource(PRoot.InputSource inputSource) Advanced.voidSchedule process inputs if needed.voidsetChildBoundsInvalid(boolean childLayoutInvalid) Set the flag indicating that one of this node's descendants has invalid bounds.voidsetChildPaintInvalid(boolean childPaintInvalid) Mark this node as having a child with invalid paint.voidsetFullBoundsInvalid(boolean fullLayoutInvalid) Set the full bounds invalid flag.voidsetInteracting(boolean isInteracting) Set if this root is interacting.voidsetPaintInvalid(boolean paintInvalid) Mark this node as having invalid paint.voidWait for all scheduled activities to finish before returning from this method.Methods inherited from class edu.umd.cs.piccolo.PNode
addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, 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, setName, setOccluded, setOffset, setOffset, setPaint, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
-
Field Details
-
PROPERTY_INPUT_SOURCES
The property name that identifies a change in the set of this root's input sources (seeInputSource). 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:
-
PROPERTY_CODE_INPUT_SOURCES
public static final int PROPERTY_CODE_INPUT_SOURCESThe property code that identifies a change in the set of this root's input sources (seeInputSource). 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:
-
PROPERTY_INTERACTING_CHANGED
The property name that identifies a change in this node's interacting state.- Since:
- 1.3
- See Also:
-
PROPERTY_CODE_INTERACTING_CHANGED
public static final int PROPERTY_CODE_INTERACTING_CHANGEDThe property code that identifies a change in this node's interacting state.- Since:
- 1.3
- See Also:
-
processingInputs
protected transient boolean processingInputsWhether this not is currently processing inputs. -
processInputsScheduled
protected transient boolean processInputsScheduledWhether this node needs to have its inputs processed.
-
-
Constructor Details
-
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 Details
-
addActivity
Add an activity to the activity scheduler associated with this root. Activities are given a chance to run during each call to the rootsprocessInputsmethod. When the activity has finished running it will automatically get removed.- Overrides:
addActivityin classPNode- Parameters:
activity- Activity that should be scheduled- Returns:
- whether it has been scheduled (always true)
-
getActivityScheduler
Get the activity scheduler associated with this root.- Returns:
- associated scheduler
-
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
Since getRoot is handled recursively, and root is the lowest point in the hierarchy, simply returns itself. -
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.- Returns:
- a singleton instance of PInputManager
-
getInteracting
public boolean getInteracting()Return true if this root has been marked as interacting. If so the root will normally render at a lower quality that is faster.- Returns:
- true if this root has user interaction taking place
- Since:
- 1.3
-
setInteracting
public void setInteracting(boolean isInteracting) Set if this root is interacting. If so the root will normally render at a lower quality that is faster. Also repaints the root if the the interaction has ended.This has similar functionality to the setInteracting method on Canvas, but this is the appropriate place to mark interactions that may occur in multiple canvases if this Root is shared.
- Parameters:
isInteracting- True if this root has user interaction taking place- Since:
- 1.3
- See Also:
-
addInputSource
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 Piccolo2D framework.- Parameters:
inputSource- An input source that should be added
-
removeInputSource
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 Piccolo2D framework.- Parameters:
inputSource- input source that should no longer be asked about input events
-
createTimer
Returns a new timer. This method allows subclasses, such as PSWTRoot to create custom timers that will be used transparently by the Piccolo2D framework.- Parameters:
delay- # of milliseconds before action listener is invokedlistener- listener to be invoked after delay- Returns:
- A new Timer
-
getGlobalTime
public long getGlobalTime()Get the global Piccolo2D time. This is set to System.currentTimeMillis() at the beginning of the rootsprocessInputsmethod. Activities should usually use this global time instead of System. currentTimeMillis() so that multiple activities will be synchronized.- Returns:
- time as recorded at the beginning of activity scheduling
-
processInputs
public void processInputs()This is the heartbeat of the Piccolo2D 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) 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:
setFullBoundsInvalidin classPNode- Parameters:
fullLayoutInvalid- true=invalid, false=valid
-
setChildBoundsInvalid
public void setChildBoundsInvalid(boolean childLayoutInvalid) Set the flag indicating that one of this node's descendants has invalid bounds.- Overrides:
setChildBoundsInvalidin classPNode- Parameters:
childLayoutInvalid- true=invalid, false=valid
-
setPaintInvalid
public void setPaintInvalid(boolean paintInvalid) Mark this node as having invalid paint. If this is set the node will later be repainted. Node this method is most often used internally.- Overrides:
setPaintInvalidin classPNode- Parameters:
paintInvalid- true if this node should be repainted
-
setChildPaintInvalid
public void setChildPaintInvalid(boolean childPaintInvalid) Mark this node as having a child with invalid paint.- Overrides:
setChildPaintInvalidin classPNode- Parameters:
childPaintInvalid- true if this node has a child with invalid paint
-
scheduleProcessInputsIfNeeded
public void scheduleProcessInputsIfNeeded()Schedule process inputs if needed.
-