net.sf.fmj.ejmf.toolkit.gui.controls
Class TimeDisplayControl

java.lang.Object
  extended by net.sf.fmj.ejmf.toolkit.gui.controls.TimeDisplayControl
All Implemented Interfaces:
java.util.EventListener, Control, ControllerListener, SourcedTimerListener, TimeSource

public class TimeDisplayControl
extends java.lang.Object
implements Control, SourcedTimerListener, TimeSource, ControllerListener

A read-only Control that displays media time.

Creates a SourcedTimer to generate ticks that trigger Control to look at media time, convert it to a string and display it.

Registers as SourcedTimerListener and ControllerListener. As ControllerListener, TimerDisplayControl listens for start/restart and stop events to correctly turn SourcedTimer on and off.

See Also:
SourcedTimer, SourcedTimerListener, TimeSource

Field Summary
 
Fields inherited from interface net.sf.fmj.ejmf.toolkit.util.TimeSource
MICROS_PER_SEC, MILLIS_PER_SEC, NANOS_PER_SEC
 
Constructor Summary
TimeDisplayControl(Controller controller)
          Create a TimeDisplayControl for displaying the current media time of the Controller passed as an argument.
TimeDisplayControl(Controller controller, SourcedTimer timer)
          Create a TimeDisplayControl for displaying the current media time of the Controller passed as an argument.
 
Method Summary
 void controllerUpdate(ControllerEvent e)
          Listen for start/stop events and start/stop SourceTimer in response.
 java.awt.Component getControlComponent()
          Return the control component.
 long getConversionDivisor()
          Report value such that getTime()/number equals seconds.
 long getTime()
          Report media time from associated Controller.
 void timerUpdate(SourcedTimerEvent e)
          Respond to 'tick' from SourcedTimer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeDisplayControl

public TimeDisplayControl(Controller controller)
Create a TimeDisplayControl for displaying the current media time of the Controller passed as an argument.

Parameters:
controller - The Controller with which to associate control.

TimeDisplayControl

public TimeDisplayControl(Controller controller,
                          SourcedTimer timer)
Create a TimeDisplayControl for displaying the current media time of the Controller passed as an argument.

The timer is used as the SourcedTimer. This form of the constructor allows reuse of an existing SourcedTimer.

Parameters:
controller - javax.media.Controller
timer - ejmf.toolkit.util.SourcedTimer
See Also:
SourcedTimer
Method Detail

getControlComponent

public java.awt.Component getControlComponent()
Return the control component.

Specified by:
getControlComponent in interface Control
Returns:
java.awt.Component

timerUpdate

public void timerUpdate(SourcedTimerEvent e)
Respond to 'tick' from SourcedTimer.

Specified by:
timerUpdate in interface SourcedTimerListener
Parameters:
e - a SourcedTimerEvent containing TimeSource that generated tick.

controllerUpdate

public void controllerUpdate(ControllerEvent e)
Listen for start/stop events and start/stop SourceTimer in response.

Specified by:
controllerUpdate in interface ControllerListener
Parameters:
e - A controller event used to determine start/stop state of timer.

getTime

public long getTime()
Report media time from associated Controller.

Specified by:
getTime in interface TimeSource
Returns:
media time in nanoseconds

getConversionDivisor

public long getConversionDivisor()
Report value such that getTime()/number equals seconds.

Specified by:
getConversionDivisor in interface TimeSource
Returns:
a long such that getTime()/number equals seconds.