Class Interpolator

java.lang.Object
org.monte.media.av.Interpolator
Direct Known Subclasses:
AbstractSplineInterpolator

public abstract class Interpolator extends Object
A linear interpolator for use in conjunction with an Animator object.
Author:
Werner Randelshofer
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new interpolator which interpolates from 0 to 1 within one second.
    Interpolator(boolean reverse)
    Creates a new interpolator which interpolates into the specified direction within one second.
    Interpolator(float startValue, float endValue)
    Creates a new interpolator which interpolates from the specified start value to the specified end value within one second.
    Interpolator(float startValue, float endValue, long timespan)
    Creates a new interpolator which interpolates from the specified start value to the specified end value within the specified timespan.
    Interpolator(long timespan)
    Creates a new interpolator which interpolates from 0 to 1 within the specified timespan.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    finish(long currentTimeMillis)
    Finishes the interpolation and calls this.notifyAll() allowing other threads to synchronize on isFinished() of the interpolator.
    protected float
    getFraction(float linearFraction)
    Computes a fraction from the specified linear fraction.
    void
    initialize(long currentTimeMillis)
    Initializes the interpolation.
    void
    interpolate(long currentTimeMillis)
    Interpolates with the current time millis.
    boolean
    isElapsed(long currentTimeMillis)
    Returns true, if the timespan of the Interpolator has elapsed since initialize was called.
    boolean
     
    boolean
     
    boolean
    Returns true, if this interpolator replaces interpolations by that interpolator.
    void
    setTimespan(long t)
     
    protected abstract void
    update(float fraction)
    Updates the interpolator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Interpolator

      public Interpolator()
      Creates a new interpolator which interpolates from 0 to 1 within one second.
    • Interpolator

      public Interpolator(long timespan)
      Creates a new interpolator which interpolates from 0 to 1 within the specified timespan.
    • Interpolator

      public Interpolator(boolean reverse)
      Creates a new interpolator which interpolates into the specified direction within one second.
      Parameters:
      reverse - Set this to true, if you want to interpolate from 1 to 0 instead of from 0 to 1.
    • Interpolator

      public Interpolator(float startValue, float endValue)
      Creates a new interpolator which interpolates from the specified start value to the specified end value within one second.
      Parameters:
      startValue - A value between 0 and 1.
      endValue - A value between 0 and 1.
    • Interpolator

      public Interpolator(float startValue, float endValue, long timespan)
      Creates a new interpolator which interpolates from the specified start value to the specified end value within the specified timespan.
      Parameters:
      startValue - A value between 0 and 1.
      endValue - A value between 0 and 1.
      timespan - A timespan in milliseconds.
  • Method Details

    • update

      protected abstract void update(float fraction)
      Updates the interpolator.
      Parameters:
      fraction - An interpolated fraction between 0 and 1.
    • getFraction

      protected float getFraction(float linearFraction)
      Computes a fraction from the specified linear fraction. In the simplest case, this method returns the linear fraction. The returned value must be between 0 and 1.
      Parameters:
      linearFraction - The linear fraction between 0 and 1.
      Returns:
      A computed fraction between 0 and 1.
    • replaces

      public boolean replaces(Interpolator that)
      Returns true, if this interpolator replaces interpolations by that interpolator.
    • initialize

      public void initialize(long currentTimeMillis)
      Initializes the interpolation.

      Once this method has been called, method #finish must be called before the interpolator can be destroyed.

      Parameters:
      currentTimeMillis -
    • isElapsed

      public boolean isElapsed(long currentTimeMillis)
      Returns true, if the timespan of the Interpolator has elapsed since initialize was called.
      Parameters:
      currentTimeMillis - The current time.
      Returns:
      Returns true, if the time since initialize was called is greater or equal the timespan of the interpolator.
    • interpolate

      public void interpolate(long currentTimeMillis)
      Interpolates with the current time millis.
      Parameters:
      currentTimeMillis -
    • finish

      public void finish(long currentTimeMillis)
      Finishes the interpolation and calls this.notifyAll() allowing other threads to synchronize on isFinished() of the interpolator.
      Parameters:
      currentTimeMillis -
    • isFinished

      public boolean isFinished()
    • isSequential

      public boolean isSequential(Interpolator that)
    • setTimespan

      public void setTimespan(long t)