Package com.luciad.view.animation
Class ALcdAnimation
java.lang.Object
com.luciad.view.animation.ALcdAnimation
- All Implemented Interfaces:
ILcdAnimation
- Direct Known Subclasses:
TLcdAnimation
Convenience class for implementing animations, including
ILcdView based animations.
It has only one abstract method: setTimeImpl(double) for updating the animation.
To customize the timing of the animation, you can supply an
Interpolator.
Additionally, you can override isLoop() to implement looping animations, and
override the empty start(), stop(), and restart() implementations
to do additional bookkeeping and cleanup, such as handling a canceled animation.
You can supply any number of
ILcdView objects at construction time. ALcdAnimation makes sure
to invalidate them when setTime(double) is invoked.- Since:
- 2012.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplementations of this interface transform the relative progress of the animation (between 0 and 1 with respect to the animation's duration). -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedALcdAnimation(double aDuration, ILcdView... aView) Creates a new animation with the given duration.protectedALcdAnimation(ILcdView... aView) Creates a new animation of one second. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the duration of this animation in seconds.Returns theALcdAnimation.Interpolatorof thisALcdAnimation.protected static doubleinterpolate(double aStart, double aTarget, double aFraction) Interpolates linearly between the two given values.booleanisLoop()If true,ALcdAnimationManagerwill play this animation repeatedly until it is explicitly terminated.voidrestart()Called byALcdAnimationManagerwhen this animation is looped and needs to start a new loop.voidsetInterpolator(ALcdAnimation.Interpolator aInterpolator) Updates the interpolator of thisALcdAnimation.final voidsetTime(double aTime) Updates the animation in function of the time elapsed since its start.protected abstract voidsetTimeImpl(double aTime) Performs the actual updates that are necessary to progress the animation to the given time.voidstart()Called byALcdAnimationManagerwhen this animation is added to the manager and needs to starts playing.voidstop()Called byALcdAnimationManagerwhen this animation is removed from the manager and needs to stops playing.
-
Constructor Details
-
ALcdAnimation
Creates a new animation of one second. The given views will be invalidated whensetTime(double)is called. By default theALcdAnimation.Interpolatorof the newALcdAnimationinstance is set toALcdAnimation.Interpolator.LINEAR.- Parameters:
aView- the given views.
-
ALcdAnimation
Creates a new animation with the given duration. The given views will be invalidated whensetTime(double)is called. By default theALcdAnimation.Interpolatorof the newALcdAnimationinstance is set toALcdAnimation.Interpolator.LINEAR.- Parameters:
aDuration- the duration of the animation (in seconds)aView- the given views.
-
-
Method Details
-
getInterpolator
Returns theALcdAnimation.Interpolatorof thisALcdAnimation.- Returns:
- the
ALcdAnimation.Interpolatorof thisALcdAnimation
-
setInterpolator
Updates the interpolator of thisALcdAnimation.- Parameters:
aInterpolator- the new interpolator for thisALcdAnimation.- Throws:
IllegalArgumentException- whenaInterpolatorequals null.
-
setTime
public final void setTime(double aTime) Updates the animation in function of the time elapsed since its start. This implementation uses the interpolator and callssetTimeImpl(double)to perform the actual update of the animation. AllILcdViewobjects provided at construction time are invalidated.- Specified by:
setTimein interfaceILcdAnimation- Parameters:
aTime- the duration (in seconds) for which the animation has been running
-
setTimeImpl
protected abstract void setTimeImpl(double aTime) Performs the actual updates that are necessary to progress the animation to the given time.- Parameters:
aTime- the duration (in seconds) for which the animation has been running
-
interpolate
protected static double interpolate(double aStart, double aTarget, double aFraction) Interpolates linearly between the two given values.- Parameters:
aStart- the first valueaTarget- the second valueaFraction- the difference between the first value and the interpolated value relative to the difference between the first and the second value- Returns:
- the linearly interpolated value
-
getDuration
public double getDuration()Description copied from interface:ILcdAnimationReturns the duration of this animation in seconds. The duration of this animation should be a strictly positive finite value.- Specified by:
getDurationin interfaceILcdAnimation- Returns:
- the duration of this animation in seconds
-
isLoop
public boolean isLoop()Description copied from interface:ILcdAnimationIf true,ALcdAnimationManagerwill play this animation repeatedly until it is explicitly terminated. Each successive playback will be surrounded with a call toILcdAnimation.start()andILcdAnimation.stop().- Specified by:
isLoopin interfaceILcdAnimation- Returns:
- true if the animation should repeat, false if it should play once and then terminate
-
restart
public void restart()Description copied from interface:ILcdAnimationCalled byALcdAnimationManagerwhen this animation is looped and needs to start a new loop.- Specified by:
restartin interfaceILcdAnimation
-
start
public void start()Description copied from interface:ILcdAnimationCalled byALcdAnimationManagerwhen this animation is added to the manager and needs to starts playing.- Specified by:
startin interfaceILcdAnimation
-
stop
public void stop()Description copied from interface:ILcdAnimationCalled byALcdAnimationManagerwhen this animation is removed from the manager and needs to stops playing.- Specified by:
stopin interfaceILcdAnimation
-