jrummikub.control
Class TurnTimer

java.lang.Object
  extended by jrummikub.control.TurnTimer
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, ITurnTimer

public class TurnTimer
extends java.lang.Object
implements java.awt.event.ActionListener, ITurnTimer

Count-down timer used to limit the turn time


Field Summary
private  int timeLeft
           
private  javax.swing.Timer timer
           
private  Event timeRunOutEvent
           
private  int totalTime
           
private  IView view
           
 
Constructor Summary
TurnTimer(IView view, int totalTime)
          Create a new timer using a given view to display the current time left
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent arg0)
           
 IEvent getTimeRunOutEvent()
          Returns the event that is emitted if the timer timed out.
 void startTimer()
          Starts the timer
 void stopTimer()
          Stops the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

private IView view

timeLeft

private int timeLeft

totalTime

private int totalTime

timer

private javax.swing.Timer timer

timeRunOutEvent

private Event timeRunOutEvent
Constructor Detail

TurnTimer

public TurnTimer(IView view,
                 int totalTime)
Create a new timer using a given view to display the current time left

Parameters:
view - view to display
totalTime - total time for turn
Method Detail

startTimer

public void startTimer()
Description copied from interface: ITurnTimer
Starts the timer

Specified by:
startTimer in interface ITurnTimer

stopTimer

public void stopTimer()
Description copied from interface: ITurnTimer
Stops the timer. Stopping an already stopped timer is a no-op.

Specified by:
stopTimer in interface ITurnTimer

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg0)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getTimeRunOutEvent

public IEvent getTimeRunOutEvent()
Description copied from interface: ITurnTimer
Returns the event that is emitted if the timer timed out.

Specified by:
getTimeRunOutEvent in interface ITurnTimer
Returns:
time out event