|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.caff.maze.MazePropertyOwner
de.caff.maze.AbstractBasicMaze
public abstract class AbstractBasicMaze
The abstract basis for a maze. This class defines a lot of useful stuff common to all mazes. The live cycle of a maze mainly falls in three parts:
![]() |
![]() |
![]() |
![]() |
Nested Class Summary | |
---|---|
protected static class |
AbstractBasicMaze.DoubleDelayedPropertyInformation
A delayed setter for double values. |
protected static class |
AbstractBasicMaze.IntegerDelayedPropertyInformation
A delayed setter for integer values. |
Nested classes/interfaces inherited from class de.caff.maze.MazePropertyOwner |
---|
MazePropertyOwner.BooleanPropertyInformation, MazePropertyOwner.EnumPropertyInformation, MazePropertyOwner.InfoPropertyDisplay, MazePropertyOwner.IntegerPropertyInformation, MazePropertyOwner.PaintPropertyInformation |
Field Summary | |
---|---|
static float |
BOX_SIZE
The size of the box to which the maze is drawn. |
static java.lang.String |
PROPERTY_CREATION_TIME
The property used when the time needed for the creation is newly calculated. |
static java.lang.String |
PROPERTY_MAZE
The property used when the maze changes. |
static java.lang.String |
PROPERTY_NUMBER_CELLS
The property used when the number of cells is changed. |
static java.lang.String |
PROPERTY_SEED
The property used when the seed changes. |
static java.lang.String |
PROPERTY_SOLUTION_LENGTH
The property used when the length of the solution chnages. |
static java.lang.String |
PROPERTY_WAY
The property used when the way changes. |
static java.lang.String |
PROPERTY_WAY_POINTS
The property used when the way points (start and/or end) changes. |
Constructor Summary | |
---|---|
protected |
AbstractBasicMaze()
Default constructor. |
Method Summary | |
---|---|
void |
addMazeFinishedListener(MazeFinishedListener listener)
Add a maze finished listener which is called when the maze (re)creation is finished. |
static int |
arg2int(java.lang.String[] args,
int arg,
int defaultValue)
Helper method creating an int value from a string from an array, used in test code in main() methods of extending classes. |
void |
createMaze()
Create the maze with a random seed. |
void |
createMaze(long randomSeed)
Create a maze with the given randomSeed. |
void |
createMaze(long randomSeed,
int version)
Create a maze with the given randomSeed using a special version of the creation algorithm. |
protected abstract void |
doDraw(MazePainter painter,
MazePaintPropertiesProvider properties)
Do the actual drawing. |
void |
draw(MazePainter painter,
MazePaintPropertiesProvider properties)
Draw this maze. |
protected void |
drawBackgroundAndWay(MazePainter painter,
MazePaintPropertiesProvider properties)
Draws the background. |
MazeCell |
getCellAt(java.awt.geom.Point2D position)
Get the cell at a given point. |
AbstractBasicMaze |
getClone()
Get a clone of this maze. |
long |
getCreationTimeMillis()
Get the creation time of this maze. |
protected abstract AbstractBasicMaze |
getGeometryClone()
Get a deep copy of this maze geometry. |
java.lang.String |
getInfo(boolean onlyVariable)
|
abstract java.lang.String |
getMazeType()
Get a internally used string describing the maze type. |
protected abstract java.awt.Shape |
getOuterBorder()
Get the borders of the maze as a shape. |
java.util.Collection<PropertyInformation> |
getPropertyInformations()
Get the property setters and displays for this maze. |
long |
getSeed()
Get the seed which with the current maze is created. |
java.util.Collection<MazeCell> |
getWay()
Get the solution way. |
MazeCell |
getWayEnd()
Get the end cell of the way. |
MazeCell |
getWayStart()
Get the start cell of the way. |
boolean |
isDuringRecreation()
Is a recreation running? |
protected void |
loadSeedWayAndVersion(DataStorage dataStorage,
java.lang.String prefix)
Load the seed and way points from the given data storage. |
protected abstract void |
recreateFromDelayedSetters()
This is called during the call of AbstractBasicMaze.setFromSetters()
and should be used to recreate the geometry of the maze from
the setters of the geometric properties. |
protected void |
recreateMaze()
Recreate the maze with the current seed. |
void |
removeMazeFinishedListener(MazeFinishedListener listener)
Remove a maze finished listener which was called when the maze (re)creation is finished. |
void |
reset()
Resets the internal data. |
abstract void |
setDefaultWayPoints()
Set some useful default way points. |
void |
setFromSetters()
Set all values from the setters of the maze, than recreate it. |
void |
setProgressShower(ProgressShower progressShower)
Set the progress shower which is called during maze creation. |
void |
setWayEnd(MazeCell end)
Set the end cell of the way. |
void |
setWayPoints(MazeCell start,
MazeCell end)
Set the way start and end points. |
void |
setWayStart(MazeCell start)
Set the start cell of the way. |
protected void |
solve()
Solve this maze. |
protected void |
storeSeedWayAndVersion(DataStorage dataStorage,
java.lang.String prefix)
Store the seed and way points to the given data storage. |
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 |
Methods inherited from interface de.caff.maze.Maze |
---|
getCellByID, getCells, getInsets, getPreferredAspectRatio, loadPersistentData, storePersistentData |
Field Detail |
---|
public static final float BOX_SIZE
public static final java.lang.String PROPERTY_MAZE
public static final java.lang.String PROPERTY_WAY_POINTS
public static final java.lang.String PROPERTY_WAY
public static final java.lang.String PROPERTY_SEED
public static final java.lang.String PROPERTY_NUMBER_CELLS
public static final java.lang.String PROPERTY_SOLUTION_LENGTH
public static final java.lang.String PROPERTY_CREATION_TIME
Constructor Detail |
---|
protected AbstractBasicMaze()
Method Detail |
---|
protected abstract AbstractBasicMaze getGeometryClone()
public AbstractBasicMaze getClone()
public boolean isDuringRecreation()
true
during a recreation phaseprotected void solve()
AbstractBasicMaze.setWayPoints(MazeCell, MazeCell)
,
AbstractBasicMaze.setWayStart(MazeCell)
,
AbstractBasicMaze.getWayStart()
,
AbstractBasicMaze.setWayEnd(MazeCell)
,
AbstractBasicMaze.getWayEnd()
,
AbstractBasicMaze.getWay()
public void setWayPoints(MazeCell start, MazeCell end)
start
- way startend
- way endpublic void setWayStart(MazeCell start)
setWayStart
in interface Maze
start
- start cellpublic void setWayEnd(MazeCell end)
setWayEnd
in interface Maze
end
- end cellpublic MazeCell getWayStart()
public MazeCell getWayEnd()
public java.util.Collection<MazeCell> getWay()
null
if there is no solutionpublic void reset()
reset
in interface Maze
public void createMaze()
createMaze
in interface Maze
protected void recreateMaze()
public void setFromSetters()
AbstractBasicMaze.recreateFromDelayedSetters()
public void setProgressShower(ProgressShower progressShower)
progressShower
- progress showerprotected abstract void recreateFromDelayedSetters()
AbstractBasicMaze.setFromSetters()
and should be used to recreate the geometry of the maze from
the setters of the geometric properties.
public void createMaze(long randomSeed)
createMaze
in interface Maze
randomSeed
- random randomSeedpublic void createMaze(long randomSeed, int version)
randomSeed
- random randomSeedversion
- maze creation algorithm versionpublic long getSeed()
public long getCreationTimeMillis()
public static int arg2int(java.lang.String[] args, int arg, int defaultValue)
main()
methods of extending classes.
args
- array of stringsarg
- index into the arraydefaultValue
- value to return if args[arg]
is not defining an int
args[arg]
or the default valuepublic abstract void setDefaultWayPoints()
public abstract java.lang.String getMazeType()
protected void drawBackgroundAndWay(MazePainter painter, MazePaintPropertiesProvider properties)
draw
routine, before any
borders are drawn, but after the shapes are (re)created.
painter
- painter to draw toproperties
- graphical maze propertiesprotected abstract void doDraw(MazePainter painter, MazePaintPropertiesProvider properties)
MazePainter.startPaintingMaze(Maze)
and
MazePainter.endPaintingMaze()
.
painter
- painter to draw toproperties
- access to properties for drawing (colors etc)public void draw(MazePainter painter, MazePaintPropertiesProvider properties)
draw
in interface Maze
painter
- painter to draw toproperties
- access to properties for drawing (colors etc)public MazeCell getCellAt(java.awt.geom.Point2D position)
getCellAt
in interface Maze
position
- cell position
null
if there is no cell at the given positionpublic java.lang.String getInfo(boolean onlyVariable)
protected abstract java.awt.Shape getOuterBorder()
public java.util.Collection<PropertyInformation> getPropertyInformations()
getPropertyInformations
in class MazePropertyOwner
protected void loadSeedWayAndVersion(DataStorage dataStorage, java.lang.String prefix)
dataStorage
- data storage to load fromprefix
- key prefix unique for each mazeprotected void storeSeedWayAndVersion(DataStorage dataStorage, java.lang.String prefix)
dataStorage
- data storage to load fromprefix
- key prefix unique for each mazepublic void addMazeFinishedListener(MazeFinishedListener listener)
addMazeFinishedListener
in interface Maze
listener
- listener to addpublic void removeMazeFinishedListener(MazeFinishedListener listener)
removeMazeFinishedListener
in interface Maze
listener
- listener to remove
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |