This class enables automating animation of object properties. The class is a TimingTarget, and should be used as a target of timing events from an Animator. These events will be used to change a specified property over time, according to how the PropertySetter is constructed.
For example, here is an animation of the "background" property of some object "obj" from blue to red over a period of one second:
PropertySetter ps = new PropertySetter(obj, "background", Color.BLUE, Color.RED); Animator anim = new Animator(1000, ps); anim.start();
Here is the same animation, created using one of the utility factory methods that returns an animator:
Animator animator = PropertySetter.createAnimator(1000, obj, "background", Color.BLUE, Color.RED); anim.start();
More complex animations can be created by passing in multiple values for the property to take on, for example:
Animator animator = PropertySetter.createAnimator(1000, obj, "background", Color.BLUE, Color.RED, Color.GREEN); anim.start();
It is also possible to define more involved and tightly-controlled steps in the animation, including the times between the values and how the values are interpolated by using the constructor that takes a {@link KeyFrames} object. KeyFrames defines the fractional times at whichan object takes on specific values, the values to assume at those times, and the method of interpolation between those values. For example, here is the same animation as above, specified through KeyFrames, where the RED color will be set 10% of the way through the animation (note that we are not setting an Interpolator, so the timing intervals will use the default LinearInterpolator):
KeyValues vals = KeyValues.create(Color.BLUE, Color.RED, Color.GREEN); KeyTimes times = new KeyTimes(0.0f, .1f, 1.0f); KeyFrames frames = new KeyFrames(vals, times); Animator animator = PropertySetter.createAnimator(1000, obj, "background", frames); anim.start();
@author Chet