com.jgoodies.animation
Class AnimationFunctions

java.lang.Object
  extended by com.jgoodies.animation.AnimationFunctions

public final class AnimationFunctions
extends Object

This class consists only of static methods that construct and operate on AnimationFunctions.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
AnimationFunction

Nested Class Summary
static class AnimationFunctions.FloatFunction
          Helper class that wraps a Float-based animation function to answer floats.
 
Field Summary
static AnimationFunction ONE
          A constant AnimationFunction that returns 1 all the time.
static AnimationFunction ZERO
          A constant AnimationFunction that returns 0.0f all the time.
 
Method Summary
static AnimationFunction alphaColor(AnimationFunction f, 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 AnimationFunctions.FloatFunction asFloat(AnimationFunction f)
          Creates a time-based function that wraps the given Float-based animation function to return the corresponding float values.
static AnimationFunction concat(AnimationFunction first, AnimationFunction second)
          Concatenates the fiven animation functions and returns a compound animation function that represents the concatenation.
static AnimationFunction constant(long duration, Object value)
          Creates and returns an animation function that returns a constant value over the given duration.
static AnimationFunction discrete(long duration, Object[] values)
          Creates and returns a discrete animation function for the given duration and values.
static AnimationFunction discrete(long duration, Object[] values, float[] keyTimes)
          Creates and returns a discrete animation function for the given duration, values and interpolation key times.
static AnimationFunction 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 fromTo(long duration, float from, float to)
          Ceates and returns a linear animation function with the given duration.
static AnimationFunction linear(long duration, Object[] 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 AnimationFunction linear(long duration, Object[] 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 linearColors(long duration, Color[] colors, float[] keyTimes)
          Creates an AnimationFunction that maps times to instances of Color.
static AnimationFunction 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 AnimationFunction repeat(AnimationFunction f, long repeatTime)
          Creates and returns an animation function that is defined by repeating the specified animation function.
static AnimationFunction reverse(AnimationFunction 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
 

Field Detail

ONE

public static final AnimationFunction ONE
A constant AnimationFunction that returns 1 all the time.


ZERO

public static final AnimationFunction ZERO
A constant AnimationFunction that returns 0.0f all the time.

Method Detail

alphaColor

public static AnimationFunction alphaColor(AnimationFunction f,
                                           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

asFloat

public static AnimationFunctions.FloatFunction asFloat(AnimationFunction f)
Creates a time-based function that wraps the given Float-based animation function to return the corresponding float values.

Parameters:
f - the underlying animation function of floats
Returns:
an animation function the returns Float objects

concat

public static AnimationFunction concat(AnimationFunction first,
                                       AnimationFunction second)
Concatenates the fiven animation functions and returns a compound animation function that represents the concatenation.

Parameters:
first - the concatenation's first AnimationFunction
second - the concatenation's second AnimationFunction
Returns:
the concatenated animation function

constant

public static AnimationFunction constant(long duration,
                                         Object 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 AnimationFunction discrete(long duration,
                                         Object[] 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 AnimationFunction discrete(long duration,
                                         Object[] 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 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 fromTo(long duration,
                                       float from,
                                       float to)
Ceates and returns a linear animation function with the given duration. The function values are Floats in the intervall [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 AnimationFunction linear(long duration,
                                       Object[] 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 AnimationFunction linear(long duration,
                                       Object[] 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 linearColors(long duration,
                                             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 arry 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 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 AnimationFunction repeat(AnimationFunction 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 AnimationFunction reverse(AnimationFunction 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


Copyright © 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved.