Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.adorphuye.othello.gui.board
Class DefaultBoardDataModel  view DefaultBoardDataModel download DefaultBoardDataModel.java

java.lang.Object
  extended bycom.adorphuye.othello.gui.board.DefaultBoardDataModel
All Implemented Interfaces:
BoardDataModel

public class DefaultBoardDataModel
extends java.lang.Object
implements BoardDataModel


Field Summary
private  com.adorphuye.othello.gui.Board board
           
private  int currentSide
           
private  int[][] data
           
private static int[][] dirs
           
static int EMPTY
           
static int ILLEGAL_MOVE
           
static int INVALID_MOVE
           
private  java.awt.Point lastMove
           
private  java.util.Vector listeners
           
static int OFF_BOARD
           
static int ON_BOARD
           
private  int[] passtable
           
private static java.lang.String[] sdirs
           
private  com.adorphuye.othello.player.Player[] sides
           
static int VALID_MOVE
           
 
Constructor Summary
DefaultBoardDataModel(int[][] dat)
           
 
Method Summary
 void addBoardListener(BoardListener l)
           
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
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.
 void fireBoardChanged(BoardEvent evt)
           
 java.util.Vector flips(java.awt.Point p, int sid)
           
 com.adorphuye.othello.gui.Board getBoard()
           
 com.adorphuye.othello.player.Player getCurrentSide()
           
 int[][] getData()
           
 int getDataAt(java.awt.Point p)
           
 java.awt.Point getLastMove()
           
 int getMovesLeft()
           
 int getMovesMade()
           
 java.util.Vector getPossibleMoves(int obj)
           
 com.adorphuye.othello.player.Player[] getSides()
           
 boolean inBounds(java.awt.Point p)
           
 int legalMove(java.awt.Point p)
           
 void nextSide()
           
 void pass(com.adorphuye.othello.player.Player p)
           
 void removeBoardListener(BoardListener l)
           
 void reset()
           
 void setBoard(com.adorphuye.othello.gui.Board b)
           
private  java.util.Vector setcan(int sid)
           
 void setData(int[][] dat)
           
 void setDataAt(java.awt.Point p, int obj)
           
 void setSides(com.adorphuye.othello.player.Player[] data)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

DefaultBoardDataModel

public DefaultBoardDataModel(int[][] dat)
Method Detail

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