Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.io
Class ChessMoveNotation

java.lang.Object
  extended byictk.boardgame.chess.io.ChessMoveNotation
All Implemented Interfaces:
MoveNotation
Direct Known Subclasses:
SAN

public abstract class ChessMoveNotation
extends java.lang.Object
implements MoveNotation

the parent class of all ChessNotations. It contains many methods for piece and coordinate (file/rank) notations in many language to be translated into numberic notation (1-8). There are a few pre-set Locales.


Field Summary
static long DEBUG
          Log.debug() mask
static char[][] FILE_SETS
          contains file sets for different languages a-h
static char[][] PIECE_SETS
          contains piece sets in differnt languages PNBRQK
static char[][] RANK_SETS
          for the unlikely case your using non arabic numbers
 
Constructor Summary
ChessMoveNotation()
           
ChessMoveNotation(java.util.Locale loc)
          note: different Locales other than the default (English) should only be used for local presentation.
 
Method Summary
 char fileToChar(int i)
          returns the character representation of the file.
 byte fileToNum(char c)
          returns the byte representation of the file.
 byte fileToNum(java.lang.String s)
          returns the byte representation of the file.
 java.util.Locale getLocale()
          returns the Locale being used with this SAN object.
 char[] getPieceSet()
          gets the piece set used in the current Locale setting
 char pieceToChar(ChessPiece p)
          returns the character representation of the piece in the correct Locale.
 char pieceToChar(int p)
          returns the character representation of the piece in the correct Locale.
 byte pieceToNum(char c)
          returns the number Piece.getIndex() from the character representation of the piece.
 byte pieceToNum(java.lang.String s)
          returns the number Piece.getIndex() from the character representation of the piece.
 char rankToChar(int i)
          returns the character representation of the rank.
 byte rankToNum(char c)
          returns the byte representation of the rank.
 boolean setLocale(java.util.Locale loc)
          sets the Locale for the ChessMoveNotation to use localised piece representations.
 void setPieceSet(char[] set)
          sets a custom piece set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ictk.boardgame.io.MoveNotation
moveToString, resultToString, stringToMove, stringToResult
 

Field Detail

DEBUG

public static final long DEBUG
Log.debug() mask


PIECE_SETS

public static final char[][] PIECE_SETS
contains piece sets in differnt languages PNBRQK


FILE_SETS

public static final char[][] FILE_SETS
contains file sets for different languages a-h


RANK_SETS

public static final char[][] RANK_SETS
for the unlikely case your using non arabic numbers

Constructor Detail

ChessMoveNotation

public ChessMoveNotation()

ChessMoveNotation

public ChessMoveNotation(java.util.Locale loc)
note: different Locales other than the default (English) should only be used for local presentation. The archive standard for SAN and PGN is English.

Method Detail

setLocale

public boolean setLocale(java.util.Locale loc)
sets the Locale for the ChessMoveNotation to use localised piece representations. Note: this should be used for local presentation only. The archive standard for SAN and PGN is English (the default). This function uses the ISO 639-2/T language code. (ftp://dkuug.dk/i18n/iso-639-2.txt)

Returns:
false if no specific pieceset is registered for that locale

getLocale

public java.util.Locale getLocale()
returns the Locale being used with this SAN object.

Returns:
null if the default is being used

getPieceSet

public char[] getPieceSet()
gets the piece set used in the current Locale setting


setPieceSet

public void setPieceSet(char[] set)
sets a custom piece set. This will hopefully be useful for using fonts that do not directly corrilate to one of the standard piece sets. Or if your Locale is not yet supported. This only takes 6 pieces in the order of P,N,B,R,Q,K.


pieceToNum

public byte pieceToNum(java.lang.String s)
returns the number Piece.getIndex() from the character representation of the piece.


pieceToNum

public byte pieceToNum(char c)
returns the number Piece.getIndex() from the character representation of the piece.


pieceToChar

public char pieceToChar(int p)
returns the character representation of the piece in the correct Locale.


pieceToChar

public char pieceToChar(ChessPiece p)
returns the character representation of the piece in the correct Locale.


fileToNum

public byte fileToNum(java.lang.String s)
returns the byte representation of the file. In English/Roman letters this would be a=1, b=2 etc


fileToNum

public byte fileToNum(char c)
returns the byte representation of the file. In English/Roman letters this would be a=1, b=2 etc. If '-' or ' ' is sent ChessBoard.NULL_FILE is returned.


rankToNum

public byte rankToNum(char c)
returns the byte representation of the rank. In English/Arabic letters this would be '1'=1, '2'=2 etc. if '-' or ' ' is sent ChessBoard.NULL_FILE is returned.


fileToChar

public char fileToChar(int i)
returns the character representation of the file. In English/Roman letters this would be 1='a', 2='b' etc.


rankToChar

public char rankToChar(int i)
returns the character representation of the rank. In English/Arabic letters this would be 1='1', 2='2' etc.


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