Class SplineInterpolator

java.lang.Object
javafx.animation.Interpolator
com.sun.scenario.animation.SplineInterpolator

public class SplineInterpolator extends Interpolator
An implementation of a spline interpolator for temporal interpolation that tries to follow the specification referenced by: http://www.w3.org/TR/SMIL/animation.html#animationNS-OverviewSpline .

Basically, a cubic Bezier curve is created with start point (0,0) and endpoint (1,1). The other two control points (px1, py1) and (px2, py2) are given by the user, where px1, py1, px1, and px2 are all in the range [0,1]. A property of this specially constrained Bezier curve is that it is strictly monotonically increasing in both X and Y with t in range [0,1].

The interpolator works by giving it a value for X. It then finds what parameter t would generate this X value for the curve. Then this t parameter is applied to the curve to solve for Y. As X increases from 0 to 1, t also increases from 0 to 1, and correspondingly Y increases from 0 to 1. The X-to-Y mapping is not a function of path/curve length.

  • Constructor Details

    • SplineInterpolator

      public SplineInterpolator(double px1, double py1, double px2, double py2)
      Creates a new instance with control points (0,0) (px1,py1) (px2,py2) (1,1) -- px1, py1, px2, py2 all in range [0,1].
      Parameters:
      px1 - X coordinate of first control point, in range [0,1]
      py1 - Y coordinate of first control point, in range [0,1]
      px2 - X coordinate of second control point, in range [0,1]
      py2 - Y coordinate of second control point, in range [0,1]
  • Method Details

    • getX1

      public double getX1()
    • getY1

      public double getY1()
    • getX2

      public double getX2()
    • getY2

      public double getY2()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • curve

      public double curve(double x)
      Returns the y-value of the cubic bezier curve that corresponds to the x input.
      Specified by:
      curve in class Interpolator
      Parameters:
      x - is x-value of cubic bezier curve, in range [0,1]
      Returns:
      corresponding y-value of cubic bezier curve -- in range [0,1]
    • toString

      public String toString()
      Overrides:
      toString in class Object