|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmaze.geometry.MazeGeometry
Contains facts about the current maze geometry. Also does coordinate transformations to help draw the various maze objects.
| Field Summary | |
protected static boolean |
Debug
Debug wallPoly transformations |
int |
hMax
Horizontal size of the maze, set by constructor. |
int |
hScale
Horizontal scale factor, set by setRect method. |
static int |
MAX_DIRECTIONS
Maximum number of directions for this geometry |
java.awt.Point |
origin
Origin on owning panel or canvas, set by setRect |
protected java.awt.Point[] |
P1
Point for one end of a wall in each direction, created by setRect. |
protected java.awt.Point[] |
P2
Point for the other end of a wall in each direction, created by setRect. |
int |
vMax
Vertical size of the maze, set by constructor. |
int |
vScale
Vertical scale factor, set by setRect method. |
| Constructor Summary | |
MazeGeometry(int h,
int v)
Creates a new MazeGeometry with the given horizontal and vertical size. |
|
| Method Summary | |
abstract Coordinate |
advance(Coordinate c,
int d)
Computes a new coordinate, given a coordinate and an absolute direction |
Coordinate |
advance(Coordinate c,
int d,
int angle)
Computes a new coordinate, given a coordinate, direction and an angle to turn |
protected double |
cellHoffset()
Computes the horizontal offset for the reference corner of each cell. |
java.awt.Polygon |
cellPoly(int x,
int y)
Computes the screen location for the cell, must be preceeded by call to setRect with correct size of current display area |
protected double |
cellVoffset()
Computes the vertical offset for the reference corner of each cell. |
GeoDirectionIterator |
iterator()
Creates a GeoDirectionIterator for this particular geometry. |
static java.lang.String |
label(int d)
Creates a String label for a given direction. |
static java.lang.String |
label(int dir,
int angle)
Creates a string label for a direction given a base direction and and angle to turn. |
static int |
left(int d)
Returns the direction one step to the "left", counter-clockwise. |
static int |
opp(int d)
Returns the direction opposite this direction. |
static int |
right(int d)
Returns the direction one step to the "right", clockwise. |
void |
setRect(java.awt.Rectangle r)
Computes the scaling for this geometry, also computes a default tiling for this geometry. |
void |
setTiling()
Computes a trivial default tiling for the surface. |
Coordinate |
start()
Finds a good starting cell near the center of the maze |
int |
startDir()
Finds a good starting pair of directions, must be distinct |
static int |
turn(int dir,
int angle)
Returns a direction offset from a given direction by an angle. |
java.awt.Point |
wallP1(int x,
int y,
int dir)
Returns one endpoint of the wall. |
java.awt.Point |
wallP2(int x,
int y,
int dir)
Returns the other endpoint of the wall. |
java.awt.Polygon |
wallPoly(int x,
int y,
int dir)
Computes the line which frames this wall of the given cell Use the following: Polygon p= wallPoly( x, y, dir );
drawLine( p.xpoints[0], p.ypoints[0], p.xpoints[1], p.ypoints[1] ); |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static int MAX_DIRECTIONS
public int hMax
public int vMax
public int hScale
public int vScale
public java.awt.Point origin
protected java.awt.Point[] P1
protected java.awt.Point[] P2
protected static boolean Debug
| Constructor Detail |
public MazeGeometry(int h,
int v)
h - int horizontal size.v - int vertical size.| Method Detail |
public static java.lang.String label(int d)
d - int numeric direction.
public static java.lang.String label(int dir,
int angle)
dir - int base direction.angle - int number of direction steps to turn.
public static int turn(int dir,
int angle)
dir - int base direction.angle - int number of direction steps to offset the base direction.
public static int left(int d)
d - int base direction.
public static int right(int d)
d - int base direction.
public static int opp(int d)
d - int base direction
public GeoDirectionIterator iterator()
GeoDirectionIterator for this particular geometry.
GeoDirectionIterator appropriate
to this geometry.
public abstract Coordinate advance(Coordinate c,
int d)
c - Coordinate starting positiond - int direction of advance
public Coordinate advance(Coordinate c,
int d,
int angle)
c - Coordinate starting positiond - int direction of advance, used to offset the coordinate.angle - int offset to the given direction.
public Coordinate start()
public int startDir()
protected double cellVoffset()
protected double cellHoffset()
public void setTiling()
public void setRect(java.awt.Rectangle r)
r - Rectangle with the overall size of the canvas
on which the maze will be drawn.setTiling()
public java.awt.Polygon cellPoly(int x,
int y)
x - int horizontal coordinate of cell.y - int vertical coordinate of cell.
public java.awt.Polygon wallPoly(int x,
int y,
int dir)
Polygon p= wallPoly( x, y, dir );
drawLine( p.xpoints[0], p.ypoints[0], p.xpoints[1], p.ypoints[1] );
x - int horizontal coordinate of the cell.y - int vertical coordinate of the cell.dir - int direction of the wall.
public java.awt.Point wallP1(int x,
int y,
int dir)
x - int horizontal coordinate of the cell.y - int vertical coordinate of the cell.dir - int direction of the wall.
public java.awt.Point wallP2(int x,
int y,
int dir)
x - int horizontal coordinate of the cell.y - int vertical coordinate of the cell.dir - int direction of the wall.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||