|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--Contest1.GameBoard
A class that represents a Game Board.
Inner Class Summary | |
(package private) class |
GameBoard.Mlistener
A class that handles mouse events on the board. |
Inner classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent,
JComponent.IntVector,
JComponent.KeyboardBinding,
JComponent.KeyboardState |
Inner classes inherited from class java.awt.Component |
Component.AWTTreeLock |
Field Summary | |
private Rectangle |
boundary
The boundary of the virtual board. |
private int |
ccols
The number of visible cell columns. |
private Color |
cell_color
The color of the cells. |
private Cell[][] |
cells
The board's cells. |
private int |
crows
The number of visible cell rows. |
private long |
generation
The current generation of the board. |
private Rectangle[] |
row_rect
An array of rectangles that describes the boundary of each cell row. |
private Thread |
t
Animation thread. |
private boolean |
threadSuspended
State of the animation thread. |
private int |
vcols
The number of virtual cell columns. |
private int |
vrows
The number of virtual cell rows. |
Fields inherited from class javax.swing.JPanel |
defaultLayout,
uiClassID |
Fields inherited from class java.awt.Container |
component,
containerListener,
containerSerializedDataVersion,
dispatcher,
layoutMgr,
maxSize,
ncomponents,
serialVersionUID |
Constructor Summary | |
(package private) |
GameBoard()
The default constructor. |
(package private) |
GameBoard(int crows,
int ccols)
Constructor. |
Method Summary | |
(package private) void |
clearBoard()
Clear the game board. |
private Rectangle |
getBoundary()
Gets the boundary spanned by the virtual rows and columns. |
(package private) Cell[][] |
getCells()
Gets this game board's cells. |
(package private) long |
getGeneration()
Gets the current generation. |
(package private) int[] |
getVisibleRowColumnOffset()
Gets the row and column offset of the origin of the visible portion of the game board. |
(package private) void |
newGeneration()
Advances the board state one generation, obeying the rules of the game. |
(package private) void |
nextGeneration()
Advances the game one generation. |
void |
paintComponent(Graphics g)
Overrides paintComponent() of JPanel to handle painting the board's graphics Context. |
(package private) void |
pauseGame()
Pauses the game thread. |
(package private) void |
resumeGame()
Resumes the game thread. |
void |
run()
Animate the play. |
(package private) void |
startGame()
Starts the game thread. |
(package private) void |
stopGame()
Stops the game thread. |
Methods inherited from class javax.swing.JPanel |
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Field Detail |
private Cell[][] cells
Cell
private int crows
private int ccols
private int vrows
private int vcols
private Rectangle[] row_rect
Rectangle
private Rectangle boundary
private Color cell_color
private Thread t
private boolean threadSuspended
private long generation
Constructor Detail |
GameBoard()
GameBoard(int crows, int ccols)
crows
- The number of cell rows for this board.ccols
- The number of cell columns for this board.Config
Method Detail |
private Rectangle getBoundary()
void startGame()
void pauseGame()
void stopGame()
void resumeGame()
void nextGeneration()
Cell[][] getCells()
long getGeneration()
int[] getVisibleRowColumnOffset()
public void paintComponent(Graphics g)
g
- Graphics context of this board.void clearBoard()
isalive
state of each cell to false.void newGeneration()
public void run()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |