edu.umd.cs.piccolox.activities
Class PPositionPathActivity

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
              extended by edu.umd.cs.piccolox.activities.PPositionPathActivity

public class PPositionPathActivity
extends PPathActivity

PPositionPathActivity animates through a sequence of points.

Version:
1.0
Author:
Jesse Grosjean

Nested Class Summary
static interface PPositionPathActivity.Target
          Interface that objects must conform to in order to have their position animated.
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.activities.PActivity
PActivity.PActivityDelegate
 
Field Summary
protected  Point2D[] positions
          Points that define the animation's path.
protected  PPositionPathActivity.Target target
          An abstract representation of the thing being positioned.
 
Fields inherited from class edu.umd.cs.piccolox.activities.PPathActivity
knots
 
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
PPositionPathActivity(long duration, long stepRate, int loopCount, int mode, PPositionPathActivity.Target target, float[] knots, Point2D[] positions)
          Constructs a position activity that will repeat the number of times specified.
PPositionPathActivity(long duration, long stepRate, PPositionPathActivity.Target target)
          Constructs a position activity that acts on the given target for the duration provided and will update it's position at the given stepRate.
PPositionPathActivity(long duration, long stepRate, PPositionPathActivity.Target target, float[] knots, Point2D[] positions)
          Constructs a position activity that acts on the given target for the duration provided and will update it's position at the given stepRate.
 
Method Summary
 Point2D getPosition(int index)
          Returns the point at the given index.
 Point2D[] getPositions()
          Returns a copy of the path's points.
protected  boolean isAnimation()
          Returns true since this activity modifies the view and so cause a repaint.
 void setPosition(int index, Point2D position)
          Sets the position of the point at the given index.
 void setPositions(GeneralPath path)
          Extracts positions from a GeneralPath and uses them to define this activity's animation points.
 void setPositions(Point2D[] positions)
          Changes all positions that define where along the target is being positioned during the animation.
 void setRelativeTargetValue(float zeroToOne, int startKnot, int endKnot)
          Overridden to interpret position at correct point along animation.
 
Methods inherited from class edu.umd.cs.piccolox.activities.PPathActivity
getKnot, getKnots, getKnotsLength, setKnot, setKnots, setRelativeTargetValue
 
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, 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

positions

protected Point2D[] positions
Points that define the animation's path.


target

protected PPositionPathActivity.Target target
An abstract representation of the thing being positioned.

Constructor Detail

PPositionPathActivity

public PPositionPathActivity(long duration,
                             long stepRate,
                             PPositionPathActivity.Target target)
Constructs a position activity that acts on the given target for the duration provided and will update it's position at the given stepRate.

Parameters:
duration - milliseconds of animation
stepRate - milliseconds between successive position updates
target - abstract representation of thing being animated

PPositionPathActivity

public PPositionPathActivity(long duration,
                             long stepRate,
                             PPositionPathActivity.Target target,
                             float[] knots,
                             Point2D[] positions)
Constructs a position activity that acts on the given target for the duration provided and will update it's position at the given stepRate. It will follow the path defined by the knots and positions arguments.

Parameters:
duration - milliseconds of animation
stepRate - milliseconds between successive position updates
target - abstract representation of thing being animated
knots - timing to use when animating
positions - points along the path

PPositionPathActivity

public PPositionPathActivity(long duration,
                             long stepRate,
                             int loopCount,
                             int mode,
                             PPositionPathActivity.Target target,
                             float[] knots,
                             Point2D[] positions)
Constructs a position activity that will repeat the number of times specified. It will act on the given target for the duration provided and will update it's position at the given stepRate. It will follow the path defined by the knots and positions arguments.

Parameters:
duration - milliseconds of animation
stepRate - milliseconds between successive position updates
loopCount - number of times this activity should repeat
mode - how easing is handled on this activity
target - abstract representation of thing being animated
knots - timing to use when animating
positions - points along the path
Method Detail

isAnimation

protected boolean isAnimation()
Returns true since this activity modifies the view and so cause a repaint.

Overrides:
isAnimation in class PActivity
Returns:
always true

getPositions

public Point2D[] getPositions()
Returns a copy of the path's points.

Returns:
array of points on the path

getPosition

public Point2D getPosition(int index)
Returns the point at the given index.

Parameters:
index - desired position index
Returns:
point at the given index

setPositions

public void setPositions(Point2D[] positions)
Changes all positions that define where along the target is being positioned during the animation.

Parameters:
positions - new animation positions

setPosition

public void setPosition(int index,
                        Point2D position)
Sets the position of the point at the given index.

Parameters:
index - index of the point to change
position - point defining the new position

setPositions

public void setPositions(GeneralPath path)
Extracts positions from a GeneralPath and uses them to define this activity's animation points.

Parameters:
path - source of points

setRelativeTargetValue

public void setRelativeTargetValue(float zeroToOne,
                                   int startKnot,
                                   int endKnot)
Overridden to interpret position at correct point along animation. TODO: improve these comments

Specified by:
setRelativeTargetValue in class PPathActivity
Parameters:
zeroToOne - how far along the activity we are
startKnot - the index of the startKnot
endKnot - the index of the endKnot


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.