java.lang.Object
org.pushingpixels.radiance.animation.api.interpolator.KeyValues<T>
Type Parameters:
T - Value type

public class KeyValues<T> extends Object
Stores a list of values that correspond to the times in a KeyTimes object. These structures are then used to create a KeyFrames object, which is then used to create a TimelinePropertyBuilder.PropertySetter for the purposes of modifying an object's property over time.

At each of the times in KeyTimes, the property will take on the corresponding value in the KeyValues object. Between these times, the property will take on a value based on the interpolation information stored in the KeyFrames object and the PropertyInterpolator for the type of the values in KeyValues.

This class has built-in support for various known types, as defined in PropertyInterpolator.

For a simple example using KeyValues to create a KeyFrames and PropertySetter object, see the class header comments in TimelinePropertyBuilder.PropertySetter.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final PropertyInterpolator<T>
     
    private T
     
    private final Class<?>
     
    private final List<T>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    KeyValues(PropertyInterpolator<T> interpolator, T[] params)
    Private constructor, called by factory method
    private
    KeyValues(T[] params)
    Private constructor, called by factory method
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> KeyValues<T>
    create(PropertyInterpolator<T> interpolator, T[] params)
    Constructs a KeyValues object from a property interpolator and one or more values.
    static <T> KeyValues<T>
    create(T... params)
    Constructs a KeyValues object from one or more values.
    (package private) int
    Returns the number of values stored in this object.
    (package private) Class<?>
    Returns the data type of the values stored in this object.
    (package private) T
    getValue(int i0, int i1, float fraction)
    Returns value calculated from the value at the lower index, the value at the upper index, the fraction elapsed between these endpoints, and the interpolator set up by this object at construction time.
    private boolean
    Utility method for determining whether this is a "to" animation (true if the first value is null).
    (package private) void
    setStartValue(T startValue)
    Called at start of animation; sets starting value in simple "to" animations.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • values

      private final List<T> values
    • interpolator

      private final PropertyInterpolator<T> interpolator
    • type

      private final Class<?> type
    • startValue

      private T startValue
  • Constructor Details

    • KeyValues

      private KeyValues(T[] params)
      Private constructor, called by factory method
    • KeyValues

      private KeyValues(PropertyInterpolator<T> interpolator, T[] params)
      Private constructor, called by factory method
  • Method Details

    • create

      @SafeVarargs public static <T> KeyValues<T> create(T... params)
      Constructs a KeyValues object from one or more values. The internal Evaluator is automatically determined by the type of the parameters.
      Type Parameters:
      T - Value type
      Parameters:
      params - the values to interpolate between. If there is only one parameter, this is assumed to be a "to" animation where the first value is dynamically determined at runtime when the animation is started.
      Returns:
      KeyValues object
      Throws:
      IllegalArgumentException - if an PropertyInterpolator cannot be found that can interpolate between the value types supplied
    • create

      public static <T> KeyValues<T> create(PropertyInterpolator<T> interpolator, T[] params)
      Constructs a KeyValues object from a property interpolator and one or more values.
      Type Parameters:
      T - Value type
      Parameters:
      interpolator - Property interpolator
      params - the values to interpolate between. If there is only one parameter, this is assumed to be a "to" animation where the first value is dynamically determined at runtime when the animation is started.
      Returns:
      KeyValues object
      Throws:
      IllegalArgumentException - if params does not have at least one value.
    • getSize

      int getSize()
      Returns the number of values stored in this object.
      Returns:
      the number of values stored in this object
    • getType

      Class<?> getType()
      Returns the data type of the values stored in this object.
      Returns:
      a Class value representing the type of values stored in this object
    • setStartValue

      void setStartValue(T startValue)
      Called at start of animation; sets starting value in simple "to" animations.
    • isToAnimation

      private boolean isToAnimation()
      Utility method for determining whether this is a "to" animation (true if the first value is null).
    • getValue

      T getValue(int i0, int i1, float fraction)
      Returns value calculated from the value at the lower index, the value at the upper index, the fraction elapsed between these endpoints, and the interpolator set up by this object at construction time.