Board Pattern Customization
From Jin
This article explains how to create new board patterns for Jin 2.14 and later. The mechanism for customizing Jin is explained in the Customization article (which you should read first). All the file names mentioned here refer to files inside the resource archive.
For an example of a board pattern, unzip slate.zip from $JIN/resources/pieces/ and examine its structure.
The definition file
At the root of the resource file is the definition file. This file tells Jin the basic information about the board pattern. It is a properties file and should contain the following properties:
classname- This property tells Jin what kind of a resource sits in the file. For board patterns, the value is
free.jin.board.BoardPattern. id- A short string identifying the board pattern. This will not be visible to the user and must be unique between all board patterns.
name- The name of the board pattern. This is the name that will be shown to the user.
boardPainter.classname- The name of the Java class that will draw the board pattern. For regular, image based board patterns, use
free.chess.BoardImageBoardPainterorfree.chess.SquareImagesBoardPainteras the value of this property (how to use each is described below). If you wish to make a special, non image based board pattern, you will need to implement thefree.chess.BoardPainterinterface (look in Jin's source code) and put the class file of your class in the resource file (and set theboardPainter.classnameproperty accordingly, of course). minJavaVersion- This is an optional property which tells Jin the minimum required version of Java that this board pattern can be used in. For example, PNG based board patterns can't be used in Java 1.1, so if you use PNG images, set this property to
1.2. Note: starting with version 2.14 Jin itself only works on Java 1.4 or later, which supports most popular image file formats, so this property is not as important anymore.
Using free.chess.BoardImageBoardPainter
This type of board painter uses a single, big image which is stretched over the entire board. It is up to you to draw the 8x8 square grid on the image.
The board image must be named board.[ext] and placed at the root of the resource file. [ext] stands for the value of the ext property in the definition file, which you should also specify. If this property is not specified, it defaults to gif.
Using free.chess.SquareImagesBoardPainter
This type of board painter uses two images - one for drawing light squares and one for drawing dark squares. It has two modes of how the images are used:
- In "scale" mode, the images are simply stretched to fill each square.
- In "slice" mode, however, a different, unscaled part of the image is selected to draw each square. The drawn image is "cut" from an imaginary infinite tiling of the provided image, with the starting point different for each square. This creates a nice, non-repeating effect. It is advised to provide either tileable or large images, as small untileable images will not look good tiled.
The images must be named light.[ext] and dark.[ext] and placed at the root of the resource file. [ext] stands for the value of the ext property in the definition file, described below.
The following properties must be set in the definition file:
ext- The type/extension of the image(s) you will use. If unspecified, it will default to
gif. imageUseMode- Specifies the image use mode, as described above. Possible values are
scaleandslice. If unspecified, will default toslice.
