Add UI to the project #29

Manually merged
regar42 merged 45 commits from mvc into master 2018-01-03 11:03:09 +00:00
3 changed files with 19 additions and 13 deletions
Showing only changes of commit 1e934b05e6 - Show all commits

No files matched your search

+4
View File
@@ -36,6 +36,10 @@ public class MazeAppModel extends Observable {
return maze; return maze;
} }
public ArrayList<VertexInterface> getShortest() {
return shortest;
}
public boolean isModified() { public boolean isModified() {
return modified; return modified;
} }
-13
View File
@@ -41,17 +41,4 @@ public class MazeApp extends JFrame
System.out.println("New maze detected"); System.out.println("New maze detected");
windowPanel.notifyForUpdates(param); 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);
}
}
} }
+15
View File
@@ -7,6 +7,8 @@ import java.awt.Graphics2D;
import java.awt.GridLayout; import java.awt.GridLayout;
import javax.swing.JPanel; import javax.swing.JPanel;
import maze.Maze; import maze.Maze;
import maze.EBox;
import dijkstra.VertexInterface;
public class MazeDrawing extends JPanel { public class MazeDrawing extends JPanel {
@@ -38,4 +40,17 @@ public class MazeDrawing extends JPanel {
this.repaint(); 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);
}
}
} }