proper.util
Class Timer

java.lang.Object
  extended by proper.util.Timer

public class Timer
extends java.lang.Object

A simple wrapper for Timer-Events, listeners must implement the TimerInterface.

Version:
$Revision: 1.2 $
Author:
FracPete
See Also:
TimerInterface

Field Summary
static int INTERVAL
          the standard time in msec
 
Constructor Summary
Timer()
          initializes the timer with standard time in msec and repeated events
Timer(int interval)
          initializes the timer with the given time in msec and repeated events
Timer(int interval, boolean repeated)
          initializes the timer with the given time in msec and whether it fires only once or on a regular basis
Timer(int interval, boolean repeated, boolean start)
          initializes the timer with the given time in msec and whether it fires only once or on a regular basis, with start you can say whether it should start immediately
 
Method Summary
 void addListener(TimerInterface o)
          adds the object to the listener list
 void clear()
          removes all the listeners and stops the timer
 int getInterval()
          returns the current timer interval (in msec)
 java.util.Vector getListeners()
          returns the current list of listeners
 boolean isRepeated()
          whether the timer is firing on a regular basis
 boolean isRunning()
          returns whether the timer is running
 void notifyListener(TimerInterface o)
          notifies the specified listener of the timer event
 void notifyListeners()
          notifies all the listeners of the timer event
 void removeListener(TimerInterface o)
          removes the object from the listeners
 void setInterval(int interval)
          sets the new timer interval (in msec)
 void setRepeated(boolean repeated)
          sets whether the timer is firing regularly or not
 void start()
          starts the timer
 void stop()
          stops the timer
 java.lang.String toString()
          this timer in a string representation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INTERVAL

public static final int INTERVAL
the standard time in msec

See Also:
Constant Field Values
Constructor Detail

Timer

public Timer()
initializes the timer with standard time in msec and repeated events

See Also:
INTERVAL

Timer

public Timer(int interval)
initializes the timer with the given time in msec and repeated events


Timer

public Timer(int interval,
             boolean repeated)
initializes the timer with the given time in msec and whether it fires only once or on a regular basis


Timer

public Timer(int interval,
             boolean repeated,
             boolean start)
initializes the timer with the given time in msec and whether it fires only once or on a regular basis, with start you can say whether it should start immediately

Method Detail

clear

public void clear()
removes all the listeners and stops the timer


addListener

public void addListener(TimerInterface o)
adds the object to the listener list


removeListener

public void removeListener(TimerInterface o)
removes the object from the listeners


getListeners

public java.util.Vector getListeners()
returns the current list of listeners


notifyListener

public void notifyListener(TimerInterface o)
notifies the specified listener of the timer event


notifyListeners

public void notifyListeners()
notifies all the listeners of the timer event


start

public void start()
starts the timer


stop

public void stop()
stops the timer


isRunning

public boolean isRunning()
returns whether the timer is running


setInterval

public void setInterval(int interval)
sets the new timer interval (in msec)


getInterval

public int getInterval()
returns the current timer interval (in msec)


setRepeated

public void setRepeated(boolean repeated)
sets whether the timer is firing regularly or not


isRepeated

public boolean isRepeated()
whether the timer is firing on a regular basis


toString

public java.lang.String toString()
this timer in a string representation

Overrides:
toString in class java.lang.Object