Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.ui.cli
Class TxChessBoardDisplay

java.lang.Object
  extended byictk.boardgame.chess.ui.cli.TxChessBoardDisplay
All Implemented Interfaces:
BoardDisplay, BoardListener, ChessBoardDisplay, CLIBoardDisplay, CLIChessBoardDisplay, java.util.EventListener

public class TxChessBoardDisplay
extends java.lang.Object
implements CLIChessBoardDisplay, BoardListener

This is a TxChess style command-line visual representation of a board. TxChess is an old C program used for email chess. The board usually looks like this:

  8   r n b q # r k
  7   p p p #   p b p
  6   #   # p # n p
  5     #   # p #   #
  4   #   P   P   #
  3     # N #   # P #
  2   P P # P N P B P
  1   R # B Q   R K #

      A B C D E F G H
 


Field Summary
 
Fields inherited from interface ictk.boardgame.chess.ui.ChessBoardDisplay
BOTTOM_COORDINATES, LEFT_COORDINATES, NO_COORDINATES, RIGHT_COORDINATES, TOP_COORDINATES
 
Constructor Summary
TxChessBoardDisplay(ChessBoard board)
           
TxChessBoardDisplay(ChessBoard board, java.io.OutputStream out)
           
TxChessBoardDisplay(ChessBoard board, java.io.PrintWriter out)
           
TxChessBoardDisplay(ChessBoard board, java.io.Writer out)
           
 
Method Summary
 void boardUpdate(Board b, int event)
          the board display is updated (printed to stream) for every event except durning traversal, in which only the final position causes a new board to be displayed.
 Board getBoard()
          returns the Board that this Display is using as a model.
 boolean getSideToMoveOnBottom()
          returns true if the board is set to re-orient itself so the side to move is at the bottom after every move on update.
 int getVisibleCoordinates()
          returns the mask of which coordinates are set visible for this board.
 java.io.Writer getWriter()
          returns the Writer currently being used.
 boolean isCompact()
          test if this display is in Compact mode
 boolean isInverse()
          checks to see if the display is assuming the foreground is darker than the background.
 boolean isLowerCaseCoordinates()
          returns if the coordinates are currently set to appear in lowercase.
 boolean isWhiteOnBottom()
          returns true if the board is oriented so white is currently on the bottom.
 void print()
          prints the current board onto the Writer.
 void print(Board board)
          prints the current specified board onto the Writer.
 void setBoard(Board board)
          set the Board that this Display will use as a model.
 void setCompact(boolean t)
          setting this attribute to true will eliminate needless space characters in the output.
 void setInverse(boolean t)
          sets the display to assume the foreground is darker than the background.
 void setLowerCaseCoordinates(boolean t)
          sets the coordinates to appear in lowercase.
 void setSideToMoveOnBottom(boolean t)
          sets the board to re-orient itself so the side to move is at the bottom after every move on update.
 void setVisibleCoordinates(int mask)
          sets which coordinates should appear when the board is displayed.
 void setWhiteOnBottom(boolean t)
          orients the board so White is on the bottom.
 void setWriter(java.io.PrintWriter out)
          sets the stream where the display will be sent.
 void update()
          this refreshes the board display.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TxChessBoardDisplay

public TxChessBoardDisplay(ChessBoard board,
                           java.io.OutputStream out)

TxChessBoardDisplay

public TxChessBoardDisplay(ChessBoard board,
                           java.io.Writer out)

TxChessBoardDisplay

public TxChessBoardDisplay(ChessBoard board,
                           java.io.PrintWriter out)

TxChessBoardDisplay

public TxChessBoardDisplay(ChessBoard board)
Method Detail

boardUpdate

public void boardUpdate(Board b,
                        int event)
the board display is updated (printed to stream) for every event except durning traversal, in which only the final position causes a new board to be displayed.

Specified by:
boardUpdate in interface BoardListener
Parameters:
b - the board the event occured on.
event - indicates what type of update has occured. (MOVE_EVENT, POSITION_EVENT etc).

setCompact

public void setCompact(boolean t)
setting this attribute to true will eliminate needless space characters in the output.
Default: false.


isCompact

public boolean isCompact()
test if this display is in Compact mode


setBoard

public void setBoard(Board board)
Description copied from interface: BoardDisplay
set the Board that this Display will use as a model.

Specified by:
setBoard in interface BoardDisplay

getBoard

public Board getBoard()
Description copied from interface: BoardDisplay
returns the Board that this Display is using as a model.

Specified by:
getBoard in interface BoardDisplay

update

public void update()
Description copied from interface: BoardDisplay
this refreshes the board display. Depending on what kind of display the implementing class is, this might do any number of different things from printing a board to System.out in the case of a CLI or refreshing the screen in the case of a GUI.

Specified by:
update in interface BoardDisplay

setWhiteOnBottom

public void setWhiteOnBottom(boolean t)
Description copied from interface: ChessBoardDisplay
orients the board so White is on the bottom. This setting is overriden by setPlayerToMoveOnBottom(true).

Specified by:
setWhiteOnBottom in interface ChessBoardDisplay

isWhiteOnBottom

public boolean isWhiteOnBottom()
Description copied from interface: ChessBoardDisplay
returns true if the board is oriented so white is currently on the bottom. This value could change on the next move, depending on the value of setPlayerToMoveOnBottom(true).

Specified by:
isWhiteOnBottom in interface ChessBoardDisplay

setSideToMoveOnBottom

public void setSideToMoveOnBottom(boolean t)
Description copied from interface: ChessBoardDisplay
sets the board to re-orient itself so the side to move is at the bottom after every move on update.

Specified by:
setSideToMoveOnBottom in interface ChessBoardDisplay

getSideToMoveOnBottom

public boolean getSideToMoveOnBottom()
Description copied from interface: ChessBoardDisplay
returns true if the board is set to re-orient itself so the side to move is at the bottom after every move on update. This does not indicate whether the board is currently oriented so that the current player to move is on the bottom.

Specified by:
getSideToMoveOnBottom in interface ChessBoardDisplay

setVisibleCoordinates

public void setVisibleCoordinates(int mask)
Description copied from interface: ChessBoardDisplay
sets which coordinates should appear when the board is displayed. Coordinates can be bitwise ORed together to get multiple coordinates to appear.
For example: TOP_COORDINATES | BOTTOM_COORDINATES

Specified by:
setVisibleCoordinates in interface ChessBoardDisplay

getVisibleCoordinates

public int getVisibleCoordinates()
Description copied from interface: ChessBoardDisplay
returns the mask of which coordinates are set visible for this board.

Specified by:
getVisibleCoordinates in interface ChessBoardDisplay

setLowerCaseCoordinates

public void setLowerCaseCoordinates(boolean t)
Description copied from interface: ChessBoardDisplay
sets the coordinates to appear in lowercase.

Specified by:
setLowerCaseCoordinates in interface ChessBoardDisplay

isLowerCaseCoordinates

public boolean isLowerCaseCoordinates()
Description copied from interface: ChessBoardDisplay
returns if the coordinates are currently set to appear in lowercase.

Specified by:
isLowerCaseCoordinates in interface ChessBoardDisplay

setInverse

public void setInverse(boolean t)
Description copied from interface: CLIBoardDisplay
sets the display to assume the foreground is darker than the background. This might be beneficial when using the display on a Black on White screen. By default all CLI Displays assume White on Black.

Specified by:
setInverse in interface CLIBoardDisplay

isInverse

public boolean isInverse()
Description copied from interface: CLIBoardDisplay
checks to see if the display is assuming the foreground is darker than the background. For example, on a Black on White display.

Specified by:
isInverse in interface CLIBoardDisplay
Returns:
true if the display assumes the foreground is darker.

setWriter

public void setWriter(java.io.PrintWriter out)
Description copied from interface: CLIBoardDisplay
sets the stream where the display will be sent. Currently a PrintWriter must be specified.
Example: display.setWriter(new PrintWriter(System.out, true));
Note: if you're expecting output and not seeing it, make sure you set auto-flush on for the PrintWriter.

Specified by:
setWriter in interface CLIBoardDisplay

getWriter

public java.io.Writer getWriter()
Description copied from interface: CLIBoardDisplay
returns the Writer currently being used. This is always a PrintWriter with other Streams or Writers nestled inside.

Specified by:
getWriter in interface CLIBoardDisplay

print

public void print()
Description copied from interface: CLIBoardDisplay
prints the current board onto the Writer.

Specified by:
print in interface CLIBoardDisplay

print

public void print(Board board)
Description copied from interface: CLIBoardDisplay
prints the current specified board onto the Writer.

Specified by:
print in interface CLIBoardDisplay

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .