Amazing Mazes

Class MazeGenAdapter

java.lang.Object
  |
  +--MazeGenAdapter

public class MazeGenAdapter
extends java.lang.Object
implements MazeAdapter

The MazeGenAdapter class provides a neutral access mechnism to the MazeGen Maze object ... a gateway so-to-speak.

Because MazeGenAdapter implements the MazeAdapter interface, maze access is insulated from the physical maze object, allowing any number of mazes to be plugged into the project.

Version:
1.0 09/04/2000
Author:
Kevin Bridges ... Copyright (c) 2001
See Also:
MazeGen

Field Summary
private static int[] dirXlator_
          This array provides a translation between the "neutral" Direction indicator and MazeGen's standard directional bit masks.
private  Maze maze_
          The MazeGen Maze which we are wrapping.
private static int[] wallXlator_
          This array provides a translation between the "neutral" Direction indicator and MazeGen's directional wall bit masks.
 
Constructor Summary
MazeGenAdapter(Maze maze)
          Construct a MazeGenAdapter instance that wraps the supplied MazeGen Maze object.
 
Method Summary
(package private) static void ()
           
(package private) static void ()
           
static int dirXlator(Direction direction)
          This static method will tranlslate a "neutral" Direction indicator to MazeGen's standard directional bit mask (i.e.
 void erectWall(java.awt.Point cellLocation, Direction direction)
          This method will erect a wall in self's maze, at the supplied cellLocation, facing the supplied direction.
 java.awt.Point getEndingCoord()
          This method will return the ending coordinate of self's maze (i.e.
 java.awt.Point getStartingCoord()
          This method will return the starting coordinate of self's maze (i.e.
 boolean passagewayOpenAt(java.awt.Point cellLocation, Direction direction)
          This method will return a true/false indicator as to whether the passageway (within self's maze) at the supplied cellLocation/direction is open or not.
 void visualizeAdvance(java.awt.Point cellLocation, Direction direction)
          This method will visualize an advancement move within self's maze at the supplied cellLocation and direction.
 void visualizeRetreat(java.awt.Point cellLocation, Direction direction)
          This method will visualize a retreat move within self's maze at the supplied cellLocation and direction.
static int wallXlator(Direction direction)
          This static method will tranlslate a "neutral" Direction indicator to MazeGen's directional wall bit mask (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

maze_

private Maze maze_
The MazeGen Maze which we are wrapping.

dirXlator_

private static final int[] dirXlator_
This array provides a translation between the "neutral" Direction indicator and MazeGen's standard directional bit masks. This xlator is keyed by the "neutral" Direction, and it's value is the MazeGen bit mask.

wallXlator_

private static final int[] wallXlator_
This array provides a translation between the "neutral" Direction indicator and MazeGen's directional wall bit masks. This xlator is keyed by the "neutral" Direction, and it's value is the MazeGen wall bit mask.
Constructor Detail

MazeGenAdapter

public MazeGenAdapter(Maze maze)
Construct a MazeGenAdapter instance that wraps the supplied MazeGen Maze object.
Parameters:
maze - the MazeGen Maze which we are wrapping.
Method Detail

getStartingCoord

public java.awt.Point getStartingCoord()
This method will return the starting coordinate of self's maze (i.e. the cell from which we will start from).
Specified by:
getStartingCoord in interface MazeAdapter
Returns:
the starting coordinate of self's maze.

getEndingCoord

public java.awt.Point getEndingCoord()
This method will return the ending coordinate of self's maze (i.e. the goal cell to traverse too).
Specified by:
getEndingCoord in interface MazeAdapter
Returns:
the ending coordinate of self's maze.

passagewayOpenAt

public boolean passagewayOpenAt(java.awt.Point cellLocation,
                                Direction direction)
This method will return a true/false indicator as to whether the passageway (within self's maze) at the supplied cellLocation/direction is open or not.
Specified by:
passagewayOpenAt in interface MazeAdapter
Parameters:
cellLocation - the maze cell coordinate that is to be checked.
direction - the direction within the cellLocation that is to be checked.
Returns:
true if the passageway (within self's maze) at the supplied cellLocation/direction is open, otherwise return false.

visualizeAdvance

public void visualizeAdvance(java.awt.Point cellLocation,
                             Direction direction)
This method will visualize an advancement move within self's maze at the supplied cellLocation and direction. An advancement move (depending on the maze) can be visualized differently than a retreat move ... say by a different color. If this is done, then the animation will picture dead-end moves more distinctly.
Specified by:
visualizeAdvance in interface MazeAdapter
Parameters:
cellLocation - the maze cell coordinate that is the start of the advancment.
direction - the direction within the cellLocation that we are to move.

visualizeRetreat

public void visualizeRetreat(java.awt.Point cellLocation,
                             Direction direction)
This method will visualize a retreat move within self's maze at the supplied cellLocation and direction. An retreat move (depending on the maze) can be visualized differently than an advancment move ... say by a different color. If this is done, then the animation will picture dead-end moves more distinctly.
Specified by:
visualizeRetreat in interface MazeAdapter
Parameters:
cellLocation - the maze cell coordinate that is the start of the retreat.
direction - the direction within the cellLocation that we are to move.

erectWall

public void erectWall(java.awt.Point cellLocation,
                      Direction direction)
This method will erect a wall in self's maze, at the supplied cellLocation, facing the supplied direction.

The context in which this is used is to NOT visualize a physical wall within the maze, but rather to close the wall that has been traversed ... in order to prevent advancment back where we came from.

 Logic Flow:
   1. No-op if supplied direction is not one of the four directional
      indicators.
   2. Logically-Or the wall bitmask to erect the wall in the specified 
      direction.
   Processing End (erectWall)
 
Specified by:
erectWall in interface MazeAdapter
Parameters:
cellLocation - the maze cell coordinate where the wall is to be erected.
direction - the direction within the cellLocation where the wall is to be erected.

dirXlator

public static int dirXlator(Direction direction)
This static method will tranlslate a "neutral" Direction indicator to MazeGen's standard directional bit mask (i.e. Maze.NORTH, Maze.SOUTH, Maze.EAST, Maze.WEST).
Parameters:
direction - the neutral direction to translate.
Returns:
MazeGen's standard directional bit mask, cooresponding to the supplied "neutral" direction.

wallXlator

public static int wallXlator(Direction direction)
This static method will tranlslate a "neutral" Direction indicator to MazeGen's directional wall bit mask (i.e. Maze.N_WALL, Maze.S_WALL, Maze.E_WALL, Maze.W_WALL).
Parameters:
direction - the neutral direction to translate.
Returns:
MazeGen's directional wall bit mask, cooresponding to the supplied "neutral" direction.

static void ()

static void ()

Author: Andrew Bridges
Copyright © 2001