| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
cz.zcu.fav.kiv.jsim.gui.JSimMainWindow
public class JSimMainWindow
The JSimMainWindow class provides services for graphic output. You should never use this class directly since the JSimSimulation class contains methods for running in graphic mode.
| Nested Class Summary | |
|---|---|
| (package private)  class | JSimMainWindow.CommonChangesAn observer responsible for disabling control buttons when the main window is waiting for its closure by the user. | 
| (package private)  class | JSimMainWindow.JFieldCurrentTimeShows the simulation's current time and its changes. | 
| (package private)  class | JSimMainWindow.MyActionAdapterThe main window's action adapter. | 
| (package private)  class | JSimMainWindow.MyMouseAdapterThe main window's mouse adapter. | 
| (package private)  class | JSimMainWindow.MyWindowAdapter | 
| Nested classes/interfaces inherited from class javax.swing.JFrame | 
|---|
| javax.swing.JFrame.AccessibleJFrame | 
| 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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy | 
| Field Summary | |
|---|---|
| private  javax.swing.JButton | buttonContinue | 
| private  javax.swing.JButton | buttonNoOfSteps | 
| private  javax.swing.JButton | buttonOneStep | 
| private  javax.swing.JPanel | buttonPanel | 
| private  javax.swing.JButton | buttonPause | 
| private  javax.swing.JButton | buttonQuit | 
| private  javax.swing.JButton | buttonUntil | 
| private  boolean | canCloseFlag saying whether it is possible to close the window. | 
| private  JSimMainWindow.CommonChanges | commonCh | 
| private  java.lang.Object | endLockThe lock used to notify the main thread while the simulation waits in waitForWindowClosure(). | 
| private  JSimMainWindow.JFieldCurrentTime | fieldCurrentTime | 
| private  javax.swing.JTextField | fieldNoOfSteps | 
| private  javax.swing.JTextField | fieldUntil | 
| private  java.lang.Object | graphicLockThe lock used to suspend the main thread while the window is open. | 
| private  JSimChange | guiUpdateThe main dispatcher of changes generated during simulation progress. | 
| static int | LIST_TYPE_PROCESS | 
| static int | LIST_TYPE_QUEUE | 
| static int | LIST_TYPE_SEMAPHORE | 
| private static java.util.logging.Logger | loggerCommon logger for all instances of this class. | 
| private  JSimSimulationMode | modeThe simulation mode: text, GUI batch, or GUI interactive. | 
| private  JSimMainWindow.MyActionAdapter | myActionListenerThe main window's action listener. | 
| private  JSimMainWindow.MyMouseAdapter | myMouseListenerThe main window's mouse listener. | 
| private  JSimSimulation | myParentSimulation this window belongs to. | 
| private  JSimMainWindow.MyWindowAdapter | myWindowListenerThe main window's window listener. | 
| private  java.lang.String | newLineThe new-line property of the OS used. | 
| private  java.util.ArrayList<JSimDisplayable> | openDetailedWindowsA list of open detailed info windows. | 
| private  boolean | pausedFlag saying whether the pause button has been pressed. | 
| private  javax.swing.JPanel | processesPanel | 
| private  JSimMainWindowList | processList | 
| private  javax.swing.JScrollPane | processListScrollPane | 
| private  JSimMainWindowList | queueList | 
| private  javax.swing.JScrollPane | queueListScrollPane | 
| private  javax.swing.JPanel | queuesPanel | 
| private  boolean | quitPressedFlag saying whether the quit button has been pressed. | 
| private static long | serialVersionUIDSerialization identification. | 
| private  javax.swing.JSplitPane | splitListPane | 
| private  javax.swing.JSplitPane | splitPane | 
| private  java.lang.Object | stepLockThe lock used to notify the main thread while the simulation is paused in GUI batch mode. | 
| private  javax.swing.JTextArea | userOutput | 
| private  javax.swing.JScrollPane | userOutputScrollPane | 
| Fields inherited from class javax.swing.JFrame | 
|---|
| accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled | 
| 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 javax.swing.WindowConstants | 
|---|
| DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
| ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
| JSimMainWindow(JSimSimulation simulation,
               JSimSimulationMode simMode)Creates a new main window with several buttons, input fields and a text area. | |
| Method Summary | |
|---|---|
| private  void | actionContinue()Unblocks the simulation. | 
| private  void | actionPause()Suspends the simulation. | 
| private  void | actionQuit()Closes the window, notifies the main thread and returns control to the simulation. | 
| private  void | actionRunNumberOfSteps()Runs the number of steps specified in the `Number of steps to run' input field. | 
| private  void | actionRunOneStep()Runs one simulation step. | 
| private  void | actionRunUntilTimeLimit()Runs an unspecified number of simulation steps until the simulation time is equal to or greater than the time specified in the `Time Limit' input field. | 
| private  void | disableRunButtons()Disables all buttons except of the `Quit' button. | 
| private  void | enableRunButtons()Enables all buttons except of the `Quit' button. | 
|  boolean | getPausePressed()Returns true if the 'Pause' button has been pressed. | 
|  boolean | getQuitPressed()Returns true if the 'Quit' button has been pressed. | 
|  JSimSimulation | getSimulation()Returns the simulation object to which this window belongs to. | 
| private  void | openUpDetailedInfoWindow(JSimMainWindowList list)Creates and displays a detailed info window that displays detailed characteristics of the object corresponding to the selected item from a list placed inside the main window. | 
|  void | printString(java.lang.String s,
            int code,
            boolean appendNewLine)Prints out a string to the user text area at the bottom of the window. | 
|  void | removeDisplayableFromOpenInfoWindows(JSimDisplayable jsd)When a detailed info window shuts up, it should invoke its main window's removeDisplayableFromInfoWindows() method in order to inform it that its displayable object is no longer showing. | 
| Methods inherited from class javax.swing.JFrame | 
|---|
| addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update | 
| Methods inherited from class java.awt.Frame | 
|---|
| addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront | 
| Methods inherited from class java.awt.Container | 
|---|
| add, add, add, add, add, addContainerListener, 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, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree | 
| Methods inherited from class java.awt.Component | 
|---|
| action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, 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, checkImage, checkImage, 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, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface java.awt.MenuContainer | 
|---|
| getFont, postEvent | 
| Field Detail | 
|---|
private static final long serialVersionUID
public static final int LIST_TYPE_PROCESS
public static final int LIST_TYPE_QUEUE
public static final int LIST_TYPE_SEMAPHORE
private static final java.util.logging.Logger logger
private JSimSimulation myParent
private JSimSimulationMode mode
private java.lang.Object graphicLock
private java.lang.Object stepLock
private java.lang.Object endLock
private JSimMainWindow.MyActionAdapter myActionListener
private JSimMainWindow.MyMouseAdapter myMouseListener
private JSimMainWindow.MyWindowAdapter myWindowListener
private javax.swing.JPanel buttonPanel
private javax.swing.JPanel processesPanel
private javax.swing.JPanel queuesPanel
private javax.swing.JTextField fieldUntil
private javax.swing.JTextField fieldNoOfSteps
private JSimMainWindow.JFieldCurrentTime fieldCurrentTime
private JSimMainWindow.CommonChanges commonCh
private javax.swing.JButton buttonQuit
private javax.swing.JButton buttonOneStep
private javax.swing.JButton buttonUntil
private javax.swing.JButton buttonNoOfSteps
private javax.swing.JButton buttonPause
private javax.swing.JButton buttonContinue
private javax.swing.JSplitPane splitPane
private javax.swing.JSplitPane splitListPane
private javax.swing.JScrollPane userOutputScrollPane
private javax.swing.JScrollPane processListScrollPane
private javax.swing.JScrollPane queueListScrollPane
private JSimMainWindowList processList
private JSimMainWindowList queueList
private javax.swing.JTextArea userOutput
private boolean canClose
private boolean quitPressed
private boolean paused
private JSimChange guiUpdate
private java.util.ArrayList<JSimDisplayable> openDetailedWindows
private java.lang.String newLine
| Constructor Detail | 
|---|
public JSimMainWindow(JSimSimulation simulation,
                      JSimSimulationMode simMode)
               throws JSimSimulationAlreadyTerminatedException,
                      JSimInvalidParametersException
simulation - The simulation object that owns this newly created window. It must not be null.simMode - The mode in which the simulation runs, design of the window depends on it.
JSimSimulationAlreadyTerminatedException - This exception is thrown out if the simulation has already terminated.
JSimInvalidParametersException - This exception is thrown out if the simulation is null or one of its locks cannot be obtained.| Method Detail | 
|---|
public JSimSimulation getSimulation()
private void actionQuit()
private void actionRunOneStep()
private void actionRunUntilTimeLimit()
private void actionRunNumberOfSteps()
private void actionPause()
private void actionContinue()
public final boolean getQuitPressed()
public final boolean getPausePressed()
public void printString(java.lang.String s,
                        int code,
                        boolean appendNewLine)
s - The string to be printed out.code - A code saying whether it is an info message (PRN_MESSAGE) or an error message (PRN_ERROR).appendNewLine - A flag indicating that the new line character should be appended to the text.private void openUpDetailedInfoWindow(JSimMainWindowList list)
list - The list from which the item is selected.public void removeDisplayableFromOpenInfoWindows(JSimDisplayable jsd)
jsd - The JSimDisplayable object whose detailed info window is just shutting up.private void disableRunButtons()
private void enableRunButtons()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||