Package swingtree.animation
Class Animatable<M>
java.lang.Object
swingtree.animation.Animatable<M>
- Type Parameters:
M
- The type of the model that is continuously transformed by theAnimationTransformation
.
This defines what is needed for animating an immutable
value type
T
through a transformation function
AnimationTransformation
and a LifeTime
determining
when the animation should run.
It is essentially just an immutable wrapper for T
,
AnimationTransformation
and a LifeTime
.
An Animatable
is designed to be provided by an immutable
view model to animate its properties using the UIFactoryMethods.animate(Var, Animatable)
or UIFactoryMethods.animate(Var, Function)
methods.
Where the Var
property is used as the mutable animation state
and the animatable defines how the property item should be transformed
repeatedly during the iterations of the entire animation lifetime.
-
Method Summary
Modifier and TypeMethodDescriptionanimator()
Returns the transformation function that is called repeatedly during the lifetime of the animation to transform the item of aVar
property when passed to theUIFactoryMethods.animate(Var, Animatable)
method.boolean
int
hashCode()
Returns the initial value of the animation or an emptyOptional
if no initial value is set.lifeTime()
Returns theLifeTime
of the animation, which is used byUIFactoryMethods.animate(Var, Animatable)
to determine for how long the animation should run.static <T> Animatable
<T> none()
static <T> Animatable
<T> of
(LifeTime lifeTime, AnimationTransformation<T> animation) Returns anAnimatable
instance that is used to transformT
values using the suppliedAnimationTransformation
function during the specifiedLifeTime
.static <T> Animatable
<T> of
(LifeTime lifeTime, T initialValue, AnimationTransformation<T> animation) Returns anAnimatable
instance that animates the supplied value through the providedAnimationTransformation
function during the specifiedLifeTime
starting with the supplied initial value as initial application/animation state.static <T> Animatable
<T> of
(T value) Returns anAnimatable
instance that merely holds the supplied value and does nothing when run due to a no-op transformation function and aLifeTime
ofLifeTime.none()
.toString()
-
Method Details
-
none
Returns anAnimatable
instance that does nothing when run due to aLifeTime
ofLifeTime.none()
. This is equivalent to a no-op and may also be used instead ofnull
in cases where anAnimatable
is expected.- Type Parameters:
T
- The type of model that is animated.- Returns:
- An
Animatable
instance that does nothing.
-
of
Returns anAnimatable
instance that merely holds the supplied value and does nothing when run due to a no-op transformation function and aLifeTime
ofLifeTime.none()
.
You can think of this as an instantaneous animation to the specified value as the first and final state of the "animation".- Type Parameters:
T
- The type of model used as new animation/application state.- Parameters:
value
- The value that should be used for setting the new application/animator state.- Returns:
- An
Animatable
instance that only holds a single animation state, which is the supplied value. - Throws:
NullPointerException
- If the supplied value isnull
.
-
of
public static <T> Animatable<T> of(LifeTime lifeTime, T initialValue, AnimationTransformation<T> animation) Returns anAnimatable
instance that animates the supplied value through the providedAnimationTransformation
function during the specifiedLifeTime
starting with the supplied initial value as initial application/animation state.- Type Parameters:
T
- The type of model that is animated.- Parameters:
lifeTime
- The lifetime of the animation.initialValue
- The initial value of the animation.animation
- The transformation function that is called repeatedly during the lifetime of the animation.- Returns:
- An
Animatable
instance that animates the supplied value. - Throws:
NullPointerException
- If any of the arguments isnull
.- See Also:
-
of
Returns anAnimatable
instance that is used to transformT
values using the suppliedAnimationTransformation
function during the specifiedLifeTime
.- Type Parameters:
T
- The type model that is animated.- Parameters:
lifeTime
- The lifetime of the animation.animation
- The transformation function that is called repeatedly during the lifetime of the animation.- Returns:
- An
Animatable
instance that animates the supplied value. - Throws:
NullPointerException
- If any of the arguments isnull
.- See Also:
-
lifeTime
Returns theLifeTime
of the animation, which is used byUIFactoryMethods.animate(Var, Animatable)
to determine for how long the animation should run.- Returns:
- The
LifeTime
of the animation.
-
initialState
Returns the initial value of the animation or an emptyOptional
if no initial value is set. This is the value that is used as the initial state of the animation before the first transformation is applied.
If there is no initial value set, the result of the first transformation is used as the initial state of the animation.- Returns:
- The initial model instance of the animation state or an empty
Optional
. - See Also:
-
animator
Returns the transformation function that is called repeatedly during the lifetime of the animation to transform the item of aVar
property when passed to theUIFactoryMethods.animate(Var, Animatable)
method.- Returns:
- The transformation function of the animation.
-
toString
-
hashCode
public int hashCode() -
equals
-