java.lang.Object
cgsuite.plugin.PluginUtilities
- public class PluginUtilities
- extends java.lang.Object
An assortment of static methods useful to plug-in writers. Includes methods
for converting between cgsuite.util.Grids, images, and strings, and a library of
commonly used icons.
|
Method Summary |
static java.awt.Dimension |
calculateIconDimensions(javax.swing.Icon[] icons,
boolean forceSquares)
|
static javax.swing.Icon |
getIcon(java.lang.String iconName)
|
static java.awt.image.BufferedImage |
gridToImage(cgsuite.util.Grid grid,
javax.swing.Icon[] icons)
Creates an image representation of a cgsuite.util.Grid. |
static java.awt.image.BufferedImage |
gridToImage(cgsuite.util.Grid grid,
javax.swing.Icon[] icons,
java.awt.Dimension cellSize,
int gap,
int lineThickness)
Creates an image representation of a cgsuite.util.Grid with the specified
cell size, gap and line thickness. |
static java.awt.image.BufferedImage |
imageToColor(java.awt.Image in,
java.awt.Color color,
java.awt.image.BufferedImage out)
Filter the image in. |
static java.awt.image.BufferedImage |
replaceGridRegion(java.awt.image.BufferedImage image,
int row,
int column,
javax.swing.Icon newIcon,
java.awt.Dimension cellSize,
int gap,
int lineThickness)
Replaces the specified cell in the specified image. |
static cgsuite.util.Grid |
stringsToGrid(java.lang.String[] strings,
java.lang.String charMap)
|
static cgsuite.util.Grid |
stringsToGrid(java.lang.String[] strings,
java.lang.String charMap,
int bitsPerEntry)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GRAY_STONE
public static java.lang.String GRAY_STONE
BLACK_BISHOP
public static java.lang.String BLACK_BISHOP
BLACK_KING
public static java.lang.String BLACK_KING
BLACK_KNIGHT
public static java.lang.String BLACK_KNIGHT
BLACK_PAWN
public static java.lang.String BLACK_PAWN
BLACK_QUEEN
public static java.lang.String BLACK_QUEEN
BLACK_ROOK
public static java.lang.String BLACK_ROOK
WHITE_BISHOP
public static java.lang.String WHITE_BISHOP
WHITE_KING
public static java.lang.String WHITE_KING
WHITE_KNIGHT
public static java.lang.String WHITE_KNIGHT
WHITE_PAWN
public static java.lang.String WHITE_PAWN
WHITE_QUEEN
public static java.lang.String WHITE_QUEEN
WHITE_ROOK
public static java.lang.String WHITE_ROOK
BLACK_GO_STONE
public static java.lang.String BLACK_GO_STONE
WHITE_GO_STONE
public static java.lang.String WHITE_GO_STONE
iconMap
private static java.util.Map iconMap
EMPTY_IMAGE
public static final java.awt.image.BufferedImage EMPTY_IMAGE
PluginUtilities
private PluginUtilities()
stringsToGrid
public static cgsuite.util.Grid stringsToGrid(java.lang.String[] strings,
java.lang.String charMap)
throws MethodInvocationException
stringsToGrid
public static cgsuite.util.Grid stringsToGrid(java.lang.String[] strings,
java.lang.String charMap,
int bitsPerEntry)
throws MethodInvocationException
getIcon
public static javax.swing.Icon getIcon(java.lang.String iconName)
calculateIconDimensions
public static java.awt.Dimension calculateIconDimensions(javax.swing.Icon[] icons,
boolean forceSquares)
gridToImage
public static java.awt.image.BufferedImage gridToImage(cgsuite.util.Grid grid,
javax.swing.Icon[] icons)
- Creates an image representation of a cgsuite.util.Grid. The cell size will
be calculated with
calculateIconDimensions 55 ,
using a default gap and line thickness of
1. All cells
will be square. See
gridToImage(Grid, Icon[], Dimension, int, int) 55 for details.
gridToImage
public static java.awt.image.BufferedImage gridToImage(cgsuite.util.Grid grid,
javax.swing.Icon[] icons,
java.awt.Dimension cellSize,
int gap,
int lineThickness)
- Creates an image representation of a cgsuite.util.Grid with the specified
cell size, gap and line thickness.
The array of Icons specifies a mapping from integers to
icons. If a given grid coordinate has value i, then the
corresponding cell in the image will contain the icon given by
icons[i]. If icons[i] is null,
then that cell will be left blank.
replaceGridRegion
public static java.awt.image.BufferedImage replaceGridRegion(java.awt.image.BufferedImage image,
int row,
int column,
javax.swing.Icon newIcon,
java.awt.Dimension cellSize,
int gap,
int lineThickness)
- Replaces the specified cell in the specified image. The image should
first be obtained using
gridToImage 55 .
This method can then be used to overwrite a single cell in the image
with a new value, usually in response to a change in the underlying
grid. This eliminates the need to call
gridToImage again
to construct a new image.
Note that the image provided will be altered rather than copied.
imageToColor
public static java.awt.image.BufferedImage imageToColor(java.awt.Image in,
java.awt.Color color,
java.awt.image.BufferedImage out)
- Filter the image
in. The result will have the same
intensity as in at each pixel, but in the color
color. The alpha channel of color
will be multiplied by that of the incoming image at each pixel.
Write to the image out (or create a new
BufferedImage if out is null). in and
out may be the same BufferedImages.