Package edu.umd.cs.piccolo.activities
Class PActivityScheduler
java.lang.Object
edu.umd.cs.piccolo.activities.PActivityScheduler
- All Implemented Interfaces:
Serializable
PActivityScheduler is responsible for maintaining a list of
activities. It is given a chance to process these activities from the PRoot's
processInputs() method. Most users will not need to use the
PActivityScheduler directly, instead you should look at:
- PNode.addActivity - to schedule a new activity
- PActivity.terminate - to terminate a running activity
- PRoot.processInputs - already calls processActivities for you.
- Version:
- 1.0
- Author:
- Jesse Grosjean
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPActivityScheduler(PRoot rootNode) Constructs an instance of PActivityScheduler. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActivity(PActivity activity) Adds the given activity to the scheduler if not already found.voidaddActivity(PActivity activity, boolean processLast) Add this activity to the scheduler.Returns a reference to the current activities list.protected TimerReturns the activity timer.booleanReturn true if any of the scheduled activities are animations.getRoot()Returns the node from which all activities will be attached.voidprocessActivities(long currentTime) Process all scheduled activities for the given time.voidremoveActivity(PActivity activity) Removes the given activity from the scheduled activities.voidRemoves all activities from the list of scheduled activities.protected voidStarts the current activity timer.protected voidStops the current activity timer.
-
Constructor Details
-
PActivityScheduler
Constructs an instance of PActivityScheduler. All activities it will schedule will take place on children of the rootNode provided.- Parameters:
rootNode- root node of all activities to be performed. All nodes being animated should have this node as an ancestor.
-
-
Method Details
-
getRoot
Returns the node from which all activities will be attached.- Returns:
- this scheduler's associated root node
-
addActivity
Adds the given activity to the scheduler if not already found.- Parameters:
activity- activity to be scheduled
-
addActivity
Add this activity to the scheduler. Sometimes it's useful to make sure that an activity is run after all other activities have been run. To do this set processLast to true when adding the activity.- Parameters:
activity- activity to be scheduledprocessLast- whether or not this activity should be performed after all other scheduled activities
-
removeActivity
Removes the given activity from the scheduled activities. Does nothing if it's not found.- Parameters:
activity- the activity to be removed
-
removeAllActivities
public void removeAllActivities()Removes all activities from the list of scheduled activities. -
getActivitiesReference
Returns a reference to the current activities list. Handle with care.- Returns:
- reference to the current activities list.
-
processActivities
public void processActivities(long currentTime) Process all scheduled activities for the given time. Each activity is given one "step", equivalent to one frame of animation.- Parameters:
currentTime- the current unix time in milliseconds.
-
getAnimating
public boolean getAnimating()Return true if any of the scheduled activities are animations.- Returns:
- true if any of the scheduled activities are animations.
-
startActivityTimer
protected void startActivityTimer()Starts the current activity timer. Multiple calls to this method are ignored. -
stopActivityTimer
protected void stopActivityTimer()Stops the current activity timer. -
getActivityTimer
Returns the activity timer. Creating it if necessary.- Returns:
- a Timer instance.
-