]> git.leonardobizzoni.com Git - astar-visualizer/commitdiff
Removed static variables
authorLeonardoBizzoni <leo2002714@gmail.com>
Sun, 8 Aug 2021 07:07:25 +0000 (09:07 +0200)
committerLeonardoBizzoni <leo2002714@gmail.com>
Sun, 8 Aug 2021 07:07:25 +0000 (09:07 +0200)
15 files changed:
src/main/java/Main/AStar.java
src/main/java/Main/Map.java
target/PathVisualizer-1.0-SNAPSHOT.jar
target/classes/Main/AStar.class
target/classes/Main/App.class
target/classes/Main/Map.class
target/classes/Main/Node.class
target/classes/Main/PathfinderUtils.class
target/maven-archiver/pom.properties
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
target/surefire-reports/Main.AppTest.txt
target/surefire-reports/TEST-Main.AppTest.xml
target/test-classes/Main/AppTest.class

index 1625baf6c557db84969a8d873c776081cefb2754..e86a96796497194af6495ed7570deb89c9b2889d 100644 (file)
@@ -15,8 +15,8 @@ public class AStar{
     
     public void searchPath(Node parent) {
         for (int i = 0; i < 4; i++) {
-            x = (int) Math.round(parent.getX() + (-map.size* Math.cos((Math.PI / 2) * i)));
-            y = (int) Math.round(parent.getY() + (-map.size* Math.sin((Math.PI / 2) * i)));
+            x = (int) Math.round(parent.getX() + (-map.getNodeSize()* Math.cos((Math.PI / 2) * i)));
+            y = (int) Math.round(parent.getY() + (-map.getNodeSize() * Math.sin((Math.PI / 2) * i)));
 
             calculateOpenNode(x, y, parent);
         }
@@ -27,12 +27,12 @@ public class AStar{
         PathfinderUtils.closedNodes.add(parent);
         PathfinderUtils.openNodes.remove(parent);
 
-        if (!map.isFinished)
+        if (!map.isFinished())
             searchPath(parent);
     }
 
     public void calculateOpenNode(int nextX, int nextY, Node parent) {
-        if (nextX >= Map.width || nextY >= Map.height || nextX < 0 || nextY < 0)
+        if (nextX >= map.getWidth() || nextY >= map.getHeight() || nextX < 0 || nextY < 0)
             return;
         if (PathfinderUtils.locateBarrier(nextX, nextY) != -1)
             return;
@@ -42,8 +42,8 @@ public class AStar{
             PathfinderUtils.endNode.setParentNode(parent);
 
             PathfinderUtils.drawPath();
-            map.isFinished = true;
-            map.running = false;
+            map.setFinished(true);
+            map.setRunning(false);
             map.repaint();
             return;
         }
@@ -68,9 +68,9 @@ public class AStar{
         int g = parent.getG();
 
         if (gx != 0 && gy != 0) {
-            g += (int) (Math.sqrt(2 * (Math.pow(map.size, 2))));
+            g += (int) (Math.sqrt(2 * (Math.pow(map.getNodeSize(), 2))));
         } else {
-            g += map.size;
+            g += map.getNodeSize();
         }
         openNode.setG(g);
 
@@ -93,7 +93,7 @@ public class AStar{
             return PathfinderUtils.openNodes.get(0);
         }
 
-        map.isFinished = true;
+        map.setFinished(true);
         map.repaint();
         return null;
     }
index c2d94e55be7c86b65d270114794b9bce403af6e0..1d307111cf24291e5869ae5e898a2003227183b1 100644 (file)
@@ -18,12 +18,9 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe
     private JFrame window;
     private char key = (char) 0;
 
-    static int width;
-    static int height;
-    boolean isFinished = false;
-    boolean running = false;
-
-    int size = 20;
+    private boolean isFinished = false;
+    private boolean running = false;
+    private int size = 20;
 
     public Map() {
         this.setBackground(new Color(40, 40, 40));
@@ -42,9 +39,6 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe
         window.pack();
         window.setVisible(true);
 
-        width = this.getWidth();
-        height = this.getHeight();
-
         this.revalidate();
         this.repaint();
     }
@@ -272,4 +266,28 @@ class Map extends JPanel implements MouseListener, MouseMotionListener, KeyListe
     @Override
     public void mouseMoved(MouseEvent e) {
     }
+
+    public boolean isFinished() {
+        return isFinished;
+    }
+
+    public void setFinished(boolean isFinished) {
+        this.isFinished = isFinished;
+    }
+
+    public boolean isRunning() {
+        return running;
+    }
+
+    public void setRunning(boolean running) {
+        this.running = running;
+    }
+
+    public int getNodeSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
 }
index 365027e5af47c8ee82876d7e5d0e04ff6bf7c779..50e97bdefc1d0ed4cfae0326cfde30096c43a866 100644 (file)
Binary files a/target/PathVisualizer-1.0-SNAPSHOT.jar and b/target/PathVisualizer-1.0-SNAPSHOT.jar differ
index 045216018ebc3e349e1fcd2efc2ada63079923a1..8fb8818aff4edf656e403ce47a97af8e4ca2942b 100644 (file)
Binary files a/target/classes/Main/AStar.class and b/target/classes/Main/AStar.class differ
index 5d655f5fae37bf711c33d7669b921f5e047bb031..13e30fb49cd7e219d5a1971c5fd60b4b030bce85 100644 (file)
Binary files a/target/classes/Main/App.class and b/target/classes/Main/App.class differ
index bb875742982432dbd0fac47c3058cbeb0ecf4a70..e9a80609cf21e651e858263d52b8786b7d5f097d 100644 (file)
Binary files a/target/classes/Main/Map.class and b/target/classes/Main/Map.class differ
index 930f2951c3a36fe849966c6cd6a37e211530f7d2..3ec59642ea54906e9c08fe2950a1b61fdfd1aeb9 100644 (file)
Binary files a/target/classes/Main/Node.class and b/target/classes/Main/Node.class differ
index a6ec0004bc6c2aa82a17eeb2102208067abaf160..ef6af34278c55708becea6b8c7a6f6d7b5051c9c 100644 (file)
Binary files a/target/classes/Main/PathfinderUtils.class and b/target/classes/Main/PathfinderUtils.class differ
index 10b255599ce1e5cdb56f2af140fe7776f404956d..6be0d6d483e7237fe4d14966a32ee46e65ff948b 100644 (file)
@@ -1,4 +1,4 @@
-#Created by Apache Maven 3.8.1
+#Created by Apache Maven 3.3.9
 groupId=Main
 artifactId=PathVisualizer
 version=1.0-SNAPSHOT
index e2dbad22775391ff4d45139036e12cbd8756e3be..01f6db6a6152ba71d025b506a9377499d0d99939 100644 (file)
@@ -1,5 +1,5 @@
 Main/Node.class
 Main/AStar.class
 Main/Map.class
-Main/App.class
 Main/PathfinderUtils.class
+Main/App.class
index cc3946dcdafcaa71064aff5f6319f99be6755177..a00021999858409f7ae62dd6dc7d703667ad1654 100644 (file)
@@ -1,5 +1,5 @@
-/home/leo/Docs/Proj/PathVisualizer/src/main/java/Main/Map.java
-/home/leo/Docs/Proj/PathVisualizer/src/main/java/Main/Node.java
-/home/leo/Docs/Proj/PathVisualizer/src/main/java/Main/AStar.java
-/home/leo/Docs/Proj/PathVisualizer/src/main/java/Main/App.java
-/home/leo/Docs/Proj/PathVisualizer/src/main/java/Main/PathfinderUtils.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/main/java/Main/PathfinderUtils.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/main/java/Main/Node.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/main/java/Main/App.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/main/java/Main/Map.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/main/java/Main/AStar.java
index e6a42ce77b149d83e6add0475cfdbdd6ce3e54a5..e1f0ebcdb4a4eaf0bb06834f67fc31462b9cdbd9 100644 (file)
@@ -1 +1 @@
-/home/leo/Docs/Proj/PathVisualizer/src/test/java/Main/AppTest.java
+/home/leo/Docs/Proj/pathfinding-visualizer/src/test/java/Main/AppTest.java
index 4193956ad376161ae8aed170e350e2f2454be268..53a7fdf1db980457e65f21a15d71f10953505a79 100644 (file)
@@ -1,4 +1,4 @@
 -------------------------------------------------------------------------------
 Test set: Main.AppTest
 -------------------------------------------------------------------------------
-Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in Main.AppTest
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.036 s - in Main.AppTest
index b9ce485d69de5c498e4fb17fe6477bad70de3120..d0700b05f7c44df29f4b257e17a7aa95a9769dc4 100644 (file)
@@ -1,63 +1,54 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="Main.AppTest" time="0.024" tests="1" errors="0" skipped="0" failures="0">
+<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="Main.AppTest" time="0.036" tests="1" errors="0" skipped="0" failures="0">
   <properties>
-    <property name="awt.toolkit" value="sun.awt.X11.XToolkit"/>
-    <property name="java.specification.version" value="11"/>
-    <property name="sun.cpu.isalist" value=""/>
-    <property name="sun.jnu.encoding" value="UTF-8"/>
-    <property name="java.class.path" value="/home/leo/Docs/Proj/PathVisualizer/target/test-classes:/home/leo/Docs/Proj/PathVisualizer/target/classes:/home/leo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/leo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
-    <property name="java.vm.vendor" value="AdoptOpenJDK"/>
+    <property name="java.specification.version" value="16"/>
+    <property name="sun.jnu.encoding" value="ANSI_X3.4-1968"/>
+    <property name="java.class.path" value="/home/leo/Docs/Proj/pathfinding-visualizer/target/test-classes:/home/leo/Docs/Proj/pathfinding-visualizer/target/classes:/home/leo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/leo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
+    <property name="java.vm.vendor" value="Oracle Corporation"/>
     <property name="sun.arch.data.model" value="64"/>
-    <property name="java.vendor.url" value="https://adoptopenjdk.net/"/>
-    <property name="user.timezone" value=""/>
-    <property name="user.country.format" value="IT"/>
-    <property name="java.vm.specification.version" value="11"/>
+    <property name="java.vendor.url" value="https://java.oracle.com/"/>
     <property name="os.name" value="Linux"/>
+    <property name="java.vm.specification.version" value="16"/>
     <property name="sun.java.launcher" value="SUN_STANDARD"/>
-    <property name="user.country" value="GB"/>
-    <property name="sun.boot.library.path" value="/opt/openjdk-bin-11.0.11_p9/lib"/>
-    <property name="sun.java.command" value="/home/leo/Docs/Proj/PathVisualizer/target/surefire/surefirebooter8825560741906188442.jar /home/leo/Docs/Proj/PathVisualizer/target/surefire 2021-07-02T09-18-56_069-jvmRun1 surefire1726243427666730328tmp surefire_02585865431578143327tmp"/>
+    <property name="user.country" value="US"/>
+    <property name="sun.boot.library.path" value="/home/leo/.config/jdks/openjdk-16.0.2/lib"/>
+    <property name="sun.java.command" value="/home/leo/Docs/Proj/pathfinding-visualizer/target/surefire/surefirebooter16569093588158702030.jar /home/leo/Docs/Proj/pathfinding-visualizer/target/surefire 2021-08-08T09-03-56_502-jvmRun1 surefire6723173350746780523tmp surefire_013466448355498983315tmp"/>
     <property name="jdk.debug" value="release"/>
-    <property name="surefire.test.class.path" value="/home/leo/Docs/Proj/PathVisualizer/target/test-classes:/home/leo/Docs/Proj/PathVisualizer/target/classes:/home/leo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/leo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
+    <property name="surefire.test.class.path" value="/home/leo/Docs/Proj/pathfinding-visualizer/target/test-classes:/home/leo/Docs/Proj/pathfinding-visualizer/target/classes:/home/leo/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/leo/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
     <property name="sun.cpu.endian" value="little"/>
     <property name="user.home" value="/home/leo"/>
     <property name="user.language" value="en"/>
     <property name="java.specification.vendor" value="Oracle Corporation"/>
-    <property name="java.version.date" value="2021-04-20"/>
-    <property name="java.home" value="/opt/openjdk-bin-11.0.11_p9"/>
+    <property name="java.version.date" value="2021-07-20"/>
+    <property name="java.home" value="/home/leo/.config/jdks/openjdk-16.0.2"/>
     <property name="file.separator" value="/"/>
-    <property name="basedir" value="/home/leo/Docs/Proj/PathVisualizer"/>
-    <property name="java.vm.compressedOopsMode" value="Zero based"/>
+    <property name="basedir" value="/home/leo/Docs/Proj/pathfinding-visualizer"/>
+    <property name="java.vm.compressedOopsMode" value="32-bit"/>
     <property name="line.separator" value="&#10;"/>
-    <property name="java.specification.name" value="Java Platform API Specification"/>
     <property name="java.vm.specification.vendor" value="Oracle Corporation"/>
-    <property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/>
-    <property name="surefire.real.class.path" value="/home/leo/Docs/Proj/PathVisualizer/target/surefire/surefirebooter8825560741906188442.jar"/>
+    <property name="java.specification.name" value="Java Platform API Specification"/>
+    <property name="surefire.real.class.path" value="/home/leo/Docs/Proj/pathfinding-visualizer/target/surefire/surefirebooter16569093588158702030.jar"/>
     <property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
-    <property name="java.runtime.version" value="11.0.11+9"/>
+    <property name="java.runtime.version" value="16.0.2+7-67"/>
     <property name="user.name" value="leo"/>
     <property name="path.separator" value=":"/>
-    <property name="os.version" value="5.12.12-gentoo-LeoKernel"/>
+    <property name="os.version" value="5.13.8_1"/>
     <property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
-    <property name="file.encoding" value="UTF-8"/>
+    <property name="file.encoding" value="ANSI_X3.4-1968"/>
     <property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
-    <property name="java.vendor.version" value="AdoptOpenJDK-11.0.11+9"/>
     <property name="localRepository" value="/home/leo/.m2/repository"/>
-    <property name="java.vendor.url.bug" value="https://github.com/AdoptOpenJDK/openjdk-support/issues"/>
+    <property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/>
     <property name="java.io.tmpdir" value="/tmp"/>
-    <property name="java.version" value="11.0.11"/>
-    <property name="user.dir" value="/home/leo/Docs/Proj/PathVisualizer"/>
+    <property name="java.version" value="16.0.2"/>
+    <property name="user.dir" value="/home/leo/Docs/Proj/pathfinding-visualizer"/>
     <property name="os.arch" value="amd64"/>
     <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
-    <property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
-    <property name="user.language.format" value="it"/>
-    <property name="sun.os.patch.level" value="unknown"/>
     <property name="java.library.path" value="/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib"/>
-    <property name="java.vm.info" value="mixed mode"/>
-    <property name="java.vendor" value="AdoptOpenJDK"/>
-    <property name="java.vm.version" value="11.0.11+9"/>
+    <property name="java.vm.info" value="mixed mode, sharing"/>
+    <property name="java.vendor" value="Oracle Corporation"/>
+    <property name="java.vm.version" value="16.0.2+7-67"/>
     <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
-    <property name="java.class.version" value="55.0"/>
+    <property name="java.class.version" value="60.0"/>
   </properties>
   <testcase name="shouldAnswerWithTrue" classname="Main.AppTest" time="0.001"/>
 </testsuite>
\ No newline at end of file
index 6b3f4e2a47ae644aee71876320b08afdf766f7ab..a08e3e3772afae6fdfb00e95ffc185c606b4b1fa 100644 (file)
Binary files a/target/test-classes/Main/AppTest.class and b/target/test-classes/Main/AppTest.class differ