|
||||||||||
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
org.vizzini.ui.game.AbstractEnvironmentUISwing
org.vizzini.ui.game.boardgame.AbstractGridBoardUISwing
org.vizzini.ui.game.boardgame.GridBoardUISwing
public abstract class GridBoardUISwing
Provides functionality for Swing 2D grid board environment user interfaces in the game framework. The grid is formed by applying the grid color to this component's background, which is overlaid by the token UIs. The token UIs are set to opaque, and their backgrounds set to the desired grid board background color.
Nested Class Summary | |
---|---|
(package private) static class |
GridBoardUISwing.MyGridLayout
Provides a grid layout which uses the Component.getWidth() and Component.getHeight() method instead of directly accessing member variables. |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static double |
LINE_WIDTH_FRACTION
Constant for determining the grid line width. |
Fields inherited from class org.vizzini.ui.game.boardgame.AbstractGridBoardUISwing |
---|
LABEL_PAINTED_PROPERTY |
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.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 | |
---|---|
GridBoardUISwing()
Construct this object. |
Method Summary | |
---|---|
void |
add(HighlightData highlightData)
Add the given highlight data. |
protected void |
applyHighlightData(HighlightData highlightData)
Apply the given highlight data. |
void |
clearHighlights()
Clear the highlighted positions. |
protected void |
computeDimensions()
Compute the dimensions. |
protected void |
createAndPlaceTokenUI(IToken token,
int file,
int rank)
Create and place a new token user interface component. |
protected JComponent |
createBlank()
Create a blank component. |
protected abstract ITokenUI |
createTokenUI(IToken token)
Create a token user interface component for the given token. |
protected void |
createTokenUIs()
Create the initial token user interface components. |
protected JComponent |
getComponent(int file,
int rank)
Return the index of the component for the given coordinates. |
int |
getFileCount()
Return the file count. |
int |
getHeight()
Returns the current height of this component. |
IPosition |
getPositionForPoint(Point point)
Map the screen coordinates to a board position. |
Dimension |
getSize()
Returns the size of this component in the form of a Dimension object. |
int |
getWidth()
Returns the current width of this component. |
void |
paintComponent(Graphics g)
Paint this component. |
protected void |
placeTokenUI(JComponent tokenUI,
int file,
int rank)
Create and place a new token user interface component. |
protected void |
reApplyHighlights()
Re-apply the highlighted positions. |
protected void |
reconcileBoard(IGridBoard board)
Reconcile the token UIs with the real board environment. |
void |
remove(HighlightData highlightData)
Remove the given highlight data. |
protected void |
setCurrentHighlightData(HighlightData highlightData)
|
void |
setDimensions(int fileCount,
int rankCount)
Construct this object with the given dimensions. |
void |
setEnvironment(IEnvironment environment)
Set the environment this UI represents. |
void |
setGridLineColor(Color color)
Set the grid line color. |
Methods inherited from class org.vizzini.ui.game.AbstractEnvironmentUISwing |
---|
assignAgentListener, assignAgentListeners, getEnvironment, getSupport, init, isAudioOn, removeAgentListener, removeAgentListeners, reset, scoreChange, setAudioOn |
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 |
Methods inherited from interface org.vizzini.ui.game.IEnvironmentUI |
---|
assignAgentListeners, configure, getEnvironment, isAudioOn, removeAgentListeners, reset, setAudioOn |
Methods inherited from interface org.vizzini.game.event.IStateListener |
---|
stateChange |
Methods inherited from interface org.vizzini.game.event.IScoreListener |
---|
scoreChange |
Field Detail |
---|
public static final double LINE_WIDTH_FRACTION
Constructor Detail |
---|
public GridBoardUISwing()
Method Detail |
---|
public void add(HighlightData highlightData)
add
in interface IGridBoardUISwing
public void clearHighlights()
clearHighlights
in interface IGridBoardUISwing
public int getFileCount()
public int getHeight()
getHeight
in class JComponent
public IPosition getPositionForPoint(Point point)
getPositionForPoint
in interface IGridBoardUISwing
point
- A mouse click point.public Dimension getSize()
getSize
in class Component
public int getWidth()
getWidth
in class JComponent
public void paintComponent(Graphics g)
paintComponent
in class JComponent
g
- The graphics object.public void remove(HighlightData highlightData)
remove
in interface IGridBoardUISwing
public void setDimensions(int fileCount, int rankCount)
fileCount
- The file count.rankCount
- The rank count.public void setEnvironment(IEnvironment environment)
setEnvironment
in interface IEnvironmentUI
setEnvironment
in class AbstractEnvironmentUISwing
environment
- Environment.public void setGridLineColor(Color color)
setGridLineColor
in interface IGridBoardUISwing
setGridLineColor
in class AbstractGridBoardUISwing
protected abstract ITokenUI createTokenUI(IToken token)
token
- The token.protected void applyHighlightData(HighlightData highlightData)
highlightData
- Highlight data.protected void computeDimensions()
protected void createAndPlaceTokenUI(IToken token, int file, int rank)
token
- The token.file
- The file position.rank
- The rank position.protected JComponent createBlank()
protected void createTokenUIs()
protected JComponent getComponent(int file, int rank)
protected void placeTokenUI(JComponent tokenUI, int file, int rank)
tokenUI
- The token user interface.file
- The file position.rank
- The rank position.protected void reApplyHighlights()
protected void reconcileBoard(IGridBoard board)
reconcileBoard
in class AbstractGridBoardUISwing
board
- The current board environment.protected void setCurrentHighlightData(HighlightData highlightData)
setCurrentHighlightData
in class AbstractGridBoardUISwing
highlightData
- The highlightData to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |