org.lyra.Host
Class Pendulum

java.lang.Object
  extended by org.lyra.Host.Pendulum
All Implemented Interfaces:
java.lang.Runnable, UpdateListener

public class Pendulum
extends java.lang.Object
implements java.lang.Runnable, UpdateListener

The Multimedia Player Daemon does not send updates to track the timing of the song. As a result the user is left with either forcing an update every half second to a second in order to ensure that it displays properly or to create their own timer.

In order to save on bandwidth we have created a timer and associated listener that will perform the function in between player updates. This class will also listen in on updates and always provide an update regardless of state. The difference however is that the thread will not be available unless the playback mode is set to play.

Version:
1.0.5, %Revision, 174%, %LastChangedDate, 27/10/12 3:33PM%
Author:
Martin Foster
See Also:
PendulumListener, Updater

Field Summary
private static java.lang.String CLASS
           
private  java.util.List<PendulumListener> Clients
           
private  Status Information
           
private  java.util.Map<java.lang.String,java.lang.String> Lang
           
private  Ledger Logger
           
(package private)  long myEnd
           
private  java.lang.Thread myThread
           
(package private)  int myTotal
           
private  boolean Process
           
 
Constructor Summary
Pendulum(Ledger logger, Status information, java.util.Map<java.lang.String,java.lang.String> lang)
          Default constructor for the class.
 
Method Summary
 void addTimerListener(PendulumListener l)
          Adds an TimerListener to the updater.
private  void fireUpdateRequired(int elapsed, int total)
          Triggers a notification to all of the elements in order to update the time and elapsed time elements for the song.
 PendulumListener[] getTimerListeners()
          Returns an array of all the TimerListeners added to this class with addTimerListener().
 void hostUpdated(UpdateEvent update)
          Updates of host information as passed through this specific method.
 void removeTimerListener(PendulumListener l)
          Removes an TimerListener from the updater.
 void run()
           
 void stopRun()
          Method used to stop any given thread running on this class.
private  void Update()
          This method will handle the actual update and decide what to so with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myThread

private java.lang.Thread myThread

Clients

private java.util.List<PendulumListener> Clients

Process

private boolean Process

myEnd

long myEnd

myTotal

int myTotal

CLASS

private static final java.lang.String CLASS
See Also:
Constant Field Values

Logger

private Ledger Logger

Information

private Status Information

Lang

private java.util.Map<java.lang.String,java.lang.String> Lang
Constructor Detail

Pendulum

public Pendulum(Ledger logger,
                Status information,
                java.util.Map<java.lang.String,java.lang.String> lang)
Default constructor for the class. Will ensure that logger and status elements are in place for the main code.

Parameters:
logger - Ledger instance for logging events.
information - Status instance for keeping track of states.
lang - Language map.
Method Detail

Update

private void Update()
This method will handle the actual update and decide what to so with it. Since we have the need to update at two points, one being the constructor and the other being the actual update handler.


addTimerListener

public void addTimerListener(PendulumListener l)
Adds an TimerListener to the updater.

Parameters:
l - Class implementing the TimerListener interface.

removeTimerListener

public void removeTimerListener(PendulumListener l)
Removes an TimerListener from the updater.

Parameters:
l - Instance of class implementing the TimerListener interface.

getTimerListeners

public PendulumListener[] getTimerListeners()
Returns an array of all the TimerListeners added to this class with addTimerListener().

Returns:
All of the TimerListeners added or an empty array if no listeners have been added.

fireUpdateRequired

private void fireUpdateRequired(int elapsed,
                                int total)
Triggers a notification to all of the elements in order to update the time and elapsed time elements for the song.

Parameters:
elapsed - Integer carrying current runtime.
total - Integer representing total play time.

hostUpdated

public void hostUpdated(UpdateEvent update)
Description copied from interface: UpdateListener
Updates of host information as passed through this specific method. Multiple updates can be triggered from this, so it becomes important to check for a specific update if necessary in order to avoid undue

Specified by:
hostUpdated in interface UpdateListener
Parameters:
update - Update notification method.
See Also:
UpdateEvent

run

public void run()
Specified by:
run in interface java.lang.Runnable

stopRun

public void stopRun()
Method used to stop any given thread running on this class. Normally called once we are done with the application.