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
-
IDSTRS
- These are names of the columns.
-
kingTiles
- These are the tiles of the kings.
-
tiles
- Board tiles where you can place the pieces.
-
BoardGrid(MouseListener)
- Creates new chessboard.
-
getPiece(int, int)
- An accessor to fetch piece in specific location.
-
getTile(int, int)
- An accessor to fetch specific tile.
-
kingTiles(int)
- Fast way of find out kings position.
-
readExternal(ObjectInput)
- Reading BoardGrid from ObjectInput.
-
setBoard(ChessSettings)
- Sets the grid to the standing defined in ChessSettings.
-
setPiece(int, int, Piece)
- An accessor to control pieces on the board.
-
writeExternal(ObjectOutput)
- Writing BoardGrid-object to ObjectOutput.
tiles
private BoardTile tiles[][]
- Board tiles where you can place the pieces.
kingTiles
private BoardTile kingTiles[]
- These are the tiles of the kings. Kind of cache to prevent
searching through board after every move.
IDSTRS
static final char IDSTRS[]
- These are names of the columns. No need to embed these in there.
BoardGrid
BoardGrid(MouseListener listen)
- Creates new chessboard.
- Parameters:
- listen - Listener for the tiles.
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Writing BoardGrid-object to ObjectOutput.
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Reading BoardGrid from ObjectInput.
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.
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.
setBoard
void setBoard(ChessSettings set)
- Sets the grid to the standing defined in ChessSettings.
- Parameters:
- set - The settings to be set on the board.
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.
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