Package org.jdesktop.animation.timing.interpolation

# Class SplineInterpolator

java.lang.Object
org.jdesktop.animation.timing.interpolation.SplineInterpolator

All Implemented Interfaces:
  `Interpolator`

public final class SplineInterpolator extends Object implements Interpolator
This class interpolates fractional values using Bezier splines. The anchor points * for the spline are assumed to be (0, 0) and (1, 1). Control points should all be in the range [0, 1].

For more information on how splines are used to interpolate, refer to the SMIL specification at http://w3c.org.

This class provides one simple built-in facility for non-linear interpolation. Applications are free to define their own Interpolator implementation and use that instead when particular non-linear effects are desired.

## Constructor Summary

Constructors
Constructor
Description
`SplineInterpolator(float x1, float y1, float x2, float y2)`
Creates a new instance of SplineInterpolator with the control points defined by (x1, y1) and (x2, y2).

## Method Summary

Modifier and Type
Method
Description
`float`
`interpolate(float lengthFraction)`
Given a fraction of time along the spline (which we can interpret as the length along a spline), return the interpolated value of the spline.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SplineInterpolator

public SplineInterpolator(float x1, float y1, float x2, float y2)
Creates a new instance of SplineInterpolator with the control points defined by (x1, y1) and (x2, y2). The anchor points are implicitly defined as (0, 0) and (1, 1).

Throws:
  `IllegalArgumentException` - This exception is thrown when values beyond the allowed [0,1] range are passed in

## Method Details

### interpolate

public float interpolate(float lengthFraction)
Given a fraction of time along the spline (which we can interpret as the length along a spline), return the interpolated value of the spline. We first calculate the t value for the length (by doing a lookup in our array of previousloy calculated values and then linearly interpolating between the nearest values) and then calculate the Y value for this t.

Specified by:
  `interpolate` in interface `Interpolator`
Parameters:
  `lengthFraction` - Fraction of time in a given time interval.
Returns:
  interpolated fraction between 0 and 1