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

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

public class StandardProgressControl
extends ChangeListenerControl
implements ControllerListener, TimeSource, SourcedTimerListener

Progress slider for StandardControlPanel. This control maintains an internal time which 'ticks'. At each tick, StandardProgressControl maps media time into a slider value and updates the progress slider.

The timer is provided by ejmf.toolkit.util.SourcedTimer. StandardProgressControl receieves 'ticks' by virtue of being a SourcedTimerListener.


Field Summary
 
Fields inherited from class net.sf.fmj.ejmf.toolkit.gui.controls.AbstractListenerControl
skin
 
Fields inherited from interface net.sf.fmj.ejmf.toolkit.util.TimeSource
MICROS_PER_SEC, MILLIS_PER_SEC, NANOS_PER_SEC
 
Constructor Summary
StandardProgressControl(Skin skin)
           
StandardProgressControl(Skin skin, Controller controller)
           
 
Method Summary
 void controllerUpdate(ControllerEvent event)
          If the progress slider is operational, the controllerUpdate method starts and stops its time based on Start- and StopEvents from the Controller.
protected  java.awt.Component createControlComponent(Skin skin)
          Create ProgressSlider
protected  java.util.EventListener createControlListener()
          Create ChangeListener.
 long getConversionDivisor()
          This method is used as a divisor to convert getTime to seconds.
 long getTime()
          As part of TimeSource interface, getTime returns the current media time in nanoseconds.
protected  void setControllerHook(Controller controller)
          Augments setController by adding itself as as ControllerListener on the Controller and forcing operational state to false.
 void setValue(long mediaTime)
          Position slider based on mediaTime
 void timerUpdate(SourcedTimerEvent e)
          This method implements the SourcedTimerListener interface.
 
Methods inherited from class net.sf.fmj.ejmf.toolkit.gui.controls.ChangeListenerControl
addControlListener, removeControlListener, setComponent, setComponentAndListener, setControlListener
 
Methods inherited from class net.sf.fmj.ejmf.toolkit.gui.controls.AbstractListenerControl
getControlComponent, getController, getDefaultControlListener, initListener, isOperational, setComponent, setComponentAndListener, setController, setControlListener, setOperational, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StandardProgressControl

public StandardProgressControl(Skin skin,
                               Controller controller)

StandardProgressControl

public StandardProgressControl(Skin skin)
Method Detail

createControlComponent

protected java.awt.Component createControlComponent(Skin skin)
Create ProgressSlider

Specified by:
createControlComponent in class AbstractListenerControl
Returns:
a Component
See Also:
ProgressSlider

setControllerHook

protected void setControllerHook(Controller controller)
Augments setController by adding itself as as ControllerListener on the Controller and forcing operational state to false. Availability of progress bar is determined only after Controller is prefetch and duration is determinate.

Overrides:
setControllerHook in class AbstractListenerControl
Parameters:
controller - Controller with which this control is associated.

createControlListener

protected java.util.EventListener createControlListener()
Create ChangeListener. Tracks user movement of progress slider and update media time accordingly.

Specified by:
createControlListener in class AbstractListenerControl
Returns:
an EventListener

setValue

public void setValue(long mediaTime)
Position slider based on mediaTime


controllerUpdate

public void controllerUpdate(ControllerEvent event)
If the progress slider is operational, the controllerUpdate method starts and stops its time based on Start- and StopEvents from the Controller. If response to MediaTimeSetEvent, the value of the progress slider is explicitly set.

The controllerUpdate method is also responsible for setting the operational state of the Control based on duration value. This is done in response to first PrefetchCompleteEvent.

Specified by:
controllerUpdate in interface ControllerListener

timerUpdate

public void timerUpdate(SourcedTimerEvent e)
This method implements the SourcedTimerListener interface. Each timer tick causes slider thumbnail to move if a ProgressBar was built for this control panel.

Specified by:
timerUpdate in interface SourcedTimerListener
See Also:
SourcedTimer

getTime

public long getTime()
As part of TimeSource interface, getTime returns the current media time in nanoseconds.

Specified by:
getTime in interface TimeSource

getConversionDivisor

public long getConversionDivisor()
This method is used as a divisor to convert getTime to seconds.

Specified by:
getConversionDivisor in interface TimeSource