java.lang.Object
com.adorphuye.othello.gui.board.DefaultBoardDataModel
- All Implemented Interfaces:
- BoardDataModel
- public class DefaultBoardDataModel
- extends java.lang.Object
- implements BoardDataModel
ON_BOARD
public static final int ON_BOARD
- See Also:
- Constant Field Values
OFF_BOARD
public static final int OFF_BOARD
- See Also:
- Constant Field Values
EMPTY
public static final int EMPTY
- See Also:
- Constant Field Values
data
private int[][] data
listeners
private java.util.Vector listeners
board
private com.adorphuye.othello.gui.Board board
lastMove
private java.awt.Point lastMove
dirs
private static final int[][] dirs
sdirs
private static final java.lang.String[] sdirs
VALID_MOVE
public static final int VALID_MOVE
- See Also:
- Constant Field Values
INVALID_MOVE
public static final int INVALID_MOVE
- See Also:
- Constant Field Values
ILLEGAL_MOVE
public static final int ILLEGAL_MOVE
- See Also:
- Constant Field Values
passtable
private int[] passtable
sides
private com.adorphuye.othello.player.Player[] sides
currentSide
private int currentSide
DefaultBoardDataModel
public DefaultBoardDataModel(int[][] dat)
setData
public void setData(int[][] dat)
- Specified by:
setData in interface BoardDataModel
getData
public int[][] getData()
- Specified by:
getData in interface BoardDataModel
setDataAt
public void setDataAt(java.awt.Point p,
int obj)
- Specified by:
setDataAt in interface BoardDataModel
getDataAt
public int getDataAt(java.awt.Point p)
- Specified by:
getDataAt in interface BoardDataModel
addBoardListener
public void addBoardListener(BoardListener l)
- Specified by:
addBoardListener in interface BoardDataModel
removeBoardListener
public void removeBoardListener(BoardListener l)
- Specified by:
removeBoardListener in interface BoardDataModel
fireBoardChanged
public void fireBoardChanged(BoardEvent evt)
- Specified by:
fireBoardChanged in interface BoardDataModel
getMovesLeft
public int getMovesLeft()
- Specified by:
getMovesLeft in interface BoardDataModel
setcan
private java.util.Vector setcan(int sid)
flips
public java.util.Vector flips(java.awt.Point p,
int sid)
- Specified by:
flips in interface BoardDataModel
inBounds
public boolean inBounds(java.awt.Point p)
legalMove
public int legalMove(java.awt.Point p)
count
private java.util.Vector count(java.awt.Point p,
int dir,
int sid)
- count the flips that would happen if you put a
stone at position c and looking in the direction dir.
getPossibleMoves
public java.util.Vector getPossibleMoves(int obj)
- Specified by:
getPossibleMoves in interface BoardDataModel
getMovesMade
public int getMovesMade()
- Specified by:
getMovesMade in interface BoardDataModel
clone
public java.lang.Object clone()
- Description copied from class:
java.lang.Object
- This method may be called to create a new copy of the
Object. The typical behavior is as follows:
o == o.clone() is false
o.getClass() == o.clone().getClass()
is true
o.equals(o) is true
However, these are not strict requirements, and may
be violated if necessary. Of the three requirements, the
last is the most commonly violated, particularly if the
subclass does not override Object.equals(Object)>Object.equals(Object) 55 .
If the Object you call clone() on does not implement
java.lang.Cloneable (which is a placeholder interface), then
a CloneNotSupportedException is thrown. Notice that
Object does not implement Cloneable; this method exists
as a convenience for subclasses that do.
Object's implementation of clone allocates space for the
new Object using the correct class, without calling any
constructors, and then fills in all of the new field values
with the old field values. Thus, it is a shallow copy.
However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override
this method as follows (it should never fail):
public Object clone()
{
try
{
super.clone();
}
catch (CloneNotSupportedException e)
{
throw new InternalError(e.getMessage());
}
}
- Specified by:
clone in interface BoardDataModel
getCurrentSide
public com.adorphuye.othello.player.Player getCurrentSide()
- Specified by:
getCurrentSide in interface BoardDataModel
setSides
public void setSides(com.adorphuye.othello.player.Player[] data)
- Specified by:
setSides in interface BoardDataModel
getLastMove
public java.awt.Point getLastMove()
pass
public void pass(com.adorphuye.othello.player.Player p)
- Specified by:
pass in interface BoardDataModel
nextSide
public void nextSide()
- Specified by:
nextSide in interface BoardDataModel
getSides
public com.adorphuye.othello.player.Player[] getSides()
- Specified by:
getSides in interface BoardDataModel
getBoard
public com.adorphuye.othello.gui.Board getBoard()
- Specified by:
getBoard in interface BoardDataModel
setBoard
public void setBoard(com.adorphuye.othello.gui.Board b)
- Specified by:
setBoard in interface BoardDataModel
reset
public void reset()
- Specified by:
reset in interface BoardDataModel