org.xith3d.loop.opscheduler.impl
Class OperationSchedulerImpl

java.lang.Object
  extended by org.xith3d.loop.UpdatingThread
      extended by org.xith3d.loop.opscheduler.impl.OperationSchedulerImpl
All Implemented Interfaces:
java.lang.Runnable, GameTimeHost, Animator, OperationScheduler, Updatable, Updater
Direct Known Subclasses:
DummyOperationSchedulerImpl

public class OperationSchedulerImpl
extends UpdatingThread
implements OperationScheduler

If you're not using RenderLoop, but want to benefit from the OperationScheduler functionality, just use this one.
This class also implements the Updater interface.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.xith3d.loop.UpdatingThread
UpdatingThread.TimingMode
 
Field Summary
 
Fields inherited from class org.xith3d.loop.UpdatingThread
PAUSE_NONE, PAUSE_TOTAL
 
Constructor Summary
OperationSchedulerImpl()
           
OperationSchedulerImpl(GameTimeHost gameTimeHost)
           
OperationSchedulerImpl(long minItTime)
           
OperationSchedulerImpl(long minItTime, GameTimeHost gameTimeHost)
           
 
Method Summary
 void addAnimatableObject(Animatable anumObj)
          Adds an animatable object to the set.
 void addAnimatableObject(Animatable animObj, boolean startAnimation)
          Adds an animatable object to the set.
 void addAnimatableObject(Animatable animObj, long gameTime, UpdatingThread.TimingMode timingMode)
           
 void addInterval(Interval interval)
          Adds a new Interval to the scheduler, which will be checked each iteration.
 void addIntervalListener(IntervalListener il)
          Registers a new IntervalListner to this OperationScheduler.
 void addUpdatable(Updatable updatable)
          Adds a new Updatable instance to the list, that is worked each frame.
protected  void callIntervalListeners(Interval interval, long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          This method is executed each time an interval is hit.
 int getNumberOfIntevals()
           
 int getNumberOfSchedOps()
           
 void removeAllIntervals()
          Removes all Intervals from the scheduler.
 void removeAnimatableObject(Animatable animObj)
          Removes an animatable object from the set.
 IntervalListener removeIntervalListener(IntervalListener il)
          Unregisters an IntervalListner from this OperationScheduler.
 void removeUpdatable(Updatable updatable)
          Removes an Updatable instance from the list, that is worked each frame.
 void scheduleOperation(ScheduledOperation schedOp)
          Adds a ScheduledOperation to the queue.
 void unscheduleOperation(ScheduledOperation schedOp)
          Removes a ScheduledOperation from the queue.
 void update()
          Checks the list of operations and intervals and calls necessary methods if the time is right.
 void update(long gameTime)
          Checks the list of operations and intervals and calls necessary methods if the time is right.
 void update(long gameTime, long frameTime, UpdatingThread.TimingMode timingMode)
          Updates this Updatable object.
 
Methods inherited from class org.xith3d.loop.UpdatingThread
begin, end, getFPSLimiter, getGameMicroTime, getGameMilliTime, getGameNanoTime, getGameTime, getIterationsCount, getLastFrameTime, getLastNanoFrameTime, getMinIterationTime, getPauseMode, getThread, getTimer, getTimingMode, isRunning, isStopping, loop, nextIteration, run, setFPSLimiter, setMinIterationTime, setPauseMode, setTimer, setTimingMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationSchedulerImpl

public OperationSchedulerImpl(long minItTime,
                              GameTimeHost gameTimeHost)

OperationSchedulerImpl

public OperationSchedulerImpl(long minItTime)

OperationSchedulerImpl

public OperationSchedulerImpl(GameTimeHost gameTimeHost)

OperationSchedulerImpl

public OperationSchedulerImpl()
Method Detail

getNumberOfSchedOps

public final int getNumberOfSchedOps()
Returns:
the number of ScheduledOperations.

getNumberOfIntevals

public final int getNumberOfIntevals()
Returns:
the number of Intervals.

scheduleOperation

public void scheduleOperation(ScheduledOperation schedOp)
Adds a ScheduledOperation to the queue. The loop works off the queue each iteration.

Specified by:
scheduleOperation in interface OperationScheduler
Parameters:
schedOp - the Operation to schedule

unscheduleOperation

public void unscheduleOperation(ScheduledOperation schedOp)
Removes a ScheduledOperation from the queue.

Specified by:
unscheduleOperation in interface OperationScheduler
Parameters:
schedOp - the Operation to unschedule

addInterval

public void addInterval(Interval interval)
Adds a new Interval to the scheduler, which will be checked each iteration. When the check() method returns true, all IntervalListeners are notified. This method immediately invokes the revive() method of the given Interval.

Specified by:
addInterval in interface OperationScheduler
Parameters:
interval - the new Interval

removeAllIntervals

public void removeAllIntervals()
Removes all Intervals from the scheduler.

Specified by:
removeAllIntervals in interface OperationScheduler

addIntervalListener

public void addIntervalListener(IntervalListener il)
Registers a new IntervalListner to this OperationScheduler.

Specified by:
addIntervalListener in interface OperationScheduler
Parameters:
il - the new IntervalListener

removeIntervalListener

public IntervalListener removeIntervalListener(IntervalListener il)
Unregisters an IntervalListner from this OperationScheduler.

Specified by:
removeIntervalListener in interface OperationScheduler
Parameters:
il - the IntervalListener to remove

addAnimatableObject

public void addAnimatableObject(Animatable animObj,
                                long gameTime,
                                UpdatingThread.TimingMode timingMode)

addAnimatableObject

public void addAnimatableObject(Animatable animObj,
                                boolean startAnimation)
Adds an animatable object to the set. And starts rotation if wanted. each rendering-loop-iteration the animate()-method is called.

Specified by:
addAnimatableObject in interface Animator
Parameters:
animObj - the object to animate
startAnimation - if true the startAnimation() method is executed immediately

addAnimatableObject

public void addAnimatableObject(Animatable anumObj)
Adds an animatable object to the set. each rendering-loop-iteration the animate()-method is called.

Specified by:
addAnimatableObject in interface Animator
Parameters:
anumObj - the object to animate

removeAnimatableObject

public void removeAnimatableObject(Animatable animObj)
Removes an animatable object from the set.

Specified by:
removeAnimatableObject in interface Animator
Parameters:
animObj - the object to remove

callIntervalListeners

protected void callIntervalListeners(Interval interval,
                                     long gameTime,
                                     long frameTime,
                                     UpdatingThread.TimingMode timingMode)
This method is executed each time an interval is hit.

Parameters:
interval - the hit Interval
gameTime - the current gameTime
frameTime - the time needed to render the last frame
timingMode -

addUpdatable

public void addUpdatable(Updatable updatable)
Adds a new Updatable instance to the list, that is worked each frame. This is like adding a ScheduledOperation, that is infinitely alive and persistent.

Specified by:
addUpdatable in interface Updater

removeUpdatable

public void removeUpdatable(Updatable updatable)
Removes an Updatable instance from the list, that is worked each frame.

Specified by:
removeUpdatable in interface Updater

update

public void update(long gameTime,
                   long frameTime,
                   UpdatingThread.TimingMode timingMode)
Updates this Updatable object.

Specified by:
update in interface Animator
Specified by:
update in interface OperationScheduler
Specified by:
update in interface Updatable
Specified by:
update in class UpdatingThread
Parameters:
gameTime - the gameTime in Milliseconds
frameTime - the frameTime in Milliseconds (needed time for the last frame)
timingMode - the TimingMode to use for frameTime.

update

public void update(long gameTime)
Checks the list of operations and intervals and calls necessary methods if the time is right.

Parameters:
gameTime - the current game time

update

public void update()
Checks the list of operations and intervals and calls necessary methods if the time is right.