fi.hut.tml.xsmiles.mlfc.smil.extension
Class AnimationScheduler

java.lang.Object
  extended byfi.hut.tml.xsmiles.mlfc.smil.extension.AnimationScheduler
All Implemented Interfaces:
java.lang.Runnable

public class AnimationScheduler
extends java.lang.Object
implements java.lang.Runnable

This is the animation scheduler. Every active animation should register itself to this scheduler. During run time, the steps are the following to comply with the "sandwich model":
Every timer tick (50 ms):
1. Scheduler clears all domBuffer values
2. Scheduler asks animation elements sequenced by priority to update domBuffer
3. Scheduler updates relevant target elements based on updated domBuffer
4. Scheduler refreshes the target elements - all animations are visible at the same time. Also no longer used domBuffer attributes are cleared.
When the animation element is removed, it should remove itself from the scheduler.

Only one instance of the scheduler is created by SMILDocumentImpl. The animated target Element must implement AnimationService to be animated.


Constructor Summary
AnimationScheduler(SMILDocumentImpl smil)
          Creates necessary private variables.
 
Method Summary
 void addAnimation(long priority, SMILAnimationImpl anim)
          Add an animation element.
 java.lang.String getAnimAttribute(org.w3c.dom.Element element, java.lang.String attribute)
          Callback method.
 boolean removeAnimation(SMILAnimationImpl anim)
          Remove an animation element from the AnimationScheduler.
 void run()
          Animate everything.
 void setAnimAttribute(org.w3c.dom.Element element, java.lang.String attribute, java.lang.String value)
          Callback method.
 void stop()
          Stop the scheduler - frees timers etc.
 void updateAnimations()
          Update all animations in the presentation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimationScheduler

public AnimationScheduler(SMILDocumentImpl smil)
Creates necessary private variables.

Method Detail

stop

public void stop()
Stop the scheduler - frees timers etc. Called from the SMILDocumentImpl.


addAnimation

public void addAnimation(long priority,
                         SMILAnimationImpl anim)
Add an animation element. Keeps them ordered by priority. Priority should be the animation element's begin time (relative to document or world time), with exceptions for timebase elements. The update() method of this animation element will be called to get the animated value for the target attribute.


removeAnimation

public boolean removeAnimation(SMILAnimationImpl anim)
Remove an animation element from the AnimationScheduler. update() method of this animation element will no longer be called.


updateAnimations

public void updateAnimations()
Update all animations in the presentation. Goes through all animation elements registered to this scheduler and updates the target attributes in the DOM.


getAnimAttribute

public java.lang.String getAnimAttribute(org.w3c.dom.Element element,
                                         java.lang.String attribute)
Callback method. updateAnimations() will call update() for every active SMILAnimationElementImpl. update() will call back this method to get the animated value, i.e. update() will not get the attribute value straight from the DOM, but from this AnimationScheduler. This method will return the "DOM buffer" value or if it doesn't exist, the real DOM value.

Parameters:
element - Target element
attribute - Target attribute
Returns:
Value of target attribute from the "DOM buffer"

setAnimAttribute

public void setAnimAttribute(org.w3c.dom.Element element,
                             java.lang.String attribute,
                             java.lang.String value)
Callback method. updateAnimations() will call update() for every active SMILAnimationElementImpl. update() will call back this method to set the calculated animated value, i.e. update() will not set the animated value straight to the DOM, but to this AnimationScheduler. updateAnimations() will finally flush these values to the DOM.

Parameters:
element - Target element
attribute - Target attribute
value - Value of target attribute, to be set to the "DOM buffer"

run

public void run()
Animate everything. This thread runs if there are more than zero animations. This thread will call updateAnimations() every 50 ms.

Specified by:
run in interface java.lang.Runnable


X-Smiles 1.2