Class KeyFrames<T>
- java.lang.Object
-
- org.pushingpixels.radiance.animation.api.interpolator.KeyFrames<T>
-
- Type Parameters:
T
- Value type
public class KeyFrames<T> extends java.lang.Object
KeyFrames holds information about the times at which values are sampled (KeyTimes) and the values at those times (KeyValues). It also holds information about how to interpolate between these values for times that lie between the sampling points.
-
-
Field Summary
Fields Modifier and Type Field Description private KeyInterpolators
interpolators
private KeyTimes
keyTimes
private KeyValues<T>
keyValues
-
Constructor Summary
Constructors Constructor Description KeyFrames(KeyValues<T> keyValues)
Simplest variation; determine keyTimes based on even division of 0-1 range based on number of keyValues.KeyFrames(KeyValues<T> keyValues, TimelineEase... interpolators)
Utility constructor that assumes even division of times according to size of keyValues and interpolation according to interpolators parameter.KeyFrames(KeyValues<T> keyValues, KeyTimes keyTimes)
This variant takes both keyValues (values at each point in time) and keyTimes (times at which values are sampled).KeyFrames(KeyValues<T> keyValues, KeyTimes keyTimes, TimelineEase... interpolators)
Full constructor: caller provides an instance of all key* structures which will be used to calculate between all times in the keyTimes list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getInterval(float fraction)
Returns time interval that contains the specified time fraction(package private) KeyTimes
getKeyTimes()
(package private) KeyValues
getKeyValues()
java.lang.Class
getType()
T
getValue(float fraction)
Returns a value for the given fraction elapsed of the animation cycle.private void
init(KeyValues<T> keyValues, KeyTimes keyTimes, TimelineEase... interpolators)
Utility function called by constructors to perform common initialization chores
-
-
-
Field Detail
-
keyTimes
private KeyTimes keyTimes
-
interpolators
private KeyInterpolators interpolators
-
-
Constructor Detail
-
KeyFrames
public KeyFrames(KeyValues<T> keyValues)
Simplest variation; determine keyTimes based on even division of 0-1 range based on number of keyValues. This constructor assumes LINEAR interpolation.- Parameters:
keyValues
- values that will be assumed at each time in keyTimes
-
KeyFrames
public KeyFrames(KeyValues<T> keyValues, KeyTimes keyTimes)
This variant takes both keyValues (values at each point in time) and keyTimes (times at which values are sampled).- Parameters:
keyValues
- values that the animation will assume at each of the corresponding times in keyTimeskeyTimes
- times at which the animation will assume the corresponding values in keyValues- Throws:
java.lang.IllegalArgumentException
- keyTimes and keySizes must have the same number of elements since these structures are meant to have corresponding entries; an exception is thrown otherwise.
-
KeyFrames
public KeyFrames(KeyValues<T> keyValues, KeyTimes keyTimes, TimelineEase... interpolators)
Full constructor: caller provides an instance of all key* structures which will be used to calculate between all times in the keyTimes list. A null interpolator parameter is equivalent to callingKeyFrames(KeyValues, KeyTimes)
.- Parameters:
keyValues
- values that the animation will assume at each of the corresponding times in keyTimeskeyTimes
- times at which the animation will assume the corresponding values in keyValuesinterpolators
- collection of Interpolators that control the calculation of values in each of the intervals defined by keyFrames. If this value is null, aLinear
will be used for all intervals. If there is only one interpolator, that interpolator will be used for all intervals. Otherwise, there must be a number of interpolators equal to the number of intervals (which is one less than the number of keyTimes).- Throws:
java.lang.IllegalArgumentException
- keyTimes and keyValues must have the same number of elements since these structures are meant to have corresponding entries; an exception is thrown otherwise.java.lang.IllegalArgumentException
- The number of interpolators must either be zero (interpolators == null), one, or one less than the size of keyTimes.
-
KeyFrames
public KeyFrames(KeyValues<T> keyValues, TimelineEase... interpolators)
Utility constructor that assumes even division of times according to size of keyValues and interpolation according to interpolators parameter.- Parameters:
keyValues
- values that the animation will assume at each of the corresponding times in keyTimesinterpolators
- collection of Interpolators that control the calculation of values in each of the intervals defined by keyFrames. If this value is null, aLinear
will be used for all intervals. If there is only one interpolator, that interpolator will be used for all intervals. Otherwise, there must be a number of interpolators equal to the number of intervals (which is one less than the number of keyTimes).- Throws:
java.lang.IllegalArgumentException
- The number of interpolators must either be zero (interpolators == null), one, or one less than the size of keyTimes.
-
-
Method Detail
-
init
private void init(KeyValues<T> keyValues, KeyTimes keyTimes, TimelineEase... interpolators)
Utility function called by constructors to perform common initialization chores
-
getType
public java.lang.Class getType()
-
getKeyValues
KeyValues getKeyValues()
-
getKeyTimes
KeyTimes getKeyTimes()
-
getInterval
public int getInterval(float fraction)
Returns time interval that contains the specified time fraction- Parameters:
fraction
- Time fraction- Returns:
- Rime interval that contains the specified time fraction
-
getValue
public T getValue(float fraction)
Returns a value for the given fraction elapsed of the animation cycle. Given the fraction, this method will determine what interval the fraction lies within, how much of that interval has elapsed, what the boundary values are (from KeyValues), what the interpolated fraction is (from the Interpolator for the interval), and what the final interpolated intermediate value is (using the appropriate Evaluator). This method will call into the Interpolator for the time interval to get the interpolated method. To ensure that future operations succeed, the value received from the interpolation will be clamped to the interval [0,1].- Parameters:
fraction
- Fraction- Returns:
- Value for the given fraction elapsed of the animation cycle.
-
-