What is Tabula Chess?
Tabula Chess is a Java library which provides a convenient chess board Swing component. Tabula does not handle any chess rules or algorithms in order to provide reuse for any application which requires a chessboard. The client using Tabula is notified when a piece is moved and is given a chance to veto the move if it violates any rules of the chess variant being played.
Features
- Multiple piece sets.
- Accepts user-supplied piece sets.
- Configurable square colors.
- Board and pieces scale to the available space.
- Client callbacks on piece movement; client may veto the move.
- Set a board position using a FEN string.
- Get the current board position at any time as a FEN string.
- Simple to use and integrate into your chess application.
Example
The Tabula Chess libary is meant to be easy to use. Clients
of this library create a new instance of
a ChessBoardContext
, configure it, then retrieve
a JComponent
to embed in a Swing GUI. Through
the MoveListener
interface, the client is given a
record of moves played on the board as well as the opportunity
to veto any illegal moves.
1 final ChessBoardContext context = new ChessBoardContext(); 2 context.setMoveListener(new MoveListener() { 3 @Override 4 public boolean acceptMove(Chessman piece, Coordinate source, Coordinate destination) { 5 System.out.printf("Moving %s %s from %s to %s %n", 6 piece.getColor(), piece.getPieceType(), source, destination); 7 return true; 8 } 9 }) 10 .setPositionFEN("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1") 11 .setColors(Color.BLACK, Color.WHITE) 12 .setPieceImageSet(PieceSets.ARIAL);
Feature Backlog
- Handle castling manouvers.
- Handle pawn promotion.
- Provide a position setup palette.
- Furnish image backgrounds for squares; provide a default set and a mechanism for client-supplied square backgrounds.
- Provide a nicer looking default set of piece images.
- Provide a mechanism to highlight squares.
- Provide a mechanism to draw on the board (e.g. arrows).
Contribute
We would especially like someone with a graphics background to contribute some nice looking piece sets and square background images. Anyone interested in development of the library are also welcome. Contact us if you are interested -- we'd love to hear from you.