fr.lri.swingstates.animations
Class AnimationTranslateTo

java.lang.Object
  extended by fr.lri.swingstates.animations.Animation
      extended by fr.lri.swingstates.animations.AnimationTranslateTo

public class AnimationTranslateTo
extends Animation

An animation that translates a CElement to a given location in one second by translating smoothly this CElement every 40 milliseconds.

Author:
Caroline Appert

Field Summary
 
Fields inherited from class fr.lri.swingstates.animations.Animation
FUNCTION_LINEAR, FUNCTION_SIGMOID, INFINITE_NUMBER_OF_LAPS
 
Constructor Summary
AnimationTranslateTo(double xTarget, double yTarget)
          Builds a "translateTo" animation.
 
Method Summary
 void doStart()
          Method called when this animation is started.
 double getTranslateXTarget()
           
 double getTranslateYTarget()
           
 Animation setAnimatedElement(CElement ce)
          Sets the CElement that must be animated by this animation.
 AnimationTranslateTo setTranslateTarget(double xTarget, double yTarget)
          Sets the final location.
 void step(double t)
          Override this abstract to specify the effect of this animation.
 
Methods inherited from class fr.lri.swingstates.animations.Animation
addTag, addTag, doResume, doStop, doSuspend, getAnimated, getDelay, getLapDuration, getNbLaps, getPacingFunction, hasTag, hasTag, isStarted, isSuspended, removeTag, removeTag, resetAnimationManager, resume, setCanvas, setDelay, setFunction, setLapDuration, setNbLaps, start, stop, suspend
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimationTranslateTo

public AnimationTranslateTo(double xTarget,
                            double yTarget)
Builds a "translateTo" animation.

Parameters:
xTarget - The x of the final position.
yTarget - The y of the final position.
Method Detail

step

public void step(double t)
Override this abstract to specify the effect of this animation.

Specified by:
step in class Animation
Parameters:
t - The parameter of this animation.

doStart

public void doStart()
Method called when this animation is started. This method does nothing. It can be redefined in derived classes.

Overrides:
doStart in class Animation
See Also:
Animation.start()

setAnimatedElement

public Animation setAnimatedElement(CElement ce)
Sets the CElement that must be animated by this animation. If the canvas that must received animation events has not yet been set, it is set to the canvas to which belongs this CElement.

Overrides:
setAnimatedElement in class Animation
Parameters:
ce - The CElement to animate.
Returns:
this animation.

getTranslateXTarget

public double getTranslateXTarget()
Returns:
the x-coordinate of the final location.

getTranslateYTarget

public double getTranslateYTarget()
Returns:
the y-coordinate of the final location.

setTranslateTarget

public AnimationTranslateTo setTranslateTarget(double xTarget,
                                               double yTarget)
Sets the final location.

Parameters:
xTarget - The x-coordinate of the final location.
yTarget - The y-coordinate of the final location.
Returns:
this animation.