|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--elge.engine.Project
Project is the second most important class. It holds all this graphs, monitors, storage and world in one and it also performs the simulation.
The project is also as bean an xml persistant class, so the state of it can be stored at any time and then resumed.
To load, save and create a project use methods in Engine
class.
As bean project also support the propertyChange interface for listener. Projects fires events for properties: world, simulations, graphs, monitors etc. View the PROP_'NAME' constants for the fire events the Project can fire.
Field Summary | |
protected long |
countDown
the countDown till the count.. |
protected Vector |
graphs
graphs |
protected int |
grRefresh
graph refresh step |
protected boolean |
inSimulation
the simulation state variable |
protected long |
iterationCount
the count to iterate in simulation |
protected Vector |
monitors
Monitors |
protected String |
name
Project name |
protected ProjectEditor |
peditor
The project editor instance. |
protected File |
projectDir
The project directory. |
static String |
PROP_GRAPHS
Property name for graphs |
static String |
PROP_ISSIMULATION
Property project in simulation |
static String |
PROP_MONITORS
Property name for monitors |
static String |
PROP_SIMULATIONS
name of simulation propery |
static String |
PROP_WORLD
Name of world propery |
protected int |
rSleep
a simulation run sleep count |
protected Thread |
simulation
the simulation thread |
protected Vector |
simulations
Simulations (runs). |
protected DataStorage |
store
The data storage. |
protected World |
world
The world the project is using. |
protected int |
wrRefresh
world refresh step |
protected WorldView |
wv
The world view if available. |
Constructor Summary | |
Project()
Creates a new instance of WorkSpace |
|
Project(String name,
World w)
Creates project with a name and world. |
Method Summary | |
void |
addGraph(Graph g)
Adds a Graph to the project |
void |
addMonitor(Monitor mon)
Adds a monitor to the project |
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds a listener for the propertye changes |
void |
endGUI()
Close all project windows. |
long |
getCountDown()
Gets how many simulations step have to be made. -1 means infinity. |
int |
getGraphRefresh()
setGraphRefresh(int) |
Vector |
getGraphs()
Gets the graphs of this project |
long |
getIterationCount()
see setIterationCount(long) |
Vector |
getMonitors()
Return actual monitors that are in project. |
String |
getName()
Gets the project name |
File |
getProjectDir()
Returns the project dir path, as it should be. |
ProjectEditor |
getProjectEditor()
|
int |
getRunSleep()
see setRunSleep(int) |
DataStorage |
getStorage()
Gets the actual DataStorage if available |
World |
getWorld()
Get the World the Project is using. |
int |
getWorldRefresh()
setWorldRefresh(int) |
WorldView |
getWorldView()
returns the WorldView if available. |
void |
hideWorldView()
Hides the world view, if it is available. |
void |
init()
|
boolean |
inSimulation()
Shows the state of the simulation. |
void |
iterate(long num)
Sets the iteration count and starts the simulation. |
void |
removeGraph(Graph g)
Removes a Graph from the project |
void |
removeGraphs(int[] idx)
Removes Graphs from the project |
void |
removeMonitor(int i)
Removes a monitor from the project |
void |
removeMonitor(int[] idxs)
Removes a monitor from the project |
void |
removeMonitor(Monitor mon)
Removes a monitor from the project |
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes a listener for the propertye changes |
void |
restart()
Restarts the simulation in these steps: - calls the stop method - calls the refreshStore method - calls the world's restart method - calls the restart method for each graph - calls the restart mehtod for each monitor - udpates the display |
void |
run()
When an object implementing interface Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread.
|
void |
runGUI()
Runs the project gui. |
void |
setGraphRefresh(int gr)
In what tick should the graphs be refreshed. |
void |
setGraphs(Vector graphs)
Sets the graphs for this project |
void |
setIterationCount(long it)
Sets how many simulation steps to do. |
void |
setMonitors(Vector mons)
Sets monitors for this project |
void |
setNameFromDir(File dir)
Sest the name of the project from the directory where it it stored. |
void |
setRunSleep(int rs)
How long should the simulation sleep between steps. |
void |
setWorld(World world)
Sets the world for the Project |
void |
setWorldRefresh(int wr)
In what tick should the world be repained. |
void |
showWorldView()
Shows the world view, if it is available. |
void |
start()
Starts simulation for exact count - getIterationCount()
Event property changed for PROP_ISSIMULATION if fired. |
void |
stop()
Stops the simulation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String PROP_WORLD
public static final String PROP_SIMULATIONS
public static final String PROP_ISSIMULATION
public static final String PROP_MONITORS
public static final String PROP_GRAPHS
protected WorldView wv
protected ProjectEditor peditor
protected World world
protected File projectDir
protected String name
protected Vector simulations
protected Vector monitors
protected Vector graphs
protected DataStorage store
protected boolean inSimulation
protected Thread simulation
protected long iterationCount
protected long countDown
protected int grRefresh
protected int wrRefresh
protected int rSleep
Constructor Detail |
public Project()
public Project(String name, World w)
name
- name of the projectw
- World the useWorld
Method Detail |
public void addPropertyChangeListener(PropertyChangeListener l)
l
- the listenerpublic void removePropertyChangeListener(PropertyChangeListener l)
l
- the lsitenerpublic File getProjectDir()
public void setWorld(World world)
world
- the WorldWorld
public World getWorld()
World
public void runGUI()
public void endGUI()
public ProjectEditor getProjectEditor()
public String getName()
public void setNameFromDir(File dir)
dir
- this should be the project directory.public WorldView getWorldView()
WorldView
public void showWorldView()
public void hideWorldView()
public Vector getMonitors()
Monitor
public void setMonitors(Vector mons)
mons
- Vector of monitorsMonitor
public void addMonitor(Monitor mon)
mon
- Monitor to be addedMonitor
public void removeMonitor(Monitor mon)
mon
- Monitor to be removedMonitor
public void removeMonitor(int i)
i
- index of the monitor that should be removedMonitor
public void removeMonitor(int[] idxs)
idxs
- indexes of the Monitors that should be removedMonitor
public void addGraph(Graph g)
g
- Graph to addGraph
public void removeGraph(Graph g)
g
- Graph to removeGraph
public void removeGraphs(int[] idx)
idx
- indexs of Graph to removeGraph
public void setGraphs(Vector graphs)
graphs
- Vector of Graph instancesGraph
public Vector getGraphs()
Graph
public void init()
public void restart()
stop()
,
World.restart()
,
Graph.restart()
,
Monitor.restart()
,
ProjectEditor.updateAfterStep()
public DataStorage getStorage()
DataStorage
public void start()
getIterationCount()
public void stop()
public void iterate(long num)
if the num is -1 then the simulation runs until the pause from the user
num
- count to iterate the simulationpublic boolean inSimulation()
public void run()
Runnable
is used
to create a thread, starting the thread causes the object's
run
method to be called in that separately executing
thread.
The general contract of the method run
is that it may
take any action whatsoever.
This method is called to run the simulation. The simulation process is follows:
- the private step method is called
- the the Thread's yield method is called
- if rSleep is > 0, the Thread's sleep is called
- or if the agentCount of the World is zero a sleep(1) method is called
After the user pause or the iteration count has passed to 0, the simulation
quits and calls the stop()
method
run
in interface Runnable
Thread.run()
,
Thread.yield()
,
Thread.sleep(long)
,
stop()
public void setGraphRefresh(int gr)
gr
- the tick stepProjectEditor.updateAfterStep()
public int getGraphRefresh()
setGraphRefresh(int)
public void setWorldRefresh(int wr)
ProjectEditor.updateAfterStep()
public int getWorldRefresh()
setWorldRefresh(int)
public void setRunSleep(int rs)
rs
- sleep count in miliseconds.public int getRunSleep()
setRunSleep(int)
public void setIterationCount(long it)
it
- the simulation step countpublic long getIterationCount()
setIterationCount(long)
public long getCountDown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |