From: leo Date: Fri, 19 Nov 2021 20:17:54 +0000 (+0100) Subject: Changed checks while create end/start node X-Git-Url: http://git.leonardobizzoni.com/?a=commitdiff_plain;h=40e6a49664b8b8fc49ef335667dbf0c4edc5000b;p=astar-visualizer Changed checks while create end/start node --- diff --git a/src/main/java/Main/Map.java b/src/main/java/Main/Map.java index 6b15afc..5a7fdc2 100644 --- a/src/main/java/Main/Map.java +++ b/src/main/java/Main/Map.java @@ -22,7 +22,7 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe private boolean running = false; private int size = 20; - int speed = 10; + int speed = 2; public Map() { this.setBackground(new Color(40, 40, 40)); @@ -127,7 +127,7 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe // If they both exist check if same node else move che start node else { - if (PathfinderUtils.isSameNode(node, PathfinderUtils.endNode)) { + if (PathfinderUtils.endNode != null && PathfinderUtils.isSameNode(node, PathfinderUtils.endNode)) { JOptionPane.showMessageDialog(null, "End node and start node can't be the same node", "Same node error", JOptionPane.ERROR_MESSAGE); return; @@ -161,7 +161,7 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe } // If they both exist check if same node else move the end node else { - if (PathfinderUtils.startNode != null && PathfinderUtils.endNode == null) { + if (PathfinderUtils.startNode !=null && PathfinderUtils.isSameNode(node, PathfinderUtils.startNode)) { JOptionPane.showMessageDialog(null, "End node and start node can't be the same node", "Same node error", JOptionPane.ERROR_MESSAGE); return; diff --git a/target/PathVisualizer-1.0-SNAPSHOT.jar b/target/PathVisualizer-1.0-SNAPSHOT.jar index 81eb8c0..b8d5142 100644 Binary files a/target/PathVisualizer-1.0-SNAPSHOT.jar and b/target/PathVisualizer-1.0-SNAPSHOT.jar differ diff --git a/target/classes/Main/Map.class b/target/classes/Main/Map.class index d0ad2d5..c18b509 100644 Binary files a/target/classes/Main/Map.class and b/target/classes/Main/Map.class differ diff --git a/target/surefire-reports/Main.AppTest.txt b/target/surefire-reports/Main.AppTest.txt index 49e3cc6..3aed947 100644 --- a/target/surefire-reports/Main.AppTest.txt +++ b/target/surefire-reports/Main.AppTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: Main.AppTest ------------------------------------------------------------------------------- -Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 s - in Main.AppTest +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.025 s - in Main.AppTest diff --git a/target/surefire-reports/TEST-Main.AppTest.xml b/target/surefire-reports/TEST-Main.AppTest.xml index bc761a0..595731f 100644 --- a/target/surefire-reports/TEST-Main.AppTest.xml +++ b/target/surefire-reports/TEST-Main.AppTest.xml @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@ - + @@ -31,7 +31,7 @@ - +