All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ejmf.toolkit.media.AbstractClock

java.lang.Object
   |
   +----ejmf.toolkit.media.AbstractClock

public class AbstractClock
extends Object
implements Clock
The AbstractClock provides an abstract implementation of the javax.media.Clock interface. All methods are implemented except for setStopTime() and getStopTime(). These methods will invariably require implementation-specific functionality and therefore are left to the subclasses to implement.

See Also:
AbstractController, StopTimeMonitor

Constructor Index

 o AbstractClock()
Constructs an AbstractClock.

Method Index

 o getMediaNanoseconds()
Get the media time in nanoseconds.
 o getMediaStartTime()
Get the media time the media is scheduled to start (if the Clock is stopped), or the media time at which the Clock started (if the Clock is started).
 o getMediaTime()
Calculates the current media time based on the current time-base time, the time-base start time, the media start time, and the rate.
 o getRate()
Get the current temporal scale factor.
 o getStopTime()
Get the last value successfully set by setStopTime.
 o getSyncTime()
Gets the time until the Clock's media synchronizes with its time-base.
 o getTimeBase()
Get the TimeBase that this Clock is using.
 o getTimeBaseStartTime()
Get the time-base time the media is scheduled to start (if the Clock is stopped), or the time-base time at which the Clock started (if the Clock is started).
 o mapToTimeBase(Time)
Given a media time, returns the corresponding time-base time.
 o setMediaTime(Time)
Sets the media time.
 o setRate(float)
Set the temporal scale factor.
 o setStopTime(Time)
Set the media time at which you want the Clock to stop.
 o setTimeBase(TimeBase)
Set the TimeBase for this Clock.
 o stop()
Stop the Clock.
 o syncStart(Time)
syncStart the AbstractClock at the previously- specified time-base start time.

Constructors

 o AbstractClock
 public AbstractClock()
Constructs an AbstractClock.

Methods

 o setTimeBase
 public synchronized void setTimeBase(TimeBase timebase) throws IncompatibleTimeBaseException
Set the TimeBase for this Clock. This method can only be called on a Stopped Clock. A ClockStartedError is thrown if setTimeBase is called on a Started Clock.

A Clock has a default TimeBase that is determined by the implementation. To reset a Clock to its default TimeBase, call setTimeBase(null).

Parameters:
timebase - The new TimeBase or null to reset the Clock to its default TimeBase.
Throws: IncompatibleTimeBaseException
Thrown if the Clock can't use the specified TimeBase.
 o getTimeBase
 public synchronized TimeBase getTimeBase()
Get the TimeBase that this Clock is using.

 o setMediaTime
 public synchronized void setMediaTime(Time t)
Sets the media time.

Parameters:
t - The media time to set
Throws: ClockStartedError
If the Clock is Started.
 o getMediaStartTime
 protected Time getMediaStartTime()
Get the media time the media is scheduled to start (if the Clock is stopped), or the media time at which the Clock started (if the Clock is started).

 o getTimeBaseStartTime
 protected Time getTimeBaseStartTime()
Get the time-base time the media is scheduled to start (if the Clock is stopped), or the time-base time at which the Clock started (if the Clock is started).

 o getMediaTime
 public synchronized Time getMediaTime()
Calculates the current media time based on the current time-base time, the time-base start time, the media start time, and the rate.

Returns:
The current media time
 o getMediaNanoseconds
 public synchronized long getMediaNanoseconds()
Get the media time in nanoseconds.

 o getSyncTime
 public synchronized Time getSyncTime()
Gets the time until the Clock's media synchronizes with its time-base.

Returns:
The time remaining until the time-base start-time if this Clock is Started and the time-base start-time has not yet been reached, or the media time otherwise.
 o mapToTimeBase
 public synchronized Time mapToTimeBase(Time t) throws ClockStoppedException
Given a media time, returns the corresponding time-base time. Uses the current rate, the time-base start time, and the media start time to calculate.

Parameters:
mediaStartTime - A media time to be mapped to a time-base time.
Returns:
A time-base time.
Throws: ClockStoppedException
If the clock has not started.
 o setRate
 public synchronized float setRate(float rate)
Set the temporal scale factor. The argument suggests the scale factor to use.

The setRate method returns the actual rate set by the Clock. Clocks should set their rate as close to the requested value as possible, but are not required to set the rate to the exact value of any argument other than 1.0. A Clock is only guaranteed to set its rate exactly to 1.0.

Parameters:
rate - The temporal scale factor (rate) to set.
Returns:
The actual rate set.
Throws: ClockStartedError
If the Clock is Started.
 o getRate
 public synchronized float getRate()
Get the current temporal scale factor. The scale factor defines the relationship between the Clock's media time and its TimeBase.

For example, a rate of 2.0 indicates that media time will pass twice as fast as the TimeBase time once the Clock starts. Similarly, a negative rate indicates that the Clock runs in the opposite direction of its TimeBase. All Clocks are guaranteed to support a rate of 1.0, the default rate. Clocks are not required to support any other rate.

 o setStopTime
 public synchronized void setStopTime(Time mediaStopTime)
Set the media time at which you want the Clock to stop. The Clock will stop when its media time passes the stop-time. To clear the stop time, set it to: Clock.RESET.

You can always call setStopTime on a Stopped Clock.

On a Started Clock, the stop-time can only be set once. A StopTimeSetError is thrown if setStopTime is called and the media stop-time has already been set.

Parameters:
mediaStopTime - The time at which you want the Clock to stop, in media time.
 o getStopTime
 public synchronized Time getStopTime()
Get the last value successfully set by setStopTime. Returns the constant Clock.RESET if no stop time is set

Returns:
The current stop time.
 o syncStart
 public synchronized void syncStart(Time t)
syncStart the AbstractClock at the previously- specified time-base start time.

Synchronous method -- return when transition complete

 o stop
 public synchronized void stop()
Stop the Clock.


All Packages  Class Hierarchy  This Package  Previous  Next  Index