Package swingtree.animation
Class AnimationState
java.lang.Object
swingtree.animation.AnimationState
- All Implemented Interfaces:
Progress
The state of an animation at a given point in time describing how far the animation has progressed
using a number between 0 and 1 (see
progress()
).
Use the numbers exposed by the methods of this value based class to define how
your animation should progress over time.-
Method Summary
Modifier and TypeMethodDescriptionstatic AnimationState
endOf
(LifeSpan lifeSpan, Stride stride, ActionEvent event, long iteration) boolean
event()
Exposes the timer event that triggered the animation.int
hashCode()
lifeSpan()
Exposes theLifeSpan
of the animation, which defines when the animation starts, for how long it should run, how is should progress and the refresh rate of the animation.static AnimationState
of
(LifeSpan lifeSpan, Stride stride, ActionEvent event, long now) double
progress()
Exposes the progress of the animation state, which is a number between 0 and 1 that represents how far the animation has progressed between its start and end.long
repeats()
A single iteration of an animation consists of its progress going from 0 to 1 in case of it being progressive, or from 1 to 0 in case of it being regressive (seeStride
).slice
(double from, double to) Slices the progress value of this animation state into a sub-Progress
of the animation which starts with a value of0.0
when the animation reaches the progress valuefrom
and ends with a value of1.0
when the animation reaches the progress valueto
.static AnimationState
startOf
(LifeSpan lifeSpan, Stride stride, ActionEvent event) toString()
-
Method Details
-
of
-
endOf
public static AnimationState endOf(LifeSpan lifeSpan, Stride stride, ActionEvent event, long iteration) -
startOf
-
progress
public double progress()Exposes the progress of the animation state, which is a number between 0 and 1 that represents how far the animation has progressed between its start and end. Note that an animation may also regress, in which case the states will transition from 1 to 0 instead of from 0 to 1. SeeStride
for more information. -
slice
Slices the progress value of this animation state into a sub-Progress
of the animation which starts with a value of0.0
when the animation reaches the progress valuefrom
and ends with a value of1.0
when the animation reaches the progress valueto
. If thefrom
andto
values are invalid, this method will correct them.- Parameters:
from
- The progress value at which the sub-progress should start. This value must be between 0 and 1, otherwise it will be adjusted and a warning will be logged.to
- The progress value at which the sub-progress should end. This value must be between 0 and 1, otherwise it will be adjusted and a warning will be logged.- Returns:
- A
Progress
object that represents the sub-progress of the animation. This sub-progress will start with a value of0.0
when the animation reaches the progress valuefrom
and will end with a value of1.0
when the animation reaches the progress valueto
.
-
repeats
public long repeats()A single iteration of an animation consists of its progress going from 0 to 1 in case of it being progressive, or from 1 to 0 in case of it being regressive (seeStride
). This method returns the number of times the animation has been repeated.- Returns:
- The number of times the animation has been repeated. This number is guaranteed to be 0 at the beginning of the animation, and for most animations it will be 0 at the end of the animation as well. An animation may be repeated if it is explicitly scheduled to run for a longer time.
-
lifeSpan
Exposes theLifeSpan
of the animation, which defines when the animation starts, for how long it should run, how is should progress and the refresh rate of the animation.- Returns:
- The
LifeSpan
of the animation, i.e. the time when the animation started and how long it should run.
-
event
Exposes the timer event that triggered the animation. Note that under the hood, all animations with the same refresh rate will be updated by the same timer and thus share the same event.- Returns:
- The timer event that triggered the animation.
-
toString
-
equals
-
hashCode
public int hashCode()
-