org.robokind.api.common.utils
Class TimerLoop

java.lang.Object
  extended by org.robokind.api.common.utils.TimerLoop

public abstract class TimerLoop
extends Object

Abstract class for performing an action at regular intervals.

Author:
Matthew Stevenson

Constructor Summary
TimerLoop(long interval)
          Creates a new TimerLoop with the given interval in milliseconds.
 
Method Summary
 long getIntervalLength()
          Returns the interval length.
 void setIntervalLength(long interval)
          Sets the interval length.
 void start()
          Start performing the action at intervals.
 void stop()
          Stop the timer.
protected abstract  void timerTick(long time, long interval)
          Action to perform at regular intervals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimerLoop

public TimerLoop(long interval)
Creates a new TimerLoop with the given interval in milliseconds.

Parameters:
interval - number of milliseconds between performing the action
Method Detail

setIntervalLength

public void setIntervalLength(long interval)
Sets the interval length.

Parameters:
interval - number of milliseconds between performing the action

getIntervalLength

public long getIntervalLength()
Returns the interval length.

Returns:
interval length

timerTick

protected abstract void timerTick(long time,
                                  long interval)
Action to perform at regular intervals.

Parameters:
time - current time
interval - length of the timer interval

start

public void start()
Start performing the action at intervals.


stop

public void stop()
Stop the timer.



Copyright © 2011. All Rights Reserved.