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

## gecco.client
Class Board

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  javax.swing.JPanel
                      gecco.client.Board

All Implemented Interfaces:
  Accessible, ImageObserver, MenuContainer, Serializable

public class Board
extends JPanel

The board is what is displayed to the user of the game. It paints the map and the pieces. The board needs to know of a Game object, whose pieces are to be painted on the board.

The board contains scrollbars used for scrolling when the map does not fit the screen. It also contain zoom buttons for zooming in or out on the board. The zoom buttons use some gif images in the icons catalog (zoomin.gif and zoomout.gif).

All painting is done in an offscreen buffer and is then copied to the screen. Use method repaintBoard, to repaint the board to reflect changes in the game.

Author:
  Andreas Enblom, Karl Hasselström
See Also:
  Serialized Form

Nested Class Summary

Nested classes inherited from class javax.swing.JPanel
`JPanel.AccessibleJPanel`

Nested classes inherited from class javax.swing.JComponent
`JComponent.AccessibleJComponent`

Nested classes inherited from class java.awt.Container
`Container.AccessibleAWTContainer`

Nested classes inherited from class java.awt.Component
`Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy`

Field Summary

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
`Board(Game game)`

Method Summary
`void` | `addBoardMouseListener(MouseListener ml)` Adds the given mouse listener the the area where the map and the pieces are painted.
`void` | `addBoardMouseMotionListener(MouseMotionListener mml)` Adds the given MouseMotionListener to the area of the board where the map and the pieces are painted.
`Dimension` | `boardSize()` Returns the size of the actual board, not counting the scroll bars and zoom buttons.
`void` | `clearMap()` Description of the Method
`Rectangle` | `getPieceBounds(Piece piece)` Returns the bounding rectangle of the given piece.
`Position` | `getPositionAt(Point p)` Converts a screen point to the Position corresponding to that point.
`Point` | `getScreenPoint(Position p)` Converts the given Position of the map to the actual screen Point in the board's coordinate system.
`void` | `hideMapPoint(Point p)` Makes the given point of the map invisible.
`void` | `loadMap(Map m)` Sets the map of the board.
`void` | `mapUpdate(Point p, int color)` Updates the given point of the map to the given color.
`void` | `repaintBoard()`
`void` | `setBoardCursor(Cursor cursor)` Set the cursor for the map area of the board.

Methods inherited from class javax.swing.JPanel
`getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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`

Constructor Detail

### Board

    public Board(Game game)

Parameters:
  `game` - The Game object whose pieces are supposed to be painted on this board.

Method Detail

### setBoardCursor

    public void setBoardCursor(Cursor cursor)

  Set the cursor for the map area of the board.

  Parameters:
    `cursor` - The new BoardCursor value

### getPositionAt

    public Position getPositionAt(Point p)

  Converts a screen point to the Position corresponding to that point. Things like zoom factor and scrollbar position are taken into account.

  Parameters:
    `p` - A pixel in the board coordinate system.
  Returns:
    The corresponding position in the map coordinate system.

### getScreenPoint

    public Point getScreenPoint(Position p)

  Converts the given Position of the map to the actual screen Point in the board's coordinate system.

  Parameters:
    `p` - A position in the map coordinate system.
  Returns:
    The corresponding pixel in the board coordinate system.

### getPieceBounds

    public Rectangle getPieceBounds(Piece piece)

  Returns the bounding rectangle of the given piece. The rectangle is given in actual screen coordinates (i.e. the coordinates of the map-and-pieces component).

  Parameters:
    `piece` - A piece.
  Returns:
    A bounding rectangle for the piece.

### loadMap

    public void loadMap(Map m)

  Sets the map of the board.

  Parameters:
    `m` - Description of Parameter

### clearMap

    public void clearMap()

  Description of the Method

### mapUpdate

    public void mapUpdate(Point p,
                          int color)

  Updates the given point of the map to the given color. Colors are given as integers as decribed in java.awt.Color.

  Parameters:
    `p` - Description of Parameter
    `color` - Description of Parameter

### hideMapPoint

    public void hideMapPoint(Point p)

  Makes the given point of the map invisible. If it has already been set as invisible, nothing is done.

  Parameters:
    `p` - Description of Parameter

### addBoardMouseListener

    public void addBoardMouseListener(MouseListener ml)

  Adds the given mouse listener the the area where the map and the pieces are painted. Use this method to assign the preferred behavior to the board (such as mouse clicks for selecting pieces).

  Parameters:
    `ml` - The new mouse listener.

### addBoardMouseMotionListener

    public void addBoardMouseMotionListener(MouseMotionListener mml)

  Adds the given MouseMotionListener to the area of the board where the map and the pieces are painted.

  Parameters:
    `mml` - The new mouse motion listener.

### repaintBoard

    public void repaintBoard()

### boardSize

    public Dimension boardSize()

  Returns the size of the actual board, not counting the scroll bars and zoom buttons.

  Returns:
    The size of the board.

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