|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsim.display.SimpleController
public class SimpleController
Field Summary | |
---|---|
static int |
PS_PAUSED
The play thread is presently paused. |
static int |
PS_PLAYING
The play thread is presently playing. |
static int |
PS_STOPPED
The play thread is presently stopped. |
GUIState |
simulation
Our simulation |
Constructor Summary | |
---|---|
SimpleController(GUIState simulation)
|
|
SimpleController(GUIState simulation,
boolean displayInspectors)
|
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 |
doClose()
Closes the Controller and shuts down the simulation. |
boolean |
doNew()
Calls forth the "New Simulation" window. |
boolean |
getIncrementSeedOnPlay()
|
int |
getPlayState()
Gets whether or not the current thread is PS_PLAYING, PS_STOPPED, or PS_PAUSED. |
void |
pressPause()
Called when the user presses the pause button. |
void |
pressPlay()
Called when the user presses the play button. |
void |
pressStop()
Called when the user presses the stop button. |
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 console |
void |
registerInspector(Inspector inspector,
Stoppable stopper)
Registers an inspector to be Stopped if necessary in the future. |
void |
removeAllInspectors(boolean killDraggedOutWindowsToo)
Stops and removes all inspectors. |
void |
setIncrementSeedOnPlay(boolean val)
|
void |
setInspectors(Bag inspectors,
Bag names)
Adds new inspectors to the Console's list, given the provided inspectors, their portrayals, and appropriate names for them. |
void |
stopAllInspectors(boolean killDraggedOutWindowsToo)
Stops all inspectors. |
boolean |
unregisterAllFrames()
Simulations can call this to clear out the "Display list" of the console |
boolean |
unregisterFrame(javax.swing.JFrame frame)
Simulations can call this to remove a frame from the "Display list" of the console |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public GUIState simulation
public static final int PS_STOPPED
public static final int PS_PLAYING
public static final int PS_PAUSED
Constructor Detail |
---|
public SimpleController(GUIState simulation)
public SimpleController(GUIState simulation, boolean displayInspectors)
Method Detail |
---|
public int getPlayState()
public void doClose()
public void setIncrementSeedOnPlay(boolean val)
public boolean getIncrementSeedOnPlay()
public void pressStop()
public void pressPause()
public void pressPlay()
public boolean registerFrame(javax.swing.JFrame frame)
registerFrame
in interface Controller
public boolean unregisterFrame(javax.swing.JFrame frame)
unregisterFrame
in interface Controller
public boolean unregisterAllFrames()
unregisterAllFrames
in interface Controller
public void doChangeCode(java.lang.Runnable r)
Controller
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.
doChangeCode
in interface Controller
public void refresh()
Controller
refresh
in interface Controller
public void setInspectors(Bag inspectors, Bag names)
setInspectors
in interface Controller
public void registerInspector(Inspector inspector, Stoppable stopper)
registerInspector
in interface Controller
public void stopAllInspectors(boolean killDraggedOutWindowsToo)
public void removeAllInspectors(boolean killDraggedOutWindowsToo)
public boolean doNew()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |