dk.brics.bisimulationGame.view
Class GameView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by dk.brics.bisimulationGame.view.GameView
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class GameView
extends javax.swing.JPanel

The game view.

The game view consists of two LTS panels, left and right, a trace panel in between and a status panel below.

Author:
Martin Mosegaard martinm@daimi.au.dk
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
static int GAME_VIEW_CLIENT
          A client does not have a reset button.
static int GAME_VIEW_LOCAL
          A local game does not have a chat function.
static int GAME_VIEW_SERVER
          A server gets both a chat function and a reset button.
private  java.awt.Dimension graphDimension
           
private  LTSPanel leftLTSPanel
          A panel for the left LTS.
private  int lowerHeight
           
private  GameViewLowerPanel lowerPanel
          The lower (south) panel of a game view.
private  java.awt.Font messageFont
           
private  LTSPanel rightLTSPanel
          A panel for the right LTS.
private static long serialVersionUID
           
private  javax.swing.JTextArea trace
          A text area inside the trace scroll pane.
private  java.awt.Dimension traceDimension
           
private  javax.swing.JScrollPane traceScrollPane
          A scroll pane for the trace.
private  int width
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
GameView(int width, int height)
          Constructs a game view but does not construct the lower panel.
 
Method Summary
 void createLowerPanel(int gameViewType)
          Creates the lower panel of a game view, based on game options
 void displayGameOver(java.lang.String message, java.awt.Color color)
          Display a game over message.
 void displayLTSs(att.grappa.Graph leftLTS, att.grappa.Graph rightLTS, att.grappa.GrappaAdapter ga)
          Display the two LTSs.
 void displayLTSTitles(java.lang.String leftLTSTitle, java.lang.String rightLTSTitle)
          Display the titles of the two LTSs.
 void displayMessage(java.lang.String message)
          Display a general message.
private  void displayRole(java.lang.String role)
          Display a role message.
 void displayStatus(java.lang.String role, java.lang.String turn, java.lang.String message)
          Display game status in the status part of the lower panel.
 void displayTurn(java.lang.String turn)
          Display a turn message.
 LTSPanel getLeftLTSPanel()
           
 GameViewLowerPanel getLowerPanel()
           
 LTSPanel getRightLTSPanel()
           
 void resetTrace()
          Clear the text in the trace scroll pane
 void updateTrace(java.lang.String action)
          Update the trace with the specified action.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

GAME_VIEW_LOCAL

public static final int GAME_VIEW_LOCAL
A local game does not have a chat function.

See Also:
Constant Field Values

GAME_VIEW_SERVER

public static final int GAME_VIEW_SERVER
A server gets both a chat function and a reset button.

See Also:
Constant Field Values

GAME_VIEW_CLIENT

public static final int GAME_VIEW_CLIENT
A client does not have a reset button.

See Also:
Constant Field Values

leftLTSPanel

private LTSPanel leftLTSPanel
A panel for the left LTS.


rightLTSPanel

private LTSPanel rightLTSPanel
A panel for the right LTS.


traceScrollPane

private javax.swing.JScrollPane traceScrollPane
A scroll pane for the trace.


lowerPanel

private GameViewLowerPanel lowerPanel
The lower (south) panel of a game view.


trace

private javax.swing.JTextArea trace
A text area inside the trace scroll pane.


graphDimension

private java.awt.Dimension graphDimension

traceDimension

private java.awt.Dimension traceDimension

width

private int width

lowerHeight

private int lowerHeight

messageFont

private java.awt.Font messageFont
Constructor Detail

GameView

public GameView(int width,
                int height)
Constructs a game view but does not construct the lower panel. This is deferred until the player has chosen options.

Parameters:
width - Width of the main window
height - Height of the main window
Method Detail

createLowerPanel

public void createLowerPanel(int gameViewType)
Creates the lower panel of a game view, based on game options

Parameters:
gameViewType - Type of game view

resetTrace

public void resetTrace()
Clear the text in the trace scroll pane


displayStatus

public void displayStatus(java.lang.String role,
                          java.lang.String turn,
                          java.lang.String message)
Display game status in the status part of the lower panel.

Parameters:
role - A role message
turn - A turn message
message - A general message

displayRole

private void displayRole(java.lang.String role)
Display a role message.

Parameters:
role - A role message

displayTurn

public void displayTurn(java.lang.String turn)
Display a turn message.

Parameters:
turn - A turn message

displayMessage

public void displayMessage(java.lang.String message)
Display a general message.

Parameters:
message - A message

displayGameOver

public void displayGameOver(java.lang.String message,
                            java.awt.Color color)
Display a game over message. This is in a different font, larger and colored.

Parameters:
message - Message to display
color - Color of the message

displayLTSTitles

public void displayLTSTitles(java.lang.String leftLTSTitle,
                             java.lang.String rightLTSTitle)
Display the titles of the two LTSs.

Parameters:
leftLTSTitle - Title of the left LTS
rightLTSTitle - Title of the right LTS

displayLTSs

public void displayLTSs(att.grappa.Graph leftLTS,
                        att.grappa.Graph rightLTS,
                        att.grappa.GrappaAdapter ga)
Display the two LTSs.

Parameters:
leftLTS - Left LTS
rightLTS - Right LTS
ga - A Grappa adapter

getLeftLTSPanel

public LTSPanel getLeftLTSPanel()
Returns:
The left LTS panel

getRightLTSPanel

public LTSPanel getRightLTSPanel()
Returns:
The right LTS panel

updateTrace

public void updateTrace(java.lang.String action)
Update the trace with the specified action.

Parameters:
action - An action name

getLowerPanel

public GameViewLowerPanel getLowerPanel()
Returns:
The lower panel of the game view