com.planeth.common.timing
Class WaitTimer

java.lang.Object
  extended bycom.planeth.common.timing.WaitTimer
All Implemented Interfaces:
ITimeControllable

public class WaitTimer
extends java.lang.Object
implements ITimeControllable

WaitTimer implementation

The difference to a Timer is as follow:
A WaitTimer hasn't any relation to a Thread.
The isWaitPeriodOver method returns false until the waiting period is over, that's all.
It's similar to a backward running stopwatch with the difference, that you can define the number of wait periods (1 to INFINITE_PERIODS) to be completed.
It can also be uses as a controller for a toggling action.

The min waitTime is 10 millis.

Author:
Andreas Grässer, gal@planet-h.com.
created May 6, 2005
See Also:
Timer, TimerManager

Field Summary
static int MINIMUM_WAIT_TIME
           
 
Constructor Summary
WaitTimer(int waitMillis)
          Constructor for WaitTimer.
WaitTimer(int waitMillis, int numberOfPeriods)
          Constructor for WaitTimer.
 
Method Summary
 boolean getTogglingFlag()
          Returns the toggling flag.
 boolean isWaitPeriodOver()
          Returns true, if the defined waitMillis are over.
 void pause(boolean pauseState)
          Pauses/unpauses the WaitTimer
 void restart()
          Restarts the WaitTimer with the defined number of wait periods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_WAIT_TIME

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

WaitTimer

public WaitTimer(int waitMillis)
Constructor for WaitTimer.
The number of periods is infinit for this constructor.

Parameters:
waitMillis - the main wait time in millis

WaitTimer

public WaitTimer(int waitMillis,
                 int numberOfPeriods)
Constructor for WaitTimer.

Parameters:
waitMillis - the main wait time in millis
numberOfPeriods - the number of wait periods to be completed until the WaitTimer ends
Method Detail

isWaitPeriodOver

public boolean isWaitPeriodOver()
Returns true, if the defined waitMillis are over.

Returns:
Returns true, if the defined waitMillis are over.

getTogglingFlag

public boolean getTogglingFlag()
Returns the toggling flag.
This flag changes its value each time a wait period is over.

Returns:
togglingFlag

restart

public void restart()
Restarts the WaitTimer with the defined number of wait periods


pause

public void pause(boolean pauseState)
Pauses/unpauses the WaitTimer

Specified by:
pause in interface ITimeControllable
Parameters:
pauseState -
See Also:
ITimeControllable.pause(boolean)