java.lang.Object
org.monte.media.av.Interpolator
- Direct Known Subclasses:
AbstractSplineInterpolator
A linear interpolator for use in conjunction with an Animator object.
- Author:
- Werner Randelshofer
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionvoidfinish(long currentTimeMillis) Finishes the interpolation and calls this.notifyAll() allowing other threads to synchronize on isFinished() of the interpolator.protected floatgetFraction(float linearFraction) Computes a fraction from the specified linear fraction.voidinitialize(long currentTimeMillis) Initializes the interpolation.voidinterpolate(long currentTimeMillis) Interpolates with the current time millis.booleanisElapsed(long currentTimeMillis) Returns true, if the timespan of the Interpolator has elapsed since initialize was called.booleanbooleanisSequential(Interpolator that) booleanreplaces(Interpolator that) Returns true, if this interpolator replaces interpolations by that interpolator.voidsetTimespan(long t) protected abstract voidupdate(float fraction) Updates the interpolator.
-
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
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
-
setTimespan
public void setTimespan(long t)
-