de.caff.maze
Class MazeTool

java.lang.Object
  extended by de.caff.maze.MazeTool

public abstract class MazeTool
extends java.lang.Object

Create mazes and find ways.

 

Field Summary
static int LATEST_VERSION
          Constant to be used for access to the latest maze tool version.
static java.lang.String MESSAGE_CREATING
          I18n resource for creation message.
 
Constructor Summary
MazeTool()
           
 
Method Summary
 boolean createMaze(Maze maze, ProgressShower progressShower)
          Create a maze with the current time as random number seed.
abstract  boolean createMaze(Maze maze, ProgressShower progressShower, long seed)
          Create a maze with the given random number seed.
static int getCurrentMazeAlgorithmVersion()
          Get the current version of the maze tool.
static MazeTool getMazeTool()
          Get the current (latest) version of the maze tool.
static MazeTool getMazeTool(int version)
          Get a special version of a maze tool.
protected static boolean setProgress(ProgressShower progressShower, int value)
          Set the progress display if a progress shower is given.
static java.util.Collection<MazeCell> solveMaze(MazeCell from, MazeCell to)
          Find a way from one cell of a maze to another.
protected static void startProgress(ProgressShower progressShower, int size)
          Start the progress display if a progress shower is given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSAGE_CREATING

public static final java.lang.String MESSAGE_CREATING
I18n resource for creation message.

See Also:
Constant Field Values

LATEST_VERSION

public static final int LATEST_VERSION
Constant to be used for access to the latest maze tool version.

See Also:
Constant Field Values
Constructor Detail

MazeTool

public MazeTool()
Method Detail

getMazeTool

public static MazeTool getMazeTool(int version)
Get a special version of a maze tool. This is thought for backward compatibility of maze files.

Parameters:
version - tool version
Returns:
matching tool or null if there is no such version

getMazeTool

public static MazeTool getMazeTool()
Get the current (latest) version of the maze tool.

Returns:
current maze tool

getCurrentMazeAlgorithmVersion

public static int getCurrentMazeAlgorithmVersion()
Get the current version of the maze tool.

Returns:
current version id

createMaze

public boolean createMaze(Maze maze,
                          ProgressShower progressShower)
Create a maze with the current time as random number seed.

Parameters:
maze - maze geometry info
progressShower - progress display (may be null)
Returns:
true: maze was created, false: user canceled the creation

createMaze

public abstract boolean createMaze(Maze maze,
                                   ProgressShower progressShower,
                                   long seed)
Create a maze with the given random number seed.

Parameters:
maze - maze geometry info
progressShower - progress display (may be null)
seed - random number seed
Returns:
true: maze was created, false: user canceled the creation

solveMaze

public static java.util.Collection<MazeCell> solveMaze(MazeCell from,
                                                       MazeCell to)
Find a way from one cell of a maze to another.

Parameters:
from - cell where the way starts
to - cell where the way ends
Returns:
the resulting way (including from and to) or null if there is no way between the cells

startProgress

protected static void startProgress(ProgressShower progressShower,
                                    int size)
Start the progress display if a progress shower is given.

Parameters:
progressShower - progress shower or null
size - progress complete size

setProgress

protected static boolean setProgress(ProgressShower progressShower,
                                     int value)
Set the progress display if a progress shower is given.

Parameters:
progressShower - progress shower or null
value - current progress value
Returns:
true if the user aborted the creation, otherwise false