org.jscience.architecture.traffic.simulation
Class SimController

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by org.jscience.architecture.traffic.Controller
                      extended by org.jscience.architecture.traffic.simulation.SimController
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.Observer, javax.accessibility.Accessible, XMLSerializable

public class SimController
extends Controller
implements java.util.Observer

The main controller for the simulation part of the application.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  EditController editController
          DOCUMENT ME!
protected  SimMenuBar menuBar
          DOCUMENT ME!
protected  java.awt.Choice speedChoice
          DOCUMENT ME!
static int[] speedSettings
          DOCUMENT ME!
static java.lang.String[] speedTexts
          DOCUMENT ME!
protected  StatisticsOverlay statsOverlay
          DOCUMENT ME!
 
Fields inherited from class org.jscience.architecture.traffic.Controller
configDialog, currentFilename, currentSelection, currentTool, helpViewer, mainController, model, settings, statusBar, toolBar, toolPanel, view, viewScroller
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SimController(SimModel m, boolean splash)
          Creates the main frame.
 
Method Summary
protected  java.lang.String appName()
          Returns the name of this controller extension.
protected  java.awt.MenuBar createMenuBar()
          DOCUMENT ME!
protected  TrafficToolBar createToolBar()
          DOCUMENT ME!
 void disableOverlay()
          Enables the statistics overlay
 void doLoad(java.lang.String filename)
          DOCUMENT ME!
 void doSave(java.lang.String filename)
          DOCUMENT ME!
 void doStep()
          Makes model do one step
 void enableOverlay()
          Enables the statistics overlay
 java.lang.String getCurrentFilename()
          Returns the filename of the currently loaded file
 java.awt.PopupMenu getPopupMenuFor(Selectable obj)
          Creates a right-click popup-menu for the given object
 SimModel getSimModel()
          Returns the current SimModel
 void load(XMLElement myElement, XMLLoader loader)
          Load this XMLSerializable
 void nextSeries()
          DOCUMENT ME!
 void openEditor()
          Opens the editor
 void pause()
          Paues the simulation
 void runSeries()
          Starts a series of 10 simulations
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setCycleCounterEnabled(boolean b)
          Enables or disables the cycle counter.
 void setDrivingPolicy(int dp)
          DOCUMENT ME!
protected  void setInfra(int nr)
          Set temp debug infra
 void setSimModel(SimModel m)
          Sets a new SimModel to be controlled
 void setSpeed(int speed)
          Sets the speed of the simulation
 void setTLC(int cat, int nr)
          DOCUMENT ME!
 void showFilePropertiesDialog()
          Shows the file properties dialog
 void showStatistics()
          Opens the statistics viewer.
 void showTracker(int type)
          Shows the tracking window.
 void stop()
          Stops the simulation and resets the infrastructure
 void unpause()
          Resumes or starts the simulation
 void update(java.util.Observable o, java.lang.Object arg)
          Called by observable SimModel (if view enabled).
 
Methods inherited from class org.jscience.architecture.traffic.Controller
changeTool, getConfigDialog, getCurrentSelection, getCurrentTool, getMainController, getModel, getStatus, getToolPanel, getView, getViewScroller, getXMLName, isViewEnabled, loadAll, newFile, newInfrastructure, openFile, quit, reportError, resizeComponents, saveAll, saveFile, saveFileAs, setConfigDialog, setCurrentFilename, setCurrentSelection, setCurrentTool, setMainController, setParentName, setStatus, setToolPanel, setViewEnabled, showConfigDialog, showError, showHelp, showSaveAsDialog, showSettings, switchConfigDialog, tryLoad, trySave, validateInfra, zoomChanged, zoomIn, zoomOut, zoomTo
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

speedTexts

public static final java.lang.String[] speedTexts
DOCUMENT ME!


speedSettings

public static final int[] speedSettings
DOCUMENT ME!


editController

protected EditController editController
DOCUMENT ME!


menuBar

protected SimMenuBar menuBar
DOCUMENT ME!


speedChoice

protected java.awt.Choice speedChoice
DOCUMENT ME!


statsOverlay

protected StatisticsOverlay statsOverlay
DOCUMENT ME!

Constructor Detail

SimController

public SimController(SimModel m,
                     boolean splash)
Creates the main frame.

Parameters:
m - The SimModel to be controlled.
splash - DOCUMENT ME!
Method Detail

getSimModel

public SimModel getSimModel()
Returns the current SimModel

Returns:
DOCUMENT ME!

setSimModel

public void setSimModel(SimModel m)
Sets a new SimModel to be controlled

Parameters:
m - DOCUMENT ME!

setCycleCounterEnabled

public void setCycleCounterEnabled(boolean b)
Enables or disables the cycle counter.

Parameters:
b - DOCUMENT ME!

load

public void load(XMLElement myElement,
                 XMLLoader loader)
          throws XMLTreeException,
                 java.io.IOException,
                 XMLInvalidInputException
Description copied from interface: XMLSerializable
Load this XMLSerializable

Specified by:
load in interface XMLSerializable
Overrides:
load in class Controller
Parameters:
myElement - The XMLElement which represents this object in the XML tree. It can contain attributes which hold information about the object.
loader - The XMLLoader which this XMLSerializable can use to load child objects.
Throws:
XMLTreeException - The parser can throw this exception if it is called by the XMLSerializable. The XMLSerializable should NOT throw this exception by itself and preferrably not catch it too.
java.io.IOException - Thrown in case of an read error in the XML file.
XMLInvalidInputException - The XMLSerializable can throw this exception if it cannot load itself or one of its child objects for whatever reason.

saveSelf

public XMLElement saveSelf()
                    throws XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveSelf in interface XMLSerializable
Overrides:
saveSelf in class Controller
Returns:
DOCUMENT ME!
Throws:
XMLCannotSaveException - DOCUMENT ME!

saveChilds

public void saveChilds(XMLSaver saver)
                throws XMLTreeException,
                       java.io.IOException,
                       XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveChilds in interface XMLSerializable
Overrides:
saveChilds in class Controller
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!

doSave

public void doSave(java.lang.String filename)
            throws InvalidFilenameException,
                   java.lang.Exception
DOCUMENT ME!

Specified by:
doSave in class Controller
Parameters:
filename - DOCUMENT ME!
Throws:
InvalidFilenameException - DOCUMENT ME!
java.lang.Exception - DOCUMENT ME!

doLoad

public void doLoad(java.lang.String filename)
            throws InvalidFilenameException,
                   java.lang.Exception
DOCUMENT ME!

Specified by:
doLoad in class Controller
Parameters:
filename - DOCUMENT ME!
Throws:
InvalidFilenameException - DOCUMENT ME!
java.lang.Exception - DOCUMENT ME!

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Called by observable SimModel (if view enabled).

Specified by:
update in interface java.util.Observer
Parameters:
o - DOCUMENT ME!
arg - DOCUMENT ME!

appName

protected java.lang.String appName()
Returns the name of this controller extension.

Specified by:
appName in class Controller
Returns:
DOCUMENT ME!

createMenuBar

protected java.awt.MenuBar createMenuBar()
DOCUMENT ME!

Specified by:
createMenuBar in class Controller
Returns:
DOCUMENT ME!

createToolBar

protected TrafficToolBar createToolBar()
DOCUMENT ME!

Specified by:
createToolBar in class Controller
Returns:
DOCUMENT ME!

showStatistics

public void showStatistics()
Opens the statistics viewer.


showTracker

public void showTracker(int type)
Shows the tracking window.

Parameters:
type - DOCUMENT ME!

enableOverlay

public void enableOverlay()
Enables the statistics overlay


disableOverlay

public void disableOverlay()
Enables the statistics overlay


setDrivingPolicy

public void setDrivingPolicy(int dp)
DOCUMENT ME!

Parameters:
dp - DOCUMENT ME!

setTLC

public void setTLC(int cat,
                   int nr)
DOCUMENT ME!

Parameters:
cat - DOCUMENT ME!
nr - DOCUMENT ME!

showFilePropertiesDialog

public void showFilePropertiesDialog()
Shows the file properties dialog

Specified by:
showFilePropertiesDialog in class Controller

getPopupMenuFor

public java.awt.PopupMenu getPopupMenuFor(Selectable obj)
                                   throws PopupException
Creates a right-click popup-menu for the given object

Specified by:
getPopupMenuFor in class Controller
Parameters:
obj - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
PopupException - DOCUMENT ME!

getCurrentFilename

public java.lang.String getCurrentFilename()
Returns the filename of the currently loaded file

Returns:
DOCUMENT ME!

setSpeed

public void setSpeed(int speed)
Sets the speed of the simulation

Parameters:
speed - DOCUMENT ME!

doStep

public void doStep()
Makes model do one step


pause

public void pause()
Paues the simulation


unpause

public void unpause()
Resumes or starts the simulation


stop

public void stop()
Stops the simulation and resets the infrastructure


runSeries

public void runSeries()
Starts a series of 10 simulations


nextSeries

public void nextSeries()
DOCUMENT ME!


openEditor

public void openEditor()
Opens the editor


setInfra

protected void setInfra(int nr)
Set temp debug infra

Parameters:
nr - DOCUMENT ME!