edu.umd.cs.jazz.animation
Class ZTransformAnimation

java.lang.Object
  |
  +--edu.umd.cs.jazz.animation.ZAnimation
        |
        +--edu.umd.cs.jazz.animation.ZTransformAnimation

public class ZTransformAnimation
extends ZAnimation

ZTransformAnimation animates an object conforming to the ZTransformable interface from a source transform to a destination transform over time. A ZAlpha class is used to specify the start time, duration, and acceleration time for this animation.

This code demonstrates how to animate a rectangle from position 0, 0 to 300, 300.


 ZRectangle aRect = new ZRectangle(0, 0, 100, 100);
 ZVisualLeaf aLeaf = new ZVisualLeaf(aRect);

 // The animation will apply to the transform group decorating the aLeaf node.
 ZTransformGroup aTarget = aLeaf.editor().getTransformGroup();

 canvas.getLayer().addChild(aTarget);

 // Create a new ZAlpha that will run from the current time for 1.5 seconds.
 // This alpha will change linearly; see the ZAlpha class to learn how to create
 // slow in slow out animation effects.
 ZAlpha alpha = new ZAlpha(1, 1500);

 // Create the ZTransformAnimation with its source and destination values. Here
 // we choose to animate the target from its current transform, to the identity transform
 // translated by 300, 300.
 AffineTransform souceTransform = aTarget.getTransform();
 AffineTransform destinationTransform = AffineTransform.getTranslateInstance(300, 300);
 ZTransformAnimation aTransformAnimation = new ZTransformAnimation(souceTransform, destinationTransform);

 // Set the target of the animation.
 aTransformAnimation.setTransformTarget(aTarget);

 // Set the alpha value for the animation. This animation will start immediately,
 // and run for 1.5 seconds.
 aTransformAnimation.setAlpha(alpha);

 // Start the animation by registering it with the ZAnimationScheduler.
 aTransformAnimation.play();
 

Author:
Jesse Grosjean
See Also:
ZAlpha

Constructor Summary
ZTransformAnimation(java.awt.geom.AffineTransform aSource, java.awt.geom.AffineTransform aDestination)
          Construct a new ZTransformAnimation.
ZTransformAnimation(double[] aSource, double[] aDestination)
          Construct a new ZTransformAnimation.
 
Method Summary
protected  void animateFrameForTime(long aTime)
          Animate one frame of this animation for the given time.
 double[] getDestinationTransform()
          Return the destination transform matrix , the transform matrix that the animation will end up at.
 double[] getSourceTransform()
          Return the source transform matrix, the transform matrix that the animation will start at.
 ZTransformable getTransformTarget()
          Return the target of this transform animation.
 void setDestinationTransform(double[] aDestination)
          Set the destination transform matrix, the transform matrix that the animation will end up at.
 void setSourceTransform(double[] aSource)
          Set the source transform matrix, the transform matrix that the animation will start at.
 void setTransformTarget(ZTransformable aTarget)
          Set the target of this transform animation.
 
Methods inherited from class edu.umd.cs.jazz.animation.ZAnimation
animationRateByElapsedFrames, animationRateByElapsedTime, animationRateByNextFrame, animationStarted, animationStopped, getAlpha, isStopped, play, scheduleNextFrame, scheduleNextFrame, setAlpha, setStartedRunnable, setStoppedRunnable, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZTransformAnimation

public ZTransformAnimation(double[] aSource,
                           double[] aDestination)
Construct a new ZTransformAnimation.

Parameters:
aSource - the source transform matrix that the animation will start at.
aDestination - the destination transform matrix that the animation will end at.

ZTransformAnimation

public ZTransformAnimation(java.awt.geom.AffineTransform aSource,
                           java.awt.geom.AffineTransform aDestination)
Construct a new ZTransformAnimation.

Parameters:
aSource - the source transform that the animation will start at.
aDestination - the destination transform that the animation will end at.
Method Detail

getSourceTransform

public double[] getSourceTransform()
Return the source transform matrix, the transform matrix that the animation will start at.


setSourceTransform

public void setSourceTransform(double[] aSource)
Set the source transform matrix, the transform matrix that the animation will start at.


getDestinationTransform

public double[] getDestinationTransform()
Return the destination transform matrix , the transform matrix that the animation will end up at.


setDestinationTransform

public void setDestinationTransform(double[] aDestination)
Set the destination transform matrix, the transform matrix that the animation will end up at.


getTransformTarget

public ZTransformable getTransformTarget()
Return the target of this transform animation. This is the object who's setTransform method will be called for each frame of the animation.


setTransformTarget

public void setTransformTarget(ZTransformable aTarget)
Set the target of this transform animation. This is the object who's setTransform method will be called for each frame of the animation.


animateFrameForTime

protected void animateFrameForTime(long aTime)
Animate one frame of this animation for the given time. The time parameter is used to generate an alpha value, which is then used to create a new transform interpolated between the source and destination transforms. The transform target is then set to this interpolated value.

Overrides:
animateFrameForTime in class ZAnimation


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