edu.umd.cs.piccolo.activities
Class PTransformActivity

java.lang.Object
  extended by edu.umd.cs.piccolo.activities.PActivity
      extended by edu.umd.cs.piccolo.activities.PInterpolatingActivity
          extended by edu.umd.cs.piccolo.activities.PTransformActivity

public class PTransformActivity
extends PInterpolatingActivity

PTransformActivity interpolates between two transforms setting its target's transform as it goes. See PNode. animate*() for an example of this activity in used. The source transform is retrieved from the target just before the animation is scheduled to start.

Version:
1.0
Author:
Jesse Grosjean

Nested Class Summary
static interface PTransformActivity.Target
          Target Objects that want to get transformed by the transform activity must implement this interface.
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.activities.PActivity
PActivity.PActivityDelegate
 
Field Summary
 
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
PTransformActivity(long duration, long stepRate, int loopCount, int mode, PTransformActivity.Target target, java.awt.geom.AffineTransform destination)
          Create a new PTransformActivity.
PTransformActivity(long duration, long stepRate, PTransformActivity.Target target)
          Constructs a transform activity that will last for the specified duration, will update at the given step rate and will be applied to the target.
PTransformActivity(long duration, long stepRate, PTransformActivity.Target target, java.awt.geom.AffineTransform destination)
          Constructs a activity that will change the target's transform in the destination transform.
 
Method Summary
protected  void activityStarted()
          Is invoked when the activity is started.
 double[] getDestinationTransform()
          Return the final transform that will be set on the transform activities target when the transform activity stops stepping.
protected  boolean isAnimation()
          Whether each step invalidates paint.
 void setDestinationTransform(double[] newDestination)
          Set the final transform that will be set on the transform activities target when the transform activity stops stepping.
 void setRelativeTargetValue(float zeroToOne)
          Set's the target value to be the interpolation between the source and destination transforms.
 
Methods inherited from class edu.umd.cs.piccolo.activities.PInterpolatingActivity
activityFinished, 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
 

Constructor Detail

PTransformActivity

public PTransformActivity(long duration,
                          long stepRate,
                          PTransformActivity.Target target)
Constructs a transform activity that will last for the specified duration, will update at the given step rate and will be applied to the target. Requires that the developer follow up with a setDestinationTransform call, otherwise the transition is undefined.

Parameters:
duration - duration in milliseconds of the entire activity
stepRate - interval in milliseconds between successive animation steps
target - the target of the activity

PTransformActivity

public PTransformActivity(long duration,
                          long stepRate,
                          PTransformActivity.Target target,
                          java.awt.geom.AffineTransform destination)
Constructs a activity that will change the target's transform in the destination transform. It will last for the specified duration, will update at the given step rate.

Parameters:
duration - duration in milliseconds of the entire activity
stepRate - interval in milliseconds between successive animation steps
target - the target of the activity
destination - transform that the target will be after the ativity is finished

PTransformActivity

public PTransformActivity(long duration,
                          long stepRate,
                          int loopCount,
                          int mode,
                          PTransformActivity.Target target,
                          java.awt.geom.AffineTransform destination)
Create a new PTransformActivity.

Parameters:
duration - the length of one loop of the activity
stepRate - the amount of time between steps of the activity
loopCount - number of times the activity should reschedule itself
mode - defines how the activity interpolates between states
target - the object that the activity will be applied to and where the source state will be taken from.
destination - the destination color state
Method Detail

isAnimation

protected boolean isAnimation()
Whether each step invalidates paint.

Overrides:
isAnimation in class PActivity
Returns:
true since a node transform affects it's node's display

getDestinationTransform

public double[] getDestinationTransform()
Return the final transform that will be set on the transform activities target when the transform activity stops stepping.

Returns:
returns the final transform as an array of doubles

setDestinationTransform

public void setDestinationTransform(double[] newDestination)
Set the final transform that will be set on the transform activities target when the transform activity stops stepping.

Parameters:
newDestination - an array of doubles representing the destination transform

activityStarted

protected void activityStarted()
Is invoked when the activity is started. Ensures that setTransform is called on the target even before the first step.

Overrides:
activityStarted in class PInterpolatingActivity

setRelativeTargetValue

public void setRelativeTargetValue(float zeroToOne)
Set's the target value to be the interpolation between the source and destination transforms. A value of 0 for zeroToOne means that the target should have the source transform. A value of 1 for zeroToOne means that the target should have the destination transform.

Overrides:
setRelativeTargetValue in class PInterpolatingActivity
Parameters:
zeroToOne - how far along the activity has progressed. 0 = not at all, 1 = completed


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.