org.problets.lib.timer
Class TimerModel

java.lang.Object
  extended by org.problets.lib.timer.TimerModel
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class TimerModel
extends java.lang.Object
implements java.awt.event.ActionListener

TimerModel class - Wraps around Timer class, - Counts to a given amount of time - And IF the applet is timed, Issues an ActionEvent to help main applet terminate itself - This is a notifier class - it notifies all its listeners through their actionPerformed. It is not capable of calling methods specific to those listeners, including paint(). - How to use: Create an instance, call startTimer() Call pauseTimer() and resumeTimer() if necessary Call stopTimer() at the end Call restartTimer() to time a new session

Author:
Amruth Kumar, Eric Fernandes

Field Summary
static java.lang.String PULSE
           
 
Constructor Summary
TimerModel(java.awt.event.ActionListener inClient, int inStopTime)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Handles updating the elapsed seconds If the elapsed time has exceeded preset end time, issues an ActionEvent for the main application.
 void addActionListener(java.awt.event.ActionListener listener)
          Method to add actionListener to the TimerModel
 int getElapsedTime()
           
 void pauseTimer()
          Pauses the timer without resetting the count.
 void removeActionListener(java.awt.event.ActionListener listener)
          Method to remove actionListener to the TimerModel
 void restartTimer()
          Restarts the timer, and initializes count.
 void resumeTimer()
          Resumes the timer, resumes the count
 void startTimer()
          Starts the timer, and initializes count.
 int stopTimer()
          Stops the timer, returns the count and resets it
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PULSE

public static final java.lang.String PULSE
See Also:
Constant Field Values
Constructor Detail

TimerModel

public TimerModel(java.awt.event.ActionListener inClient,
                  int inStopTime)
Parameters:
Any - class that implements ActionListener interface
The - duration in minutes that the timer should tick
Method Detail

getElapsedTime

public int getElapsedTime()

startTimer

public void startTimer()
Starts the timer, and initializes count.


pauseTimer

public void pauseTimer()
Pauses the timer without resetting the count.


resumeTimer

public void resumeTimer()
Resumes the timer, resumes the count


stopTimer

public int stopTimer()
Stops the timer, returns the count and resets it


restartTimer

public void restartTimer()
Restarts the timer, and initializes count. Different from startTimer in that this will stop the timer if it is already running, and start it again. To be used every time the timer is brought back to use for a new purpose.


addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Method to add actionListener to the TimerModel


removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Method to remove actionListener to the TimerModel


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Handles updating the elapsed seconds If the elapsed time has exceeded preset end time, issues an ActionEvent for the main application.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - The ActionEvent object.