Fix when path is drawn or before being animated

* Fix maze edition when path is drawn
* Clear the path before animating it
This commit is contained in:
regar42 committed 2018-01-14 18:00:45 +01:00
1 parent b1891f7118
commit a664c399ff
1 file changed
+2 -1
+2 -1
View File
@@ -178,6 +178,7 @@ public final class MazeDrawing extends JPanel implements MouseListener {
JOptionPane.showMessageDialog(this, JOptionPane.showMessageDialog(this,
"Click on the maze to see the shortest path evolve"); "Click on the maze to see the shortest path evolve");
pathCounter = 0; pathCounter = 0;
repaint();
} }
for (VertexInterface vertex : shortestPath) { for (VertexInterface vertex : shortestPath) {
@@ -204,7 +205,7 @@ public final class MazeDrawing extends JPanel implements MouseListener {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int boxRow = getBoxRow(e.getX()); int boxRow = getBoxRow(e.getX());
int boxLine = getBoxLine(e.getY()); int boxLine = getBoxLine(e.getY());
if (mazeApp.isPathDrawn() == 0) { if (mazeApp.isPathDrawn() != 1) {
// Don't do anything if there is no box where the mouse is // Don't do anything if there is no box where the mouse is
if (boxRow >= mazeApp.getModelDimensionX() if (boxRow >= mazeApp.getModelDimensionX()
|| boxLine >= mazeApp.getModelDimensionY()) { || boxLine >= mazeApp.getModelDimensionY()) {