maze
Class MazeWindow
- public class MazeWindow
- extends JFrame
Title: Maze Window
Description: A View-Control design pattern that shows the maze and implements the control to perform various operations on a maze
Copyright: Copyright (c) 2002
Company:
- Version:
- 1.0
- Author:
- Zoran Budimlic
maze
Maze maze
- The Maze for which this View is set up
ROWS
int ROWS
- Number of rows in the maze
COLS
int COLS
- Number of coloumns in the maze
xStart
int xStart
- The X coordinate of the starting point for drawing the maze
xEnd
int xEnd
- The X coordinate of the end point for drawing the maze
yStart
int yStart
- The Y coordinate of the starting point for drawing the maze
yEnd
int yEnd
- The Y coordinate of the end point for drawing the maze
dx
int dx
- The cell size on the X axis in pixels
dy
int dy
- The cell size on the Y axis in pixels
PAUSE_MS
int PAUSE_MS
- The amount of time (in miliseconds) to pause when the pause() method is called
paint
public void paint(Graphics g)
- Draw the maze on the panel.
- Parameters:
g
- The Graphics object on which to draw
getColor
private Color getColor(int x,
int y)
- Compute the appropriate color for the cell in the maze based on the status of the cell. If the cell is not visited, the color will be green, if it is on the path, the color will be red, if it is abandoned, the color will be gray
- Parameters:
x
- The X coordinate of the cell
y
- The Y coordinate of the cell
- Returns:
NewMaze_actionPerformed
void NewMaze_actionPerformed(ActionEvent e)
- What happends when the user does something with the New button
- Parameters:
e
-
ClearMaze_actionPerformed
void ClearMaze_actionPerformed(ActionEvent e)
- What happends when the user does something with the Clear button
- Parameters:
e
- The event (click) that is being dispatched
DepthFirst_actionPerformed
void DepthFirst_actionPerformed(ActionEvent e)
- What happends when the user does something with the DepthFirst button
- Parameters:
e
- The event (click) that is being dispatched
BreadthFirst_actionPerformed
void BreadthFirst_actionPerformed(ActionEvent e)
- What happends when the user does something with the BreadthFirst button
- Parameters:
e
- The event (click) that is being dispatched
AStar_actionPerformed
void AStar_actionPerformed(ActionEvent e)
- What happends when the user does something with the A* button
- Parameters:
e
- The event (click) that is being dispatched
SetSize_actionPerformed
void SetSize_actionPerformed(ActionEvent e)
- What happends when the user chooses the Set Size menu item
- Parameters:
e
- The event that is being dispatched
refresh
public void refresh(int x,
int y)
- Refresh the cell in the maze. This method should be called whenever the user changes the status of a cell. It will repaint the cell and the wall(s) around it.
- Parameters:
x
- The X coordinate of the cell
y
- The Y coordinate of the cell
refreshAndRepaint
public void refreshAndRepaint(int x,
int y)
- Refresh and repaint the cell in the maze. This method will not only refresh the given cell in the maze, but it will also pause the maze thread so that the user interface can redraw the maze
- Parameters:
x
- The X coordinate of the cell
y
- The Y coordinate of the cell
setMazeSize
public void setMazeSize(int x,
int y)
- Set the maze dimensions. Recompute the drawing borders and cell dimensions in pixels.
- Parameters:
x
- The new X dimension
y
- The new Y dimension