Package com.jgoodies.animation
Class AnimationFunctions
- java.lang.Object
-
- com.jgoodies.animation.AnimationFunctions
-
public final class AnimationFunctions extends java.lang.ObjectThis class consists only of static methods that construct and operate onAnimationFunctions.- Version:
- $Revision: 1.11 $
- See Also:
AnimationFunction
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAnimationFunctions.AlphaColorAnimationFunctionHelper class for animation functions that answer translucent colors.private static classAnimationFunctions.ColorFunctionHelper class for interpolating colors.private static classAnimationFunctions.InterpolatedAnimationFunction<T>Helper class for interpolation based animation functions.static classAnimationFunctions.InterpolationModeprivate static classAnimationFunctions.RandomAnimationFunctionProduces and returns random Integer values.private static classAnimationFunctions.RepeatedAnimationFunction<T>Helper class used to repeat or sequence an animation function.private static classAnimationFunctions.ReversedAnimationFunction<T>Helper class for reversing an animation function.private static classAnimationFunctions.SequencedAnimationFunction<T>Helper class to compose an animation functions from a sequences of such functions.
-
Field Summary
Fields Modifier and Type Field Description static AnimationFunction<java.lang.Float>ONEA constantAnimationFunctionthat returns1fall the time.static AnimationFunction<java.lang.Float>ZEROA constantAnimationFunctionthat returns0fall the time.
-
Constructor Summary
Constructors Modifier Constructor Description privateAnimationFunctions()
-
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 anAnimationFunctionthat maps times to instances ofColor.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.
-
-
-
Field Detail
-
ONE
public static final AnimationFunction<java.lang.Float> ONE
A constantAnimationFunctionthat returns1fall the time.
-
ZERO
public static final AnimationFunction<java.lang.Float> ZERO
A constantAnimationFunctionthat returns0fall the time.
-
-
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 valuesbaseColor- 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 durationvalue- 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 durationvalues- 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 durationvalues- an array of discrete result valueskeyTimes- 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 durationfrom- the initial result valueby- 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 durationfrom- the initial result valueto- 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 durationvalues- 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 durationvalues- an array of valueskeyTimes- 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 anAnimationFunctionthat maps times to instances ofColor. The mapping is interpolated from an array of Colors using an array of key times.- Parameters:
duration- the duration of this animation functioncolors- the colors to interpolate.keyTimes- an array of key times used to distribute the result values over the time.- Returns:
- An
AnimationFunctionthat maps times to sRGB colors. This mapping is defined by an array ofColorvalues 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 valuemax- the maximum result valuechangeProbability- 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 repeatrepeatTime- 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
-
-