gui

Class Grid


public class Grid
extends java.lang.Object

This class handles the values for the grid, displayed on the GUI.

Field Summary

static byte
CURRENT_SEARCH_POS
private static byte
NUM_STAUS
static byte
OPTIMAL_POSITION
static byte
SEARCHED
static byte
SEARCH_CANDIDATE
static byte
SELECTED
static byte
UNSELECTED
private byte[][]
grid
private int
gridSize
private Point2D
lastPos
private int
maxCol
private int
maxLine
private int
minCol
private int
minLine
private Point2D
optPosOld

Constructor Summary

Grid(int size)
The parameter sets the size of the grid.

Method Summary

int
getGridSize()
int
getMaxCol()
int
getMaxLine()
int
getMinCol()
int
getMinLine()
byte
getStatus(int row, int col)
Returns the status of the grid at the specified coordinate.
void
reset()
void
setStatus(int col, int row, byte status)
Use this method to set the status of the grid at a certain position.
void
updateOptPos(Point2D optPos)

Field Details

CURRENT_SEARCH_POS

public static final byte CURRENT_SEARCH_POS
Field Value:
2

NUM_STAUS

private static final byte NUM_STAUS
Field Value:
5

OPTIMAL_POSITION

public static final byte OPTIMAL_POSITION
Field Value:
4

SEARCHED

public static final byte SEARCHED
Field Value:
3

SEARCH_CANDIDATE

public static final byte SEARCH_CANDIDATE
Field Value:
5

SELECTED

public static final byte SELECTED
Field Value:
1

UNSELECTED

public static final byte UNSELECTED
Field Value:
0

grid

private byte[][] grid

gridSize

private int gridSize

lastPos

private Point2D lastPos

maxCol

private int maxCol

maxLine

private int maxLine

minCol

private int minCol

minLine

private int minLine

optPosOld

private Point2D optPosOld

Constructor Details

Grid

public Grid(int size)
            throws GridException
The parameter sets the size of the grid. The size MUST be odd in order to reserve the same amount of gridpositions greater ans smaller than zero.

Method Details

getGridSize

public int getGridSize()

getMaxCol

public int getMaxCol()

getMaxLine

public int getMaxLine()

getMinCol

public int getMinCol()

getMinLine

public int getMinLine()

getStatus

public byte getStatus(int row,
                      int col)
Returns the status of the grid at the specified coordinate.
Returns:
byte Status at the coordinate

reset

public void reset()

setStatus

public void setStatus(int col,
                      int row,
                      byte status)
            throws GridException
Use this method to set the status of the grid at a certain position. Use the static variables inherited in this class to set the status. A GridException is thrown if the status or the coordinates are invalid.
Parameters:

updateOptPos

public void updateOptPos(Point2D optPos)
            throws GridException