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
-
AbstractClock()
- Constructs an AbstractClock.
-
getMediaNanoseconds()
- Get the media time in nanoseconds.
-
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).
-
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.
-
getRate()
- Get the current temporal scale factor.
-
getStopTime()
- Get the last value successfully set by setStopTime.
-
getSyncTime()
- Gets the time until the Clock's media synchronizes with its
time-base.
-
getTimeBase()
- Get the TimeBase that this Clock is using.
-
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).
-
mapToTimeBase(Time)
- Given a media time, returns the corresponding time-base
time.
-
setMediaTime(Time)
- Sets the media time.
-
setRate(float)
- Set the temporal scale factor.
-
setStopTime(Time)
- Set the media time at which you want the
Clock
to stop.
-
setTimeBase(TimeBase)
- Set the
TimeBase
for this Clock
.
-
stop()
- Stop the Clock.
-
syncStart(Time)
- syncStart the AbstractClock at the previously-
specified time-base start time.
AbstractClock
public AbstractClock()
- Constructs an AbstractClock.
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
.
getTimeBase
public synchronized TimeBase getTimeBase()
- Get the TimeBase that this Clock is using.
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.
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).
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).
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
getMediaNanoseconds
public synchronized long getMediaNanoseconds()
- Get the media time in nanoseconds.
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.
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.
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.
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.
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.
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.
syncStart
public synchronized void syncStart(Time t)
- syncStart the AbstractClock at the previously-
specified time-base start time.
Synchronous method -- return when transition complete
stop
public synchronized void stop()
- Stop the Clock.
All Packages Class Hierarchy This Package Previous Next Index