net.jinx.action
Class RealTimeClock

java.lang.Object
  extended by net.jinx.action.Actor
      extended by net.jinx.action.Clock
          extended by net.jinx.action.RealTimeClock
All Implemented Interfaces:
java.lang.Runnable, OwnerListener, SceneListener

public class RealTimeClock
extends Clock
implements java.lang.Runnable

Clock extension where ClockEvents are sent at regular intervals. IdleEvents are sent as often as possible between ClockEvents.

Scheduling of ClockEvents is handled through the use of a net.jinx.time.StopWatch object. When the system is very busy, RealTimeClocks will behave almost as though they've been paused.

API Stability: Alpha.


Field Summary
 
Fields inherited from class net.jinx.action.Clock
sync
 
Constructor Summary
RealTimeClock(float deltaTime)
           
RealTimeClock(java.lang.String name, float deltaTime)
          Constructs a new RealTimeClock with a default name.
 
Method Summary
 float getTimeFactor()
          Provides the time factor that affects the speed of simulation.
 boolean isPaused()
          Returns true if this Clock is paused.
 boolean isStopped()
          Provides a way to check if the time keeping thread is running.
 void pause()
          Pauses this Clock.
 void play()
          Unpauses and/or constructs a new java.lang.Thread to handle time keeping.
 void run()
          This method is for the time keeping thread only.
 void setTimeFactor(float timeFactor)
          Sets the time factor that affects the speed of simulation.
 void stop()
          Stops the time keeping thread.
 
Methods inherited from class net.jinx.action.Clock
actorAdded, actorRemoved, getDeltaTime, processEvent, sendClockEvent, sendClockStateEvent, sendIdleEvent, setDeltaTime
 
Methods inherited from class net.jinx.action.Actor
checkAllowAdd, getName, getOwner, hashCode, ownerChanged, sendEvent, sendEvent, sendEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RealTimeClock

public RealTimeClock(float deltaTime)

RealTimeClock

public RealTimeClock(java.lang.String name,
                     float deltaTime)
Constructs a new RealTimeClock with a default name.

Parameters:
deltaTime - the change in time value for this clock.
Throws:
java.lang.IllegalArgumentException - if deltaTime is less than or equal to zero.
Method Detail

setTimeFactor

public void setTimeFactor(float timeFactor)
Sets the time factor that affects the speed of simulation.

Parameters:
timeFactor - the multiplier.
Throws:
java.lang.IllegalArgumentException - if the time factor is less than or equal to zero.

getTimeFactor

public float getTimeFactor()
Provides the time factor that affects the speed of simulation.

Returns:
the multiplier.

pause

public void pause()
Pauses this Clock.


isPaused

public boolean isPaused()
Returns true if this Clock is paused.

Returns:
true if this Clock is paused.

play

public void play()
Unpauses and/or constructs a new java.lang.Thread to handle time keeping.


stop

public void stop()
Stops the time keeping thread. The Thread will keep running for a short time. Use the isStopped() method to check for this condition if you need to.


isStopped

public boolean isStopped()
Provides a way to check if the time keeping thread is running.

Returns:
true if the thread isn't running.

run

public void run()
This method is for the time keeping thread only.

Specified by:
run in interface java.lang.Runnable
Throws:
java.lang.IllegalThreadStateException - if the current thread is not the time keeping thread.