The Physiologist's Friend Simulation API

ch.unizh.ini.friend.simulation
Class TimedSimulation

java.lang.Object
  extended by ch.unizh.ini.friend.simulation.AbstractSimulation
      extended by ch.unizh.ini.friend.simulation.TimedSimulation
All Implemented Interfaces:
SimulationTask, ActionListener, EventListener

public class TimedSimulation
extends AbstractSimulation
implements ActionListener

Implementation of the simulation loop with the javax.swing.Timer mechanism. The Timer calls are not coalesced into a single call if they queue up.

Version:
$Revision: 1.7 $
Author:
Christof Marti

Field Summary
protected  Timer timer
          The simulation timer.
 
Fields inherited from class ch.unizh.ini.friend.simulation.AbstractSimulation
delay, on, step
 
Constructor Summary
TimedSimulation(SimulationStep step, int delay)
          Creates a new instance with the given simulation step.
 
Method Summary
 void actionPerformed(ActionEvent actionEvent)
          Gets notified by the timer.
 void addUpdateable(Updateable u)
          Adds an updateable to the simulation.
 void removeUpdateable(Updateable u)
          Removes an updateable from the simulation.
 void start()
          Starts the simulation (timer).
 void stop()
          Stops the simulation (timer).
 
Methods inherited from class ch.unizh.ini.friend.simulation.AbstractSimulation
getDelay, getNumberOfIterationsPerStep, getStep, isOn, setDelay, setNumberOfIterationsPerStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

protected Timer timer
The simulation timer.

Constructor Detail

TimedSimulation

public TimedSimulation(SimulationStep step,
                       int delay)
Creates a new instance with the given simulation step.

Parameters:
step - The simulation step instance.
Method Detail

actionPerformed

public void actionPerformed(ActionEvent actionEvent)
Gets notified by the timer.

Specified by:
actionPerformed in interface ActionListener

start

public void start()
Starts the simulation (timer).

Specified by:
start in interface SimulationTask
Specified by:
start in class AbstractSimulation

stop

public void stop()
Stops the simulation (timer).

Specified by:
stop in interface SimulationTask
Specified by:
stop in class AbstractSimulation

addUpdateable

public void addUpdateable(Updateable u)
Adds an updateable to the simulation.

Specified by:
addUpdateable in interface SimulationTask
Specified by:
addUpdateable in class AbstractSimulation
Parameters:
u - An updateable.

removeUpdateable

public void removeUpdateable(Updateable u)
Removes an updateable from the simulation.

Specified by:
removeUpdateable in interface SimulationTask
Specified by:
removeUpdateable in class AbstractSimulation
Parameters:
u - An updateable.

http://www.ini.unizh.ch/~tobi/friend