edu.umd.cs.piccolox.activities
Class PPathActivity

java.lang.Object
  extended by edu.umd.cs.piccolo.activities.PActivity
      extended by edu.umd.cs.piccolo.activities.PInterpolatingActivity
          extended by edu.umd.cs.piccolox.activities.PPathActivity
Direct Known Subclasses:
PPositionPathActivity

public abstract class PPathActivity
extends PInterpolatingActivity

PPathActivity is the abstract base class for all path activity interpolators. Path activities interpolate between multiple states over the duration of the activity.

Knots are used to determine when in time the activity should move from state to state. Knot values should be increasing in value from 0 to 1 inclusive. This class is based on the Java 3D PathInterpolator object, see that class documentation for more information on the basic concepts used in this classes design.

See PPositionPathActivity for a concrete path activity that will animate through a list of points.

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
protected  float[] knots
          The "knots" that define this path's activity timing through its activity and should be an monotonously increasing array starting where each value is >=0 and ending at 1f.
 
Fields inherited from class edu.umd.cs.piccolo.activities.PInterpolatingActivity
DESTINATION_TO_SOURCE, SOURCE_TO_DESTINATION, 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
PPathActivity(long duration, long stepRate, float[] knots)
          Constructs a PPathActivity that will last the specified duration, will animate every stepRate and will progress according to the knots provided.
PPathActivity(long duration, long stepRate, int loopCount, int mode, float[] knots)
          Constructs a PPathActivity that will repeat the specified number of times, last the specified duration, will animate every stepRate and will progress according to the knots provided.
 
Method Summary
 float getKnot(int index)
          Returns the value of the knot at the given index.
 float[] getKnots()
          Return the knots that define the timing of this activity.
 int getKnotsLength()
          Returns the number of knots that define the timing of this activity.
 void setKnot(int index, float knot)
          Changes the knot at the given index.
 void setKnots(float[] newKnots)
          Changes the knots that define the timing of this activity.
 void setRelativeTargetValue(float zeroToOne)
          Sets the target's value taking knot timing into account.
abstract  void setRelativeTargetValue(float zeroToOne, int startKnot, int endKnot)
          An abstract method that allows subclasses to define what target value matches the given progress and knots.
 
Methods inherited from class edu.umd.cs.piccolo.activities.PInterpolatingActivity
activityFinished, activityStarted, activityStep, computeSlowInSlowOut, getFirstLoop, getLoopCount, getMode, getSlowInSlowOut, setDuration, setFirstLoop, setLoopCount, setMode, setRelativeTargetValueAdjustingForMode, setSlowInSlowOut, terminate
 
Methods inherited from class edu.umd.cs.piccolo.activities.PActivity
getActivityScheduler, getDelegate, getDuration, getNextStepTime, getStartTime, getStepRate, getStopTime, isAnimation, isStepping, paramString, processStep, setActivityScheduler, setDelegate, setStartTime, setStepRate, startAfter, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

knots

protected float[] knots
The "knots" that define this path's activity timing through its activity and should be an monotonously increasing array starting where each value is >=0 and ending at 1f.

Constructor Detail

PPathActivity

public PPathActivity(long duration,
                     long stepRate,
                     float[] knots)
Constructs a PPathActivity that will last the specified duration, will animate every stepRate and will progress according to the knots provided.

Parameters:
duration - duration in milliseconds that this activity should last
stepRate - interval in milliseconds between animation steps
knots - array defining the speed of the animation alongs it's animation

PPathActivity

public PPathActivity(long duration,
                     long stepRate,
                     int loopCount,
                     int mode,
                     float[] knots)
Constructs a PPathActivity that will repeat the specified number of times, last the specified duration, will animate every stepRate and will progress according to the knots provided.

Parameters:
duration - duration in milliseconds that this activity should last
stepRate - interval in milliseconds between animation steps
knots - array defining the speed of the animation alongs it's animation
loopCount - # of times activity should repeat
mode - controls easing of the activity
Method Detail

getKnotsLength

public int getKnotsLength()
Returns the number of knots that define the timing of this activity.

Returns:
# of knots

setKnots

public void setKnots(float[] newKnots)
Changes the knots that define the timing of this activity.

Parameters:
newKnots - the new knots to assign to this activity

getKnots

public float[] getKnots()
Return the knots that define the timing of this activity.

Returns:
new knots

setKnot

public void setKnot(int index,
                    float knot)
Changes the knot at the given index.

Parameters:
index - index of knot to change
knot - new value to assign to the knot

getKnot

public float getKnot(int index)
Returns the value of the knot at the given index.

Parameters:
index - index of desired knot
Returns:
value of knot at given index

setRelativeTargetValue

public void setRelativeTargetValue(float zeroToOne)
Sets the target's value taking knot timing into account.

Overrides:
setRelativeTargetValue in class PInterpolatingActivity
Parameters:
zeroToOne - how much of this activity has elapsed 0=none, 1=completed

setRelativeTargetValue

public abstract void setRelativeTargetValue(float zeroToOne,
                                            int startKnot,
                                            int endKnot)
An abstract method that allows subclasses to define what target value matches the given progress and knots.

Parameters:
zeroToOne - how far between the knots the activity is
startKnot - knot that defines the start of this particular interpolation
endKnot - knot that defines the end of this particular interpolation


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.