haifa.shopsim.UI
Class MainGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--javax.swing.JApplet
                                |
                                +--haifa.shopsim.UI.MainGUI
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, UIStringConstants

public class MainGUI
extends javax.swing.JApplet
implements UIStringConstants

This class is one of the several usuable products of the JobShopSimualtion Project. It is the Algorithm testing/educational tool. It is the class that should be run as the main class when running this tool as a stand alone application. It may also be run as an applet.

When run as an applet, job shop files may be loaded only from the host at which the applet is sitting. This should suffice for demonstration purpuses. see the init() method.

Applet code should be:

...
param name = "SHOP_DATA1" value = "shop1.jbs*A three machine problem"
param name = "SHOP_DATA2" value = "10x10.jbs*The famous 10 by 10 problem"
...

This GUI features the following states of execution:

  1. Reset State
  2. Loaded State
  3. Alg Selected State
  4. Running State
  5. Finished State

Version:
1.1
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
protected  int ALG_SELECTED_STATE
          This state implies that an algorithm is selected and also a shop is loaded.
protected  java.util.Vector algButtunsVector
           
protected  javax.swing.ButtonGroup algGroup
           
protected  javax.swing.JMenu algorithmMenu
           
protected  javax.swing.JPanel algPanel
          Location in which the GUI algorithm appears.
protected  javax.swing.JPanel animArea
          For animation.
protected  javax.swing.JSplitPane bottomSplitPane
          Vertical split between shopdata and gantt.
protected  javax.swing.JPanel centerBottomPanel
           
protected  javax.swing.JSplitPane centerSplitPane
          Splits between the upper splitPane and the shopData,gantt.
protected  javax.swing.JPanel centerTopPanel
           
protected static int CLOSE_ITEM_POS
           
protected  javax.swing.JLabel commandLabel
           
protected  GUIAlgorithm currentAlgorithm
          A refrence to the currently selected shopAlgorithm, may be null.
protected  javax.swing.AbstractButton defaultRV
          A reference to the default random variable button.
protected static int EXIT_ITEM_POS
           
protected  javax.swing.JMenu fileMenu
           
(package private)  javax.swing.Action[] fileMenuActions
          Action events of the file menu.
protected  int FINISHED_STATE
          This state implies that a simulation run was running and is now finished.
protected static javax.swing.JFrame frame
           
protected  javax.swing.JPanel ganttArea
          For gantt chart.
protected  GeneralProblemSizeChooser generalProblemSizeChooser
          The size chooser used to determine how many jobs are on each route.
protected  javax.swing.JMenu helpMenu
           
(package private)  javax.swing.Action[] helpMenuActions
          Action events of the Help menu.
protected static java.lang.String HOME_PAGE
          If the user chooses exit during an applet, it is brought to this page.
protected static boolean isApplication
          False if applet true if application
protected  JobShopGraphics jobShopGraphics
          The Graphics information (to be read from .jbs file).
protected  java.awt.event.ActionEvent lastAe
           
protected  AlgorithmSelectionAction lastAsa
           
protected  int LOADED_STATE
          This state implies that a shop is loaded but not running and an algorithm is still not selected.
protected  LogWindow logWindow
          Results from the kernel, algorithms and stat collector are printed to this window.
protected  javax.swing.JPanel mainPanel
           
protected static int MAX_JOBS
          The highest multiplicty that the GUI enviornment allows.
protected  javax.swing.JMenuBar menuBar
           
protected static int OPEN_ITEM_POS
           
protected  javax.swing.JPanel patchPanel
           
protected  RandomTimeMaker randomTimeMaker
          The random variable generator.
protected  int RESET_STATE
          This is the state immidiently after opening or after closing a shop.
protected  javax.swing.JRootPane rootPane
          Used when working with a JFrame and setting a menu.
protected  int RUNNING_STATE
          This state implies that a shop is currently running.
protected  javax.swing.ButtonGroup rvGroup
           
protected  javax.swing.JMenu rvMenu
           
protected static int SET_NR_ITEM_POS
           
protected  ShopAnim shopAnim
          The animation.
protected  ShopData shopData
          A reference to the data regarding the current job shop, may be null if no shop data is set.
protected  javax.swing.JTextArea shopDataTextArea
          The text area in which the shop data is displayed.
protected  javax.swing.JPanel shopStateArea
          For shopState table.
protected  ShopTraceMaker shopTraceMaker
          Listens to shop events and transaltes them to trace events as seen by the gantt chart in the simJava package.
protected  ShopViewUpdater shopViewUpdater
          Gets events from ShopSimulation and updates listeners according to speed control.
protected  javax.swing.JMenu simulationMenu
           
(package private)  javax.swing.Action[] simulationMenuActions
          Action events of the simulation menu.
protected static int SPEED_ITEM_POS
           
protected  SpeedControlAction speedControlAction
           
protected  javax.swing.JSlider speedSlider
          Slider used by speed control.
protected static int START_ITEM_POS
           
protected  StatisticsCollector stat
          The statistics Collector.
protected  int state
          The variable that states the state in which the MainGUI is found.
protected  javax.swing.JComponent stateTable
          A reference to the stateTable
protected static int STOP_ITEM_POS
           
protected  ThreadFastShopRun threadFastShopRun
          A reference to the ShopSimulation object (the object that runs the simulation).
protected  TimingDiagram timingDiagram
          Used to display Gantt Chart.
protected  javax.swing.JSplitPane upperSplitPane
          Splits between Algorithm and animation/stateTable.
protected  java.util.Map urlFilesMap
           
protected static int VIEW_ITEM_POS
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
serialVersionUID, stub
 
Fields inherited from class java.awt.Panel
base, nameCounter
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface haifa.shopsim.UI.UIStringConstants
ABOUT_TEXT, ALG_SELECTED_STRING, ALGORITHMS_TEXT, ANIM_SUPPRESSED_STRING, FRAME_TITLE, JBS_FILES_TEXT, JOB_SHOP_LOADED_STRING, NO_SHOP_DATA_STRING, SIMULATION_ABORTED_STRING, SIMULATION_FINISHED_STRING, USING_SIM_TEXT, VACANT_ALG_AREA_STRING, VACANT_ANIM_AREA_STRING, VACANT_GANTT_AREA_STRING, VACANT_SHOP_STATE_AREA_STRING, WELCOME_STRING
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainGUI()
           
 
Method Summary
 void destory()
           
protected  void exitApplet()
          Kills the applet and goes to HOME_PAGE with the browser.
protected static void exitApplication()
          Called to exit.
protected  void fixAlgSelectedState()
           
protected  void fixFinishedState()
           
protected  void fixLoadedState()
           
protected  void fixResetState()
           
protected  void fixRunningState()
           
protected  void fullyEnableMenu(javax.swing.JMenu menu)
           
 void init()
          Reads parameters, sets up, etc...
protected  void loadShopData(java.io.Reader reader)
          Loads and allocates shopData.
protected  void loadShopGraphics(java.io.Reader reader)
          Loads and allocates jobShopGraphics.
static void main(java.lang.String[] a)
           
protected  void notifyAboutSpeed()
           
 void setCommandLabel(java.lang.String cmd)
          Changes the command label
 MainGUI setUp(javax.swing.JRootPane rootPane_)
          Sets up GUI.
private  void setUpAlgorithmsMenu()
           
protected  void setUpDataFilesMenuForApplet()
           
 void start()
           
 void stop()
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, createRootPaneException, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paint, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, transferFocus, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

RESET_STATE

protected final int RESET_STATE
This is the state immidiently after opening or after closing a shop. Everything is Reset.

LOADED_STATE

protected final int LOADED_STATE
This state implies that a shop is loaded but not running and an algorithm is still not selected.

ALG_SELECTED_STATE

protected final int ALG_SELECTED_STATE
This state implies that an algorithm is selected and also a shop is loaded.

RUNNING_STATE

protected final int RUNNING_STATE
This state implies that a shop is currently running.

FINISHED_STATE

protected final int FINISHED_STATE
This state implies that a simulation run was running and is now finished. It is similar to the ALG_SELECTED_STATE in the sense that both an algoirthm and a shop data are present

state

protected int state
The variable that states the state in which the MainGUI is found.

HOME_PAGE

protected static final java.lang.String HOME_PAGE
If the user chooses exit during an applet, it is brought to this page.

MAX_JOBS

protected static final int MAX_JOBS
The highest multiplicty that the GUI enviornment allows.

isApplication

protected static boolean isApplication
False if applet true if application

rootPane

protected javax.swing.JRootPane rootPane
Used when working with a JFrame and setting a menu.

algPanel

protected javax.swing.JPanel algPanel
Location in which the GUI algorithm appears.

shopStateArea

protected javax.swing.JPanel shopStateArea
For shopState table.

ganttArea

protected javax.swing.JPanel ganttArea
For gantt chart.

animArea

protected javax.swing.JPanel animArea
For animation.

mainPanel

protected javax.swing.JPanel mainPanel

commandLabel

protected javax.swing.JLabel commandLabel

centerTopPanel

protected javax.swing.JPanel centerTopPanel

centerBottomPanel

protected javax.swing.JPanel centerBottomPanel

upperSplitPane

protected javax.swing.JSplitPane upperSplitPane
Splits between Algorithm and animation/stateTable.

centerSplitPane

protected javax.swing.JSplitPane centerSplitPane
Splits between the upper splitPane and the shopData,gantt.

bottomSplitPane

protected javax.swing.JSplitPane bottomSplitPane
Vertical split between shopdata and gantt.

menuBar

protected javax.swing.JMenuBar menuBar

fileMenu

protected javax.swing.JMenu fileMenu

simulationMenu

protected javax.swing.JMenu simulationMenu

algorithmMenu

protected javax.swing.JMenu algorithmMenu

helpMenu

protected javax.swing.JMenu helpMenu

rvMenu

protected javax.swing.JMenu rvMenu

rvGroup

protected javax.swing.ButtonGroup rvGroup

algGroup

protected javax.swing.ButtonGroup algGroup

fileMenuActions

javax.swing.Action[] fileMenuActions
Action events of the file menu. Each of these has a corresponeding inner class.

OPEN_ITEM_POS

protected static final int OPEN_ITEM_POS

CLOSE_ITEM_POS

protected static final int CLOSE_ITEM_POS

EXIT_ITEM_POS

protected static final int EXIT_ITEM_POS

speedControlAction

protected SpeedControlAction speedControlAction

simulationMenuActions

javax.swing.Action[] simulationMenuActions
Action events of the simulation menu. Each of these has a corresponeding inner class.

START_ITEM_POS

protected static final int START_ITEM_POS

STOP_ITEM_POS

protected static final int STOP_ITEM_POS

SPEED_ITEM_POS

protected static final int SPEED_ITEM_POS

VIEW_ITEM_POS

protected static final int VIEW_ITEM_POS

SET_NR_ITEM_POS

protected static final int SET_NR_ITEM_POS

helpMenuActions

javax.swing.Action[] helpMenuActions
Action events of the Help menu.

shopAnim

protected ShopAnim shopAnim
The animation.

jobShopGraphics

protected JobShopGraphics jobShopGraphics
The Graphics information (to be read from .jbs file). May be null if no graphics are read.

stateTable

protected javax.swing.JComponent stateTable
A reference to the stateTable

logWindow

protected LogWindow logWindow
Results from the kernel, algorithms and stat collector are printed to this window.

shopTraceMaker

protected ShopTraceMaker shopTraceMaker
Listens to shop events and transaltes them to trace events as seen by the gantt chart in the simJava package.

shopViewUpdater

protected ShopViewUpdater shopViewUpdater
Gets events from ShopSimulation and updates listeners according to speed control.

timingDiagram

protected TimingDiagram timingDiagram
Used to display Gantt Chart. Taken from the simJava package.

shopDataTextArea

protected javax.swing.JTextArea shopDataTextArea
The text area in which the shop data is displayed.

speedSlider

protected javax.swing.JSlider speedSlider
Slider used by speed control. The SpeedControlAction displays this slider.

threadFastShopRun

protected ThreadFastShopRun threadFastShopRun
A reference to the ShopSimulation object (the object that runs the simulation).

currentAlgorithm

protected GUIAlgorithm currentAlgorithm
A refrence to the currently selected shopAlgorithm, may be null.

shopData

protected ShopData shopData
A reference to the data regarding the current job shop, may be null if no shop data is set.

stat

protected StatisticsCollector stat
The statistics Collector.

randomTimeMaker

protected RandomTimeMaker randomTimeMaker
The random variable generator.

generalProblemSizeChooser

protected GeneralProblemSizeChooser generalProblemSizeChooser
The size chooser used to determine how many jobs are on each route.

defaultRV

protected javax.swing.AbstractButton defaultRV
A reference to the default random variable button.

algButtunsVector

protected java.util.Vector algButtunsVector

lastAsa

protected AlgorithmSelectionAction lastAsa

lastAe

protected java.awt.event.ActionEvent lastAe

patchPanel

protected javax.swing.JPanel patchPanel

urlFilesMap

protected java.util.Map urlFilesMap

frame

protected static javax.swing.JFrame frame
Constructor Detail

MainGUI

public MainGUI()
Method Detail

setUp

public MainGUI setUp(javax.swing.JRootPane rootPane_)
Sets up GUI. Returns 'this'. This is basically like a co'tr

setUpAlgorithmsMenu

private void setUpAlgorithmsMenu()

fixResetState

protected void fixResetState()

fixLoadedState

protected void fixLoadedState()

fixAlgSelectedState

protected void fixAlgSelectedState()

fixRunningState

protected void fixRunningState()

fixFinishedState

protected void fixFinishedState()

loadShopData

protected void loadShopData(java.io.Reader reader)
                     throws java.lang.Exception
Loads and allocates shopData.

loadShopGraphics

protected void loadShopGraphics(java.io.Reader reader)
                         throws java.lang.Exception
Loads and allocates jobShopGraphics. Assumes that shopData is already set properly. If there

setCommandLabel

public void setCommandLabel(java.lang.String cmd)
Changes the command label

fullyEnableMenu

protected void fullyEnableMenu(javax.swing.JMenu menu)

notifyAboutSpeed

protected void notifyAboutSpeed()

init

public void init()
Reads parameters, sets up, etc...
Overrides:
init in class java.applet.Applet

setUpDataFilesMenuForApplet

protected void setUpDataFilesMenuForApplet()

start

public void start()
Overrides:
start in class java.applet.Applet

stop

public void stop()
Overrides:
stop in class java.applet.Applet

destory

public void destory()

exitApplet

protected void exitApplet()
Kills the applet and goes to HOME_PAGE with the browser.

main

public static void main(java.lang.String[] a)

exitApplication

protected static void exitApplication()
Called to exit. Currently just kills the JVM.