Package de.caff.maze

Various classes for mace creation.

See:
          Description

Interface Summary
Constants  
DataStorage An interface for temporary or persistent storage of data.
Maze Basic interface of a Maze.
MazeFinishedListener A listener which is informed when a maze has finished its creation.
MazePainter Interface for generalized painting, allowing easier conversion to vector formats.
MazePaintPropertiesProvider Interface of objects which know how a maze is painted.
MazePrintPropertiesProvider Provider for informations on how to print a maze.
MazeSaveImagePropertiesProvider Provider for informations on how to print a maze.
OutputMazePainterCreator Simple creator for maze painters.
ProgressShower  
PropertyInformation Information about a property.
SystemAccess Allow access to the underlying system for storage of persisitent data, file access and printing.
 

Class Summary
AbstractBasicMaze The abstract basis for a maze.
AbstractBasicMaze.DoubleDelayedPropertyInformation A delayed setter for double values.
AbstractBasicMaze.IntegerDelayedPropertyInformation A delayed setter for integer values.
AbstractPropertyInformation Basic implementation of a PropertyInformation.
ApplicationSystemAccess System access if running as an application.
CircularMaze A circular maze consisting of cells in concentric rings.
DiamondMaze A rectangular maze with diamond shaped cells.
DxfMazePainter Painter which outputs the maze into a DXF file.
FileDataStorage Data storage using a system access.
Graphics2DMazePainter The standard maze painter which paints everything to a Graphics2D object.
HexagonalMaze Maze with hexagonal cells, while the complete maze tries to be rectangular which better fits on screen and paper.
JnlpSystemAccess System access when running under Java WebStart.
LongTextField Text field useful to input a long integer.
MazeCanvas A canvas for maze display (including progress display if creation takes too long).
MazeCell Basic class describing a cell in a maze.
MazeFrame The main window of a simple maze application.
MazePaintProperties Properties describing how a maze is painted.
MazePrintProperties Properties describing how a maze is painted.
MazePropertyOwner Something which knows about maze properties.
MazePropertyOwner.BooleanPropertyInformation A boolean property and its setters.
MazePropertyOwner.EnumPropertyInformation An enumerated property and its setters.
MazePropertyOwner.InfoPropertyDisplay Display of a purely informational property.
MazePropertyOwner.IntegerPropertyInformation An integer property and its setters.
MazePropertyOwner.PaintPropertyInformation A color property and its setters.
MazeResourceBundle I18n default resource bundle: English.
MazeResourceBundle_de I18n resource bundle for German language.
MazeSaveImageProperties Properties describing how a maze is painted.
MazeTool Create mazes and find ways.
MultiMazeControlPanel A control panel able to handle different mazes.
NullSystemAccess A minimalist system access which does not actually access the system.
OctogonalMaze A maze with octogonal cells and smaller square cells in a checker board pattern.
PrintPropertiesDialog Dialog for print properties.
PropertySetterPanel Panel to display various properties and their setters.
RectangularMaze A rectangular maze with square cells.
SaveImagePropertiesDialog Dialog for print properties.
Stringizer Makes strings from values and vice versa.
SvgMazePainter Painter which outputs the maze into an SVG file.
SystemAccess.FileType Just a file extension and the resource for a description of the type it defines.
TemporaryDataStorage Data storage which has no access to the system.
TriangularMaze A maze with triangular shape, consisting of triangular cells.
 

Enum Summary
MazePainter.PaintObjectType The current state of painting.
MazePrintPropertiesProvider.BlowUpFactor A factor describing on how many pages the maze is drawn.
 

Package de.caff.maze Description

Various classes for mace creation.

Package Specification

The classes of this package form the building blocks of the maze creation tool irrGardener.

There are classes with different purposes. The main categories are:

Maze Description

In this category there are classes which describe how mazes are build. All maze types provided by this program have in common that they

All mazes have to implement the Maze interface, and at the moment all implemented mazes even extend AbstractBasicMaze. The mazes implemented are:

As said all mazes consist of cells which have to be extensions of MazeCell. Because MazeCells provide knowledge which cells are their neighbours the creation of a maze can be abstracted. After the creation is finished the knowledge which cells are connected is enough abstraction to find a way from one cell to any other

Maze Creation

The maze cell abstraction described in the previous paragraph is enough to allow creation and solving indepently from the maze type. Both algorithms are implemented in MazeTool.

The algoritm for maze creation is based on the fact that each maze cell belongs to a set. In the very beginning (when no cells are connected), each cell is in a set of its own. Now the algorithm picks a cell and a neighbour of it randomly, connect them and unite their sets, so that they are in the same set (now containing 2 cells). It goes on doing so, but now two things can happen:

  1. The cell and/or the neighbor are in different sets which already contain more than 1 element:
    this is no problem at all, as before the cells are connected and the sets are united
  2. The cell and the neighbor already belong to the same set.
    In this case nothing happens, because belonging to the same set means that they are already connected, even if they are not connected directly. Understanding this point (that being in the same set is the same as being connected) is the crucial step in understanding the algorithm.

At a given point (when various cells are already connected, but still not all) the algorithm is changed because selecting a cell and a neighbor at random now quite often result in point 2 above: they are already in the same set, so nothing happens and the random choice has to start again. Instead a set is chosen randomly, and starting from a random cell in the set the algorithm looks for a neighbour which does not already belong to the current set. In this case the neighbour is connected, both sets are united and everything starts again: choose a set at random, start for a random cell and look for unconnected neighbors...

Handling Properties

Mazes of the same type can have different properties like number of cells (often determined by a number of horizontal and a number of vertical cells) and other geometric properties. And all mazes can be painted differently (colors, linestyle).

To handle the first kind of properties a has a collection of PropertyInformations which tell which properties are defined and know how to provide a setter for each setable property. There are various implementations including AbstractPropertyInformation and several inner classes of MazePropertyOwner.

The second kind of properties are handled by the MazePaintProperties interface and the extending interface MazePrintProperties and their implementations like MazePaintPropertiesProvider and MazePrintPropertiesProvider.

System Abstraction

Because the program shall be runnable as an application, an applet (currently not implemented) and via Java Web Start it's helpful to abstract from the underlying system to allow preference saving and restoring, saving and loading of mazes and printing.

The underlying system is abstracted by DataStorage (for access to preferences) and the extending interface SystemAccess which adds access to the printer and files. Implementation of the former are FileDataStorage (saving preferences to a file) and TemporaryDataStorage (which does store preferences only internally during the runtime of the program to provide a fallback). The latter has implementations ApplicationSystemAccess (standard access when running as an application), JnlpSystemAccess (system access via JNLP/Java Web Start) and NullSystemAccess (which does not access any system, acting as a fallback).

Miscellaneous

Most of the classes not mentioned yet fall are Swing classes which are used to pack everything together:

Finally there are some helpers: