Search this API

y.anim
Class AnimationFactory

java.lang.Object
  extended by y.anim.AnimationFactory

public final class AnimationFactory
extends java.lang.Object

Factory class that provides methods to create meta animations. The following meta animations can be created:

 

Method Summary
static CompositeAnimationObject createConcurrency()
          Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently.
static CompositeAnimationObject createConcurrency(AnimationObject ao1, AnimationObject ao2)
          Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently and conveniently adds the two specified AnimationObject instances.
static AnimationObject createEasedAnimation(AnimationObject ao)
          Creates an eased AnimationObject.
static AnimationObject createEasedAnimation(AnimationObject ao, double stopAcceleration, double startDeceleration)
          Creates an eased AnimationObject, which results in a linear increase in animation speed up to stopAcceleration and a linear decrease in animation speed from startDeceleration.
static CompositeAnimationObject createLazySequence()
          Creates a CompositeAnimationObject that represents a sequence of regular animations.
static CompositeAnimationObject createLazySequence(AnimationObject ao1, AnimationObject ao2)
          Creates a CompositeAnimationObject that represents a sequence of regular animations and conveniently adds the two specified AnimationObject instances.
static AnimationObject createPause(long preferredDuration)
          Creates an AnimationObject that blocks for the specified duration.
static AnimationObject createRepetition(AnimationObject ao, int repetitions, boolean initDisposeRepeatedly)
          Creates an AnimationObject that repeats the specified animation for the specified number of times.
static AnimationObject createRepetitionForDuration(AnimationObject ao, long duration, boolean initDisposeRepeatedly)
          Creates an AnimationObject that repeats the specified animation for the specified duration.
static CompositeAnimationObject createScalingConcurrency()
          Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently.
static CompositeAnimationObject createScalingConcurrency(AnimationObject ao1, AnimationObject ao2)
          Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently and conveniently adds the two specified AnimationObject instances.
static CompositeAnimationObject createSequence()
          Creates a CompositeAnimationObject that represents a sequence of regular animations.
static CompositeAnimationObject createSequence(AnimationObject ao1, AnimationObject ao2)
          Creates a CompositeAnimationObject that represents a sequence of regular animations and conveniently adds the two specified AnimationObject instances.
static AnimationObject createStateGuardian(AnimationObject ao)
          Creates an AnimationObject that ignores calls to initAnimation if initAnimation has and disposeAnimation has not been called already (and vice versa).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createEasedAnimation

public static AnimationObject createEasedAnimation(AnimationObject ao)
Creates an eased AnimationObject. Calling this factory method is equivalent to invoking
Animations.createEasedAnimation( ao, 0.5, 0.5 ).


createEasedAnimation

public static AnimationObject createEasedAnimation(AnimationObject ao,
                                                   double stopAcceleration,
                                                   double startDeceleration)
Creates an eased AnimationObject, which results in a linear increase in animation speed up to stopAcceleration and a linear decrease in animation speed from startDeceleration. Between stopAcceleration and startDeceleration the animation speed is constant. The associated speed curve is

Parameters:
stopAcceleration - specifies the time to stop increasing the animation speed. Must be in [0.0,1.0].
startDeceleration - specifies the time to start decreasing the animation speed. Must be in [0.0,1.0].
Throws:
java.lang.IllegalArgumentException - if either stopAcceleration not in [0.0,1.0] or startDeceleration not in [0.0,1.0].

createConcurrency

public static CompositeAnimationObject createConcurrency()
Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently. The preferred duration of a composite animation created by this method is the maximum of the preferred durations of the registered animations. The registered animations will start concurrently. Each animation will stop after running for its preferred duration.

The CompositeAnimationObject created by this method will throw an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a set of concurrently running animations.
See Also:
createScalingConcurrency(), createSequence()

createConcurrency

public static CompositeAnimationObject createConcurrency(AnimationObject ao1,
                                                         AnimationObject ao2)
Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently and conveniently adds the two specified AnimationObject instances. The preferred duration of a composite animation created by this method is the maximum of the preferred durations of the registered animations. The registered animations will start concurrently. Each animation will stop after running for its preferred duration.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a set of concurrently running animations.
See Also:
createScalingConcurrency(AnimationObject, AnimationObject), createSequence(AnimationObject, AnimationObject)

createScalingConcurrency

public static CompositeAnimationObject createScalingConcurrency()
Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently. The preferred duration of a composite animation created by this method is the maximum of the preferred durations of the registered animations. The registered animations will start and stop concurrently, i.e. the duration of all registered animations will be scaled up to the preferred duration of the composite.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a set of concurrently running animations.
See Also:
createConcurrency(), createSequence()

createScalingConcurrency

public static CompositeAnimationObject createScalingConcurrency(AnimationObject ao1,
                                                                AnimationObject ao2)
Creates a CompositeAnimationObject that represents a set of regular animations that will run concurrently and conveniently adds the two specified AnimationObject instances. The preferred duration of a composite animation created by this method is the maximum of the preferred durations of the registered animations. The registered animations will start and stop concurrently, i.e. the duration of all registered animations will be scaled up to the preferred duration of the composite.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a set of concurrently running animations.
See Also:
createConcurrency(AnimationObject, AnimationObject), createSequence()

createLazySequence

public static CompositeAnimationObject createLazySequence()
Creates a CompositeAnimationObject that represents a sequence of regular animations. The preferred duration of a composite animation created by this method is the sum of the preferred durations of the registered animations. The registered animations initAnimation method is called right before the first call to the registered animation's calcFrame method. The registered animations disposeAnimation method is called right after the last call to the registered animation's calcFrame method.
Note:
Expensive initAnimation or disposeAnimation will severely reduce the frame rate for the sequential animation.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a sequence of regular animations.
See Also:
createSequence(), createConcurrency()

createLazySequence

public static CompositeAnimationObject createLazySequence(AnimationObject ao1,
                                                          AnimationObject ao2)
Creates a CompositeAnimationObject that represents a sequence of regular animations and conveniently adds the two specified AnimationObject instances. The preferred duration of a composite animation created by this method is the sum of the preferred durations of the registered animations. The registered animations initAnimation method is called right before the first call to the registered animation's calcFrame method. The registered animations disposeAnimation method is called right after the last call to the registered animation's calcFrame method.
Note:
Expensive initAnimation or disposeAnimation will severely reduce the frame rate for the sequential animation.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a sequence of regular animations.
See Also:
createSequence(AnimationObject, AnimationObject), createConcurrency(AnimationObject, AnimationObject)

createSequence

public static CompositeAnimationObject createSequence()
Creates a CompositeAnimationObject that represents a sequence of regular animations. The preferred duration of a composite animation created by this method is the sum of the preferred durations of the registered animations. Initialization and disposal of registered animations is done in the composite's initAnimation and disposeAnimation methods.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a sequence of regular animations.
See Also:
createLazySequence(), createConcurrency()

createSequence

public static CompositeAnimationObject createSequence(AnimationObject ao1,
                                                      AnimationObject ao2)
Creates a CompositeAnimationObject that represents a sequence of regular animations and conveniently adds the two specified AnimationObject instances. The preferred duration of a composite animation created by this method is the sum of the preferred durations of the registered animations. Initialization and disposal of registered animations is done in the composite's initAnimation and disposeAnimation methods.

The CompositeAnimationObject created by this method will thrown an IllegalStateException if an AnimationObject is added to it after its initAnimation method has been called.

Returns:
a CompositeAnimationObject that represents a sequence of regular animations.
See Also:
createLazySequence(AnimationObject, AnimationObject), createConcurrency(AnimationObject, AnimationObject)

createRepetitionForDuration

public static AnimationObject createRepetitionForDuration(AnimationObject ao,
                                                          long duration,
                                                          boolean initDisposeRepeatedly)
Creates an AnimationObject that repeats the specified animation for the specified duration.

Parameters:
ao - the AnimationObject to be repeated
duration - the preferred duration of the repetition
initDisposeRepeatedly - specifies whether the specified animation's initAnimation and disposeAnimation methods are called in between repetition steps or only once at the beginning and the end of the animation
Returns:
an AnimationObject that repeats the specified animation for the specified duration.

createRepetition

public static AnimationObject createRepetition(AnimationObject ao,
                                               int repetitions,
                                               boolean initDisposeRepeatedly)
Creates an AnimationObject that repeats the specified animation for the specified number of times.

Parameters:
ao - the AnimationObject to be repeated
repetitions - the number of repetitions
initDisposeRepeatedly - specifies whether the specified animation's initAnimation and disposeAnimation methods are called in between repetition steps or only once at the beginning and the end of the animation
Returns:
an AnimationObject that repeats the specified animation for the specified number of times.

createPause

public static AnimationObject createPause(long preferredDuration)
Creates an AnimationObject that blocks for the specified duration.

Parameters:
preferredDuration - the duration in milliseconds
Throws:
java.lang.IllegalArgumentException - if preferredDuration is less than 0.

createStateGuardian

public static AnimationObject createStateGuardian(AnimationObject ao)
Creates an AnimationObject that ignores calls to initAnimation if initAnimation has and disposeAnimation has not been called already (and vice versa). This behavior is useful if it is desirable to manually initialize ao before it is passed to an AnimationPlayer for processing.

Parameters:
ao - the AnimationObject to be guarded
Returns:
an AnimationObject that collapses multiple calls to initAnimation and disposeAnimation.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.