FileDocCategorySizeDatePackage
TimeContainerRootSupport.javaAPI DocphoneME MR2 API (J2ME)6682Wed May 02 18:00:34 BST 2007com.sun.perseus.model

TimeContainerRootSupport

public class TimeContainerRootSupport extends TimeContainerSupport
version
$Id: TimeContainerRootSupport.java,v 1.2 2006/04/21 06:37:20 st125089 Exp $

Fields Summary
protected long
beginWallClockTime
The time at which the document started. This is initially set when animation is started and then modified when the document's timeline is seeked to a particular time.
protected Time
lastSampleTime
The last sample time.
protected boolean
seekingBack
Flags that the seek is backwards
Constructors Summary
TimeContainerRootSupport()
There is no parent container for this root. The parent is this node itself. Also, the root time container has a default 0-offset begin condition added to it so that the first interval is created and is [0, INDEFINITE[.


                                                 
     
        timeContainer = this;

        // Add a new 0-offset begin condition.
        new OffsetCondition(this, true, 0);
    
Methods Summary
voiddispatchBeginEvent(Time beginTime)
Dispatches beginEvent. See the TimedElementSupport class method implementation. This class also uses the opportunity to record what the wallclock time is for the begin time so that localTimes can be converted later.

param
beginTime the interval begin time

        super.dispatchBeginEvent(beginTime);

        beginWallClockTime = System.currentTimeMillis();

        // With the following, beginTime will map to beginWallClockTime,
        // as expected.
        beginWallClockTime -= beginTime.value;
    
TimegetContainerSimpleDuration()
For the root container, there is no container simple duration, so we retun INDEFINITE, no matter what the state is.

return
the container's simple duration.

        return Time.INDEFINITE;
    
com.sun.perseus.model.TimeContainerRootSupportgetRootContainer()
Helper method.

return
this timed element's root container.

        return this;
    
voidsample(Time currentTime)
Overrides the default sample time to capture the last sample time.

param
currentTime the time at which this element should be sampled.

        super.sample(currentTime);
        lastSampleTime = currentTime;
    
voidseekTo(Time seekToTime)
Seek to the requested time. The time is assumed to be in document simple time.

param
seekToTime the time to seek to

        if (!seekToTime.isResolved()) {
            throw new IllegalStateException();
        }

        seeking = true;
        seekingBack = !seekToTime.greaterThan(lastSampleTime);
        try {
            sample(seekToTime);
        } finally {
            seeking = false;
        }
    
protected voidsetTimeContainer(TimeContainerSupport timeContainer)
Always throws an exception because a root container should not have a parent container.

param
timeContainer time container
throws
IllegalArgumentException always thrown for a root time container which should not have a parent container.

        throw new IllegalArgumentException();
    
TimetoContainerSimpleTime(Time rootSimpleTime)
Converts the input root container simple time (i.e., a time in the root container's simple time interval) to a time in this element's time container simple duration.

param
rootSimpleTime the time in the root container's simple duration.
return
a simple time in the parent container's simple duration The return value is in the [0, container simple duration] interval.

        return rootSimpleTime;
    
TimetoRootContainerSimpleTime(Time simpleTime)
Converts the input simple time (i.e., a time in the parent container's simple duration) to a root container simple time (i.e., a time in the root time container's simple time interval).

param
simpleTime the time in the parent container's simple duration
return
a time in the root time container's simple duration (i.e., in the root container's simple time interval).

        return simpleTime;
    
TimetoRootContainerSimpleTimeClamp(Time simpleTime)
Converts the input simple time (i.e., a time in the parent container's simple duration) to a root container simple time (i.e., a time in the root time container's simple time interval).

param
simpleTime the time in the parent container's simple duration
return
a time in the root time container's simple duration (i.e., in the root container's simple time interval).

        // Note that no clamping is necessary here because the clamping is
        // done in a timed element, relative to its container's simple time.
        // By the time this is called on the root, the child timed element has
        // already applied the root's constraints.
        return simpleTime;
    
longtoWallClockTime(long localTime)
Converts the input 'local' time to an absolute wallclock time.

param
localTime the time to convert to wallclock time
return
the time, converted to wall clock time.

        return beginWallClockTime + localTime;