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

Variable Index

 o _defaultGran
How often in milliseconds the baseTimer triggers

Constructor Index

 o SourcedTimer(TimeSource)
Create a SourcedTimer for the given source using default granularity.
 o SourcedTimer(TimeSource, int)
Create a SourcedTimer for the given source with the specified granularity.
 o SourcedTimer(TimeSource, Timer)
Create a SourcedTimer for the given source.

Method Index

 o actionPerformed(ActionEvent)
Called in response to an ActionEvent from the associated base timer.
 o addSourcedTimerListener(SourcedTimerListener)
Add a listener to this object.
 o getConversionDivisor()
A client of SourcedTimer may need to convert source timer time from raw units to some other units for display purposes.
 o start()
Start the timer.
 o stop()
Stop the timer.

Variables

 o _defaultGran
 protected static int _defaultGran
How often in milliseconds the baseTimer triggers

Constructors

 o SourcedTimer
 public SourcedTimer(TimeSource src)
Create a SourcedTimer for the given source using default granularity.

Parameters:
src - An object that implements the TimeSource interface.
 o 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.
 o 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.

Methods

 o start
 public void start()
Start the timer. The associated base timer is started if it is not already running.

 o stop
 public void stop()
Stop the timer. The associated base timer is stopped.

 o 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.
 o addSourcedTimerListener
 public void addSourcedTimerListener(SourcedTimerListener l)
Add a listener to this object.

Parameters:
l - An object that implements SourcedTimerListener interface.
 o 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