Class LifeSpan

java.lang.Object
swingtree.animation.LifeSpan

@Immutable public final class LifeSpan extends Object
The lifespan defines when 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 as well as a unique id which ensures that two instances of this class are never equal.
This object is intended to be accessed as part of an AnimationState within an Animation and is typically used to decide how an animation should behave.
  • Method Details

    • startingNowWith

      public static LifeSpan startingNowWith(LifeTime lifeTime)
    • startingNowWithOffset

      public static LifeSpan startingNowWithOffset(long offset, TimeUnit unit, LifeTime lifeTime)
    • endingNowWith

      public static LifeSpan endingNowWith(LifeTime lifeTime)
    • lifeTime

      public LifeTime lifeTime()
    • startTime

      public long startTime()
    • getStartTimeIn

      public long getStartTimeIn(TimeUnit unit)
      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

      public long getEndTimeIn(TimeUnit unit, long iteration)
      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:
      true if the animation is expired, false otherwise.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object