All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kpalin.alabra.BoardGrid

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----kpalin.alabra.BoardGrid

public class BoardGrid
extends Panel
implements Serializable
This is the visual representation of the chessboard.

Author:
Kimmo Palin

Variable Index

 o IDSTRS
These are names of the columns.
 o kingTiles
These are the tiles of the kings.
 o tiles
Board tiles where you can place the pieces.

Constructor Index

 o BoardGrid(MouseListener)
Creates new chessboard.

Method Index

 o getPiece(int, int)
An accessor to fetch piece in specific location.
 o getTile(int, int)
An accessor to fetch specific tile.
 o kingTiles(int)
Fast way of find out kings position.
 o readExternal(ObjectInput)
Reading BoardGrid from ObjectInput.
 o setBoard(ChessSettings)
Sets the grid to the standing defined in ChessSettings.
 o setPiece(int, int, Piece)
An accessor to control pieces on the board.
 o writeExternal(ObjectOutput)
Writing BoardGrid-object to ObjectOutput.

Variables

 o tiles
 private BoardTile tiles[][]
Board tiles where you can place the pieces.

 o kingTiles
 private BoardTile kingTiles[]
These are the tiles of the kings. Kind of cache to prevent searching through board after every move.

 o IDSTRS
 static final char IDSTRS[]
These are names of the columns. No need to embed these in there.

Constructors

 o BoardGrid
 BoardGrid(MouseListener listen)
Creates new chessboard.

Parameters:
listen - Listener for the tiles.

Methods

 o writeExternal
 public void writeExternal(ObjectOutput out) throws IOException
Writing BoardGrid-object to ObjectOutput.

 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Reading BoardGrid from ObjectInput.

 o kingTiles
 public BoardTile kingTiles(int side)
Fast way of find out kings position.

Parameters:
side - Side of the wanted king.
Returns:
Tile where the king is.
 o setPiece
 public void setPiece(int row,
                      int col,
                      Piece p)
An accessor to control pieces on the board.

Parameters:
row - Row of the piece.
col - Column of the piece.
p - The piece you want to put there. null for clearing position.
 o setBoard
 void setBoard(ChessSettings set)
Sets the grid to the standing defined in ChessSettings.

Parameters:
set - The settings to be set on the board.
 o getPiece
 public Piece getPiece(int col,
                       int row)
An accessor to fetch piece in specific location. Throws exception if coordinates are invalid.

Parameters:
col - Column of the tile.
row - Row of the tile.
Returns:
Returns piece on the tile, null if theres not a piece.
 o getTile
 BoardTile getTile(int col,
                   int row)
An accessor to fetch specific tile. Throws exception if coordinates are invalid. Please try to avoid using this but this is needed for king cache in ChessPlay

Parameters:
col - Columun of the tile.
row - Row of the tile.
Returns:
Returns tile.

All Packages  Class Hierarchy  This Package  Previous  Next  Index