All Packages Class Hierarchy This Package Previous Next Index
Class ejmf.toolkit.util.SourcedTimer
java.lang.Object
|
+----ejmf.toolkit.util.SourcedTimer
- public class SourcedTimer
- extends Object
- implements ActionListener
The SourcedTimer class implements a timer dependent
on a named source. This is a generalization of a timer simply dependent
on a monotonically increasing clock.
An instance of SourcedTimer creates a java.swing.Timer and becomes
a listener on that timer. This timer is called the base timer.
Every time the base timer fires, the SourcedTimer object asks its
source what time it is and then notifies its listeners.
This class is used by the TimerPlayer to track media time.
- See Also:
- Timer, TimeSource, TimerPlayer
-
_defaultGran
- How often in milliseconds the baseTimer triggers
-
SourcedTimer(TimeSource)
- Create a SourcedTimer for the given source using
default granularity.
-
SourcedTimer(TimeSource, int)
- Create a SourcedTimer for the given source with the specified
granularity.
-
SourcedTimer(TimeSource, Timer)
-
Create a SourcedTimer for the given source.
-
actionPerformed(ActionEvent)
- Called in response to an ActionEvent from the associated
base timer.
-
addSourcedTimerListener(SourcedTimerListener)
- Add a listener to this object.
-
getConversionDivisor()
- A client of SourcedTimer may need to convert source timer time
from raw units to some other units for display purposes.
-
start()
- Start the timer.
-
stop()
- Stop the timer.
_defaultGran
protected static int _defaultGran
- How often in milliseconds the baseTimer triggers
SourcedTimer
public SourcedTimer(TimeSource src)
- Create a SourcedTimer for the given source using
default granularity.
- Parameters:
- src
- An object that implements the TimeSource interface.
SourcedTimer
public SourcedTimer(TimeSource src,
Timer timer)
- Create a SourcedTimer for the given source. Use the Timer
passed as an argument for the base timer.
- Parameters:
- src
- An object that implements the TimeSource interface.
- timer
- A java.swing.Timer object for use as base timer.
SourcedTimer
public SourcedTimer(TimeSource src,
int granularity)
- Create a SourcedTimer for the given source with the specified
granularity.
- Parameters:
- src
- An object that implements the TimeSource interface.
- granularity
- Periood in milliseconds that base timer should fire.
start
public void start()
- Start the timer. The associated base timer is started if
it is not already running.
stop
public void stop()
- Stop the timer. The associated base timer is stopped.
actionPerformed
public void actionPerformed(ActionEvent e)
- Called in response to an ActionEvent from the associated
base timer. Nominally this method is called every granularity
milliseconds.
- Parameters:
- e
- ActionEvent from base timer.
addSourcedTimerListener
public void addSourcedTimerListener(SourcedTimerListener l)
- Add a listener to this object.
- Parameters:
- l
- An object that implements SourcedTimerListener interface.
getConversionDivisor
public long getConversionDivisor()
- A client of SourcedTimer may need to convert source timer time
from raw units to some other units for display purposes.
This method is available to listeners who have a reference
to a SourcedTimer but not necessarily the source itself.
It simply delegates to the source and asks what number are
raw units divider by to arrive at seconds.
- Returns:
- A number used to divide base timer time
for conversion to seconds.
All Packages Class Hierarchy This Package Previous Next Index