|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.holub.life.Neighborhood
public final class Neighborhood
A group of Cell
objects. Cells are grouped into neighborhoods
to make board updates more efficient. When a neighborhood is
quiescent (none of the Cells it contains are active), then it
ignores any requests to update itself.
11-29-04 Alexy Marinichev fixed the disapearing-glider problem by clearing the active edges in transistion() rather then figureNextState(). The original call is commented out and the new line is marked with "(1)"
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.holub.life.Cell |
---|
Cell.Memento |
Field Summary |
---|
Fields inherited from interface com.holub.life.Cell |
---|
DUMMY, LOAD, STORE |
Constructor Summary | |
---|---|
Neighborhood(int gridSize,
Cell prototype)
Create a new Neigborhood containing gridSize-by-gridSize clones of the prototype. |
Method Summary | |
---|---|
void |
clear()
Set the cell and all subcells into a "dead" state. |
Cell |
create()
The "clone" method used to create copies of the current neighborhood. |
Storable |
createMemento()
This method is used by container of the outermost cell. |
Cell |
edge(int row,
int column)
Return the edge cell in the indicated row and column. |
boolean |
figureNextState(Cell north,
Cell south,
Cell east,
Cell west,
Cell northeast,
Cell northwest,
Cell southeast,
Cell southwest)
Figures the next state of the current neighborhood and the contained neigborhoods (or cells). |
boolean |
isAlive()
Return true if this cell or any subcells are alive. |
Direction |
isDisruptiveTo()
Shows the direction of the cells along the edge of the block that will change state in the next transition. |
void |
redraw(Graphics g,
Rectangle here,
boolean drawAll)
Redraw the current neighborhood only if necessary (something changed in the last transition). |
boolean |
transfer(Storable memento,
Point corner,
boolean load)
Cause subcells to add an annotation to the indicated memento if they happen to be alive. |
boolean |
transition()
Transition the neighborhood to the previously-computed state. |
void |
userClicked(Point here,
Rectangle surface)
Notification of a mouse click. |
int |
widthInCells()
Return the specified width plus the current cell's width |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Neighborhood(int gridSize, Cell prototype)
Method Detail |
---|
public Cell create()
create
in interface Cell
public Direction isDisruptiveTo()
isDisruptiveTo
in interface Cell
public boolean figureNextState(Cell north, Cell south, Cell east, Cell west, Cell northeast, Cell northwest, Cell southeast, Cell southwest)
figureNextState
in interface Cell
north
- The neighbor to our northsouth
- The neighbor to our southeast
- The neighbor to our eastwest
- The neighbor to our westnortheast
- The neighbor to our northeastnorthwest
- The neighbor to our northwestsoutheast
- The neighbor to our southeastsouthwest
- The neighbor to our southwest
transition()
public boolean transition()
transition
in interface Cell
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)
public void redraw(Graphics g, Rectangle here, boolean drawAll)
redraw
in interface Cell
g
- Draw onto this graphics.here
- Bounding rectangle for current Neighborhood.drawAll
- force a redraw, even if nothing has changed.transition()
public Cell edge(int row, int column)
edge
in interface Cell
row
- The requested row. Must be on the edge of
the block.column
- The requested column. Must be on the edge
of the block.
public void userClicked(Point here, Rectangle surface)
userClicked
in interface Cell
here
- The position of the click relative to the bounding
rectangle of the current Cell.public boolean isAlive()
Cell
isAlive
in interface Cell
public int widthInCells()
Cell
widthInCells
in interface Cell
public void clear()
Cell
clear
in interface Cell
public boolean transfer(Storable memento, Point corner, boolean load)
transfer
in interface Cell
public Storable createMemento()
Cell
createMemento
in interface Cell
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |