|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Cell
This interface is the basic unit that comprises a life board.
It's implemented both by Resident
(which represents
an individual cell on the board) and Neighborhood
,
which represents a group of cells.
Nested Class Summary | |
---|---|
static interface |
Cell.Memento
The Cell.Memento interface stores the state of a Cell and all its subcells for future restoration. |
Field Summary | |
---|---|
static Cell |
DUMMY
The DUMMY Singleton represents a permanently dead (thus stable) cell. |
static boolean |
LOAD
Possible value for the "load" argument to transfer() |
static boolean |
STORE
Possible value for the "load" argument to transfer() |
Method Summary | |
---|---|
void |
clear()
Set the cell and all subcells into a "dead" state. |
Cell |
create()
Return a fresh (newly created) object identical to yourself in content. |
Storable |
createMemento()
This method is used by container of the outermost cell. |
Cell |
edge(int row,
int column)
Access a specific contained cell located at the edge of the composite cell. |
boolean |
figureNextState(Cell north,
Cell south,
Cell east,
Cell west,
Cell northeast,
Cell northwest,
Cell southeast,
Cell southwest)
Figure out the next state of the cell, given the specified neighbors. |
boolean |
isAlive()
Return true if this cell or any subcells are alive. |
Direction |
isDisruptiveTo()
Returns a Direction indicated the directions of the cells that have changed state. |
void |
redraw(Graphics g,
Rectangle here,
boolean drawAll)
Redraw yourself in the indicated rectangle on the indicated Graphics object if ncessary. |
boolean |
transfer(Storable memento,
Point upperLeftCorner,
boolean doLoad)
This method is used internally to save or restore the state of a cell from a memento. |
boolean |
transition()
Transition to the state computed by the most recent call to figureNextState(com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell) |
void |
userClicked(Point here,
Rectangle surface)
A user has clicked somewhere within you. |
int |
widthInCells()
Return the specified width plus the current cell's width |
Field Detail |
---|
static final boolean STORE
static final boolean LOAD
static final Cell DUMMY
Method Detail |
---|
boolean figureNextState(Cell north, Cell south, Cell east, Cell west, Cell northeast, Cell northwest, Cell southeast, Cell southwest)
Cell edge(int row, int column)
row
- The requested row. Must be on the edge of
the block.column
- The requested column. Must be on the edge
of the block.
boolean transition()
figureNextState(com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell, com.holub.life.Cell)
void redraw(Graphics g, Rectangle here, boolean drawAll)
g
- redraw using this graphics,here
- a rectangle that describes the bounds of the
current cell.drawAll
- if true, draw an entire compound cell;
otherwise, draw only the subcells that need to be redrawn.void userClicked(Point here, Rectangle surface)
here
- The position of the click relative to the bounding
rectangle of the current Cell.boolean isAlive()
int widthInCells()
Cell create()
Direction isDisruptiveTo()
void clear()
boolean transfer(Storable memento, Point upperLeftCorner, boolean doLoad)
Storable createMemento()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |