APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.animation

public abstract Class Interpolator

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.scenario.animation.LinearInterpolator, com.sun.scenario.animation.NumberTangentInterpolator, com.sun.scenario.animation.SplineInterpolator, com.sun.scenario.animation.StepInterpolator
Imports
javafx.geometry.Point2D, javafx.util.Duration, com.sun.javafx.animation.InterpolatorHelper, com.sun.scenario.animation.LinearInterpolator, .NumberTangentInterpolator, .SplineInterpolator, .StepInterpolator

The abstract class defines several 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()".

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Interpolator.StepPosition

Specifies the step position of a step interpolator.

Field Summary

Modifier and TypeField and Description
public static final Interpolator
DISCRETE

Built-in interpolator that provides discrete time interpolation.

public static final Interpolator
EASE_BOTH

Built-in interpolator instance that provides ease in/out behavior.

public static final Interpolator
EASE_IN

Built-in interpolator instance that provides ease in behavior.

public static final Interpolator
EASE_OUT

Built-in interpolator instance that provides ease out behavior.

private static final double
public static final Interpolator
LINEAR

Built-in interpolator instance that is equivalent to ofLinear([0, 0], [1, 1]).

public static final Interpolator
STEP_END

Built-in interpolator instance that is equivalent to Interpolator.ofSteps(1, StepPosition.END).

public static final Interpolator
STEP_START

Built-in interpolator instance that is equivalent to Interpolator.ofSteps(1, StepPosition.START).

Constructor Summary

AccessConstructor and Description
protected
Interpolator()

The constructor of Interpolator.

Method Summary

Modifier and TypeMethod and Description
private static double
clamp(double t)

protected abstract double

Returns:

the curved value
curve
(double
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.
t
)

Mapping from [0.0..1.0] to itself.

public Object

Returns:

interpolated value
interpolate
(Object
start value
startValue
,
Object
end value
endValue
,
double
a value between 0.0 and 1.0
fraction
)

This method takes two Objects along with a fraction between 0.0 and 1.0 and returns the interpolated value.

public boolean

Returns:

the interpolated value
interpolate
(boolean
the first data point
startValue
,
boolean
the second data point
endValue
,
double
the fraction in [0.0...1.0]
fraction
)

This method takes two boolean values along with a fraction between 0.0 and 1.0 and returns the interpolated value.

public double

Returns:

the interpolated value
interpolate
(double
the first data point
startValue
,
double
the second data point
endValue
,
double
the fraction in [0.0...1.0]
fraction
)

This method takes two double values along with a fraction between 0.0 and 1.0 and returns the interpolated value.

public int

Returns:

the interpolated value
interpolate
(int
the first data point
startValue
,
int
the second data point
endValue
,
double
the fraction in [0.0...1.0]
fraction
)

This method takes two int values along with a fraction between 0.0 and 1.0 and returns the interpolated value.

public long

Returns:

the interpolated value
interpolate
(long
the first data point
startValue
,
long
the second data point
endValue
,
double
the fraction in [0.0...1.0]
fraction
)

This method takes two int values along with a fraction between 0.0 and 1.0 and returns the interpolated value.

public static Interpolator

Returns:

a linear interpolator
ofLinear
(Point2D...
the control points
controlPoints
)

Returns an interpolator that interpolates linearly between its specified control points.

public static Interpolator

Returns:

a spline interpolator
ofSpline
(double
x coordinate of the first control point
x1
,
double
y coordinate of the first control point
y1
,
double
x coordinate of the second control point
x2
,
double
y coordinate of the second control point
y2
)

Returns an Interpolator whose curve() is shaped using the spline control points defined by (x1, y1 ) and (x2, y2).

public static Interpolator

Returns:

a step interpolator
ofSteps
(int
the number of intervals in the step interpolator
intervalCount
,
Interpolator.StepPosition
the StepPosition of the step interpolator
position
)

Returns a step interpolator that divides the input time into a series of intervals, each interval being equal in length, where each interval maps to a constant output time value.

public static Interpolator

Returns:

a tangent interpolator
ofTangent
(Duration
the delta time of the in-tangent, relative to the KeyFrame
t1
,
double
the value of the in-tangent
v1
,
Duration
the delta time of the out-tangent, relative to the KeyFrame
t2
,
double
the value of the out-tangent
v2
)

Returns a tangent interpolator.

public static Interpolator

Returns:

a tangent interpolator
ofTangent
(Duration
the delta time of the tangent
t
,
double
the value of the tangent
v
)

Returns a tangent interpolator, for which in-tangent and out-tangent are identical.

public static Interpolator

Returns:

a spline interpolator
SPLINE
(double
x coordinate of the first control point
x1
,
double
y coordinate of the first control point
y1
,
double
x coordinate of the second control point
x2
,
double
y coordinate of the second control point
y2
)
Deprecated since 26. use ofSpline(double, double, double, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofSpline(double, double, double, double) instead.

public static Interpolator

Returns:

a new step interpolator
STEPS
(int
the number of intervals in the step interpolator
intervalCount
,
Interpolator.StepPosition
the StepPosition of the step interpolator
position
)
Deprecated since 26. use ofSteps(int, StepPosition) instead

This is a legacy method named inconsistently with method naming conventions, use ofSteps(int, StepPosition) instead.

public static Interpolator

Returns:

a tangent interpolator
TANGENT
(Duration
the delta time of the in-tangent, relative to the KeyFrame
t1
,
double
the value of the in-tangent
v1
,
Duration
the delta time of the out-tangent, relative to the KeyFrame
t2
,
double
the value of the out-tangent
v2
)
Deprecated since 26. use ofTangent(Duration, double, Duration, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofTangent(Duration, double, Duration, double) instead.

public static Interpolator

Returns:

a tangent interpolator
TANGENT
(Duration
the delta time of the tangent
t
,
double
the value of the tangent
v
)
Deprecated since 26. use ofTangent(Duration, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofTangent(Duration, double) instead.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DISCRETEback to summary
public static final Interpolator DISCRETE

Built-in interpolator that provides discrete time interpolation. The return value of interpolate() is endValue only when the input fraction is 1.0, and startValue otherwise.

EASE_BOTHback to summary
public static final Interpolator EASE_BOTH

Built-in interpolator instance that provides ease in/out behavior.

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.

EASE_INback to summary
public static final Interpolator EASE_IN

Built-in interpolator instance that provides ease in behavior.

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.

EASE_OUTback to summary
public static final Interpolator EASE_OUT

Built-in interpolator instance that provides ease out behavior.

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.

EPSILONback to summary
private static final double EPSILON
LINEARback to summary
public static final Interpolator LINEAR

Built-in interpolator instance that is equivalent to ofLinear([0, 0], [1, 1]).

STEP_ENDback to summary
public static final Interpolator STEP_END

Built-in interpolator instance that is equivalent to Interpolator.ofSteps(1, StepPosition.END).

Since
23
STEP_STARTback to summary
public static final Interpolator STEP_START

Built-in interpolator instance that is equivalent to Interpolator.ofSteps(1, StepPosition.START).

Since
23

Constructor Detail

Interpolatorback to summary
protected Interpolator()

The constructor of Interpolator.

Method Detail

clampback to summary
private static double clamp(double t)
curveback to summary
protected abstract double curve(double t)

Mapping from [0.0..1.0] to itself.

Parameters
t:double

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.

Returns:double

the curved value

interpolateback to summary
public 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.

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().

Parameters
startValue:Object

start value

endValue:Object

end value

fraction:double

a value between 0.0 and 1.0

Returns:Object

interpolated value

Annotations
@SuppressWarnings:unchecked, rawtypes
interpolateback to summary
public 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.

Before calculating the interpolated value, the fraction is altered according to the function defined in curve().

Parameters
startValue:boolean

the first data point

endValue:boolean

the second data point

fraction:double

the fraction in [0.0...1.0]

Returns:boolean

the interpolated value

interpolateback to summary
public 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.

Before calculating the interpolated value, the fraction is altered according to the function defined in curve().

Parameters
startValue:double

the first data point

endValue:double

the second data point

fraction:double

the fraction in [0.0...1.0]

Returns:double

the interpolated value

interpolateback to summary
public 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.

Before calculating the interpolated value, the fraction is altered according to the function defined in curve().

Parameters
startValue:int

the first data point

endValue:int

the second data point

fraction:double

the fraction in [0.0...1.0]

Returns:int

the interpolated value

interpolateback to summary
public 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.

Before calculating the interpolated value, the fraction is altered according to the function defined in curve().

Parameters
startValue:long

the first data point

endValue:long

the second data point

fraction:double

the fraction in [0.0...1.0]

Returns:long

the interpolated value

ofLinearback to summary
public static Interpolator ofLinear(Point2D... controlPoints)

Returns an interpolator that interpolates linearly between its specified control points.

Each control point associates an input progress value (X) with an output progress value (Y). The input progress value is the normalized progress of the animation, while the output progress value is the normalized progress of the value change. This means that when the time has reached X of the animation, the animation should be at Y of its value change. Both values are specified in normalized coordinates, but are not required to fall within the [0..1] interval.

If the input progress value (X) of a control point is unspecified (Double#NaN), it is distributed evenly between its neighboring control points. If the input progress value of the first or last control point is unspecified, it is set to 0 or 1, respectively.

The control point list is canonicalized so that input progress values (X) are non-decreasing in the order provided. In particular, if a control point specifies an X value that is lower than any preceding control point's X value, it is adjusted to match the greatest preceding X value.

Parameters
controlPoints:Point2D[]

the control points

Returns:Interpolator

a linear interpolator

Exceptions
NullPointerException:
if controlPoints is null
IllegalArgumentException:
if controlPoints contains less than two items
Since
26
ofSplineback to summary
public static Interpolator ofSpline(double x1, double y1, double x2, double y2)

Returns an Interpolator whose 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).

Parameters
x1:double

x coordinate of the first control point

y1:double

y coordinate of the first control point

x2:double

x coordinate of the second control point

y2:double

y coordinate of the second control point

Returns:Interpolator

a spline interpolator

Exceptions
IllegalArgumentException:
if x1 or x2 is outside of [0, 1]
Since
26
ofStepsback to summary
public static Interpolator ofSteps(int intervalCount, Interpolator.StepPosition position)

Returns a step interpolator that divides the input time into a series of intervals, each interval being equal in length, where each interval maps to a constant output time value. The output time value is determined by the StepPosition.

Parameters
intervalCount:int

the number of intervals in the step interpolator

position:Interpolator.StepPosition

the StepPosition of the step interpolator

Returns:Interpolator

a step interpolator

Exceptions
IllegalArgumentException:
if intervals is less than 1, or if intervals is less than 2 when position is StepPosition#NONE
NullPointerException:
if position is null
Since
26
ofTangentback to summary
public static Interpolator ofTangent(Duration t1, double v1, Duration t2, double v2)

Returns a tangent interpolator. A tangent interpolator allows to define the behavior of an animation curve very precisely by defining the tangents close to a key frame. A tangent interpolator defines the behavior to the left and to the right of a key frame, therefore it is only useful within a 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.

A tangent interpolator
defines the behavior to the left and to the right of a key frame,
therefore it is only useful within a Timeline

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.

Parameters
t1:Duration

the delta time of the in-tangent, relative to the KeyFrame

v1:double

the value of the in-tangent

t2:Duration

the delta time of the out-tangent, relative to the KeyFrame

v2:double

the value of the out-tangent

Returns:Interpolator

a tangent interpolator

Since
26
ofTangentback to summary
public static Interpolator ofTangent(Duration t, double v)

Returns a tangent interpolator, for which in-tangent and out-tangent are identical. This is especially useful for the first and the last key frame of a Timeline, because for these key frames only one tangent is used.

Parameters
t:Duration

the delta time of the tangent

v:double

the value of the tangent

Returns:Interpolator

a tangent interpolator

Since
26
See Also
ofTangent(Duration, double, Duration, double)
SPLINEback to summary
public static Interpolator SPLINE(double x1, double y1, double x2, double y2)

Deprecated

since 26.

use ofSpline(double, double, double, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofSpline(double, double, double, double) instead.

Parameters
x1:double

x coordinate of the first control point

y1:double

y coordinate of the first control point

x2:double

x coordinate of the second control point

y2:double

y coordinate of the second control point

Returns:Interpolator

a spline interpolator

Annotations
@Deprecated
since:26
Exceptions
IllegalArgumentException:
if x1 or x2 is outside of [0, 1]
STEPSback to summary
public static Interpolator STEPS(int intervalCount, Interpolator.StepPosition position)

Deprecated

since 26.

use ofSteps(int, StepPosition) instead

This is a legacy method named inconsistently with method naming conventions, use ofSteps(int, StepPosition) instead.

Parameters
intervalCount:int

the number of intervals in the step interpolator

position:Interpolator.StepPosition

the StepPosition of the step interpolator

Returns:Interpolator

a new step interpolator

Annotations
@Deprecated
since:26
Exceptions
IllegalArgumentException:
if intervals is less than 1, or if intervals is less than 2 when position is StepPosition#NONE
NullPointerException:
if position is null
Since
23
TANGENTback to summary
public static Interpolator TANGENT(Duration t1, double v1, Duration t2, double v2)

Deprecated

since 26.

use ofTangent(Duration, double, Duration, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofTangent(Duration, double, Duration, double) instead.

Parameters
t1:Duration

the delta time of the in-tangent, relative to the KeyFrame

v1:double

the value of the in-tangent

t2:Duration

the delta time of the out-tangent, relative to the KeyFrame

v2:double

the value of the out-tangent

Returns:Interpolator

a tangent interpolator

Annotations
@Deprecated
since:26
TANGENTback to summary
public static Interpolator TANGENT(Duration t, double v)

Deprecated

since 26.

use ofTangent(Duration, double) instead

This is a legacy method named inconsistently with method naming conventions, use ofTangent(Duration, double) instead.

Parameters
t:Duration

the delta time of the tangent

v:double

the value of the tangent

Returns:Interpolator

a tangent interpolator

Annotations
@Deprecated
since:26
javafx.animation back to summary

public final Enum Interpolator.StepPosition

extends Enum<Interpolator.StepPosition>
Class Inheritance

Specifies the step position of a step interpolator.

The step position determines the location of rise points in the input progress interval, which are the locations on the input progress axis where the output progress value jumps from one step to the next.

Since
23

Field Summary

Modifier and TypeField and Description
public static final Interpolator.StepPosition
BOTH

The interval starts with a rise point when the input progress value is 0, and ends with a rise point when the input progress value is 1.

public static final Interpolator.StepPosition
END

The interval ends with a rise point when the input progress value is 1.

public static final Interpolator.StepPosition
NONE

All rise points are within the open interval (0..1).

public static final Interpolator.StepPosition
START

The interval starts with a rise point when the input progress value is 0.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Interpolator.StepPosition
public static Interpolator.StepPosition[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOTHback to summary
public static final Interpolator.StepPosition BOTH

The interval starts with a rise point when the input progress value is 0, and ends with a rise point when the input progress value is 1.

BOTH

ENDback to summary
public static final Interpolator.StepPosition END

The interval ends with a rise point when the input progress value is 1.

END

NONEback to summary
public static final Interpolator.StepPosition NONE

All rise points are within the open interval (0..1).

NONE

STARTback to summary
public static final Interpolator.StepPosition START

The interval starts with a rise point when the input progress value is 0.

START

Constructor Detail

StepPositionback to summary
private StepPosition()

Method Detail

valueOfback to summary
public static Interpolator.StepPosition valueOf(String name)
valuesback to summary
public static Interpolator.StepPosition[] values()