de.caff.maze
Class CircularMaze

java.lang.Object
  extended by de.caff.maze.MazePropertyOwner
      extended by de.caff.maze.AbstractBasicMaze
          extended by de.caff.maze.CircularMaze
All Implemented Interfaces:
Maze

public class CircularMaze
extends AbstractBasicMaze

A circular maze consisting of cells in concentric rings. It is possible to create it with a center cell, no center cell or a hole in the center (a "e;ring"e;).

 

Nested Class Summary
 
Nested classes/interfaces inherited from class de.caff.maze.AbstractBasicMaze
AbstractBasicMaze.DoubleDelayedPropertyInformation, AbstractBasicMaze.IntegerDelayedPropertyInformation
 
Nested classes/interfaces inherited from class de.caff.maze.MazePropertyOwner
MazePropertyOwner.BooleanPropertyInformation, MazePropertyOwner.EnumPropertyInformation, MazePropertyOwner.InfoPropertyDisplay, MazePropertyOwner.IntegerPropertyInformation, MazePropertyOwner.PaintPropertyInformation
 
Field Summary
static int CENTER_CELL_ID
          Special id for center cell.
static java.lang.String MAZE_TYPE
          The type of this maze (for storage).
static java.lang.String PROPERTY_INNER_RADIUS
          Property key for the settable inner radius property.
static java.lang.String PROPERTY_NR_INNERMOST_RING
          Property key for the settable number of innermost rings property.
static java.lang.String PROPERTY_NR_RINGS
          Property key for the settable number of rings property.
 
Fields inherited from class de.caff.maze.AbstractBasicMaze
BOX_SIZE, PROPERTY_CREATION_TIME, PROPERTY_MAZE, PROPERTY_NUMBER_CELLS, PROPERTY_SEED, PROPERTY_SOLUTION_LENGTH, PROPERTY_WAY, PROPERTY_WAY_POINTS
 
Constructor Summary
CircularMaze(float centerRadius, int numFirstRing, int numRings)
          Create a circular maze.
 
Method Summary
protected  void doDraw(MazePainter painter, MazePaintPropertiesProvider properties)
          Do the actual drawing.
 MazeCell getCellByID(int id)
          Get the cell with the given id.
 MazeCell[] getCells()
          Get all cells of this maze.
protected  AbstractBasicMaze getGeometryClone()
          Get a deep copy of this maze geometry.
 java.awt.Insets getInsets(MazePaintPropertiesProvider properties, float scaling)
          Get the necessary insets depending on the paint properties.
 java.lang.String getMazeType()
          Get a internally used string describing the maze.
 int getNumCells()
          Get the number of cells of this maze.
protected  java.awt.Shape getOuterBorder()
          Get the shape of the outer border of this maze.
 float getPreferredAspectRatio()
          Get the preferred aspect ratio (width/height) for this maze.
 java.util.Collection<PropertyInformation> getPropertyInformations()
          Get the property setters and displays for this maze.
 boolean hasCenterCell()
          Has this maze a center cell?
 void loadPersistentData(DataStorage systemAccess)
          Load extra data defining the maze from the system access.
static void main(java.lang.String[] args)
          Test code.
 void recreateFromDelayedSetters()
          Recreate this maze from the setters which define the geometry.
 void reset()
          Forget all connections.
 void setDefaultWayPoints()
          Set some useful default way points.
 void storePersistentData(DataStorage systemAccess)
          Store extra data defining the maze to the system access.
 
Methods inherited from class de.caff.maze.AbstractBasicMaze
addMazeFinishedListener, arg2int, createMaze, createMaze, createMaze, draw, drawBackgroundAndWay, getCellAt, getClone, getCreationTimeMillis, getInfo, getSeed, getWay, getWayEnd, getWayStart, isDuringRecreation, loadSeedWayAndVersion, recreateMaze, removeMazeFinishedListener, setFromSetters, setProgressShower, setWayEnd, setWayPoints, setWayStart, solve, storeSeedWayAndVersion
 
Methods inherited from class de.caff.maze.MazePropertyOwner
addPropertyChangeListener, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAZE_TYPE

public static final java.lang.String MAZE_TYPE
The type of this maze (for storage).

See Also:
Constant Field Values

PROPERTY_INNER_RADIUS

public static final java.lang.String PROPERTY_INNER_RADIUS
Property key for the settable inner radius property.

See Also:
Constant Field Values

PROPERTY_NR_INNERMOST_RING

public static final java.lang.String PROPERTY_NR_INNERMOST_RING
Property key for the settable number of innermost rings property.

See Also:
Constant Field Values

PROPERTY_NR_RINGS

public static final java.lang.String PROPERTY_NR_RINGS
Property key for the settable number of rings property.

See Also:
Constant Field Values

CENTER_CELL_ID

public static final int CENTER_CELL_ID
Special id for center cell.

See Also:
Constant Field Values
Constructor Detail

CircularMaze

public CircularMaze(float centerRadius,
                    int numFirstRing,
                    int numRings)
Create a circular maze.

Parameters:
centerRadius - the radius of the center in units of ring thickness. There are 3 different cases:
  • The value is positive. This defines a maze with a circular center cell.
  • The value is zero. This defines a maze with no center cell, i.e. a maze where the inner ring cells are formed like pie slices.
  • The value is less than zero. This defines a maze with an empty center, i.e. a maze formed like a ring.
numFirstRing - number of cells in innermost ring
numRings - number of rings
Method Detail

getGeometryClone

protected AbstractBasicMaze getGeometryClone()
Get a deep copy of this maze geometry.

Specified by:
getGeometryClone in class AbstractBasicMaze
Returns:
deep copy

getMazeType

public java.lang.String getMazeType()
Get a internally used string describing the maze.

Specified by:
getMazeType in class AbstractBasicMaze
Returns:
maze type

getCells

public MazeCell[] getCells()
Get all cells of this maze.

Returns:
the maze cells

reset

public void reset()
Forget all connections.

Specified by:
reset in interface Maze
Overrides:
reset in class AbstractBasicMaze

doDraw

protected void doDraw(MazePainter painter,
                      MazePaintPropertiesProvider properties)
Do the actual drawing. The call to this method is embedded in the the calls to MazePainter.startPaintingMaze(Maze) and MazePainter.endPaintingMaze().

Specified by:
doDraw in class AbstractBasicMaze
Parameters:
painter - painter to draw to
properties - access to properties for drawing (colors etc)

getPreferredAspectRatio

public float getPreferredAspectRatio()
Get the preferred aspect ratio (width/height) for this maze.

Returns:
preferred aspect ratio

getInsets

public java.awt.Insets getInsets(MazePaintPropertiesProvider properties,
                                 float scaling)
Get the necessary insets depending on the paint properties. Usually the insets are necessary to allow for the thick border line to be drawn completely.

Parameters:
properties - paint properties
scaling - scaling used when painting
Returns:
insets

getNumCells

public int getNumCells()
Get the number of cells of this maze.

Returns:
the number of cells

getCellByID

public MazeCell getCellByID(int id)
Get the cell with the given id.

Parameters:
id - cell id
Returns:
the cell with the given id or null if there is no such cell
See Also:
MazeCell.getID()

hasCenterCell

public boolean hasCenterCell()
Has this maze a center cell?

Returns:
true: maze has center cell, else false

setDefaultWayPoints

public void setDefaultWayPoints()
Set some useful default way points.

Specified by:
setDefaultWayPoints in class AbstractBasicMaze

recreateFromDelayedSetters

public void recreateFromDelayedSetters()
Recreate this maze from the setters which define the geometry.

Specified by:
recreateFromDelayedSetters in class AbstractBasicMaze

getPropertyInformations

public java.util.Collection<PropertyInformation> getPropertyInformations()
Get the property setters and displays for this maze.

Overrides:
getPropertyInformations in class AbstractBasicMaze
Returns:
colletion of property setters

getOuterBorder

protected java.awt.Shape getOuterBorder()
Get the shape of the outer border of this maze.

Specified by:
getOuterBorder in class AbstractBasicMaze
Returns:
the shape defining the outer border

loadPersistentData

public void loadPersistentData(DataStorage systemAccess)
Load extra data defining the maze from the system access.

Parameters:
systemAccess - system access

storePersistentData

public void storePersistentData(DataStorage systemAccess)
Store extra data defining the maze to the system access.

Parameters:
systemAccess - system access

main

public static void main(java.lang.String[] args)
Test code.

Parameters:
args - unsued