ca.sqlpower.wabit.swingui.chart.effect.interp
Class PolynomialInterpolator

java.lang.Object
  extended by ca.sqlpower.wabit.swingui.chart.effect.interp.PolynomialInterpolator
All Implemented Interfaces:
Interpolator

@Immutable
public class PolynomialInterpolator
extends java.lang.Object
implements Interpolator

A general polynomial interpolator that can be used to create "ease in", "ease out", and linear interpolations.


Constructor Summary
PolynomialInterpolator(double exponent)
          Creates a new interpolator instance which uses the given exponent.
 
Method Summary
static PolynomialInterpolator easeInInstance()
          Returns an "ease in" instance (exponent 2).
static PolynomialInterpolator easeInInstance(double degree)
          Returns an "ease in" instance of the given degree.
static PolynomialInterpolator easeOutInstance()
          Returns an "ease out" instance (exponent 1/2).
static PolynomialInterpolator easeOutInstance(double degree)
          Returns an "ease out" instance (exponent 1/degree).
 double value(double start, double end, double pct)
          Calculates and returns an interpolated value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomialInterpolator

public PolynomialInterpolator(double exponent)
Creates a new interpolator instance which uses the given exponent.

Parameters:
exponent - The degree of the polynomial that controls the step size. A value between 0 and 1 gives an "ease out" interpolator of decreasing severity; 1.0 gives a linear interpolator; greater than 1 gives an "ease in" instance of increasing severity.
Method Detail

easeOutInstance

public static PolynomialInterpolator easeOutInstance()
Returns an "ease out" instance (exponent 1/2).

Ease out interpolators start with relatively large steps but ease out to the end of their range with gradually smaller steps.

Returns:
An "ease out" polynomial interpolator.

easeOutInstance

public static PolynomialInterpolator easeOutInstance(double degree)
Returns an "ease out" instance (exponent 1/degree).

Ease out interpolators start with relatively large steps but ease out to the end of their range with gradually smaller steps.

Returns:
An "ease out" polynomial interpolator.

easeInInstance

public static PolynomialInterpolator easeInInstance()
Returns an "ease in" instance (exponent 2).

Ease in interpolators ease in with relatively small steps but approach the end of their range with increasingly larger steps.

Returns:
An "ease in" polynomial interpolator.

easeInInstance

public static PolynomialInterpolator easeInInstance(double degree)
Returns an "ease in" instance of the given degree.

Ease in interpolators ease in with relatively small steps but approach the end of their range with increasingly larger steps.

Returns:
An "ease in" polynomial interpolator.

value

public double value(double start,
                    double end,
                    double pct)
Description copied from interface: Interpolator
Calculates and returns an interpolated value.

Specified by:
value in interface Interpolator
Parameters:
start - The value that will be returned when pct == 0.0
end - The value that will be returned when pct == 1.0
pct - A value between 0.0 and 1.0 that indicates how far "along the way" the interpolated value should be. Values outside the range 0.0..1.0 produce undefined results.
Returns:
An interpolated value for the given parameters. When pct=0.0, the value of start is returned. When pct=1.0, the value of end is returned. For values of pct between 0.0 and 1.0, the returned value is calculated according to the particular Interpolator in use. In general, it is not guaranteed to lie between start and end (some interpolators may "overshoot" either endpoint then come back to it).


Copyright © 2009. All Rights Reserved.