prefuse.activity
Class Activity

java.lang.Object
  extended by prefuse.activity.Activity
Direct Known Subclasses:
Action

public abstract class Activity
extends java.lang.Object

Represents an activity that can be scheduled and run. This could include data processing, animation, and time-sensitive operations.

Author:
jeffrey heer
See Also:
ActivityManager, Action

Field Summary
static long DEFAULT_STEP_TIME
           
static long INFINITY
           
 
Constructor Summary
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.
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITY

public static final long INFINITY
See Also:
Constant Field Values

DEFAULT_STEP_TIME

public static final long DEFAULT_STEP_TIME
See Also:
Constant Field Values
Constructor Detail

Activity

public Activity(long duration)
Creates a new Activity.

Parameters:
duration - the length of this activity. A value of INFINITY indicates an infinite running time.
See Also:
Activity(long, long, long)

Activity

public Activity(long duration,
                long stepTime)
Creates a new Activity.

Parameters:
duration - the length of this activity. A value of INFINITY indicates an infinite running time.
stepTime - the delay time between steps of this activity
See Also:
Activity(long, long, long)

Activity

public Activity(long duration,
                long stepTime,
                long startTime)
Creates a new Activity.

Parameters:
duration - the length of this activity. A value of INFINITY indicates an infinite running time.
stepTime - the delay time between steps of this activity
startTime - the time at which this activity should begin
Method Detail

run

public void run()
Schedules this Activity to start immediately.


runAt

public void runAt(long startTime)
Schedules this Activity for the specified startTime, overwriting the Activity's currently set startTime.

Parameters:
startTime - the time at which the activity should run

runAfter

public void runAfter(Activity before)
Schedules this Activity to start immediately after another Activity. This Activity will be scheduled to start immediately after the first one finishes, overwriting any previously set startTime. If the first Activity is cancelled, this one will not run. This functionality is provided by using an ActivityListener to monitor the first Activity. The listener is removed upon completion or cancellation of the first Activity. This method does not in any way affect the scheduling of the first Activity. If the first Activity is never scheduled, this Activity will correspondingly never be run unless scheduled by a separate scheduling call.

Parameters:
before - the Activity that must finish before this one starts

alwaysRunAfter

public void alwaysRunAfter(Activity before)
Schedules this Activity to start immediately after another Activity. This Activity will be scheduled to start immediately after the first one finishes, overwriting any previously set startTime. If the first Activity is cancelled, this one will not run. This functionality is provided by using an ActivityListener to monitor the first Activity. The listener will persist across mulitple runs, meaning the second Activity will always be evoked upon a successful finish of the first. This method does not in any way affect the scheduling of the first Activity. If the first Activity is never scheduled, this Activity will correspondingly never be run unless scheduled by a separate scheduling call.

Parameters:
before - the Activity that must finish before this one starts

run

protected abstract void run(long elapsedTime)
Run this activity one step. Subclasses should override this method to specify the actions this activity should perform.

Parameters:
elapsedTime - the time elapsed since the start of the activity.

cancel

public void cancel()
Cancels this activity, if scheduled. This will stop a running activity, and will remove the activity from the ActivityManager's schedule.


isScheduled

public boolean isScheduled()
Indicates if this activity is currently scheduled with the ActivityManager

Returns:
true if scheduled, false otherwise

isRunning

public boolean isRunning()
Indicates if this activity is currently running.

Returns:
true if running, false otherwise

addActivityListener

public void addActivityListener(ActivityListener l)
Add an ActivityListener to monitor this activity's events.

Parameters:
l - the ActivityListener to add

removeActivityListener

public void removeActivityListener(ActivityListener l)
Remove a registered ActivityListener

Parameters:
l - the ActivityListener to remove

fireActivityScheduled

protected void fireActivityScheduled()

fireActivityStarted

protected void fireActivityStarted()

fireActivityStepped

protected void fireActivityStepped()

fireActivityFinished

protected void fireActivityFinished()

fireActivityCancelled

protected void fireActivityCancelled()

getPace

public double getPace(long elapsedTime)
Returns a value between 0 and 1 inclusive, indicating the current position in an animation or other similarly parameterized activity. The returned value is determined by consulting this Activity's pacing function.

Parameters:
elapsedTime - the time in milliseconds since the start of this Activity.
Returns:
a value between 0 and 1 indicating the current position in an animation.
See Also:
getPacingFunction()

getPacingFunction

public Pacer getPacingFunction()
Returns the pacing function associated with this Activity. Pacing functions are used to control the pace of animations.

Returns:
this Activity's pacing function. A value of null indicates a basic, linear pace is used, moving from 0 to 1 uniformly over time.

setPacingFunction

public void setPacingFunction(Pacer pfunc)
Sets the pacing function associated with this Activity. Pacing functions are used to control the pace of animations.

Parameters:
pfunc - this Activity's new pacing function, or null to indicate a basic, linear pace moving from 0 to 1 uniformly over time.

getStopTime

public long getStopTime()
Get the time at which this activity should complete.

Returns:
the stopping time for this activity, or Long.MAX_VALUE if this activity should run indefinitely.

getNextTime

public long getNextTime()
Get the time at which this activity should be run next.

Returns:
the time this activity should run next

getDuration

public long getDuration()
Returns the duration of this activity

Returns:
the duration of this activity, in milliseconds

setDuration

public void setDuration(long duration)
Set the duration of this activity

Parameters:
duration - The new duration, in milliseconds, for this activity. A value of INFINITY indicates that this activity should run indefinitely.

getStartTime

public long getStartTime()
Returns this activity's start time

Returns:
the starting time for this activity

setStartTime

public void setStartTime(long time)
Sets this activity's start time

Parameters:
time - the new starting time for this activity

getStepTime

public long getStepTime()
Returns the delay between runs for this activity

Returns:
the step time between runs of this activity

setStepTime

public void setStepTime(long time)
Sets the delay between runs for this activity

Parameters:
time - the new step time between runs of this activity

isEnabled

public boolean isEnabled()
Indicates whether or not this activity is currently enabled.

Returns:
true if enabled, false otherwise

setEnabled

public void setEnabled(boolean s)
Sets whether this component is enabled.

Parameters:
s - true to enable component, false to disable it


Copyright © 2007 Regents of the University of California