FileDocCategorySizeDatePackage
TimeContainerSupport.javaAPI DocphoneME MR2 API (J2ME)9428Wed May 02 18:00:36 BST 2007com.sun.perseus.model

TimeContainerSupport

public class TimeContainerSupport extends TimedElementSupport
version
$Id: TimeContainerSupport.java,v 1.4 2006/06/29 10:47:35 ln156897 Exp $

Fields Summary
protected Time
simpleTime
The container's current simple time
protected Vector
timedElementChildren
The set of children TimedElementSupport contained in this container.
Constructors Summary
public TimeContainerSupport()
Default constructor


           
      
    
Methods Summary
voiddispatchEndEvent(Time currentTime)
Dispatches endEvent. As per the SMIL 2 specification, this dispatches an endEvent for the resolved end time, not the observed end time.

param
currentTime the current sampling time.
see
SMIL2's Begin value semantics

        super.dispatchEndEvent(currentTime);

        // Now, force children to end now. Before invoking children, we need 
        // to update the container's simpleTime.
        long time = currentInterval.end.value - currentInterval.begin.value;
        if (simpleDur.isResolved()) {
            if (time > 0) {
                time = time % simpleDur.value;
                if (time == 0) {
                    time = simpleDur.value;
                }
            } 
        }
        
        endChildrenAt(time);
    
voiddispatchOnNewInterval()
Calls all the registered TimeDependents so that they are notified of a new TimeInterval creation. When a time container creates a new interval, its children are re-initialized.

        super.dispatchOnNewInterval();
        
        // Now, re-initialize all children.
        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child = 
                (TimedElementSupport) timedElementChildren.elementAt(i);
            child.initialize();
        }                
    
voiddump()
Traces this viewport tree

        dump(this, "", System.err);
    
static voiddump(TimedElementSupport t, java.lang.String prefix, java.io.PrintStream out)
Debug: traces the input ModelNode, using the input prefix

param
t the node to dump
param
prefix the string used to prefix the node information
param
out the stream where the node structure is dumped.

        out.println(prefix + t);
        if (t instanceof TimeContainerSupport) {
            TimeContainerSupport tc = (TimeContainerSupport) t;
            for (int i = 0; i < tc.timedElementChildren.size(); i++) {
                TimedElementSupport c 
                    = (TimedElementSupport) tc
                        .timedElementChildren.elementAt(i);
                dump(c, prefix + "+--> ", out);
            }
        }
    
voidendChildrenAt(long time)
Implementation helper. Ends all children at the requested input time.

param
time the time, in this container's simple time system, at which children should be stopped.

        setSimpleTime(time);

        // First, end all children. Adding end times does not cause a state
        // transition. To make the children transition to their new state, we 
        // invoke sample in a second iteration (see below).
        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child 
                = (TimedElementSupport) timedElementChildren.elementAt(i);
            child.end();
        }

        // Now, sample children on the end time
        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child 
                = (TimedElementSupport) timedElementChildren.elementAt(i);
            child.sample(simpleTime);
        }        
    
public TimegetSimpleTime()

return
this container's current simple time

        return simpleTime;
    
protected voidinitialize()
Resets this container and all its children. This, in effect, moves the container back to the begining of its timeline, i.e., prior to begining the first interval.

        super.initialize();

        // If a new interval was created, children have already been initialized
        // (see dispatchOnNewInterval). Otherwise, make sure we initialize the 
        // full tree.
        if (currentInterval == null) {
            for (int i = 0; i < timedElementChildren.size(); i++) {
                TimedElementSupport child 
                    = (TimedElementSupport) timedElementChildren.elementAt(i);
                child.initialize();
            }        
        }
    
protected voidonStartingRepeat(int prevIter, int curIter)
When a container starts a new iteration, it needs to: - end its children at the end of the previous interval. - reset its children.

param
prevIter the last iteration this element was playing.
param
curIter the new iteration this element is playing.

        // First, force ending children at the end of the previous iteration.
        long time = currentInterval.begin.value 
                    + 
                    simpleDur.value * (prevIter + 1);
        
        endChildrenAt(time);

        // Now, reset the children so that they are ready for the next sampling
        // at the begining of current interval.
        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child = 
                (TimedElementSupport) timedElementChildren.elementAt(i);
            child.initialize();
        }        
        
    
voidremoveSyncBaseTimesUnder(com.sun.perseus.model.TimeContainerSupport syncTimeContainer)
Removes all IntervalTimeInstances in the begin and end instance list if the syncBase is a descendant of syncTimeContainer

param
syncTimeContainer the container under which times should be removed.

        super.removeSyncBaseTimesUnder(syncTimeContainer);

        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child = 
                (TimedElementSupport) timedElementChildren.elementAt(i);
            child.removeSyncBaseTimesUnder(syncTimeContainer);
        }        
    
voidreset()
When a container resets, it needs to clear all its children which have IntervalTimeInstances on syncBases which are also children (or descendants) of this container.

see
SMIL 2 Specification, Resetting element state

        super.reset();

        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child = 
                (TimedElementSupport) timedElementChildren.elementAt(i);
            child.removeSyncBaseTimesUnder(this);
        }
        
    
voidsampleAt(long simpleTime)
Samples this time container at the given simple time.

param
simpleTime this timed element's simple time.

        setSimpleTime(simpleTime);

        for (int i = 0; i < timedElementChildren.size(); i++) {
            TimedElementSupport child 
                = (TimedElementSupport) timedElementChildren.elementAt(i);
            if (seeking) {
                child.seeking = true;
                child.sample(this.simpleTime);
                child.seeking = false;
            } else {
                child.sample(this.simpleTime);
            }
        }
    
voidsetSimpleTime(long time)
Implementation helper to set the simple time object.

param
time the new simple time value

        if (simpleTime == Time.UNRESOLVED) {
            simpleTime = new Time(time);
        } else {
            simpleTime.value = time;
        }