public class TLcdAnimation extends ALcdAnimation
ILcdAnimation
which is lambda-friendly.
ALcdAnimation.setTime(double)
method is implemented by delegating to a
Consumer<double>
, which can be supplied to the constructor
of this class using a lambda. Similarly, the
start()
and stop()
methods are delegated to
a pair of Runnable
s also supplied at construction time.ALcdAnimation.Interpolator
Constructor and Description |
---|
TLcdAnimation(double aDuration,
boolean aLoop,
Consumer<Double> aFunction,
ILcdView... aViews)
Creates an animation which uses the given
Consumer in its
ALcdAnimation.setTime(double) method. |
TLcdAnimation(double aDuration,
boolean aLoop,
Consumer<Double> aFunction,
Runnable aBefore,
Runnable aAfter,
ILcdView... aViews)
Same as
TLcdAnimation(double, boolean, Consumer, ILcdView...) , but also takes
two runnables that are executed by start() and stop() . |
Modifier and Type | Method and Description |
---|---|
double |
getDuration()
Returns the duration of this animation in seconds.
|
boolean |
isLoop()
If true,
ALcdAnimationManager will play this animation repeatedly
until it is explicitly terminated. |
void |
restart()
|
protected void |
setTimeImpl(double aTime)
Invokes the
Consumer passed to the constructor of this class. |
void |
start()
Calls the runnable passed to
TLcdAnimation(double, boolean, Consumer, Runnable, Runnable, ILcdView...) . |
void |
stop()
Calls the runnable passed to
TLcdAnimation(double, boolean, Consumer, Runnable, Runnable, ILcdView...) . |
getInterpolator, interpolate, setInterpolator, setTime
public TLcdAnimation(double aDuration, boolean aLoop, Consumer<Double> aFunction, ILcdView... aViews)
Consumer
in its
ALcdAnimation.setTime(double)
method. The start()
and stop()
methods are empty when using this constructor.aDuration
- the duration of the animation in secondsaLoop
- true if the animation should loopaFunction
- implementation of setTime()
, must not be nullaViews
- the views that are affected by this animationpublic TLcdAnimation(double aDuration, boolean aLoop, Consumer<Double> aFunction, Runnable aBefore, Runnable aAfter, ILcdView... aViews)
TLcdAnimation(double, boolean, Consumer, ILcdView...)
, but also takes
two runnables that are executed by start()
and stop()
.aDuration
- the duration of the animation in secondsaLoop
- true if the animation should loopaFunction
- implementation of setTime()
, must not be nullaBefore
- executed when the animation starts, must not be nullaAfter
- executed when the animation stops, must not be nullaViews
- the views that are affected by this animationpublic double getDuration()
ILcdAnimation
getDuration
in interface ILcdAnimation
getDuration
in class ALcdAnimation
public void start()
TLcdAnimation(double, boolean, Consumer, Runnable, Runnable, ILcdView...)
.start
in interface ILcdAnimation
start
in class ALcdAnimation
public void stop()
TLcdAnimation(double, boolean, Consumer, Runnable, Runnable, ILcdView...)
.stop
in interface ILcdAnimation
stop
in class ALcdAnimation
public boolean isLoop()
ILcdAnimation
ALcdAnimationManager
will play this animation repeatedly
until it is explicitly terminated. Each successive playback will be
surrounded with a call to ILcdAnimation.start()
and ILcdAnimation.stop()
.isLoop
in interface ILcdAnimation
isLoop
in class ALcdAnimation
protected void setTimeImpl(double aTime)
Consumer
passed to the constructor of this class. The parameter
passed to the consumer is aTime / getDuration()
, i.e. a value between 0 and
1.setTimeImpl
in class ALcdAnimation
aTime
- the duration (in seconds) for which the animation has been runningpublic void restart()
restart
in interface ILcdAnimation
restart
in class ALcdAnimation