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.
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 Details

    • startingNowWith

      public static LifeSpan startingNowWith(LifeTime lifeTime)
      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

      public static LifeSpan startingNowWithOffset(long offset, TimeUnit unit, LifeTime lifeTime)
      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

      public static LifeSpan endingNowWith(LifeTime lifeTime)
      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

      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