Package swingtree.animation
Class LifeSpan
java.lang.Object
swingtree.animation.LifeSpan
The lifespan defines when an
This object is intended to be accessed as part of an
Animation starts and for how long it should run.
It consists of a start time and LifeTime, which defines a delay, interval and duration.
This object is intended to be accessed as part of an
AnimationStatus within
an Animation and is typically used to decide how an animation should behave.-
Method Summary
Modifier and TypeMethodDescriptionstatic LifeSpanendingNowWith(LifeTime lifeTime) Creates a lifespan that ends now and has the specified lifetime.booleanlonggetEndTimeIn(TimeUnit unit, long iteration) Returns the end time of the specified iteration in the given time unit.longgetStartTimeIn(TimeUnit unit) Returns the time when the animation should start in the given time unit.inthashCode()booleanAllows you to check whether the animation is expired or not.lifeTime()static LifeSpanstartingNowWith(LifeTime lifeTime) Creates a lifespan that starts now and has the specified lifetime.static LifeSpanstartingNowWithOffset(long offset, TimeUnit unit, LifeTime lifeTime) Creates a lifespan that starts after the specified offset starting from now and has the specified lifetime.longtoString()
-
Method Details
-
startingNowWith
Creates a lifespan that starts now and has the specified lifetime.- Parameters:
lifeTime- The lifetime of the animation.- Returns:
- A lifespan that starts now and has the specified lifetime.
-
startingNowWithOffset
Creates a lifespan that starts after the specified offset starting from now and has the specified lifetime.- Parameters:
offset- The offset from now when the animation should start.unit- The time unit of the offset.lifeTime- The lifetime of the animation.- Returns:
- A lifespan that starts after the specified offset from now, with the specified lifetime.
-
endingNowWith
Creates a lifespan that ends now and has the specified lifetime.- Parameters:
lifeTime- The lifetime of the animation.- Returns:
- A lifespan that ends now and has the specified lifetime.
-
lifeTime
-
startTime
public long startTime() -
getStartTimeIn
Returns the time when the animation should start in the given time unit.- Parameters:
unit- The time unit in which the start time should be returned.- Returns:
- The time when the animation should start.
-
getEndTimeIn
Returns the end time of the specified iteration in the given time unit. The end time is the time when the animation is scheduled to be finished. This is essentially the start time plus the duration of the animation times the provided iteration number.- Parameters:
unit- The time unit in which the end time should be returned.iteration- The iteration for which the end time should be determined and returned.- Returns:
- The end time of the specified iteration in the given time unit.
-
isExpired
public boolean isExpired()Allows you to check whether the animation is expired or not. An animation is considered expired if the current time is greater than the start time plus the duration of the animation.- Returns:
trueif the animation is expired,falseotherwise.
-
equals
-
hashCode
public int hashCode() -
toString
-