Class SwingLooper

java.lang.Object
org.vanted.animation.loopers.Looper
org.vanted.animation.loopers.SwingLooper

public class SwingLooper
extends Looper
Reverses the animation after it goes forward. (Reverses when the loop number is an odd number)
TODO: The SwingLooper only behaves properly for loop durations that are longer than the largest time value in the animation's data point list.
Author:
- Patrick Shaw
  • Constructor Details

    • SwingLooper

      public SwingLooper()
  • Method Details

    • findPreviousIndex

      public <V,​ T extends TimePoint<V>> int findPreviousIndex​(List<T> dataPoints, int oldPreviousIndex, int currentLoopNumber, double time)
      Description copied from class: Looper
      (Provided this method is not overridden) Finds the largest index, from a set of data points, who's getTime() method is <= time.
      Overrides:
      findPreviousIndex in class Looper
      Type Parameters:
      V - The type of data value that the data point holds.
      T - The type of data point that the interpolator is interpolating for.
      Parameters:
      dataPoints - The set of data points that the interpolator is interpolating on
      oldPreviousIndex - The old index that was being used before this method was called
      currentLoopNumber - The current loop number of the animation
      time - The time that has elapsed since the start of the animation loop.
      Returns:
      The largest index from a set of data points, who's getTime() return value is <= time.
      See Also:
      TimePoint.getTime()
    • getTimeSinceStartOfLoop

      public double getTimeSinceStartOfLoop​(int currentLoopNumber, double startTime, double loopDuration, double time)
      Description copied from class: Looper
      Calculates the time since the start of the loop
      Overrides:
      getTimeSinceStartOfLoop in class Looper
      Parameters:
      currentLoopNumber - The animation's loop number.
      Returns:
      The time since the start of the animation's current loop.
    • getNextLoopPreviousIndex

      public <V,​ T extends TimePoint<V>> int getNextLoopPreviousIndex​(List<T> dataPoints, int newLoopNumber)
      Description copied from class: Looper
      Specifies what the previousIndex animation should be set to when it starts a new loop.
      Overrides:
      getNextLoopPreviousIndex in class Looper
      Parameters:
      dataPoints - The set of data points that the interpolator is interpolating on.
      newLoopNumber - The animation's new loop number.
      Returns:
      The new previousIndex value of the Animation.