diff --git a/src/model/MazeAppModel.java b/src/model/MazeAppModel.java index e0be3d1..b782287 100644 --- a/src/model/MazeAppModel.java +++ b/src/model/MazeAppModel.java @@ -36,6 +36,10 @@ public class MazeAppModel extends Observable { return maze; } + public ArrayList getShortest() { + return shortest; + } + public boolean isModified() { return modified; } diff --git a/src/ui/MazeApp.java b/src/ui/MazeApp.java index 03f00ef..48c6256 100644 --- a/src/ui/MazeApp.java +++ b/src/ui/MazeApp.java @@ -41,17 +41,4 @@ public class MazeApp extends JFrame System.out.println("New maze detected"); windowPanel.notifyForUpdates(param); } - - public void paintShortestPath(Graphics2D g, int width, int height) { - - g.setColor(Color.ORANGE); - int dimensionX = maze.getDimensionX(); - int dimensionY = maze.getDimensionY(); - int boxWidth = width/dimensionX; - int boxHeight = height/dimensionY; - for (VertexInterface vertex : shortest) { - EBox box = (EBox) vertex; - g.fillOval(box.getX()*boxHeight, box.getY()*boxWidth, boxWidth, boxHeight); - } - } } diff --git a/src/ui/MazeDrawing.java b/src/ui/MazeDrawing.java index 2a83fe1..ce96b79 100644 --- a/src/ui/MazeDrawing.java +++ b/src/ui/MazeDrawing.java @@ -7,6 +7,8 @@ import java.awt.Graphics2D; import java.awt.GridLayout; import javax.swing.JPanel; import maze.Maze; +import maze.EBox; +import dijkstra.VertexInterface; public class MazeDrawing extends JPanel { @@ -38,4 +40,17 @@ public class MazeDrawing extends JPanel { this.repaint(); } } + + public void paintShortestPath(Graphics2D g, int width, int height) { + + g.setColor(Color.ORANGE); + int dimensionX = mazeApp.getMazeAppModel().getMaze().getDimensionX(); + int dimensionY = mazeApp.getMazeAppModel().getMaze().getDimensionY(); + int boxWidth = width / dimensionX; + int boxHeight = height / dimensionY; + for (VertexInterface vertex : mazeApp.getMazeAppModel().getShortest()) { + EBox box = (EBox) vertex; + g.fillOval(box.getX()*boxWidth, box.getY()*boxHeight, boxWidth, boxHeight); + } + } }