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 aVarproperty when passed to theUIFactoryMethods.animate(Var, Animatable)method.booleaninthashCode()Returns the initial value of the animation or an emptyOptionalif no initial value is set.lifeTime()Returns theLifeTimeof 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 anAnimatableinstance that is used to transformTvalues using the suppliedAnimationTransformationfunction during the specifiedLifeTime.static <T> Animatable<T> of(LifeTime lifeTime, T initialValue, AnimationTransformation<T> animation) Returns anAnimatableinstance that animates the supplied value through the providedAnimationTransformationfunction during the specifiedLifeTimestarting with the supplied initial value as initial application/animation state.static <T> Animatable<T> of(T value) Returns anAnimatableinstance that merely holds the supplied value and does nothing when run due to a no-op transformation function and aLifeTimeofLifeTime.none().toString()
-
Method Details
-
none
Returns anAnimatableinstance that does nothing when run due to aLifeTimeofLifeTime.none(). This is equivalent to a no-op and may also be used instead ofnullin cases where anAnimatableis expected.- Type Parameters:
T- The type of model that is animated.- Returns:
- An
Animatableinstance that does nothing.
-
of
Returns anAnimatableinstance that merely holds the supplied value and does nothing when run due to a no-op transformation function and aLifeTimeofLifeTime.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
Animatableinstance 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 anAnimatableinstance that animates the supplied value through the providedAnimationTransformationfunction during the specifiedLifeTimestarting 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
Animatableinstance that animates the supplied value. - Throws:
NullPointerException- If any of the arguments isnull.- See Also:
-
of
Returns anAnimatableinstance that is used to transformTvalues using the suppliedAnimationTransformationfunction 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
Animatableinstance that animates the supplied value. - Throws:
NullPointerException- If any of the arguments isnull.- See Also:
-
lifeTime
Returns theLifeTimeof the animation, which is used byUIFactoryMethods.animate(Var, Animatable)to determine for how long the animation should run.- Returns:
- The
LifeTimeof the animation.
-
initialState
Returns the initial value of the animation or an emptyOptionalif 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 aVarproperty when passed to theUIFactoryMethods.animate(Var, Animatable)method.- Returns:
- The transformation function of the animation.
-
toString
-
hashCode
public int hashCode() -
equals
-