|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimbad.sim.Simulator
public class Simulator
The Simulator class. It manages the list of agents and performs the simulation steps. For each agent a simulation step is is as follow:
Nested Class Summary | |
---|---|
private class |
Simulator.SimulatorThread
|
Field Summary | |
---|---|
private java.util.ArrayList |
agents
The list of all agents. |
private javax.swing.JComponent |
applicationComponent
Keeps track of application's main component -- can be null |
private long |
counter
Count simulation steps. |
(package private) FrameMeter |
fps
|
private int |
framesPerSecond
number of frames per virtual seconds - 20 is a good value |
private Lock |
lock
Used for mutual exclusion. |
private java.util.ArrayList |
objects
The list of all objects in the world. |
(package private) PhysicalEngine |
physicalEngine
Handles all algorithms and resources related to agent interactions. |
private Simulator.SimulatorThread |
simulatorThread
Thread for the background mode |
private java.util.Timer |
timer
|
private boolean |
usePhysics
Control the usage of physical law in the simulation |
private float |
virtualTimeFactor
|
(package private) World |
world
|
Constructor Summary | |
---|---|
Simulator(javax.swing.JComponent applicationComponent,
World world,
EnvironmentDescription ed)
Constructs the simulator object |
Method Summary | |
---|---|
private void |
addMobileAndStaticObjects(EnvironmentDescription ed)
Add all agents and objects. |
private void |
createAgentsUI()
Creates the UI that may be associated to each agent. |
void |
dispose()
Dispose all resources. |
java.util.ArrayList |
getAgentList()
|
protected int |
getFramesPerSecond()
|
protected boolean |
getUsePhysics()
Gets use physics indicator. |
float |
getVirtualTimeFactor()
|
void |
initBehaviors()
initialize the behavior of all agents. |
private void |
initialize(EnvironmentDescription ed)
Initialize the simulator - only called once. |
void |
lock()
Obtain simulator critical resources. |
void |
performSimulationStep()
Perform a single step of simulation |
void |
resetSimulation()
Reset the simulation. |
void |
restartSimulation()
Simulator control. |
void |
setApplicationComponent(javax.swing.JComponent component)
|
protected void |
setFramesPerSecond(int fps)
|
protected void |
setUsePhysics(boolean usePhysics)
Sets use physics indicator. |
void |
setVirtualTimeFactor(float fact)
Set the time factor. |
void |
simulateOneStep()
The main simulator method. |
void |
startBackgroundMode()
Starts special background mode |
void |
startSimulation()
Starts the simulator loop. |
void |
stopBackgroundMode()
Stops special background mode |
void |
stopSimulation()
Stop (or pause) the simulator loop. |
void |
unlock()
Release simulator critical resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Lock lock
private javax.swing.JComponent applicationComponent
World world
FrameMeter fps
private java.util.Timer timer
private java.util.ArrayList objects
private java.util.ArrayList agents
private int framesPerSecond
private float virtualTimeFactor
private Simulator.SimulatorThread simulatorThread
private boolean usePhysics
PhysicalEngine physicalEngine
private long counter
Constructor Detail |
---|
public Simulator(javax.swing.JComponent applicationComponent, World world, EnvironmentDescription ed)
applicationComponent
- - A reference to the main Application container.world
- - The 3d world object.ed
- - the Environment description.Method Detail |
---|
private void initialize(EnvironmentDescription ed)
public void dispose()
private void addMobileAndStaticObjects(EnvironmentDescription ed)
private void createAgentsUI()
public void simulateOneStep()
public void initBehaviors()
public void startSimulation()
public void stopSimulation()
public void restartSimulation()
public void resetSimulation()
public void performSimulationStep()
public java.util.ArrayList getAgentList()
protected void setUsePhysics(boolean usePhysics)
protected boolean getUsePhysics()
protected void setFramesPerSecond(int fps)
protected int getFramesPerSecond()
public void setVirtualTimeFactor(float fact)
factor
- : typical value 1.0 (default) , 2.0 or 0.5public float getVirtualTimeFactor()
public void setApplicationComponent(javax.swing.JComponent component)
public void lock()
public void unlock()
public void startBackgroundMode()
public void stopBackgroundMode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |