org.apache.batik.anim

Class AnimationEngine

public abstract class AnimationEngine extends Object

An abstract base class for managing animation in a document.
Nested Class Summary
protected static classAnimationEngine.AnimationInfo
Class to hold target information of an animation.
protected classAnimationEngine.Listener
Listener class for changes to base values on a target element.
protected static classAnimationEngine.Sandwich
Class to hold an animation sandwich for a particular attribute.
protected static classAnimationEngine.TargetInfo
Class to hold XML and CSS animations for a target element.
Field Summary
static shortANIM_TYPE_CSS
static shortANIM_TYPE_OTHER
static shortANIM_TYPE_XML
protected HashMapanimations
Map of AbstractAnimations to AnimationInfo objects.
protected Documentdocument
The document this AnimationEngine is managing animation for.
protected longpauseTime
The time at which the document was paused, or 0 if the document is not paused.
protected AnimationEngine.ListenertargetListener
The listener object for animation target base value changes.
protected HashMaptargets
Map of AnimationTargets to TargetInfo objects.
protected TimedDocumentRoottimedDocumentRoot
The root time container for the document.
Constructor Summary
AnimationEngine(Document doc)
Creates a new AnimationEngine for the given document.
Method Summary
voidaddAnimation(AnimationTarget target, short type, String ns, String an, AbstractAnimation anim)
Adds an animation to the document.
voidaddTimegraphListener(TimegraphListener l)
Adds a {@link TimegraphListener} to the document.
protected abstract TimedDocumentRootcreateDocumentRoot()
Creates a new returns a new TimedDocumentRoot object for the document.
voiddispose()
Disposes this animation engine.
protected AnimationEngine.AnimationInfogetAnimationInfo(AbstractAnimation anim)
Returns the AnimationInfo for the given AbstractAnimation.
floatgetCurrentTime()
Returns the current document time.
protected AnimationEngine.SandwichgetSandwich(AnimationTarget target, short type, String ns, String an)
Returns the Sandwich for the given animation type/attribute.
protected AnimationEngine.TargetInfogetTargetInfo(AnimationTarget target)
Returns the TargetInfo for the given AnimationTarget.
booleanisPaused()
Returns whether animations are currently paused.
protected voidmoveToBottom(AbstractAnimation anim)
Moves the given animation to the bottom of the sandwich.
protected voidmoveToTop(AbstractAnimation anim)
Moves the given animation to the top of the sandwich.
voidpause()
Pauses the animations.
protected voidpushDown(AbstractAnimation anim)
Moves the animation down the sandwich such that it is in the right position according to begin time and document order.
voidremoveAnimation(AbstractAnimation anim)
Removes an animation from the document.
voidremoveFill(AbstractAnimation anim)
Invoked to indicate that this timed element has had its fill removed.
voidremoveTimegraphListener(TimegraphListener l)
Removes a {@link TimegraphListener} from the document.
voidsampledAt(AbstractAnimation anim, float simpleTime, float simpleDur, int repeatIteration)
Invoked to indicate that this timed element has been sampled at the given time.
voidsampledLastValue(AbstractAnimation anim, int repeatIteration)
Invoked to indicate that this timed element has been sampled at the end of its active time, at an integer multiple of the simple duration.
floatsetCurrentTime(float t)
Sets the current document time.
protected floattick(float time, boolean hyperlinking)
Updates the animations in the document to the given document time.
voidtoActive(AbstractAnimation anim, float begin)
Invoked to indicate an animation became active at the specified time.
voidtoInactive(AbstractAnimation anim, boolean isFrozen)
Invoked to indicate that this timed element became inactive.
voidunpause()
Unpauses the animations.

Field Detail

ANIM_TYPE_CSS

public static final short ANIM_TYPE_CSS

ANIM_TYPE_OTHER

public static final short ANIM_TYPE_OTHER

ANIM_TYPE_XML

public static final short ANIM_TYPE_XML

animations

protected HashMap animations
Map of AbstractAnimations to AnimationInfo objects.

document

protected Document document
The document this AnimationEngine is managing animation for.

pauseTime

protected long pauseTime
The time at which the document was paused, or 0 if the document is not paused.

targetListener

protected AnimationEngine.Listener targetListener
The listener object for animation target base value changes.

targets

protected HashMap targets
Map of AnimationTargets to TargetInfo objects.

timedDocumentRoot

protected TimedDocumentRoot timedDocumentRoot
The root time container for the document.

Constructor Detail

AnimationEngine

public AnimationEngine(Document doc)
Creates a new AnimationEngine for the given document.

Method Detail

addAnimation

public void addAnimation(AnimationTarget target, short type, String ns, String an, AbstractAnimation anim)
Adds an animation to the document.

Parameters: target the target element of the animation type the type of animation (must be one of the ANIM_TYPE_* constants defined in this class ns the namespace URI of the attribute being animated, if type == {@link #ANIM_TYPE_XML} an the attribute name if type == {@link #ANIM_TYPE_XML}, the property name if type == {@link #ANIM_TYPE_CSS}, and the animation type otherwise anim the animation

addTimegraphListener

public void addTimegraphListener(TimegraphListener l)
Adds a {@link TimegraphListener} to the document.

createDocumentRoot

protected abstract TimedDocumentRoot createDocumentRoot()
Creates a new returns a new TimedDocumentRoot object for the document.

dispose

public void dispose()
Disposes this animation engine.

getAnimationInfo

protected AnimationEngine.AnimationInfo getAnimationInfo(AbstractAnimation anim)
Returns the AnimationInfo for the given AbstractAnimation.

getCurrentTime

public float getCurrentTime()
Returns the current document time.

getSandwich

protected AnimationEngine.Sandwich getSandwich(AnimationTarget target, short type, String ns, String an)
Returns the Sandwich for the given animation type/attribute.

getTargetInfo

protected AnimationEngine.TargetInfo getTargetInfo(AnimationTarget target)
Returns the TargetInfo for the given AnimationTarget.

isPaused

public boolean isPaused()
Returns whether animations are currently paused.

moveToBottom

protected void moveToBottom(AbstractAnimation anim)
Moves the given animation to the bottom of the sandwich.

moveToTop

protected void moveToTop(AbstractAnimation anim)
Moves the given animation to the top of the sandwich.

pause

public void pause()
Pauses the animations.

pushDown

protected void pushDown(AbstractAnimation anim)
Moves the animation down the sandwich such that it is in the right position according to begin time and document order.

removeAnimation

public void removeAnimation(AbstractAnimation anim)
Removes an animation from the document.

removeFill

public void removeFill(AbstractAnimation anim)
Invoked to indicate that this timed element has had its fill removed.

removeTimegraphListener

public void removeTimegraphListener(TimegraphListener l)
Removes a {@link TimegraphListener} from the document.

sampledAt

public void sampledAt(AbstractAnimation anim, float simpleTime, float simpleDur, int repeatIteration)
Invoked to indicate that this timed element has been sampled at the given time.

Parameters: anim the animation simpleTime the sample time in local simple time simpleDur the simple duration of the element repeatIteration the repeat iteration during which the element was sampled

sampledLastValue

public void sampledLastValue(AbstractAnimation anim, int repeatIteration)
Invoked to indicate that this timed element has been sampled at the end of its active time, at an integer multiple of the simple duration. This is the "last" value that will be used for filling, which cannot be sampled normally.

setCurrentTime

public float setCurrentTime(float t)
Sets the current document time.

tick

protected float tick(float time, boolean hyperlinking)
Updates the animations in the document to the given document time.

Parameters: time the document time to sample at hyperlinking whether the document should be seeked to the given time, as with hyperlinking

toActive

public void toActive(AbstractAnimation anim, float begin)
Invoked to indicate an animation became active at the specified time.

Parameters: anim the animation begin the time the element became active, in document simple time

toInactive

public void toInactive(AbstractAnimation anim, boolean isFrozen)
Invoked to indicate that this timed element became inactive.

Parameters: anim the animation isFrozen whether the element is frozen or not

unpause

public void unpause()
Unpauses the animations.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.