|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.activities.PActivity
public class PActivity
PActivity controls some time dependent aspect of Piccolo, such as animation. Once created activities must be scheduled with the PActivityScheduler managed by the PRoot to run. They are automatically removed from the scheduler when the animation has finished.
See the PNode.animate*() methods for an example of how to set up and run different activities.
Nested Class Summary | |
---|---|
static interface |
PActivity.PActivityDelegate
PActivityDelegate is used by classes to learn about and act on the different states that a PActivity goes through, such as when the activity starts and stops stepping. |
Field Summary | |
---|---|
static int |
TERMINATE_AND_FINISH
|
static int |
TERMINATE_AND_FINISH_IF_STEPPING
|
static int |
TERMINATE_WITHOUT_FINISHING
|
Constructor Summary | |
---|---|
PActivity(long aDuration)
Constructs a new PActivity. |
|
PActivity(long aDuration,
long aStepRate)
Constructs a new PActivity. |
|
PActivity(long aDuration,
long aStepRate,
long aStartTime)
Constructs a new PActivity. |
Method Summary | |
---|---|
protected void |
activityFinished()
This method is called after an activity is has finished running and the activity has been removed from the PActivityScheduler queue. |
protected void |
activityStarted()
This method is called right before an activity is scheduled to start running. |
protected void |
activityStep(long elapsedTime)
This is the method that most activities override to perform their behavior. |
PActivityScheduler |
getActivityScheduler()
|
PActivity.PActivityDelegate |
getDelegate()
Get the delegate for this activity. |
long |
getDuration()
Return the amount of time that this activity should take to complete, after the startStepping method is called. |
long |
getNextStepTime()
|
long |
getStartTime()
Return the time that this activity should start running in PRoot global time. |
long |
getStepRate()
Return the amount of time that this activity should delay between steps. |
long |
getStopTime()
Return the time when this activity should finish running. |
protected boolean |
isAnimation()
Return true if this activity is performing an animation. |
boolean |
isStepping()
Return true if this activity is stepping. |
protected java.lang.String |
paramString()
Returns a string representing the state of this node. |
long |
processStep(long currentTime)
The activity scheduler calls this method and it is here that the activity decides if it should do a step or not for the given time. |
void |
setActivityScheduler(PActivityScheduler aScheduler)
|
void |
setDelegate(PActivity.PActivityDelegate delegate)
Set the delegate for this activity. |
void |
setDuration(long aDuration)
Set the amount of time that this activity should take to complete, after the startStepping method is called. |
void |
setStartTime(long aTriggerTime)
Set the time that this activity should start running in PRoot global time. |
void |
setStepRate(long aStepRate)
Set the amount of time that this activity should delay between steps. |
void |
startAfter(PActivity first)
Schedules this activity to start after the first activity has finished. |
void |
terminate()
Stop this activity immediately, and remove it from the activity scheduler. |
void |
terminate(int terminationBehavior)
Stop this activity immediately, and remove it from the activity scheduler. |
java.lang.String |
toString()
Returns a string representation of this object for debugging purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TERMINATE_WITHOUT_FINISHING
public static final int TERMINATE_AND_FINISH
public static final int TERMINATE_AND_FINISH_IF_STEPPING
Constructor Detail |
---|
public PActivity(long aDuration)
aDuration
- the amount of time that this activity should take to complete, -1 for infinite.public PActivity(long aDuration, long aStepRate)
aDuration
- the amount of time that this activity should take to complete, -1 for infinite.aStepRate
- the maximum rate that this activity should receive step events.public PActivity(long aDuration, long aStepRate, long aStartTime)
aDuration
- the amount of time that this activity should take to complete, -1 for infinite.aStepRate
- the maximum rate that this activity should receive step events.aStartTime
- the time (relative to System.currentTimeMillis()) that
this activity should start.Method Detail |
---|
public long getStartTime()
public void setStartTime(long aTriggerTime)
public long getStepRate()
public void setStepRate(long aStepRate)
public long getNextStepTime()
public long getDuration()
public void setDuration(long aDuration)
public PActivityScheduler getActivityScheduler()
public void setActivityScheduler(PActivityScheduler aScheduler)
public boolean isStepping()
protected boolean isAnimation()
protected void activityStarted()
protected void activityStep(long elapsedTime)
elapsedTime
- the amount of time that has passed relative to the activities startTime.protected void activityFinished()
public PActivity.PActivityDelegate getDelegate()
public void setDelegate(PActivity.PActivityDelegate delegate)
public void startAfter(PActivity first)
public void terminate()
public void terminate(int terminationBehavior)
public long processStep(long currentTime)
public long getStopTime()
public java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String paramString()
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |