Class PActivityScheduler

java.lang.Object
edu.umd.cs.piccolo.activities.PActivityScheduler
All Implemented Interfaces:
Serializable

public class PActivityScheduler extends Object implements 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 Details

    • PActivityScheduler

      public PActivityScheduler(PRoot rootNode)
      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

      public PRoot getRoot()
      Returns the node from which all activities will be attached.
      Returns:
      this scheduler's associated root node
    • addActivity

      public void addActivity(PActivity activity)
      Adds the given activity to the scheduler if not already found.
      Parameters:
      activity - activity to be scheduled
    • addActivity

      public void addActivity(PActivity activity, boolean processLast)
      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 scheduled
      processLast - whether or not this activity should be performed after all other scheduled activities
    • removeActivity

      public void removeActivity(PActivity activity)
      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

      public List 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

      protected Timer getActivityTimer()
      Returns the activity timer. Creating it if necessary.
      Returns:
      a Timer instance.