minesweeper
Class MineFieldCell

java.lang.Object
  |
  +--minesweeper.MineFieldCell

public class MineFieldCell
extends Object

A cell of the mine field.


Field Summary
private  boolean bContainsAMine
          Indicates whether this cells contains a mine.
private  boolean bIsRevealed
          Indicates whether the real content of this cell is revealed.
private  boolean bPlayerSupposesAMine
          Indicates whether the player thinks that this cell contains a mine.
private  JButton btnButton
          The button displayed when the content of this cell is not revealed.
private static JLabel[] DIGITS
          An array of digits; these labels should not be modified.
private static JLabel EMPTY
          An empty cell.
private static JLabel ERROR
          A mine that was wrongly supposed.
private static ImageIcon FLAG
          A flag.
private  int iSurroundingMines
          Stores the number of mines around this cell.
private  EventListenerList lstListeners
          The list of listeners.
private  LinkedList lstSurrounders
          The list of surrounders.
private  minesweeper.event.MineFieldCellEvent mfceEvent
          The source of events.
private static JLabel MINE
          A mine.
 
Constructor Summary
MineFieldCell()
          Creates a new mine field cell.
 
Method Summary
(package private) static void ()
          The "static constructor" of this class.
 void addListener(minesweeper.event.MineFieldCellListener mfclListener)
          Adds the specified mine field cell listener to receive event from this cell.
 boolean doesContainAMine()
          Indicates whether this cell has a mine.
protected  void fireDisplayChanged()
          Fires a displayChanged event.
protected  void fireFlagAdded()
          Fires a flagAdded event.
protected  void fireFlagRemoved()
          Fires a flagRemoved event.
protected  void fireSteppedOnAMine()
          Fires a steppedOnAMine event.
 Component getComponent()
          Returns the Component that is to be used to render this mine field cell, or null if the cell is empty with no mines around.
 int getSurroundingMineCount()
          Indicates the number of mines around this cell.
 void increaseSurroundingMineCount()
          Increase the number of mines around this cell.
 boolean isFlagged()
          Indicates whether this cell has a flag.
 boolean isRevealed()
          Indicates whether the real content of this cell is revealed.
 void registerAsSurrounder(MineFieldCell mfcSurrounder)
          Registers the specified mine field cell as a surrounder of this one.
 void removeListener(minesweeper.event.MineFieldCellListener mfclListener)
          Removes the specified mine field cell listener so that it no longer receive events from this cell.
 void reset()
          Reset the mine field cell.
 void reveal()
          Reveals the content of this cell.
 void revealError()
          Reveals the content of this cell if the user assumption was wrong.
 void revealSurrounders()
          Reveals the surrounders of this cell, if this cell is already revealed and the number of surrounding flags matches the number of surrounding mines.
 void settleAMine()
          Settles a mine in this cell.
 void toggleFlag()
          Toggles the flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

EMPTY

private static final JLabel EMPTY
An empty cell.

ERROR

private static final JLabel ERROR
A mine that was wrongly supposed.

MINE

private static final JLabel MINE
A mine.

FLAG

private static final ImageIcon FLAG
A flag.

DIGITS

private static final JLabel[] DIGITS
An array of digits; these labels should not be modified.

btnButton

private final JButton btnButton
The button displayed when the content of this cell is not revealed.

lstSurrounders

private final LinkedList lstSurrounders
The list of surrounders.

bContainsAMine

private boolean bContainsAMine
Indicates whether this cells contains a mine.

bPlayerSupposesAMine

private boolean bPlayerSupposesAMine
Indicates whether the player thinks that this cell contains a mine.

bIsRevealed

private boolean bIsRevealed
Indicates whether the real content of this cell is revealed.

iSurroundingMines

private int iSurroundingMines
Stores the number of mines around this cell.

lstListeners

private final EventListenerList lstListeners
The list of listeners.

mfceEvent

private minesweeper.event.MineFieldCellEvent mfceEvent
The source of events.
Constructor Detail

MineFieldCell

public MineFieldCell()
Creates a new mine field cell.
Method Detail

static void ()
The "static constructor" of this class.

getComponent

public Component getComponent()
Returns the Component that is to be used to render this mine field cell, or null if the cell is empty with no mines around.

doesContainAMine

public boolean doesContainAMine()
Indicates whether this cell has a mine.

getSurroundingMineCount

public int getSurroundingMineCount()
Indicates the number of mines around this cell.

isFlagged

public boolean isFlagged()
Indicates whether this cell has a flag.

isRevealed

public boolean isRevealed()
Indicates whether the real content of this cell is revealed.

increaseSurroundingMineCount

public void increaseSurroundingMineCount()
Increase the number of mines around this cell.

registerAsSurrounder

public void registerAsSurrounder(MineFieldCell mfcSurrounder)
Registers the specified mine field cell as a surrounder of this one.

reset

public void reset()
Reset the mine field cell.

reveal

public void reveal()
Reveals the content of this cell.

revealError

public void revealError()
Reveals the content of this cell if the user assumption was wrong.

revealSurrounders

public void revealSurrounders()
Reveals the surrounders of this cell, if this cell is already revealed and the number of surrounding flags matches the number of surrounding mines.

settleAMine

public void settleAMine()
Settles a mine in this cell.

toggleFlag

public void toggleFlag()
Toggles the flag.

addListener

public void addListener(minesweeper.event.MineFieldCellListener mfclListener)
Adds the specified mine field cell listener to receive event from this cell.

removeListener

public void removeListener(minesweeper.event.MineFieldCellListener mfclListener)
Removes the specified mine field cell listener so that it no longer receive events from this cell.

fireDisplayChanged

protected void fireDisplayChanged()
Fires a displayChanged event.

fireFlagAdded

protected void fireFlagAdded()
Fires a flagAdded event.

fireFlagRemoved

protected void fireFlagRemoved()
Fires a flagRemoved event.

fireSteppedOnAMine

protected void fireSteppedOnAMine()
Fires a steppedOnAMine event.