de.tabacha.cgo.gui
Class BoardComponent

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byde.tabacha.cgo.gui.BoardComponent
All Implemented Interfaces:
javax.accessibility.Accessible, Constants, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class BoardComponent
extends javax.swing.JPanel
implements Constants

A swing component for displaying a (conway)go board.
$Id: BoardComponent.java,v 1.15 2004/12/23 21:42:43 mk Exp $

Version:
$Revision: 1.15 $
See Also:
for support to enter a move., Serialized Form
Threadsafe?
false

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private) static byte JUMP_CARET
           
(package private) static byte NO_CARET
           
(package private) static byte PUT_CARET
           
 
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.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface de.tabacha.cgo.Constants
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BoardComponent()
          Constructor.
 
Method Summary
 void abortEdit(HumanPlayer moveBuilder)
           
protected  void computeSizes(int width, int height)
          Calculates the sizes of the elements.
 void endEdit(HumanPlayer moveBuilder)
           
 Board getBoard()
          Returns the board model.
static int getWaitMove()
          Returns the time to wait between two moves, in sec/1000.
 boolean isEditing()
          Returns true if this component is in editor mode.
protected  void paintComponent(java.awt.Graphics g)
          Actually paints the board on the screen.
protected  void performJump(Jump jump)
          Performs a jump.
protected  Field performLeap(Field from, byte direction)
          Performs a leap.
 void performMove(Move move)
          Shows a move on the screen.
protected  void performPut(Field field)
          Performs a put.
 Field point2Field(java.awt.Point point)
          Converts a point in the component's pixel coordinates to a field on the board.
 void reshape(int x, int y, int width, int height)
          Changes size and/or location of the component.
 void setBoard(Board board)
          Sets a new board.
(package private)  void setCaret(Field selected, byte type)
          Shows, changes or removes the caret.
static void setWaitMove(int mSec)
          Sets the time to wait between two moves, in sec/1000.
 void startEdit(HumanPlayer moveBuilder)
           
 void waitAtomic()
          Wait for user to realize atomic change.
 void waitMove()
          Wait for user to realize completion of move.
 
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, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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
 

Field Detail

NO_CARET

static final byte NO_CARET
See Also:
Constant Field Values

JUMP_CARET

static final byte JUMP_CARET
See Also:
Constant Field Values

PUT_CARET

static final byte PUT_CARET
See Also:
Constant Field Values
Constructor Detail

BoardComponent

public BoardComponent()
Constructor.

Method Detail

getWaitMove

public static int getWaitMove()
Returns the time to wait between two moves, in sec/1000.


setWaitMove

public static void setWaitMove(int mSec)
Sets the time to wait between two moves, in sec/1000.


computeSizes

protected void computeSizes(int width,
                            int height)
Calculates the sizes of the elements.


point2Field

public Field point2Field(java.awt.Point point)
Converts a point in the component's pixel coordinates to a field on the board.


waitMove

public void waitMove()
Wait for user to realize completion of move.


waitAtomic

public void waitAtomic()
Wait for user to realize atomic change.


getBoard

public Board getBoard()
Returns the board model.


setBoard

public void setBoard(Board board)
Sets a new board. Changes on this board will not automatically seen on the screen, use the method "performMove" instead.

Parameters:
board - the new board. If it is null, an empty board will be created and shown.

isEditing

public boolean isEditing()
Returns true if this component is in editor mode.


reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)
Changes size and/or location of the component. (This method is officially deprecated but all similar methods rely on it.)


startEdit

public void startEdit(HumanPlayer moveBuilder)
Threadsafe?
true

endEdit

public void endEdit(HumanPlayer moveBuilder)
Threadsafe?
true

abortEdit

public void abortEdit(HumanPlayer moveBuilder)
Threadsafe?
true

performMove

public void performMove(Move move)
Shows a move on the screen. No check for validity.

Parameters:
move - The move to perform

performPut

protected void performPut(Field field)
Performs a put.


performJump

protected void performJump(Jump jump)
Performs a jump.


performLeap

protected Field performLeap(Field from,
                            byte direction)
Performs a leap.

Returns:
The new ball field.

setCaret

void setCaret(Field selected,
              byte type)
Shows, changes or removes the caret.

Parameters:
selected - Where to show the caret. May only be null if type is NO_CARET.
type - What caret to show. One of the constants NO_CARET, JUMP_CARET, PUT_CARET.

paintComponent

protected void paintComponent(java.awt.Graphics g)
Actually paints the board on the screen.