uchicago.src.sim.engine
Class AbstractGUIController

java.lang.Object
  extended by uchicago.src.sim.engine.BaseController
      extended by uchicago.src.sim.engine.AbstractGUIController
All Implemented Interfaces:
IController, SimEventListener, TickCounter
Direct Known Subclasses:
Controller

public abstract class AbstractGUIController
extends BaseController

Base class for GUI controllers. This provides access to various dialogs and JPanels that can be used subclassses creating full-blown GUI controllers.

Version:
$Revision: 1.19 $ $Date: 2005/08/01 20:36:18 $

Field Summary
static boolean ALPHA_ORDER
           
protected  java.util.ArrayList chartModels
           
protected  RepastConsole console
           
static boolean CONSOLE_ERR
           
static boolean CONSOLE_OUT
           
protected  java.util.ArrayList customCharts
           
static boolean DEFAULTS_INCLUDE_RNGSEED
           
protected  java.util.Vector mediaSchedulers
          Lists of MediaSchedulers used to schedule media actions (taking snapshots etc.)
protected  java.lang.String[] myParams
          Repast parameters.
static boolean PROBE_ALPHA_ORDER
           
static boolean SHOW_CHARTS
           
static boolean UPDATE_PROBES
           
 
Fields inherited from class uchicago.src.sim.engine.BaseController
done, doStep, executeBegin, exitOnExit, go, isGui, listenerList, model, monitor, params, pauseActionsExecuted, pauseAt, pauseAtAction, pauseSim, persistentObj, runFinished, runThread, schedule, simRun, sleepValue, time
 
Constructor Summary
AbstractGUIController()
          Constructs an AbstractGUIController with no associated model, or parameters.
AbstractGUIController(ParameterSetter parameters)
          Constructs a AbstractGUIController whose model has the specified parameters.
 
Method Summary
 void beginModel()
          Executes begin() on the SimModel associated with this AbstractGUIController.
 void enableManipulation(boolean enable)
          Enables the user customized actions.
 void exitSim()
          Exits the simulation.
 void exitSimulation()
          Exits the simulation.
 boolean getConsoleErr()
           
 boolean getConsoleOut()
           
 IntrospectPanel getModelParameterPanel()
          Creates an IntrospectPanel that contains the parameters this AbstractGUIController's SimModel.
 IntrospectPanel getRepastParameterPanel()
          Creates an IntrospectPanel that contains the parameters for all repast models.
 long getRunCount()
          Returns the current run count.
 boolean isBatch()
          Is this a BatchController.
 boolean isGUI()
          Returns true;
 void loadAndStart()
          Loads any default parameters and starts the simulation.
 void makeCurrentParamsDefault()
          Makes the SimModel's current parameters the default parameters.
protected  void onTickCountUpdate()
          Updates the tick clock whenever the tick count is incremented
 void pauseSimulation()
          Pauses the simulation.
 void setConsoleErr(boolean err)
           
 void setConsoleOut(boolean out)
           
 void setModel(SimModel model)
          Sets the model that is controlled by this Controller.
protected  void setParameters()
          Sets the parameters of this AbstractGUIController's SimModel to their default values, if any.
 void setup()
          Sets up this controller and is associated SimModel prior to a model run.
 void showChartDialog(javax.swing.JFrame f)
          Displays a dialog for creating custom charts.
 void showLoadModelDialog(javax.swing.JFrame frame)
          Displays the LoadModelDialog and loads the selected SimModel.
 void showMakeMovieDialog(javax.swing.JFrame frame)
          Displays a dialog for creating movies of the simulation.
 javax.swing.Action showSnapshotDialog(javax.swing.JFrame f)
          Displays the dialog for taking snapshot images.
 void showVersion()
          Displays a message box showing the version number of repast.
 void showWriteParamsDialog(javax.swing.JFrame f)
          Displays a dialog for writing the SimModel's parameters to a file.
 void shutdown()
          Exits the simulation but does not exit the jvm.
 void simEventPerformed(SimEvent evt)
          Invoked by a source on which this is a listener when a SimEvent is fired.
 void stepSim()
          Steps the simulation through one iteration of execution.
 void stopSimulation()
          Stops the simulation.
 
Methods inherited from class uchicago.src.sim.engine.BaseController
addSimEventListener, fireSimEvent, getCellDepth, getCellHeight, getCellWidth, getCurrentTime, getDefaultModelParameters, getExitOnExit, getModel, getModelParameters, getPauseAt, getPersistentObj, getRandomSeed, getSchedule, notifyMonitor, pauseSim, putPersistentObj, removeSimEventListener, setCellDepth, setCellHeight, setCellWidth, setExitOnExit, setPauseAt, setRandomSeed, setSchedule, setupSchedule, startSim, stopSim
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_CHARTS

public static boolean SHOW_CHARTS

PROBE_ALPHA_ORDER

public static boolean PROBE_ALPHA_ORDER

ALPHA_ORDER

public static boolean ALPHA_ORDER

CONSOLE_OUT

public static boolean CONSOLE_OUT

CONSOLE_ERR

public static boolean CONSOLE_ERR

DEFAULTS_INCLUDE_RNGSEED

public static boolean DEFAULTS_INCLUDE_RNGSEED

UPDATE_PROBES

public static boolean UPDATE_PROBES

myParams

protected java.lang.String[] myParams
Repast parameters.


mediaSchedulers

protected java.util.Vector mediaSchedulers
Lists of MediaSchedulers used to schedule media actions (taking snapshots etc.)


chartModels

protected java.util.ArrayList chartModels

customCharts

protected java.util.ArrayList customCharts

console

protected RepastConsole console
Constructor Detail

AbstractGUIController

public AbstractGUIController()
Constructs an AbstractGUIController with no associated model, or parameters.


AbstractGUIController

public AbstractGUIController(ParameterSetter parameters)
Constructs a AbstractGUIController whose model has the specified parameters. The model itself is set via setModel().

Parameters:
parameters - default values for the model's parameters
Method Detail

setConsoleOut

public void setConsoleOut(boolean out)

getConsoleOut

public boolean getConsoleOut()

setConsoleErr

public void setConsoleErr(boolean err)

getConsoleErr

public boolean getConsoleErr()

setModel

public void setModel(SimModel model)
Sets the model that is controlled by this Controller.

Specified by:
setModel in interface IController
Overrides:
setModel in class BaseController
Parameters:
model - the model associated with this BaseController

showLoadModelDialog

public void showLoadModelDialog(javax.swing.JFrame frame)
Displays the LoadModelDialog and loads the selected SimModel.

Parameters:
frame - the parent frame for the LoadModelDialog

beginModel

public void beginModel()
Executes begin() on the SimModel associated with this AbstractGUIController. This is useful for displaying and recording the state of the model before any scheduled actions are executed. In addition this will displays any custom charts associated with this model if that option is selected.

Overrides:
beginModel in class BaseController

stepSim

public void stepSim()
Steps the simulation through one iteration of execution.


loadAndStart

public void loadAndStart()
Loads any default parameters and starts the simulation. This is a convenient way to start a "gui" simulation without waiting for user input or even showing the gui.


setup

public void setup()
Sets up this controller and is associated SimModel prior to a model run.


exitSim

public void exitSim()
Exits the simulation. This saves chart and display locations and size, as well as any custom models.


shutdown

public void shutdown()
Exits the simulation but does not exit the jvm. This is useful if you run a simulation in from some other application within the same jvm instance.


onTickCountUpdate

protected void onTickCountUpdate()
Updates the tick clock whenever the tick count is incremented

Specified by:
onTickCountUpdate in class BaseController

enableManipulation

public void enableManipulation(boolean enable)
Enables the user customized actions.

Parameters:
enable -

stopSimulation

public void stopSimulation()
Stops the simulation. Note that the simulation will continue until the next time the looping condition is checked. Consequently, if the running loop begins its next iteration before the stop condition is received then an additional iteration of the simulation will occur.


pauseSimulation

public void pauseSimulation()
Pauses the simulation.


exitSimulation

public void exitSimulation()
Exits the simulation.


setParameters

protected void setParameters()
Sets the parameters of this AbstractGUIController's SimModel to their default values, if any. These default values are the values specified in a parameter file when repast was loaded or the values recorded when the makeCurParamsDefault method is called.


getModelParameterPanel

public IntrospectPanel getModelParameterPanel()
Creates an IntrospectPanel that contains the parameters this AbstractGUIController's SimModel. This is a gui representation of a SimModel's parameters.


getRepastParameterPanel

public IntrospectPanel getRepastParameterPanel()
Creates an IntrospectPanel that contains the parameters for all repast models.


showSnapshotDialog

public javax.swing.Action showSnapshotDialog(javax.swing.JFrame f)
Displays the dialog for taking snapshot images. Also deals appropriately with the results of the dialog, scheduling image capture appropriately. Note it is the caller's responsiblity to deal with the returned Action if necessary. For example, by creating a JButton.

Parameters:
f - the parent frame for the dialog
Returns:
An Action that when executed takes a snapshot. This will be null if the button snapshot option in the dialog is not selected.

showMakeMovieDialog

public void showMakeMovieDialog(javax.swing.JFrame frame)
Displays a dialog for creating movies of the simulation. This also deals with the results of that dialog appropriately, scheduling frame capture and so forth.

Parameters:
frame - the parent frame for the dialog

showVersion

public void showVersion()
Displays a message box showing the version number of repast.


makeCurrentParamsDefault

public void makeCurrentParamsDefault()
Makes the SimModel's current parameters the default parameters. These parameters will then be used as the default parameters when setup is performed.


showWriteParamsDialog

public void showWriteParamsDialog(javax.swing.JFrame f)
Displays a dialog for writing the SimModel's parameters to a file.

Parameters:
f - the parent frame for this dialog

showChartDialog

public void showChartDialog(javax.swing.JFrame f)
Displays a dialog for creating custom charts. This also deals with the results of that dialog, creating the actual charts and so forth.

Parameters:
f -

simEventPerformed

public void simEventPerformed(SimEvent evt)
Invoked by a source on which this is a listener when a SimEvent is fired. Controller listens for stop, end, and rng_seed events. Stop will stop the simulation, end will end the simluation and an rng_seed event will update the model panel with the new rng seed value.


getRunCount

public long getRunCount()
Returns the current run count. GUI Controllers do not count runs and thus this always returns 1.

Returns:

isGUI

public boolean isGUI()
Returns true;


isBatch

public boolean isBatch()
Description copied from class: BaseController
Is this a BatchController. Returns false.

Specified by:
isBatch in interface IController
Overrides:
isBatch in class BaseController