com.jme.util
Class Timer

java.lang.Object
  extended by com.jme.util.Timer
Direct Known Subclasses:
LWJGLTimer, NanoTimer

public abstract class Timer
extends Object

Timer is the base class for a high resolution timer. It is created from getTimer("display system")

Version:
$Id: Timer.java,v 1.18 2007/03/09 10:19:34 rherlitz Exp $
Author:
Mark Powell

Constructor Summary
Timer()
           
 
Method Summary
abstract  float getFrameRate()
          Returns the "calls per second".
abstract  long getResolution()
          Returns the resolution of the timer.
abstract  long getTime()
          Returns the current time in ticks.
 float getTimeInSeconds()
          Returns the time in seconds.
abstract  float getTimePerFrame()
          Returns the time, in seconds, between the last call and the current one.
static Timer getTimer()
          Returns the high resolution timer.
abstract  void reset()
          Reset the timer to 0.
static void setTimer(Timer timer)
          Set a user defined timer instance
abstract  void update()
          update recalculates the frame rate based on the previous call to update.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Method Detail

getTime

public abstract long getTime()
Returns the current time in ticks. A tick is an arbitrary measure of time defined by the timer implementation. The number of ticks per second is given by getResolution(). The timer starts at 0 ticks.

Returns:
a long value representing the current time

getTimeInSeconds

public float getTimeInSeconds()
Returns the time in seconds. The timer starts at 0.0 seconds.

Returns:
the current time in seconds

getResolution

public abstract long getResolution()
Returns the resolution of the timer.

Returns:
the number of timer ticks per second

getFrameRate

public abstract float getFrameRate()
Returns the "calls per second". If this is called every frame, then it will return the "frames per second".

Returns:
The "calls per second".

getTimePerFrame

public abstract float getTimePerFrame()
Returns the time, in seconds, between the last call and the current one.

Returns:
Time between this call and the last one.

update

public abstract void update()
update recalculates the frame rate based on the previous call to update. It is assumed that update is called each frame.


getTimer

public static Timer getTimer()
Returns the high resolution timer. Timer is a singleton class so only one instance of Timer is allowed.

Returns:
the timer defined by the SystemProvider

setTimer

public static void setTimer(Timer timer)
Set a user defined timer instance

Parameters:
timer - timer to use

reset

public abstract void reset()
Reset the timer to 0. Clear any tpf history.