|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--org.moyoman.client.reference.Board
Provides a Go board user interface.
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 ActionManager |
_actionManager
Handle to the action manager. |
private double |
_annotationFontFraction
The annotation font size as a fraction of _squareSize. |
private Annotation[][] |
_annotations
The intersection annotations. |
private Color |
_boardColor
The board color. |
private int |
_borderSize
Border size. |
private AudioClip |
_click
Click audio clip. |
private int |
_dimension
The grid dimension. |
private boolean |
_doCompute
Flag indicating if parameters need to be computed. |
private double |
_dotFraction
Dot radius as a fraction of _squareSize. |
private int |
_fileHeight
Height of the file label area. |
private Color |
_gridColor
The grid color. |
private Color |
_highlightColor
The highlight color. |
private double |
_highlightFraction
Highlight radius as a fraction of _squareSize. |
private Point |
_highlightIntersection
The last highlighted intersection. |
private boolean |
_isLabelPainted
Flag indicating the coordinate labels are painted. |
private boolean |
_isLastMoveMarked
Flag indicating the last move is marked. |
private boolean |
_isSoundOn
Flag indicating whether to use sound. |
private double |
_labelFraction
Label border fraction. |
private Color |
_markColor
The mark color. |
private Stone |
_markedToken
Token to be marked. |
private double |
_markFraction
Mark radius as a fraction of _squareSize. |
private Point |
_max
The maximum point of the grid in screen coordinates. |
private Point |
_min
The minimum point of the grid in screen coordinates. |
private int |
_offset
Border size. |
private double |
_offsetFraction
Grid offset as a fraction of _squareSize. |
private JPopupMenu |
_popupMenu
The popup menu. |
private Dimension |
_previousSize
The previous panel size. |
private int |
_rankWidth
Width of the rank label area. |
private Rectangle |
_rectangle
Board rectangle. |
private Map |
_sizeToFont
Font cache, stored by size. |
private int |
_squareSize
Square size. |
private Color |
_textColor
The text color. |
private double |
_tokenFraction
Token radius as a fraction of _squareSize. |
private List |
_tokens
The tokens on the board |
private static String[] |
FILE_STRINGS
String representations of file index. |
static String |
LABEL_PAINTED_PROPERTY
Name of the label painted property. |
static String |
LAST_MOVE_MARKED_PROPERTY
Name of the label painted property. |
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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Board()
Construct this object. |
Method Summary | |
void |
add(Stone stone)
Add the given token to the board. |
void |
add(Stone[] stones)
Add the given tokens to the board. |
protected void |
add(Stone stone,
boolean repaint,
boolean doSound)
Add the given token to the board. |
void |
clear()
Clear the tokens and annotations from the board. |
void |
clearAnnotations()
Clear all annotations. |
protected void |
computeParameters()
Compute the board parameters. |
protected Point |
computeScreenPoint(int x,
int y)
Compute and return the screen coordinates for the given intersection. |
protected void |
computeScreenPoint(int x,
int y,
Point point)
Compute and return the screen coordinates for the given intersection. |
protected int |
computeSize(double fraction)
Compute a size based upon the given fraction and the square size. |
JCheckBoxMenuItem |
createLabelPaintedUI()
Create a label painted user interface widget. |
JCheckBoxMenuItem |
createLastMoveMarkedUI()
Create a last move marked user interface widget. |
protected JPopupMenu |
createPopupMenu()
Create and configure the popup menu. |
protected void |
drawCircle(Graphics2D g,
int centerX,
int centerY,
int radius,
boolean filled)
Draw a circle at the given coordinates. |
protected void |
drawString(Graphics2D g,
String string,
int centerX,
int centerY,
Font font)
Draw the given string using the given font. |
void |
drawStringAt(String string,
Point intersection)
Draw the given string at the given intersection. |
void |
drawStringAt(String string,
Point intersection,
Font font)
Draw the given string at the given intersection using the given font. |
Annotation |
get(int x,
int y)
Return the annotation at the given intersection. |
int |
getDimension()
Return the dimension of this board. |
static String |
getFileString(int file)
Return the alphabetic file designation for the given index. |
Point |
getIntersectionFor(Point point)
Return the nearest intersection to the given screen point. |
static String |
getPositionString(int x,
int y)
Return the formatted string representation of the given position. |
protected Font |
getRelativeFont(double fraction,
Font font)
Return the font sized relative to the given fraction. |
List |
getState()
Return the current board state. |
void |
highlightIntersection(Point point)
Highlight the given intersection. |
boolean |
isSoundOn()
Return true if sound is on. |
void |
labelPaintedActionPerformed(ActionEvent event)
Callback for the label painted action. |
void |
lastMoveMarkedActionPerformed(ActionEvent event)
Callback for the last move marked action. |
void |
markToken(Stone stone)
Mark the token at the given position. |
protected void |
paintAnnotations(Graphics2D g)
Paint the annotations. |
protected void |
paintBoard(Graphics2D g)
Paint the grid lines. |
protected void |
paintComponent(Graphics g)
Paint this component. |
protected void |
paintCoordinateLabels(Graphics2D g)
Paint the coordinate labels. |
protected void |
paintHighlight(Graphics2D g)
Paint the intersection highlight, if any. |
protected void |
paintTokens(Graphics2D g)
Paint the tokens. |
protected void |
rangeCheck(String label,
int x)
Perform a range check. |
void |
remove(Stone stone)
Remove the given token from the board. |
void |
remove(Stone[] stones)
Remove the given tokens from the board. |
void |
remove(Stone stone,
boolean repaint)
Remove the given token from the board. |
void |
setAnnotation(int x,
int y,
String text,
Color foreground,
Color background,
boolean isEllipseVisible,
boolean append)
Set the given parameters on the annotation at the given intersection. |
void |
setAnnotation(int x,
int y,
String text,
Color foreground,
Color background,
boolean isEllipseVisible,
boolean append,
Object clientKey,
Object clientValue)
Set the given parameters on the annotation at the given intersection. |
void |
setBoardBorderWidth(int width)
Set the board board width. |
void |
setBoardColor(Color color)
Set the board color. |
void |
setDimension(int dimension)
Set the dimension of this board. |
void |
setFont(Font font)
Set the font. |
void |
setGridColor(Color color)
Set the grid color. |
void |
setHighlightColor(Color color)
Set the highlight color. |
void |
setLabelPainted(boolean isLabelPainted)
Set the flag indicating this should draw coordinate labels. |
void |
setLastMoveMarked(boolean isLastMoveMarked)
Set the flag indicating this should mark the last move. |
void |
setMarkColor(Color color)
Set the mark color. |
void |
setSoundOn(boolean isSoundOn)
Set the sound flag. |
void |
setState(List state)
Set the board state. |
void |
setTextColor(Color color)
Set the text 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 String LABEL_PAINTED_PROPERTY
public static final String LAST_MOVE_MARKED_PROPERTY
private static final String[] FILE_STRINGS
private ActionManager _actionManager
private AudioClip _click
private Color _boardColor
private Color _gridColor
private Color _highlightColor
private Color _markColor
private Color _textColor
private Dimension _previousSize
private JPopupMenu _popupMenu
private List _tokens
private Map _sizeToFont
private Point _highlightIntersection
private Point _max
private Point _min
private Rectangle _rectangle
private Stone _markedToken
private Annotation[][] _annotations
private boolean _doCompute
private boolean _isLabelPainted
private boolean _isLastMoveMarked
private boolean _isSoundOn
private double _annotationFontFraction
private double _dotFraction
private double _highlightFraction
private double _labelFraction
private double _markFraction
private double _offsetFraction
private double _tokenFraction
private int _borderSize
private int _dimension
private int _fileHeight
private int _offset
private int _rankWidth
private int _squareSize
Constructor Detail |
public Board()
Method Detail |
public void setAnnotation(int x, int y, String text, Color foreground, Color background, boolean isEllipseVisible, boolean append)
x
- X coordinate.y
- Y coordinate.text
- Annotation text.foreground
- Foreground color.background
- Background color.isEllipseVisible
- Flag indicating if the annotation should show an
ellipse.append
- Flag indicating if the text should be appended to existing
text.public void setAnnotation(int x, int y, String text, Color foreground, Color background, boolean isEllipseVisible, boolean append, Object clientKey, Object clientValue)
x
- X coordinate.y
- Y coordinate.text
- Annotation text.foreground
- Foreground color.background
- Background color.isEllipseVisible
- Flag indicating if the annotation should show an
ellipse.append
- Flag indicating if the text should be appended to existing
text.clientKey
- Client property key.clientValue
- Client property value.public void setBoardBorderWidth(int width)
public void setBoardColor(Color color)
public void setDimension(int dimension)
public int getDimension()
public static String getFileString(int file)
public static String getPositionString(int x, int y)
public void setFont(Font font)
setFont
in class JComponent
public void setGridColor(Color color)
public void setHighlightColor(Color color)
public Point getIntersectionFor(Point point)
public void setLabelPainted(boolean isLabelPainted)
public void setLastMoveMarked(boolean isLastMoveMarked)
public void setMarkColor(Color color)
public void setSoundOn(boolean isSoundOn)
public boolean isSoundOn()
public void setState(List state)
state
- List of Stone
s.public List getState()
public void setTextColor(Color color)
public void add(Stone stone)
public void add(Stone[] stones)
public void clear()
public void clearAnnotations()
public JCheckBoxMenuItem createLabelPaintedUI()
public JCheckBoxMenuItem createLastMoveMarkedUI()
public void drawStringAt(String string, Point intersection)
string
- The string being drawn.intersection
- The coordinates of the intersection.public void drawStringAt(String string, Point intersection, Font font)
string
- The string being drawn.intersection
- The coordinates of the intersection.font
- The font to use.public Annotation get(int x, int y)
public void highlightIntersection(Point point)
public void labelPaintedActionPerformed(ActionEvent event)
public void lastMoveMarkedActionPerformed(ActionEvent event)
public void markToken(Stone stone)
public void remove(Stone stone)
public void remove(Stone stone, boolean repaint)
public void remove(Stone[] stones)
protected Font getRelativeFont(double fraction, Font font)
protected void add(Stone stone, boolean repaint, boolean doSound)
stone
- Stone to add.repaint
- Flag indicating whether a repaint should be requested.doSound
- Flag indicating whether to make a sound.protected void computeParameters()
protected Point computeScreenPoint(int x, int y)
protected void computeScreenPoint(int x, int y, Point point)
x
- X coordinate.y
- Y coordinate.point
- Point provided to hold the answer.protected int computeSize(double fraction)
protected JPopupMenu createPopupMenu()
protected void drawCircle(Graphics2D g, int centerX, int centerY, int radius, boolean filled)
protected void drawString(Graphics2D g, String string, int centerX, int centerY, Font font)
g
- The graphics.string
- The string being drawn.centerX
- The center X coordinate.centerY
- The center Y coordinate.font
- The font to use.protected void paintAnnotations(Graphics2D g)
protected void paintBoard(Graphics2D g)
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
protected void paintCoordinateLabels(Graphics2D g)
protected void paintHighlight(Graphics2D g)
protected void paintTokens(Graphics2D g)
protected void rangeCheck(String label, int x)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |