fr.inria.insitu.glite.activities
Class InterpolatingActivity

java.lang.Object
  extended by fr.inria.insitu.glite.activities.Activity
      extended by fr.inria.insitu.glite.activities.InterpolatingActivity
Direct Known Subclasses:
AnimateBoundsActivity, AnimateColorsActivity

public class InterpolatingActivity
extends Activity

InterpolatingActivity 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 fr.inria.insitu.glite.activities.Activity
Activity.ActivityDelegate
 
Field Summary
static int DESTINATION_TO_SOURCE
          Constant specifying that the interpolation goes from destination to source.
static int SOURCE_TO_DESTINATION
          Constant specifying that the interpolation goes from source to destination.
static int SOURCE_TO_DESTINATION_TO_SOURCE
          Constant specifying that the interpolation goes from source to destination and then back to source.
 
Fields inherited from class fr.inria.insitu.glite.activities.Activity
DEFAULT_ACTIVITY_STEP_RATE, TERMINATE_AND_FINISH, TERMINATE_AND_FINISH_IF_STEPPING, TERMINATE_WITHOUT_FINISHING
 
Constructor Summary
InterpolatingActivity(long duration, long stepRate)
          Constructor.
InterpolatingActivity(long duration, long stepRate, int loopCount, int mode)
          Constructor.
InterpolatingActivity(long duration, long stepRate, long startTime, int loopCount, int mode)
          Create a new InterpolatingActivity.
 
Method Summary
 float computeSlowInSlowOut(float zeroToOne)
          Computes the Slow In/Slow Out.
 boolean getFirstLoop()
           
 int getLoopCount()
           
 int getMode()
           
 boolean getSlowInSlowOut()
           
 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.
 void setSlowInSlowOut(boolean isSlowInSlowOut)
           
 void terminate()
          Stop this activity immediately, and remove it from the activity scheduler.
 
Methods inherited from class fr.inria.insitu.glite.activities.Activity
getActivityScheduler, getDelegate, getDuration, getNextStepTime, getStartTime, getStepRate, getStopTime, isStepping, processStep, setActivityScheduler, setDelegate, setStartTime, setStepRate, start, startAfter, stop, terminate, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCE_TO_DESTINATION

public static final int SOURCE_TO_DESTINATION
Constant specifying that the interpolation goes from source to destination.

See Also:
Constant Field Values

DESTINATION_TO_SOURCE

public static final int DESTINATION_TO_SOURCE
Constant specifying that the interpolation goes from destination to source.

See Also:
Constant Field Values

SOURCE_TO_DESTINATION_TO_SOURCE

public static final int SOURCE_TO_DESTINATION_TO_SOURCE
Constant specifying that the interpolation goes from source to destination and then back to source.

See Also:
Constant Field Values
Constructor Detail

InterpolatingActivity

public InterpolatingActivity(long duration,
                             long stepRate)
Constructor.

Parameters:
duration - the activity duraction
stepRate - the stepping rate

InterpolatingActivity

public InterpolatingActivity(long duration,
                             long stepRate,
                             int loopCount,
                             int mode)
Constructor.

Parameters:
duration - the activity duraction
stepRate - the stepping rate
loopCount - the number of loops
mode - the interpolating mode, either SOURCE_TO_DESTINATION, DESTINATION_TO_SOURCE or SOURCE_TO_DESTINATION_TO_SOURCE.

InterpolatingActivity

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

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 Activity
Parameters:
aDuration - the amount of time that this activity should take to complete

getMode

public int getMode()
Returns:
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.

Parameters:
mode - the interpolating mode, either SOURCE_TO_DESTINATION, DESTINATION_TO_SOURCE or SOURCE_TO_DESTINATION_TO_SOURCE.

getLoopCount

public int getLoopCount()
Returns:
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.

Parameters:
loopCount - the count

getFirstLoop

public boolean getFirstLoop()
Returns:
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.

Parameters:
firstLoop - set to true if the activity is executing its first loop

getSlowInSlowOut

public boolean getSlowInSlowOut()
Returns:
true if the interpolating does Slow In/Slow Out

setSlowInSlowOut

public void setSlowInSlowOut(boolean isSlowInSlowOut)
Parameters:
isSlowInSlowOut - @return true if the interpolating should do Slow In/Slow Out

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 Activity

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.

Parameters:
zeroToOne - value varying from 0 to 1

computeSlowInSlowOut

public float computeSlowInSlowOut(float zeroToOne)
Computes the Slow In/Slow Out.

Parameters:
zeroToOne - the current linear interpolation parameter
Returns:
the corrected parameter taking into account Slow In/Slot Out


Copyright © 2006 by Jean-Daniel Fekete and INRIA, France All rights reserved.