|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A Controller is the top-level object responsible for setting up and running the GUIState. More or less, the Controller calls the init, start, step, finish, and quit methods on the GUIState. The Controller also provides a window management facility. The controller allows the GUIState to register windows to appear in a list to the user and to be closed properly when the program is quit. The controller also manages a repository of current inspectors. Both of these facilities are optional. Subclasses are not required to implement all these methods; they can stub some out except for doChangeCode(...).
Method Summary | |
void |
doChangeCode(java.lang.Runnable r)
This method will interrupt the simulation (pause it), call your runnable, then continue (uninterrupt) the simulation. |
void |
refresh()
Lazily updates and redraws all the displays and inspectors. |
boolean |
registerFrame(javax.swing.JFrame frame)
Simulations can call this to add a frame to be listed in the "Display list" of the Controller. |
void |
setInspectors(Bag inspectors,
Bag names)
Replaces current inspectors with the ones provided. |
boolean |
unregisterAllFrames()
Simulations can call this to clear out the "Display list" of the Controller. |
boolean |
unregisterFrame(javax.swing.JFrame frame)
Simulations can call this to remove a frame from the "Display list" of the Controller. |
Method Detail |
public void doChangeCode(java.lang.Runnable r)
You have other options for updating the model from external threads. One option is to add a Steppable to GUIState's scheduleImmediate(...) queue. When the Steppable is stepped, it will be done so inside the model's thread. This is asynchronous (non-blocking), however.
Alternatively, you can synchronize on state.schedule and run your code. This is synchronous.
public boolean registerFrame(javax.swing.JFrame frame)
public boolean unregisterFrame(javax.swing.JFrame frame)
public boolean unregisterAllFrames()
public void refresh()
public void setInspectors(Bag inspectors, Bag names)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |