|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.TablePanel
edu.neu.ccs.gui.CheckerBoard
CheckerBoard implements a checkerboard in which one can
interactively contrast two colors. This is useful for a developer
in planning color combinations because it is often difficult to tell
how two colors will look when placed side by side. The board is
rendered in a BufferedPanel.
Normally, a CheckerBoard object also comes with two
ColorView dropdown panels that
may be used to interactively select the contrasting colors and a
button that will reset the colors to their original state. However,
it is also possible to omit these interactive controls and then the
panel may be used for board games such as checkers and chess. To do
this, one may add Paintable game pieces to the
internal BufferedPanel and then may manipulate these
pieces either programmatically or by using the mouse.
Colors may be entered in the ColorView dropdown panels
in the following ways:
The default constructor creates a checkerboard with default settings and but, as of 2.6.0, does not install the checkerboard in a frame automatically.
Using the general constructor, one can control settings, choose whether to show the interactive controls, and whether to frame the panel automatically.
ColorView,
VisualColorSampler,
Serialized Form| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
private int |
block
The size of a checkerboard block. |
static int |
BLOCK
The default checkerboard block size = 48. |
private Rectangle2D[][] |
blocks
The array of checkerboard blocks. |
static Color |
COLOR0
The default color for checkerboard blocks whose (row + column) sum is even: black. |
static Color |
COLOR1
The default color for checkerboard blocks whose (row + column) sum is odd: white. |
private SimpleAction |
colorCheckerBoard
The action to make a checkerboard patten. |
static int |
gap
The pixel gap between items in this panel. |
static int |
MAXIMUM_BLOCK
The maximum checkerboard block size = 80. |
static int |
MINIMUM_BLOCK
The minimum checkerboard block size = 16. |
private SimpleAction |
resetColorViews
The action to reset the colors to their original settings. |
private ColorView |
view0
Color view 0. |
private ColorView |
view1
Color view 1. |
private BufferedPanel |
window
The checkerboard graphics window. |
| Fields inherited from class edu.neu.ccs.gui.TablePanel |
DEFAULT_ALIGNMENT, DEFAULT_ORIENTATION, tg |
| Fields inherited from class edu.neu.ccs.gui.DisplayPanel |
background, codec, CODEC |
| Fields inherited from class javax.swing.JPanel |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
CheckerBoard()
The constructor that creates a checkerboard panel using the default block size and default colors and includes the interactive color controls. |
|
CheckerBoard(int block,
Color color0,
Color color1,
boolean showColorViews,
boolean autoFrame)
The constructor that permits the caller to control the size of the checkerboard block (within limits), the initial block colors, whether to show the interactive color controls, and whether to automatically put the checkerboard into a JPTFrame. |
|
| Method Summary | |
private int |
adjustBlock(int block)
Adjust the block size to lie between the minimum and maximum. |
private void |
autoFramePanel(boolean autoFrame)
Auto frame if desired. |
protected void |
colorCheckerBoard()
The method to color the checkerboard patten. |
private void |
createCheckerBoard(int block)
Create the checker board and the blocks data structure. |
private void |
createColorViews(Color color0,
Color color1)
Create the color views with the given original colors. |
int |
getBlockSize()
Returns the checkerboard block size. |
BufferedPanel |
getCheckerboard()
Returns a reference to the checkerboard BufferedPanel
on which the checkerboard is painted. |
int |
getCheckerBoardSize()
Returns the checkerboard BufferedPanel size. |
Color |
getColor0()
Returns the color for blocks with (row + column) sum even. |
Color |
getColor1()
Returns the color for blocks with (row + column) sum odd. |
private void |
installContents(boolean showColorViews)
Install the contents in this panel. |
void |
resetColorViews()
Resets the colors to their original settings. |
void |
setColor0(Color color0)
Sets the color for blocks with (row + column) sum even to the given color. |
void |
setColor1(Color color1)
Sets the color for blocks with (row + column) sum odd to the given color. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int gap
public static final int MAXIMUM_BLOCK
public static final int BLOCK
public static final int MINIMUM_BLOCK
public static final Color COLOR0
public static final Color COLOR1
private BufferedPanel window
private int block
private Rectangle2D[][] blocks
private ColorView view0
private ColorView view1
private SimpleAction colorCheckerBoard
private SimpleAction resetColorViews
| Constructor Detail |
public CheckerBoard()
The constructor that creates a checkerboard panel using the default block size and default colors and includes the interactive color controls.
As of 2.6.0, this constructor does not automatically open the checkerboard in a frame. This turnes out to be a more convenient default behavior.
public CheckerBoard(int block,
Color color0,
Color color1,
boolean showColorViews,
boolean autoFrame)
The constructor that permits the caller to control the size of the
checkerboard block (within limits), the initial block colors, whether
to show the interactive color controls, and whether to automatically
put the checkerboard into a JPTFrame.
block - the size of a checkerboard blockcolor0 - color for blocks with (row + column) sum evencolor1 - color for blocks with (row + column) sum oddshowColorViews - whether to show the interactive color controlsautoFrame - whether to automatically frame the checkerboard| Method Detail |
public final BufferedPanel getCheckerboard()
Returns a reference to the checkerboard BufferedPanel
on which the checkerboard is painted.
This permits the user to add Paintable objects such as
"game pieces" to the paintable sequence layer of the checkerboard.
public final int getBlockSize()
Returns the checkerboard block size.
The checkerboard panel has size equal to 8 times the block size.
public final int getCheckerBoardSize()
Returns the checkerboard BufferedPanel size.
The checkerboard panel has size equal to 8 times the block size.
The caller should not modify the BufferedPanel size
using calls from the BufferedPanel class.
public final Color getColor0()
public final Color getColor1()
public final void setColor0(Color color0)
Sets the color for blocks with (row + column) sum even to the given color.
Does nothing if the given color is
null
color0 - color for blocks with (row + column) sum even
public final void setColor1(Color color1)
Sets the color for blocks with (row + column) sum odd to the given color.
Does nothing if the given color is
null
color1 - color for blocks with (row + column) sum odd
public final void resetColorViews()
private final int adjustBlock(int block)
private final void createCheckerBoard(int block)
private final void createColorViews(Color color0,
Color color1)
color0 - color for blocks with (row + column) sum evencolor1 - color for blocks with (row + column) sum oddprivate final void installContents(boolean showColorViews)
private final void autoFramePanel(boolean autoFrame)
protected final void colorCheckerBoard()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||