Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.sim.engine
Class Controller

    java.lang.Object
      uchicago.src.sim.engine.BaseController
          uchicago.src.sim.engine.AbstractGUIController
              uchicago.src.sim.engine.Controller

All Implemented Interfaces:
  IController, SimEventListener, TickCounter

    public class Controller

extends AbstractGUIController

Default GUI control of the simulation. Allows start stop, step, exit, as well as setup to re-run the simulation after a stop. A user will interact with a `Controller` through the GUI, but, under normal circumstances, should not create one. See `SimInit` for more on how to run a simulation.

A list of the buttons displayed by the controller and what they do follows:

- Setup: sets up the simulation for another run
- Start: starts the simulation when paused or not yet running
- Step: run one execution cycle of the simulation
- Stop: stops the simulation
- Pause: pauses the simulation
- Exit: stops and exits the simulation

Version:
  $Revision: 1.48 $ $Date: 2005/08/16 16:42:54 $
Author:
  Nick Collier

Field Summary
`protected BatchController` | `batchController` used to do the multi-runs
`protected javax.swing.JButton` | `btnBegin`
`protected javax.swing.JButton` | `btnExit`
`protected javax.swing.JButton` | `btnLoad`
`protected javax.swing.JButton` | `btnMultRunsStart`
`protected javax.swing.JButton` | `btnPause`
`protected javax.swing.JButton` | `btnSettings`
`protected javax.swing.JButton` | `btnSetup`
`protected javax.swing.JButton` | `btnStart`
`protected javax.swing.JButton` | `btnStep`
`protected javax.swing.JButton` | `btnStop`
`protected java.util.ArrayList` | `keyListeners`
`protected java.util.ArrayList` | `listeners`
`protected IntrospectPanel` | `modelPanel`
`protected RepastParamPanel` | `parameterFilePanel`
`protected RepastActionPanel` | `repastPanel`
`protected javax.swing.JLabel` | `runCountLabel`
`protected javax.swing.JFrame` | `settingsFrame`
`protected IntrospectPanel` | `simPanel`
`protected javax.swing.JTabbedPane` | `tabPane`
`protected javax.swing.JFrame` | `tbFrame`
`protected javax.swing.JLabel` | `tickCount`
`protected javax.swing.JToolBar` | `toolBar`
`protected java.util.ArrayList` | `userButtons`

Fields inherited from class uchicago.src.sim.engine.AbstractGUIController
`ALPHA_ORDER, chartModels, console, CONSOLE_ERR, CONSOLE_OUT, customCharts, DEFAULTS_INCLUDE_RNGSEED, mediaSchedulers, myParams, PROBE_ALPHA_ORDER, SHOW_CHARTS, 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
`Controller()` Constructs a Controller with no associated model, or parameters.
`Controller(ParameterSetter parameters)` Constructs a controller whose model has the specified parameters.

Method Summary
`javax.swing.JButton` | `addButton(javax.swing.JButton b)` Adds a user defined button to the toolbar.
`javax.swing.JButton` | `addButton(java.lang.String label, java.awt.event.ActionListener listener)` Adds a user defined button to the toolbar.
`void` | `addExitListener(java.awt.event.ActionListener listener)` Adds an ActionListener listening for exit button presses.
`javax.swing.JButton` | `addIconButton(java.lang.String path, java.awt.event.ActionListener l)` Adds a user defined button to the toolbar.
`void` | `addKeyListener(java.awt.event.KeyListener listener)` Adds a KeyListener listening for any keyboard action when the control toolbar has focus.
`void` | `addPauseListener(java.awt.event.ActionListener listener)` Adds an ActionListener listening for pause button presses.
`void` | `addStartListener(java.awt.event.ActionListener listener)` Adds an ActionListener listening for start button presses.
`void` | `addStepListener(java.awt.event.ActionListener listener)` Adds an ActionListener listening for step button presses.
`void` | `addStopListener(java.awt.event.ActionListener listener)` Adds an ActionListener listening for stop button presses.
`void` | `beginModel()` Executes begin() on the SimModel associated with this AbstractGUIController.
`void` | `display()` Displays the controller
`javax.swing.JFrame` | `getFrame()` Returns the JFrame for controller tool bar.
`javax.swing.JTabbedPane` | `getTabPane()` Returns the JTabbedPane that contains the parameter panel etc.
`javax.swing.JToolBar` | `getToolBar()` Returns the tool bar containing the stop, start etc. buttons.
`protected void` | `initParamFileOptions()` loads up the parameter file chooser panel
`protected void` | `onTickCountUpdate()` Updates the tick clock whenever the tick count is incremented
`void` | `pauseSim()` Pauses the simulation
`void` | `setModel(SimModel model)` Sets the model that is controlled by this Controller.
`void` | `setup()` Sets up this controller and is associated SimModel prior to a model run.
`void` | `showSettings()`
`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.
`protected void` | `startMultRunsSim()` method called when the triple play button is pushed
`void` | `startSim()` Starts the simulation.
`void` | `stepSim()` Steps the simulation through one iteration of execution.
`void` | `stopSim()` Stops the simulation.

Methods inherited from class uchicago.src.sim.engine.AbstractGUIController
`enableManipulation, exitSim, exitSimulation, getConsoleErr, getConsoleOut, getModelParameterPanel, getRepastParameterPanel, getRunCount, isBatch, isGUI, loadAndStart, makeCurrentParamsDefault, pauseSimulation, setConsoleErr, setConsoleOut, setParameters, showChartDialog, showLoadModelDialog, showMakeMovieDialog, showSnapshotDialog, showVersion, showWriteParamsDialog, stopSimulation`

Methods inherited from class uchicago.src.sim.engine.BaseController
`addSimEventListener, fireSimEvent, getCellDepth, getCellHeight, getCellWidth, getCurrentTime, getDefaultModelParameters, getExitOnExit, getModel, getModelParameters, getPauseAt, getPersistentObj, getRandomSeed, getSchedule, notifyMonitor, putPersistentObj, removeSimEventListener, setCellDepth, setCellHeight, setCellWidth, setExitOnExit, setPauseAt, setRandomSeed, setSchedule, setupSchedule`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### toolBar

    protected javax.swing.JToolBar toolBar

### tbFrame

    protected javax.swing.JFrame tbFrame

### btnSetup

    protected javax.swing.JButton btnSetup

### btnStart

    protected javax.swing.JButton btnStart

### btnStep

    protected javax.swing.JButton btnStep

### btnStop

    protected javax.swing.JButton btnStop

### btnPause

    protected javax.swing.JButton btnPause

### btnExit

    protected javax.swing.JButton btnExit

### btnLoad

    protected javax.swing.JButton btnLoad

### btnSettings

    protected javax.swing.JButton btnSettings

### btnBegin

    protected javax.swing.JButton btnBegin

### btnMultRunsStart

    protected javax.swing.JButton btnMultRunsStart

### parameterFilePanel

    protected RepastParamPanel parameterFilePanel

### batchController

    protected BatchController batchController

  used to do the multi-runs

### tickCount

    protected javax.swing.JLabel tickCount

### runCountLabel

    protected javax.swing.JLabel runCountLabel

### settingsFrame

    protected javax.swing.JFrame settingsFrame

### tabPane

    protected javax.swing.JTabbedPane tabPane

### modelPanel

    protected IntrospectPanel modelPanel

### simPanel

    protected IntrospectPanel simPanel

### repastPanel

    protected RepastActionPanel repastPanel

### userButtons

    protected java.util.ArrayList userButtons

### listeners

    protected java.util.ArrayList listeners

### keyListeners

    protected java.util.ArrayList keyListeners

Constructor Detail

### Controller

    public Controller()

  Constructs a Controller with no associated model, or parameters.

### Controller

    public Controller(ParameterSetter parameters)

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

  Parameters:
    `parameters` - default values for the model's parameters

Method Detail

### 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 `AbstractGUIController`
  Parameters:
    `model` - the model associated with this BaseController

### addButton

    public javax.swing.JButton addButton(java.lang.String label,
                                         java.awt.event.ActionListener listener)

  Adds a user defined button to the toolbar. This must be called in the model's setup method or the button will not be added.

  Parameters:
    `label` - the label for the new JButton
    `listener` - the ActionListener fired when the button is clicked

### addButton

    public javax.swing.JButton addButton(javax.swing.JButton b)

  Adds a user defined button to the toolbar. This must be called in the model's setup method or the button will not be added.

  Parameters:
    `b` - the JButton to add

### addIconButton

    public javax.swing.JButton addIconButton(java.lang.String path,
                                             java.awt.event.ActionListener l)

  Adds a user defined button to the toolbar. This must be called in the model's setup method or the button will not be added. The location of the image to create the icon from is given the specified path.

  Parameters:
    `path` - the path to image to use as an ImageIcon for the created JButton
    `l` - ActionListener fired when the button is clicked

### initParamFileOptions

    protected void initParamFileOptions()

  loads up the parameter file chooser panel

### startMultRunsSim

    protected void startMultRunsSim()

  method called when the triple play button is pushed

### startSim

    public void startSim()

  Description copied from class: `BaseController`
  Starts the simulation. Fires a START_EVENT before the simulation thread is actually started.

  Specified by:
    `startSim` in interface `IController`
  Overrides:
    `startSim` in class `BaseController`

### stopSim

    public void stopSim()

  Description copied from class: `BaseController`
  Stops the simulation.

  Specified by:
    `stopSim` in interface `IController`
  Overrides:
    `stopSim` in class `BaseController`

### shutdown

    public void shutdown()

  Description copied from class: `AbstractGUIController`
  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.

  Overrides:
    `shutdown` in class `AbstractGUIController`

### showSettings

    public void showSettings()

### stepSim

    public void stepSim()

  Description copied from class: `AbstractGUIController`
  Steps the simulation through one iteration of execution.

  Overrides:
    `stepSim` in class `AbstractGUIController`

### beginModel

    public void beginModel()

  Description copied from class: `AbstractGUIController`
  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 `AbstractGUIController`

### pauseSim

    public void pauseSim()

  Description copied from class: `BaseController`
  Pauses the simulation

  Specified by:
    `pauseSim` in interface `IController`
  Overrides:
    `pauseSim` in class `BaseController`

### setup

    public void setup()

  Description copied from class: `AbstractGUIController`
  Sets up this controller and is associated SimModel prior to a model run.

  Overrides:
    `setup` in class `AbstractGUIController`

### onTickCountUpdate

    protected void onTickCountUpdate()

  Updates the tick clock whenever the tick count is incremented

  Overrides:
    `onTickCountUpdate` in class `AbstractGUIController`

### display

    public void display()

  Displays the controller

### getFrame

    public javax.swing.JFrame getFrame()

  Returns the JFrame for controller tool bar.

### getToolBar

    public javax.swing.JToolBar getToolBar()

  Returns the tool bar containing the stop, start etc. buttons.

### getTabPane

    public javax.swing.JTabbedPane getTabPane()

  Returns the JTabbedPane that contains the parameter panel etc.

### addStartListener

    public void addStartListener(java.awt.event.ActionListener listener)

  Adds an ActionListener listening for start button presses. The source for the event fired here will be the start button with an actionCommand of "start".

  Parameters:
    `listener` - the listener to listen for button clicks.

### addStopListener

    public void addStopListener(java.awt.event.ActionListener listener)

  Adds an ActionListener listening for stop button presses. The source for the event fired here will be the stop button with an actionCommand of "stop".

  Parameters:
    `listener` - the listener to listen for button clicks.

### addPauseListener

    public void addPauseListener(java.awt.event.ActionListener listener)

  Adds an ActionListener listening for pause button presses. The source for the event fired here will be the pause button with an actionCommand of "pause".

  Parameters:
    `listener` - the listener to listen for button clicks.

### addExitListener

    public void addExitListener(java.awt.event.ActionListener listener)

  Adds an ActionListener listening for exit button presses. The source for the event fired here will be the exit button with an actionCommand of "exit".

  Parameters:
    `listener` - the listener to listen for button clicks.

### addStepListener

    public void addStepListener(java.awt.event.ActionListener listener)

  Adds an ActionListener listening for step button presses. The source for the event fired here will be the step button with an actionCommand of "step".

  Parameters:
    `listener` - the listener to listen for button clicks.

### addKeyListener

    public void addKeyListener(java.awt.event.KeyListener listener)

  Adds a KeyListener listening for any keyboard action when the control toolbar has focus.

  Parameters:
    `listener` - the listener to listen for keyboard events

### 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.

  Specified by:
    `simEventPerformed` in interface `SimEventListener`
  Overrides:
    `simEventPerformed` in class `AbstractGUIController`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD