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
Modifier and TypeClassDescriptionstatic interface
Implementations of this interface transform the relative progress of the animation (between 0 and 1 with respect to the animation's duration). -
Constructor Summary
ModifierConstructorDescriptionprotected
ALcdAnimation
(double aDuration, ILcdView... aView) Creates a new animation with the given duration.protected
ALcdAnimation
(ILcdView... aView) Creates a new animation of one second. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Returns the duration of this animation in seconds.Returns theALcdAnimation.Interpolator
of thisALcdAnimation
.protected static double
interpolate
(double aStart, double aTarget, double aFraction) Interpolates linearly between the two given values.boolean
isLoop()
If true,ALcdAnimationManager
will play this animation repeatedly until it is explicitly terminated.void
restart()
Called byALcdAnimationManager
when this animation is looped and needs to start a new loop.void
setInterpolator
(ALcdAnimation.Interpolator aInterpolator) Updates the interpolator of thisALcdAnimation
.final void
setTime
(double aTime) Updates the animation in function of the time elapsed since its start.protected abstract void
setTimeImpl
(double aTime) Performs the actual updates that are necessary to progress the animation to the given time.void
start()
Called byALcdAnimationManager
when this animation is added to the manager and needs to starts playing.void
stop()
Called byALcdAnimationManager
when 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.Interpolator
of the newALcdAnimation
instance 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.Interpolator
of the newALcdAnimation
instance is set toALcdAnimation.Interpolator.LINEAR
.- Parameters:
aDuration
- the duration of the animation (in seconds)aView
- the given views.
-
-
Method Details
-
getInterpolator
Returns theALcdAnimation.Interpolator
of thisALcdAnimation
.- Returns:
- the
ALcdAnimation.Interpolator
of thisALcdAnimation
-
setInterpolator
Updates the interpolator of thisALcdAnimation
.- Parameters:
aInterpolator
- the new interpolator for thisALcdAnimation
.- Throws:
IllegalArgumentException
- whenaInterpolator
equals 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. AllILcdView
objects provided at construction time are invalidated.- Specified by:
setTime
in 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:ILcdAnimation
Returns the duration of this animation in seconds. The duration of this animation should be a strictly positive finite value.- Specified by:
getDuration
in interfaceILcdAnimation
- Returns:
- the duration of this animation in seconds
-
isLoop
public boolean isLoop()Description copied from interface:ILcdAnimation
If true,ALcdAnimationManager
will play this animation repeatedly until it is explicitly terminated. Each successive playback will be surrounded with a call toILcdAnimation.start()
andILcdAnimation.stop()
.- Specified by:
isLoop
in 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:ILcdAnimation
Called byALcdAnimationManager
when this animation is looped and needs to start a new loop.- Specified by:
restart
in interfaceILcdAnimation
-
start
public void start()Description copied from interface:ILcdAnimation
Called byALcdAnimationManager
when this animation is added to the manager and needs to starts playing.- Specified by:
start
in interfaceILcdAnimation
-
stop
public void stop()Description copied from interface:ILcdAnimation
Called byALcdAnimationManager
when this animation is removed from the manager and needs to stops playing.- Specified by:
stop
in interfaceILcdAnimation
-