public abstract class Activity
extends java.lang.Object
ActivityManager
,
Action
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_STEP_TIME |
static long |
INFINITY |
Constructor and Description |
---|
Activity(long duration)
Creates a new Activity.
|
Activity(long duration,
long stepTime)
Creates a new Activity.
|
Activity(long duration,
long stepTime,
long startTime)
Creates a new Activity.
|
Modifier and Type | Method and Description |
---|---|
void |
addActivityListener(ActivityListener l)
Add an ActivityListener to monitor this activity's events.
|
void |
alwaysRunAfter(Activity before)
Schedules this Activity to start immediately after another Activity.
|
void |
cancel()
Cancels this activity, if scheduled.
|
protected void |
fireActivityCancelled() |
protected void |
fireActivityFinished() |
protected void |
fireActivityScheduled() |
protected void |
fireActivityStarted() |
protected void |
fireActivityStepped() |
long |
getDuration()
Returns the duration of this activity
|
long |
getNextTime()
Get the time at which this activity should be run next.
|
double |
getPace(long elapsedTime)
Returns a value between 0 and 1 inclusive, indicating the current
position in an animation or other similarly parameterized activity.
|
Pacer |
getPacingFunction()
Returns the pacing function associated with this Activity.
|
long |
getStartTime()
Returns this activity's start time
|
long |
getStepTime()
Returns the delay between runs for this activity
|
long |
getStopTime()
Get the time at which this activity should complete.
|
boolean |
isEnabled()
Indicates whether or not this activity is currently enabled.
|
boolean |
isRunning()
Indicates if this activity is currently running.
|
boolean |
isScheduled()
Indicates if this activity is currently scheduled
with the ActivityManager
|
void |
removeActivityListener(ActivityListener l)
Remove a registered ActivityListener
|
void |
run()
Schedules this Activity to start immediately.
|
protected abstract void |
run(long elapsedTime)
Run this activity one step.
|
void |
runAfter(Activity before)
Schedules this Activity to start immediately after another Activity.
|
void |
runAt(long startTime)
Schedules this Activity for the specified startTime, overwriting the
Activity's currently set startTime.
|
void |
setDuration(long duration)
Set the duration of this activity
|
void |
setEnabled(boolean s)
Sets whether this component is enabled.
|
void |
setPacingFunction(Pacer pfunc)
Sets the pacing function associated with this Activity.
|
void |
setStartTime(long time)
Sets this activity's start time
|
void |
setStepTime(long time)
Sets the delay between runs for this activity
|
public static final long INFINITY
public static final long DEFAULT_STEP_TIME
public Activity(long duration)
duration
- the length of this activity.
A value of INFINITY
indicates an infinite running time.Activity(long, long, long)
public Activity(long duration, long stepTime)
duration
- the length of this activity.
A value of INFINITY
indicates an infinite running time.stepTime
- the delay time between steps of this activityActivity(long, long, long)
public Activity(long duration, long stepTime, long startTime)
duration
- the length of this activity.
A value of INFINITY
indicates an infinite running time.stepTime
- the delay time between steps of this activitystartTime
- the time at which this activity should beginpublic void run()
public void runAt(long startTime)
startTime
- the time at which the activity should runpublic void runAfter(Activity before)
before
- the Activity that must finish before this one startspublic void alwaysRunAfter(Activity before)
before
- the Activity that must finish before this one startsprotected abstract void run(long elapsedTime)
elapsedTime
- the time elapsed since the start of the activity.public void cancel()
public boolean isScheduled()
public boolean isRunning()
public void addActivityListener(ActivityListener l)
l
- the ActivityListener to addpublic void removeActivityListener(ActivityListener l)
l
- the ActivityListener to removeprotected void fireActivityScheduled()
protected void fireActivityStarted()
protected void fireActivityStepped()
protected void fireActivityFinished()
protected void fireActivityCancelled()
public double getPace(long elapsedTime)
elapsedTime
- the time in milliseconds since the start of this
Activity.getPacingFunction()
public Pacer getPacingFunction()
public void setPacingFunction(Pacer pfunc)
pfunc
- this Activity's new pacing function, or null to
indicate a basic, linear pace moving from 0 to 1 uniformly
over time.public long getStopTime()
public long getNextTime()
public long getDuration()
public void setDuration(long duration)
duration
- The new duration, in milliseconds, for this activity.
A value of INFINITY
indicates that this activity should run
indefinitely.public long getStartTime()
public void setStartTime(long time)
time
- the new starting time for this activitypublic long getStepTime()
public void setStepTime(long time)
time
- the new step time between runs of this activitypublic boolean isEnabled()
public void setEnabled(boolean s)
s
- true to enable component, false to disable itCopyright ? 2013 Regents of the University of California