edu.umd.cs.piccolo.activities
Class PInterpolatingActivity

java.lang.Object
  extended by edu.umd.cs.piccolo.activities.PActivity
      extended by edu.umd.cs.piccolo.activities.PInterpolatingActivity
Direct Known Subclasses:
PColorActivity, PPathActivity, PTransformActivity

public class PInterpolatingActivity
extends PActivity

PInterpolatingActivity interpolates between two states (source and destination) over the duration of the activity. The interpolation can be either linear or slow- in, slow-out.

The mode determines how the activity interpolates between the two states. The default mode interpolates from source to destination, but you can also go from destination to source, and from source to destination to source.

A loopCount of greater then one will make the activity reschedule itself when it has finished. This makes the activity loop between the two states.

Version:
1.0
Author:
Jesse Grosjean

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.activities.PActivity
PActivity.PActivityDelegate
 
Field Summary
static int DESTINATION_TO_SOURCE
           
static int SOURCE_TO_DESTINATION
           
static int SOURCE_TO_DESTINATION_TO_SOURCE
           
 
Fields inherited from class edu.umd.cs.piccolo.activities.PActivity
TERMINATE_AND_FINISH, TERMINATE_AND_FINISH_IF_STEPPING, TERMINATE_WITHOUT_FINISHING
 
Constructor Summary
PInterpolatingActivity(long duration, long stepRate)
           
PInterpolatingActivity(long duration, long stepRate, int loopCount, int mode)
           
PInterpolatingActivity(long duration, long stepRate, long startTime, int loopCount, int mode)
          Create a new PInterpolatingActivity.
 
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.
 float computeSlowInSlowOut(float zeroToOne)
           
 boolean getFirstLoop()
          Return true if the activity is executing its first loop.
 int getLoopCount()
          Return the number of times the activity should automatically reschedule itself after it has finished.
 int getMode()
          Return the mode that defines how the activity interpolates between states.
 boolean getSlowInSlowOut()
           
protected  java.lang.String paramString()
          Returns a string representing the state of this node.
 void setDuration(long aDuration)
          Set the amount of time that this activity should take to complete, after the startStepping method is called.
 void setFirstLoop(boolean firstLoop)
          Set if the activity is executing its first loop.
 void setLoopCount(int loopCount)
          Set the number of times the activity should automatically reschedule itself after it has finished.
 void setMode(int mode)
          Set the mode that defines how the activity interpolates between states.
 void setRelativeTargetValue(float zeroToOne)
          Subclasses should override this method and set the value on their target (the object that they are modifying) accordingly.
protected  void setRelativeTargetValueAdjustingForMode(float zeroToOne)
           
 void setSlowInSlowOut(boolean isSlowInSlowOut)
           
 void terminate()
          Stop this activity immediately, and remove it from the activity scheduler.
 
Methods inherited from class edu.umd.cs.piccolo.activities.PActivity
getActivityScheduler, getDelegate, getDuration, getNextStepTime, getStartTime, getStepRate, getStopTime, isAnimation, isStepping, processStep, setActivityScheduler, setDelegate, setStartTime, setStepRate, startAfter, terminate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCE_TO_DESTINATION

public static final int SOURCE_TO_DESTINATION
See Also:
Constant Field Values

DESTINATION_TO_SOURCE

public static final int DESTINATION_TO_SOURCE
See Also:
Constant Field Values

SOURCE_TO_DESTINATION_TO_SOURCE

public static final int SOURCE_TO_DESTINATION_TO_SOURCE
See Also:
Constant Field Values
Constructor Detail

PInterpolatingActivity

public PInterpolatingActivity(long duration,
                              long stepRate)

PInterpolatingActivity

public PInterpolatingActivity(long duration,
                              long stepRate,
                              int loopCount,
                              int mode)

PInterpolatingActivity

public PInterpolatingActivity(long duration,
                              long stepRate,
                              long startTime,
                              int loopCount,
                              int mode)
Create a new PInterpolatingActivity.

Parameters:
duration - the length of one loop of the activity
stepRate - the amount of time between steps of the activity
startTime - the time (relative to System.currentTimeMillis()) that this activity should start.
loopCount - number of times the activity should reschedule itself
mode - defines how the activity interpolates between states
Method Detail

setDuration

public void setDuration(long aDuration)
Set the amount of time that this activity should take to complete, after the startStepping method is called. The duration must be greater then zero so that the interpolation value can be computed.

Overrides:
setDuration in class PActivity

getMode

public int getMode()
Return the mode that defines how the activity interpolates between states.


setMode

public void setMode(int mode)
Set the mode that defines how the activity interpolates between states.


getLoopCount

public int getLoopCount()
Return the number of times the activity should automatically reschedule itself after it has finished.


setLoopCount

public void setLoopCount(int loopCount)
Set the number of times the activity should automatically reschedule itself after it has finished.


getFirstLoop

public boolean getFirstLoop()
Return true if the activity is executing its first loop. Subclasses normally initialize their source state on the first loop.


setFirstLoop

public void setFirstLoop(boolean firstLoop)
Set if the activity is executing its first loop. Subclasses normally initialize their source state on the first loop. This method will rarely need to be called, unless your are reusing activities.


getSlowInSlowOut

public boolean getSlowInSlowOut()

setSlowInSlowOut

public void setSlowInSlowOut(boolean isSlowInSlowOut)

activityStarted

protected void activityStarted()
Description copied from class: PActivity
This method is called right before an activity is scheduled to start running. After this method is called step() will be called until the activity finishes.

Overrides:
activityStarted in class PActivity

activityStep

protected void activityStep(long elapsedTime)
Description copied from class: PActivity
This is the method that most activities override to perform their behavior. It will be called repeatedly when the activity is running.

Overrides:
activityStep in class PActivity
Parameters:
elapsedTime - the amount of time that has passed relative to the activities startTime.

activityFinished

protected void activityFinished()
Description copied from class: PActivity
This method is called after an activity is has finished running and the activity has been removed from the PActivityScheduler queue.

Overrides:
activityFinished in class PActivity

terminate

public void terminate()
Stop this activity immediately, and remove it from the activity scheduler. If this activity is currently running then stoppedStepping will be called after it has been removed from the activity scheduler.

Overrides:
terminate in class PActivity

setRelativeTargetValue

public void setRelativeTargetValue(float zeroToOne)
Subclasses should override this method and set the value on their target (the object that they are modifying) accordingly.


computeSlowInSlowOut

public float computeSlowInSlowOut(float zeroToOne)

setRelativeTargetValueAdjustingForMode

protected void setRelativeTargetValueAdjustingForMode(float zeroToOne)

paramString

protected java.lang.String paramString()
Returns a string representing the state of this node. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overrides:
paramString in class PActivity
Returns:
a string representation of this node's state


Copyright 2005 by University of Maryland, College Park, MD 20742, USA All rights reserved.

Web Accessibility