model: * Add getShortest() to MazeAppModel, which returns the list of vertexes on the shortest path from departure to arrival ui: * Move paintShortestPath from MazeApp to MazeDrawing * Fix a bug in paintShortestPath where a switch between width and height caused ellipses to be mislocated (probably still the same confusion between the x and y axes)
45 lines
892 B
Java
45 lines
892 B
Java
package ui;
|
|
|
|
import javax.swing.*;
|
|
import maze.Maze;
|
|
import model.MazeAppModel;
|
|
import maze.EBox;
|
|
|
|
import java.util.Observable;
|
|
import java.util.Observer;
|
|
|
|
public class MazeApp extends JFrame
|
|
implements Observer {
|
|
|
|
private final MazeMenuBar mazeMenuBar;
|
|
private final WindowPanel windowPanel;
|
|
private MazeAppModel mazeAppModel;
|
|
|
|
public MazeApp() {
|
|
|
|
super("Maze Solving Application");
|
|
|
|
this.mazeAppModel = new MazeAppModel();
|
|
mazeAppModel.addObserver(this);
|
|
|
|
setJMenuBar(mazeMenuBar = new MazeMenuBar(this));
|
|
setContentPane(windowPanel = new WindowPanel(this));
|
|
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
pack();
|
|
setVisible(true);
|
|
}
|
|
|
|
public MazeAppModel getMazeAppModel() {
|
|
return mazeAppModel;
|
|
}
|
|
|
|
@Override
|
|
public void update(Observable obs, Object param) {
|
|
|
|
System.out.println("New maze detected");
|
|
windowPanel.notifyForUpdates(param);
|
|
}
|
|
}
|