pt.ua.gboard.games
Class LabyrinthGelem

java.lang.Object
  extended by pt.ua.gboard.Gelem
      extended by pt.ua.gboard.games.LabyrinthGelem

public class LabyrinthGelem
extends Gelem

Labyrinth graphical element.

This gelem draws an appropriate labyrinth cell taking into consideration the contents of the eight adjacent cells.

+++
+X+
+++

This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.

Author:
Miguel Oliveira e Silva (mos@ua.pt)

Field Summary
static int ROAD
           
static int ROAD_E
           
static int ROAD_N
           
static int ROAD_NE
           
static int ROAD_NW
           
static int ROAD_S
           
static int ROAD_SE
           
static int ROAD_SW
           
static int ROAD_W
           
 
Constructor Summary
LabyrinthGelem(int form)
           
LabyrinthGelem(int form, int numberOfLines, int numberOfColumns)
           
 
Method Summary
 void draw(java.awt.Graphics g, int line, int column, int cellWidth, int cellHeight, java.awt.Color background)
          Draw Gelem in GBoard (it should be exported only to GBoard).
 void erase(java.awt.Graphics g, int line, int column, int cellWidth, int cellHeight, java.awt.Color background)
          Erase Gelem from GBoard (it should be exported only to GBoard).
 boolean isRoad()
           
 boolean isWall()
           
static void resetShowRoadBoundaries()
          Singleton method to reset the visualization of road boundaries (this is the default).
static void setGapPercentageSize(double perc)
          Singleton method to define the separation gap between a wall and a road.
static void setShowRoadBoundaries()
          Singleton method to set the visualization of road boundaries (as a thin yellow square).
static boolean validForm(int form)
           
 
Methods inherited from class pt.ua.gboard.Gelem
height, intersects, isMutable, mutable, numberOfColumns, numberOfLines, width, x, y
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROAD_NW

public static final int ROAD_NW
See Also:
Constant Field Values

ROAD_N

public static final int ROAD_N
See Also:
Constant Field Values

ROAD_NE

public static final int ROAD_NE
See Also:
Constant Field Values

ROAD_W

public static final int ROAD_W
See Also:
Constant Field Values

ROAD_E

public static final int ROAD_E
See Also:
Constant Field Values

ROAD_SW

public static final int ROAD_SW
See Also:
Constant Field Values

ROAD_S

public static final int ROAD_S
See Also:
Constant Field Values

ROAD_SE

public static final int ROAD_SE
See Also:
Constant Field Values

ROAD

public static final int ROAD
See Also:
Constant Field Values
Constructor Detail

LabyrinthGelem

public LabyrinthGelem(int form)

LabyrinthGelem

public LabyrinthGelem(int form,
                      int numberOfLines,
                      int numberOfColumns)
Method Detail

setGapPercentageSize

public static void setGapPercentageSize(double perc)
Singleton method to define the separation gap between a wall and a road.

requires: perc >= 0.0 && perc <= 100.0

Parameters:
perc - percentage value

setShowRoadBoundaries

public static void setShowRoadBoundaries()
Singleton method to set the visualization of road boundaries (as a thin yellow square).


resetShowRoadBoundaries

public static void resetShowRoadBoundaries()
Singleton method to reset the visualization of road boundaries (this is the default).


validForm

public static boolean validForm(int form)

isWall

public boolean isWall()

isRoad

public boolean isRoad()

draw

public void draw(java.awt.Graphics g,
                 int line,
                 int column,
                 int cellWidth,
                 int cellHeight,
                 java.awt.Color background)
Description copied from class: Gelem
Draw Gelem in GBoard (it should be exported only to GBoard).

requires: g != null && background != null (incomplete!)

Specified by:
draw in class Gelem
Parameters:
g - Java's Graphics object to use in drawing
line - line in GBoard to draw Gelem.
column - column in GBoard to draw Gelem.
cellWidth - number of horizontal pixels per cell
cellHeight - number of vertical pixels per cell
background - background color

erase

public void erase(java.awt.Graphics g,
                  int line,
                  int column,
                  int cellWidth,
                  int cellHeight,
                  java.awt.Color background)
Description copied from class: Gelem
Erase Gelem from GBoard (it should be exported only to GBoard).

requires: g != null && background != null (incomplete!)

Specified by:
erase in class Gelem
Parameters:
g - Java's Graphics object to use in drawing
line - line in GBoard to draw Gelem.
column - column in GBoard to draw Gelem.
cellWidth - number of horizontal pixels per cell
cellHeight - number of vertical pixels per cell