Added JavaFX Dependencies and resource mapping for seperation of concerns.

This commit is contained in:
Jonathan Turner 2024-02-11 01:39:16 -05:00
parent 5c2fde6c69
commit 53d046858f
6 changed files with 36 additions and 21 deletions

30
pom.xml
View File

@ -13,5 +13,33 @@
<maven.compiler.target>19</maven.compiler.target> <maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>20.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>edu.jturn.cs3642.CS3642-Artificial_Intelligence/Assignments.A1.GUIDriver</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -14,6 +14,8 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.PriorityQueue; import java.util.PriorityQueue;
@ -122,32 +124,17 @@ public class Driver {
} }
private static void writeToFile(String name, StringBuffer values) { private static void writeToFile(String name, StringBuffer values) {
File directory = new File("src/Assignments/A1/results"); URL resourcePath = Driver.class.getResource("/A1/results/AStar.txt");
if (!directory.exists()) { URI resourceURI = URI.create(resourcePath.toString());
directory.mkdirs(); File resource = new File(resourceURI.getPath());
System.out.println("Creating Directory: results");
}
File output = new File(directory, name + ".txt"); try (FileWriter out = new FileWriter(resource)) {
try {
if (!output.createNewFile()) {
System.out.println("File Already Exists: " + name + ".txt");
} else {
System.out.println("File Created: " + name + ".txt");
}
} catch (IOException e) {
System.err.println("Error creating file: " + e.getMessage());
}
try (FileWriter out = new FileWriter(output)) {
out.write(values.toString()); out.write(values.toString());
System.out.println("Data written to file: " + name + ".txt"); System.out.println("Data written to file: " + name + ".txt");
} catch (IOException e) { } catch (IOException e) {
System.err.println("Error writing to file: " + e.getMessage()); System.err.println("Error writing to file: " + e.getMessage());
} }
openDirectoryFile(resource);
openDirectoryFile(output);
} }
private static void openDirectoryFile(File open) { private static void openDirectoryFile(File open) {

View File

View File

View File

View File