net.sourceforge.nite.time
Class DefaultClock

java.lang.Object
  extended by net.sourceforge.nite.time.DefaultClock
All Implemented Interfaces:
Clock

public class DefaultClock
extends java.lang.Object
implements Clock

An implementation of the Clock interface.

Author:
jeanc, jonathan, judy

Field Summary
static int PAUSE
           
 java.util.Set timeHandlers
           
static int WARN
           
 
Constructor Summary
DefaultClock()
           
DefaultClock(NMetaData meta, java.lang.String observation)
          this constructor takes the list of 'NSignal's to be (potentially) synced by the clock.
 
Method Summary
 void deregisterTimeHandler(TimeHandler display)
          Deregister a TimeHandler so that it can no longer set and get times from this Clock
 void ensureVisible(java.awt.Container desk)
          ensure visibility of interface
 void ensureVisible(java.awt.Rectangle rect, java.awt.Container desk)
          ensure we have some buttons to play with!
 javax.swing.JInternalFrame getDisplay()
          Return the visual display of this clock (as a control strip)
 NMediaHandler getMediaHandler()
          return the handler for all PlayingTimeHandlers on this clock
 double getSystemTime()
          Return the current system time
 int getWindSkip()
          get the number of seconds the fast-forward and rewind buttons jump
 boolean isMediaPlaying()
          return true if the media is in the 'playing' state
 void pause()
          pass a pause message to any ClockFace ui component, causing any media files to be paused
 void play()
          pass a play message to any ClockFace ui component, causing any media files to start playing
 double pollMediaTime()
          Finds out the time from the master media - also sends sync signals if neccesary.
 void registerMaxTime(int max, PlayingTimeHandler display)
          Called by registered displays to allow the slider to be set correctly.
 void registerTimeHandler(TimeHandler display)
          Register a TimeHandler that will henceforth be able to set and get times from this Clock.
 void setInterventionType(int ervention)
          set the intervention type when signal drift exceeds the threshold: PAUSE to reset all the signals by pausing and restarting; WARN to simply print a message
 void setMasterPlayer(PlayingTimeHandler pth)
          set the PlayingTimeHandler that controls time for this Clock
 void setMaximumDrift(double drift)
          set the high-end cutoff - if video or audio drift from the master signal by more than this number, we intervene either by pausing and restarting all the signals, or by printing a warning message
 void setSendSynchronization(boolean val)
          set the player to send synchronize messages to registered TimeHandlers
 void setSystemTime(double newTime)
          Set the time and notify all handlers.
 void setSystemTime(double newTime, TimeHandler setter)
          Set the time and notify all handlers, except the one that just set the time.
 void setTimeSpan(double start, double end)
          Receive notification of a new span and pass the new span to all registered TimeHandlers.
 void setTimeSpan(double start, double end, boolean play)
          Receive notification of a new span and pass the new span to all registered TimeHandlers; the third argument specifies whether the segment is 'played' in real time by the clock.
 void setTimeSpan(double start, double end, TimeHandler setter)
          Receive notification of a new span and pass the new span to all registered TimeHandlers other than the one passed as an argument.
 void setTimeSpan(double start, double end, TimeHandler setter, boolean play)
          Receive notification of a new span and pass the new span to all registered TimeHandlers other than the one passed as an argument; the third argument specifies whether the segment is 'played' in real time by the clock.
 void setVerbose(boolean verb)
          set the verbosity.
 void setWindSkip(int seconds)
          set the number of seconds the fast-forward and rewind buttons jump
 void showSignal(java.lang.String filename, NSignal signal, java.lang.String agent)
          show the signal: this will involve either finding the already-registered signal and moving that window to the front, or actually starting up a new media player and registering it
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeHandlers

public java.util.Set timeHandlers

PAUSE

public static final int PAUSE
See Also:
Constant Field Values

WARN

public static final int WARN
See Also:
Constant Field Values
Constructor Detail

DefaultClock

public DefaultClock()

DefaultClock

public DefaultClock(NMetaData meta,
                    java.lang.String observation)
this constructor takes the list of 'NSignal's to be (potentially) synced by the clock.

Method Detail

registerTimeHandler

public void registerTimeHandler(TimeHandler display)
Register a TimeHandler that will henceforth be able to set and get times from this Clock. This now does a different thing for PlayingTimeHandlers, which are assumed to be continuous, and TimeHandlers which are assumed to be discrete. PlayingTimeHandlers get their own MediaHandler, so all media instances can be controlled 'as one'.

Specified by:
registerTimeHandler in interface Clock

registerMaxTime

public void registerMaxTime(int max,
                            PlayingTimeHandler display)
Called by registered displays to allow the slider to be set correctly. This now also registers the playing time handlers, so we can make sure they're all actually playing a media file.

Specified by:
registerMaxTime in interface Clock

pollMediaTime

public double pollMediaTime()
Finds out the time from the master media - also sends sync signals if neccesary.


deregisterTimeHandler

public void deregisterTimeHandler(TimeHandler display)
Deregister a TimeHandler so that it can no longer set and get times from this Clock

Specified by:
deregisterTimeHandler in interface Clock

getMediaHandler

public NMediaHandler getMediaHandler()
return the handler for all PlayingTimeHandlers on this clock


getSystemTime

public double getSystemTime()
Return the current system time

Specified by:
getSystemTime in interface Clock

setTimeSpan

public void setTimeSpan(double start,
                        double end)
Receive notification of a new span and pass the new span to all registered TimeHandlers. This version plays the segment through in real time; if you don't want that behaviour, use the version with a third (boolean) argument to turn off the playing behaviour.

Specified by:
setTimeSpan in interface Clock

setTimeSpan

public void setTimeSpan(double start,
                        double end,
                        boolean play)
Receive notification of a new span and pass the new span to all registered TimeHandlers; the third argument specifies whether the segment is 'played' in real time by the clock.

Specified by:
setTimeSpan in interface Clock

setTimeSpan

public void setTimeSpan(double start,
                        double end,
                        TimeHandler setter)
Receive notification of a new span and pass the new span to all registered TimeHandlers other than the one passed as an argument. This version plays the segment through in real time; if you don't want that behaviour, use the version with a fourth (boolean) argument to turn off the playing behaviour.

Specified by:
setTimeSpan in interface Clock

setTimeSpan

public void setTimeSpan(double start,
                        double end,
                        TimeHandler setter,
                        boolean play)
Receive notification of a new span and pass the new span to all registered TimeHandlers other than the one passed as an argument; the third argument specifies whether the segment is 'played' in real time by the clock.

Specified by:
setTimeSpan in interface Clock

setSystemTime

public void setSystemTime(double newTime)
Set the time and notify all handlers.

Specified by:
setSystemTime in interface Clock

setSystemTime

public void setSystemTime(double newTime,
                          TimeHandler setter)
Set the time and notify all handlers, except the one that just set the time.

Specified by:
setSystemTime in interface Clock

getDisplay

public javax.swing.JInternalFrame getDisplay()
Return the visual display of this clock (as a control strip)

Specified by:
getDisplay in interface Clock

setWindSkip

public void setWindSkip(int seconds)
set the number of seconds the fast-forward and rewind buttons jump

Specified by:
setWindSkip in interface Clock

getWindSkip

public int getWindSkip()
get the number of seconds the fast-forward and rewind buttons jump

Specified by:
getWindSkip in interface Clock

ensureVisible

public void ensureVisible(java.awt.Container desk)
ensure visibility of interface

Specified by:
ensureVisible in interface Clock

ensureVisible

public void ensureVisible(java.awt.Rectangle rect,
                          java.awt.Container desk)
ensure we have some buttons to play with!

Specified by:
ensureVisible in interface Clock

setSendSynchronization

public void setSendSynchronization(boolean val)
set the player to send synchronize messages to registered TimeHandlers


showSignal

public void showSignal(java.lang.String filename,
                       NSignal signal,
                       java.lang.String agent)
show the signal: this will involve either finding the already-registered signal and moving that window to the front, or actually starting up a new media player and registering it


isMediaPlaying

public boolean isMediaPlaying()
return true if the media is in the 'playing' state


play

public void play()
pass a play message to any ClockFace ui component, causing any media files to start playing

Specified by:
play in interface Clock

pause

public void pause()
pass a pause message to any ClockFace ui component, causing any media files to be paused

Specified by:
pause in interface Clock

setMasterPlayer

public void setMasterPlayer(PlayingTimeHandler pth)
set the PlayingTimeHandler that controls time for this Clock

Specified by:
setMasterPlayer in interface Clock

setMaximumDrift

public void setMaximumDrift(double drift)
set the high-end cutoff - if video or audio drift from the master signal by more than this number, we intervene either by pausing and restarting all the signals, or by printing a warning message


setVerbose

public void setVerbose(boolean verb)
set the verbosity. In verbose mode you get a printout of all signal values at all triel points; otherwise only interventions are noted.


setInterventionType

public void setInterventionType(int ervention)
set the intervention type when signal drift exceeds the threshold: PAUSE to reset all the signals by pausing and restarting; WARN to simply print a message