org.jscience.computing.game.chess
Interface ChessGraphics

All Known Implementing Classes:
SampleChessGraphics

public interface ChessGraphics

This interface allows other programs to customize the appearence of the graphics used by the class JChess to visualize the chess board. All methods expect one of constants of either WHITE or BLACK as parameters; otherwise, an exception may be thrown. The following conventions should be used to implement this interface in a usable way:

Here is some sample code that demonstrates how to potentially customize only some graphics by simply overwriting some methods of the ChessGraphics implementing class SampleChessGraphics:
 java.net.URL blackKingImageURL = ...;
 java.net.URL whitePawnURL = ...;
 java.net.URL blackPawnURL = ...;
 JChess jchess = new JChess();
 jchess.setGraphics(new SampleChessGraphics(1) {
     public ImageIcon getKingIcon(int color) {
         // customizing only the black king
         if (color == ChessGraphics.WHITE)
             return super.getKingIcon(ChessGraphics.WHITE);
         else return new ImageIcon(blackKingImageURL);
     }
 

public ImageIcon getPawnIcon(int color) { switch (color) { case ChessGraphics.WHITE: return new ImageIcon(whitePawnURL); case ChessGraphics.BLACK: return new ImageIcon(blackPawnURL); default: throw new IllegalArgumentException(); } } }); new JGameFrame(jchess).setVisible(true);

See Also:
SampleChessGraphics, JChess.setGraphics(ChessGraphics)

Field Summary
static int BLACK
          DOCUMENT ME!
static int WHITE
          DOCUMENT ME!
 
Method Summary
 javax.swing.ImageIcon getBishopIcon(int color)
          DOCUMENT ME!
 javax.swing.ImageIcon getKingIcon(int color)
          DOCUMENT ME!
 javax.swing.ImageIcon getKnightIcon(int color)
          DOCUMENT ME!
 javax.swing.ImageIcon getPawnIcon(int color)
          DOCUMENT ME!
 javax.swing.ImageIcon getQueenIcon(int color)
          DOCUMENT ME!
 javax.swing.ImageIcon getRookIcon(int color)
          DOCUMENT ME!
 

Field Detail

WHITE

static final int WHITE
DOCUMENT ME!

See Also:
Constant Field Values

BLACK

static final int BLACK
DOCUMENT ME!

See Also:
Constant Field Values
Method Detail

getKingIcon

javax.swing.ImageIcon getKingIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!

getQueenIcon

javax.swing.ImageIcon getQueenIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!

getRookIcon

javax.swing.ImageIcon getRookIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!

getKnightIcon

javax.swing.ImageIcon getKnightIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!

getBishopIcon

javax.swing.ImageIcon getBishopIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!

getPawnIcon

javax.swing.ImageIcon getPawnIcon(int color)
DOCUMENT ME!

Parameters:
color - DOCUMENT ME!
Returns:
DOCUMENT ME!