edu.umd.cs.jazz.animation
Class ZStrokeAnimation

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

public class ZStrokeAnimation
extends ZAnimation

ZStrokeAnimation animates an object conforming to the ZStroke interface from a source stroke to a destination stroke 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 the stroke of a rectangle from width 0 to width 5.


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

 canvas.getLayer().addChild(aLeaf);

 // 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 a stroke with width 0 to a stroke with width 5.
 ZStrokeAnimation aStrokeAnimation = new ZStrokeAnimation(new BasicStroke(0), new BasicStroke(5));

 // Set the target of the animation.
 aStrokeAnimation.setStrokeTarget(aRect);

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

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

Author:
Jesse Grosjean
See Also:
ZAlpha

Constructor Summary
ZStrokeAnimation(java.awt.BasicStroke aSource, java.awt.BasicStroke aDestination)
          Construct a new ZStrokeAnimation.
 
Method Summary
protected  void animateFrameForTime(long aTime)
          Animate one frame of this animation for the given time.
 java.awt.BasicStroke getDestinationStroke()
          Return the destination stroke, the stroke that the animation will end at.
 java.awt.BasicStroke getSourceStroke()
          Return the source stroke, the stroke that the animation will start at.
 ZStroke getStrokeTarget()
          Return the target of this stroke animation.
 void setDestinationStroke(java.awt.BasicStroke aStroke)
          Set the destination stroke, the stroke that the animation will end at.
 void setSourceStroke(java.awt.BasicStroke aStroke)
          Set the source stroke, the stroke that the animation will start at.
 void setStrokeTarget(ZStroke aTarget)
          Set the target of this stroke 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

ZStrokeAnimation

public ZStrokeAnimation(java.awt.BasicStroke aSource,
                        java.awt.BasicStroke aDestination)
Construct a new ZStrokeAnimation.

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

getSourceStroke

public java.awt.BasicStroke getSourceStroke()
Return the source stroke, the stroke that the animation will start at.


setSourceStroke

public void setSourceStroke(java.awt.BasicStroke aStroke)
Set the source stroke, the stroke that the animation will start at.


getDestinationStroke

public java.awt.BasicStroke getDestinationStroke()
Return the destination stroke, the stroke that the animation will end at.


setDestinationStroke

public void setDestinationStroke(java.awt.BasicStroke aStroke)
Set the destination stroke, the stroke that the animation will end at.


getStrokeTarget

public ZStroke getStrokeTarget()
Return the target of this stroke animation. This is the object who's setStroke method will be called for each frame of the animation.


setStrokeTarget

public void setStrokeTarget(ZStroke aTarget)
Set the target of this stroke animation. This is the object who's setStroke 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 paramater is used to generate an alpha value, which is then used to create a new stroke interpolated between the source and destination strokes. The stroke 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.