public abstract class ALcdAnimationManager extends Object
ILcdAnimation
instances can be played
back simultaneously. However, each animation must be associated with a particular key. Only one
animation can be bound to a single key at the same time, so as to prevent conflicts between
animations that try to assign different values to the same parameters of an animated object (e.g.
multiple animations that want to modify the world-to-view transformation of the view). This
class is a singleton
. The animation manager uses a separate thread to keep
track of time, but invokes the setTime
method of the
animations on the painting thread. The setTargetUpdateRate(double)
method
sets the target frame rate at which animations are played. For every frame, each animation's
setTime()
method is called with the time elapsed since the
animation was started.
An animation is started (ILcdAnimation.start()
) when being
added to the animation manager ( putAnimation(Object[], ILcdAnimation)
) and stopped
(ILcdAnimation.stop()
) when it has reached the end of its
duration and does not need to be looped, or when it is explicitly removed using removeAnimation(Object[])
. When looped animations (ILcdAnimation.isLoop()
)
have reached the end of their duration, the animation manager invokes ILcdAnimation.restart()
to initiate a new loop.
Animations that affect an ILcdView
should be implemented by extending ALcdAnimation
where the relevant views can be provided as constructor arguments.Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Adds the given listener so that it gets notified of property changes.
|
abstract ILcdAnimation |
getAnimation(Object aAnimatedObjectKey)
Returns the current animation for the passed key, or null if there isn't one.
|
abstract ILcdAnimation |
getAnimation(Object[] aAnimatedObjectKeys)
Returns the current animation for the passed keys, or null if there isn't one.
|
abstract int |
getAnimationCount()
Gets the number of registered animations.
|
static ALcdAnimationManager |
getInstance()
Returns the singleton instance of this class.
|
abstract double |
getTargetUpdateRate()
Returns the target update rate (in frames per second).
|
abstract boolean |
isPaused()
Checks whether the animation manager is paused or not.
|
abstract boolean |
isRunning()
Determines whether the animation manager is running.
|
abstract void |
putAnimation(Object[] aAnimatedObjectKeys,
ILcdAnimation aAnimation)
Starts the specified animation for an array of keys.
|
abstract void |
putAnimation(Object aAnimatedObjectKey,
ILcdAnimation aAnimation)
Starts the specified animation for the given key.
|
abstract void |
removeAnimation(Object aAnimatedObjectKey)
Stops and removes the animation associated with the specified key, if any.
|
abstract void |
removeAnimation(Object[] aAnimatedObjectKeys)
Stops and removes the animation associated with the specified array of keys, if any.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Removes the given listener so that it no longer gets notified of property changes.
|
abstract void |
setPaused(boolean aPaused)
Pauses this animation manager.
|
abstract void |
setTargetUpdateRate(double aTargetUpdateRate)
The argument to this method specifies the desired animation update rate (in frames per
second).
|
public static ALcdAnimationManager getInstance()
public abstract void setTargetUpdateRate(double aTargetUpdateRate)
aTargetUpdateRate
- the desired animation frameratepublic abstract double getTargetUpdateRate()
public abstract void setPaused(boolean aPaused)
aPaused
- if true, pauses all running animations. If false, continues all paused animations from the point
they were paused.isPaused()
public abstract boolean isPaused()
setPaused(boolean)
public abstract void putAnimation(Object aAnimatedObjectKey, ILcdAnimation aAnimation)
aAnimatedObjectKey
- the object with which to associate the animationaAnimation
- the animation to be played backpublic abstract void putAnimation(Object[] aAnimatedObjectKeys, ILcdAnimation aAnimation)
aAnimatedObjectKeys
- the array of keys with which to associate the animationaAnimation
- the animation to be played backpublic abstract ILcdAnimation getAnimation(Object[] aAnimatedObjectKeys)
aAnimatedObjectKeys
- the objects with which to associate the animationpublic abstract ILcdAnimation getAnimation(Object aAnimatedObjectKey)
aAnimatedObjectKey
- the object with which to associate the animationpublic abstract void removeAnimation(Object aAnimatedObjectKey)
aAnimatedObjectKey
- the object from which to remove any currently running animationpublic abstract void removeAnimation(Object[] aAnimatedObjectKeys)
aAnimatedObjectKeys
- the array of keys for which to remove any currently running
animationpublic abstract int getAnimationCount()
public abstract boolean isRunning()
Note that the animation manager is automatically started when an animation is added and stopped when the last animation finishes.
true
if running, {code false} if not runningpublic void addPropertyChangeListener(PropertyChangeListener aListener)
aListener
- the listener to addpublic void removePropertyChangeListener(PropertyChangeListener aListener)
aListener
- the listener to remove