Class AnimationFunctions


  • public final class AnimationFunctions
    extends java.lang.Object
    This class consists only of static methods that construct and operate on AnimationFunctions.
    Version:
    $Revision: 1.11 $
    See Also:
    AnimationFunction
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private AnimationFunctions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static AnimationFunction<java.awt.Color> alphaColor​(AnimationFunction<java.lang.Integer> f, java.awt.Color baseColor)
      Creates and returns an animation function that returns time-based sRGB colors that are built from a given base color and an animation function of alpha values.
      static <T> AnimationFunction<T> concat​(AnimationFunction<T>... functions)
      Concatenates the given animation functions and returns a compound animation function that represents the concatenation.
      static <T> AnimationFunction<T> constant​(long duration, T value)
      Creates and returns an animation function that returns a constant value over the given duration.
      static <T> AnimationFunction<T> discrete​(long duration, T... values)
      Creates and returns a discrete animation function for the given duration and values.
      static <T> AnimationFunction<T> discrete​(long duration, T[] values, float[] keyTimes)
      Creates and returns a discrete animation function for the given duration, values and interpolation key times.
      static AnimationFunction<java.lang.Float> fromBy​(long duration, float from, float by)
      Creates and returns a linear animation function for the given duration that returns Float in interval [from, from + by].
      static AnimationFunction<java.lang.Float> fromTo​(long duration, float from, float to)
      Creates and returns a linear animation function with the given duration.
      static <T extends java.lang.Number>
      AnimationFunction<T>
      linear​(long duration, T[] values)
      Creates and returns a linear animation function that is defined by an array of numeric values; these are distributed equally over the duration.
      static <T extends java.lang.Number>
      AnimationFunction<T>
      linear​(long duration, T[] values, float[] keyTimes)
      Creates and returns a linear animation function that is defined by an array of numeric values and an array of relative key times.
      static AnimationFunction<java.awt.Color> linearColors​(long duration, java.awt.Color[] colors, float[] keyTimes)
      Creates an AnimationFunction that maps times to instances of Color.
      static AnimationFunction<java.lang.Integer> random​(int min, int max, float changeProbability)
      Creates and returns an animation function that returns random values from the interval [min, max] with a given change probability.
      static <T> AnimationFunction<T> repeat​(AnimationFunction<T> f, long repeatTime)
      Creates and returns an animation function that is defined by repeating the specified animation function.
      static <T> AnimationFunction<T> reverse​(AnimationFunction<T> f)
      Creates and returns an animation function that is defined by reverting the given animation function in time.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnimationFunctions

        private AnimationFunctions()
    • Method Detail

      • alphaColor

        public static AnimationFunction<java.awt.Color> alphaColor​(AnimationFunction<java.lang.Integer> f,
                                                                   java.awt.Color baseColor)
        Creates and returns an animation function that returns time-based sRGB colors that are built from a given base color and an animation function of alpha values.

        Useful for fading effects.

        Parameters:
        f - the animation function of alpha values
        baseColor - the base color
        Returns:
        an animation function of colors
      • concat

        public static <T> AnimationFunction<T> concat​(AnimationFunction<T>... functions)
        Concatenates the given animation functions and returns a compound animation function that represents the concatenation.
        Parameters:
        functions - the animation functions to concatenate
        Returns:
        the concatenated animation function
      • constant

        public static <T> AnimationFunction<T> constant​(long duration,
                                                        T value)
        Creates and returns an animation function that returns a constant value over the given duration.
        Parameters:
        duration - the function's duration
        value - the Object that will be returned all the time
        Returns:
        a constant animation function
      • discrete

        public static <T> AnimationFunction<T> discrete​(long duration,
                                                        T... values)
        Creates and returns a discrete animation function for the given duration and values. The values are equally distributed over the duration.
        Parameters:
        duration - the function's duration
        values - an array of discrete result values
        Returns:
        a discrete animation function
      • discrete

        public static <T> AnimationFunction<T> discrete​(long duration,
                                                        T[] values,
                                                        float[] keyTimes)
        Creates and returns a discrete animation function for the given duration, values and interpolation key times.
        Parameters:
        duration - the function's duration
        values - an array of discrete result values
        keyTimes - an array of key times used to distribute the result values over the time
        Returns:
        a discrete animation function
      • fromBy

        public static AnimationFunction<java.lang.Float> fromBy​(long duration,
                                                                float from,
                                                                float by)
        Creates and returns a linear animation function for the given duration that returns Float in interval [from, from + by].
        Parameters:
        duration - the animation duration
        from - the initial result value
        by - the difference that is added to the initial value
        Returns:
        a linear animation function with values in [from, from + by]
      • fromTo

        public static AnimationFunction<java.lang.Float> fromTo​(long duration,
                                                                float from,
                                                                float to)
        Creates and returns a linear animation function with the given duration. The function values are Floats in the interval [from, to].
        Parameters:
        duration - the animation duration
        from - the initial result value
        to - the last result value
        Returns:
        a linear animation function with values in [from, to]
      • linear

        public static <T extends java.lang.Number> AnimationFunction<T> linear​(long duration,
                                                                               T[] values)
        Creates and returns a linear animation function that is defined by an array of numeric values; these are distributed equally over the duration.
        Parameters:
        duration - the animation duration
        values - an array of values
        Returns:
        a linear animation function for the given values
      • linear

        public static <T extends java.lang.Number> AnimationFunction<T> linear​(long duration,
                                                                               T[] values,
                                                                               float[] keyTimes)
        Creates and returns a linear animation function that is defined by an array of numeric values and an array of relative key times.
        Parameters:
        duration - the animation duration
        values - an array of values
        keyTimes - an array of key times used to distribute the result values over the time
        Returns:
        a linear animation function for the given values
      • linearColors

        public static AnimationFunction<java.awt.Color> linearColors​(long duration,
                                                                     java.awt.Color[] colors,
                                                                     float[] keyTimes)
        Creates an AnimationFunction that maps times to instances of Color. The mapping is interpolated from an array of Colors using an array of key times.
        Parameters:
        duration - the duration of this animation function
        colors - the colors to interpolate.
        keyTimes - an array of key times used to distribute the result values over the time.
        Returns:
        An AnimationFunction that maps times to sRGB colors. This mapping is defined by an array of Color values and a corresponding array of key times that is used to interpolate sub-AnimationFunction for the red, green, blue and alpha values.
      • random

        public static AnimationFunction<java.lang.Integer> random​(int min,
                                                                  int max,
                                                                  float changeProbability)
        Creates and returns an animation function that returns random values from the interval [min, max] with a given change probability.
        Parameters:
        min - the minimum result value
        max - the maximum result value
        changeProbability - the probability that the value changes
        Returns:
        an animation function with random values in [min, max]
      • repeat

        public static <T> AnimationFunction<T> repeat​(AnimationFunction<T> f,
                                                      long repeatTime)
        Creates and returns an animation function that is defined by repeating the specified animation function.
        Parameters:
        f - the animation function to repeat
        repeatTime - the time to repeat the function
        Returns:
        the repeated animation function
      • reverse

        public static <T> AnimationFunction<T> reverse​(AnimationFunction<T> f)
        Creates and returns an animation function that is defined by reverting the given animation function in time.
        Parameters:
        f - the animation function to reverse
        Returns:
        the reversed animation function