public abstract class Interpolator extends Object
interpolate
methods, which are
used to calculate interpolated values. Various built-in implementations of
this class are offered. Applications may choose to implement their own
Interpolator
to get custom interpolation behavior.
A custom Interpolator
has to be defined in terms of a "
curve()
".
Modifier and Type | Field and Description |
---|---|
static Interpolator |
DISCRETE
Built-in interpolator that provides discrete time interpolation.
|
static Interpolator |
EASE_BOTH
Built-in interpolator instance that provides ease in/out behavior.
|
static Interpolator |
EASE_IN
Built-in interpolator instance that provides ease in behavior.
|
static Interpolator |
EASE_OUT
Built-in interpolator instance that provides ease out behavior.
|
static Interpolator |
LINEAR
Built-in interpolator that provides linear time interpolation.
|
Modifier | Constructor and Description |
---|---|
protected |
Interpolator()
The constructor of
Interpolator . |
Modifier and Type | Method and Description |
---|---|
protected abstract double |
curve(double t)
Mapping from [0.0..1.0] to itself.
|
boolean |
interpolate(boolean startValue,
boolean endValue,
double fraction)
This method takes two
boolean values along with a
fraction between 0.0 and 1.0 and returns the
interpolated value. |
double |
interpolate(double startValue,
double endValue,
double fraction)
This method takes two
double values along with a fraction
between 0.0 and 1.0 and returns the interpolated value. |
int |
interpolate(int startValue,
int endValue,
double fraction)
This method takes two
int values along with a fraction
between 0.0 and 1.0 and returns the interpolated value. |
long |
interpolate(long startValue,
long endValue,
double fraction)
This method takes two
int values along with a fraction
between 0.0 and 1.0 and returns the interpolated value. |
Object |
interpolate(Object startValue,
Object endValue,
double fraction)
This method takes two
Objects along with a fraction
between 0.0 and 1.0 and returns the interpolated value. |
static Interpolator |
SPLINE(double x1,
double y1,
double x2,
double y2)
Creates an
Interpolator , which curve() is
shaped using the spline control points defined by (x1 , y1
) and (x2 , y2 ). |
static Interpolator |
TANGENT(Duration t,
double v)
Creates a tangent interpolator, for which in-tangent and out-tangent are
identical.
|
static Interpolator |
TANGENT(Duration t1,
double v1,
Duration t2,
double v2)
Create a tangent interpolator.
|
public static final Interpolator DISCRETE
interpolate()
is endValue
only when the
input fraction
is 1.0, and startValue
otherwise.public static final Interpolator LINEAR
interpolate()
is startValue
+ (endValue
- startValue
) * fraction
.public static final Interpolator EASE_BOTH
An ease-both interpolator will make an animation start slow, then accelerate and slow down again towards the end, all in a smooth manner.
The implementation uses the algorithm for easing defined in SMIL 3.0 with an acceleration and deceleration factor of 0.2, respectively.
public static final Interpolator EASE_IN
An ease-in interpolator will make an animation start slow and then accelerate smoothly.
The implementation uses the algorithm for easing defined in SMIL 3.0 with an acceleration factor of 0.2.
public static final Interpolator EASE_OUT
An ease-out interpolator will make an animation slow down toward the end smoothly.
The implementation uses the algorithm for easing defined in SMIL 3.0 with an deceleration factor of 0.2.
public static Interpolator SPLINE(double x1, double y1, double x2, double y2)
Interpolator
, which curve()
is
shaped using the spline control points defined by (x1
, y1
) and (x2
, y2
). The anchor points of the spline are
implicitly defined as (0.0
, 0.0
) and (1.0
,
1.0
).x1
- x coordinate of the first control pointy1
- y coordinate of the first control pointx2
- x coordinate of the second control pointy2
- y coordinate of the second control pointpublic static Interpolator TANGENT(Duration t1, double v1, Duration t2, double v2)
Timeline
.
If used in a KeyFrame
after a KeyFrame that has different interpolator,
it's treated as if the out-tangent of that KeyFrame was equal to the value in the KeyFrame.
The parameters define the tangent of the animation curve for the in tangent (before a key frame) and out tangent (after a key frame). Each tangent is specified with a pair, the distance to the key frame and the value of the tangent at this moment.
The interpolation then follows a bezier curve, with 2 control points defined by the specified tangent and positioned at 1/3 of the duration before the second KeyFrame or after the first KeyFrame. See the picture above.
t1
- The delta time of the in-tangent, relative to the KeyFramev1
- The value of the in-tangentt2
- The delta time of the out-tangent, relative to the KeyFramev2
- The value of the out-tangentpublic static Interpolator TANGENT(Duration t, double v)
Timeline
, because for these key frames only one tangent is
used.t
- The delta time of the tangentv
- The value of the tangentTANGENT(Duration, double, Duration, double)
public Object interpolate(Object startValue, Object endValue, double fraction)
Objects
along with a fraction
between 0.0
and 1.0
and returns the interpolated value.
If both Objects
implement Number
, their values are
interpolated. If startValue
implements Interpolatable
the
calculation defined in interpolate()
is used. If neither of these conditions are met, a
discrete interpolation is used, i.e. endValue
is returned if and
only if fraction
is 1.0
, otherwise startValue
is
returned.
Before calculating the interpolated value, the fraction is altered
according to the function defined in curve()
.
startValue
- start valueendValue
- end valuefraction
- a value between 0.0 and 1.0public boolean interpolate(boolean startValue, boolean endValue, double fraction)
boolean
values along with a
fraction
between 0.0
and 1.0
and returns the
interpolated value.
Before calculating the interpolated value, the fraction is altered
according to the function defined in curve()
.
startValue
- the first data pointendValue
- the second data pointfraction
- the fraction in [0.0...1.0]
public double interpolate(double startValue, double endValue, double fraction)
double
values along with a fraction
between 0.0
and 1.0
and returns the interpolated value.
Before calculating the interpolated value, the fraction is altered
according to the function defined in curve()
.
startValue
- the first data pointendValue
- the second data pointfraction
- the fraction in [0.0...1.0]
public int interpolate(int startValue, int endValue, double fraction)
int
values along with a fraction
between 0.0
and 1.0
and returns the interpolated value.
Before calculating the interpolated value, the fraction is altered
according to the function defined in curve()
.
startValue
- the first data pointendValue
- the second data pointfraction
- the fraction in [0.0...1.0]
public long interpolate(long startValue, long endValue, double fraction)
int
values along with a fraction
between 0.0
and 1.0
and returns the interpolated value.
Before calculating the interpolated value, the fraction is altered
according to the function defined in curve()
.
startValue
- the first data pointendValue
- the second data pointfraction
- the fraction in [0.0...1.0]
protected abstract double curve(double t)
t
- time, but normalized to the range [0.0..1.0], where 0.0 is the
start of the current interval, while 1.0 is the end of the
current interval. Usually a function that increases
monotonically.Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.