Skip to content
This repository was archived by the owner on May 8, 2023. It is now read-only.
Merged

Lars #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified out/production/PathfindingProject/Files/Controller.class
Binary file not shown.
Binary file modified out/production/PathfindingProject/Files/Model.class
Binary file not shown.
Binary file not shown.
Binary file modified out/production/PathfindingProject/Files/View.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 51 additions & 0 deletions out/production/PathfindingProject/Files/Views/view.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" style="-fx-background-color: green;" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints halignment="CENTER" hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<HBox alignment="CENTER" style="-fx-background-color: #333333;" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.hgrow="NEVER" GridPane.valignment="CENTER" GridPane.vgrow="NEVER">
<children>
<ComboBox fx:id="selectField" prefWidth="150.0" promptText="Algorithm" />
<Button fx:id="button" mnemonicParsing="false" text="Button" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
</HBox>
<ScrollPane fx:id="scrollPane" maxHeight="600.0" maxWidth="800.0" pannable="true" prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: black; -fx-border-width: 5px;" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.hgrow="SOMETIMES" GridPane.rowIndex="1" GridPane.rowSpan="2147483647" GridPane.valignment="CENTER" GridPane.vgrow="SOMETIMES">
<content>
<Canvas fx:id="canvas" height="400.0" nodeOrientation="INHERIT" width="400.0" />
</content></ScrollPane>
</children>
</GridPane>
Binary file modified out/production/PathfindingProject/Files/controllers/Input.class
Binary file not shown.
Binary file modified out/production/PathfindingProject/Files/models/Graph.class
Binary file not shown.
Binary file added out/test/PathfindingProject/StarterTest.class
Binary file not shown.
6 changes: 3 additions & 3 deletions src/files/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ private void onlyOneInstance (){

// ON Start
private void run(){
Graph graph = model.getGraph();
view.getUI().getGraphic().setGraph(graph);
view.getUI().getGraphic().draw();
//Graph graph = model.getGraph();
//view.getUI().getGraphic().setGraph(graph);
//view.getUI().getGraphic().draw();
}
}
5 changes: 0 additions & 5 deletions src/files/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
*/
public class Model {
private static boolean created = false;
private int tempVertices;
private Graph graph;

public Model(){
this.onlyOneInstance(); // Limit to only 1 instance of the Model class
Environment environment = new Environment();
Pathfinding pathfinding = new Pathfinding();

//graph = new Graph(6);
//graph.graphTest(6);
}
Expand All @@ -32,12 +30,9 @@ private void onlyOneInstance (){
}
}



public Graph getGraph() {
return graph;
}

public void setGraph(Graph graph) {
this.graph = graph;
}
Expand Down
9 changes: 2 additions & 7 deletions src/files/Starter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Application setup and main file (start of program)
// Model View Controller Design Pattern
// This is the Main file (renamed to Controller)
// This is the Main file (renamed to Starter)
// The controller manages the interaction between input, model, logic and view.

// Model - Data and Logic (Calculations and Path Finding) - Can be considered as a cook
Expand All @@ -19,12 +19,7 @@ public static void main(String[] args) {
// Initialize Application Scene
public void start(Stage stage) {
stage.setTitle("Pathfinding Project 2019");

// Model-View-Controller Architectural Pattern
Model model = new Model(); // Model logic seperated from the controller and view
View view = new View(stage); // View logic seperated from the controller and model
Controller controller = new Controller(model,view); // Controller is dependant on the model and view

new Controller(new Model(),new View(stage)); // Model-View-Controller Architectural Pattern
stage.show(); // Show Stage
}
}
62 changes: 15 additions & 47 deletions src/files/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,28 @@
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

// View manages the graphics
// This is the Root node of Application
public class View extends Group {
public class View {
private static boolean created = false; // if created
private UserInterface UI;
private Stage stage;

// Settings
private int sceneWidth = 640;
private int sceneHeight = 480;
private String viewFXMLLink = "View.fxml";
private Node fxml;

private int sceneWidth = 1280;
private int sceneHeight = 720;
private String viewFXMLLink = "views/view.fxml";
private UserInterface UI;

View(Stage stage){
this.onlyOneInstance(); // Limit to only 1 instance of the Model class
this.stage = stage;
this.setScene(stage);
UI = new UserInterface(this);
this.getChildren().add(UI);
addUI();
Node fxml = this.loadFXML();
this.setScene((Parent)fxml);
this.UI = new UserInterface(fxml);
}

private void onlyOneInstance (){
Expand All @@ -41,53 +38,24 @@ private void onlyOneInstance (){
}
}

private void loadFXML(){
private Node loadFXML(){
try {
this.fxml = FXMLLoader.load(getClass().getResource(this.viewFXMLLink));
this.convertFXMLToNodes();
return FXMLLoader.load(getClass().getResource(this.viewFXMLLink));
} catch (Exception exception){
System.err.println(exception);
System.err.println("FXML couldnt load...");
System.err.println("FXML couldnt load..."); // dont care about the exception message, just tell us fxml didnt load
System.exit(0);
return null;
}
}

private void convertFXMLToNodes(){
try {
/*
selectFrom = (ComboBox) this.fxml.lookup("#selectFrom");
selectTo = (ComboBox) this.fxml.lookup("#selectTo");
selectTime = (ComboBox) this.fxml.lookup("#selectTime");
departure = (RadioButton) this.fxml.lookup("#departure");
arrival = (RadioButton) this.fxml.lookup("#arrival");
button = (Button) this.fxml.lookup("#seeDepartures");
tableView = (TableView) this.fxml.lookup("#tableView");
message = (Label) this.fxml.lookup("#message");
*/
} catch(Exception exception){
System.err.println(exception);
System.err.println("Couldnt convert FXML to Nodes. Check if Type is correct.");
System.exit(0);
}
private void setScene(Parent fxml){
this.stage.setScene(new Scene(fxml, sceneWidth, sceneHeight)); // Scene with ScrollPane
}


private void setScene(Stage stage){
ScrollPane scrollPane = new ScrollPane(); // ScrollPane
scrollPane.setContent(this.fxml);
scrollPane.setStyle("-fx-alignment: center");
stage.setScene(new Scene(scrollPane, sceneWidth, sceneHeight)); // Scene with ScrollPane
}


public UserInterface getUI(){
return UI;
}

private void addUI(){

}

public void setMaximized(Boolean bool){
this.stage.setMaximized(bool);
}
Expand Down
4 changes: 2 additions & 2 deletions src/files/controllers/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public Input(Model model, View view){

private void addEventListeners(ArrayList<Node> nodes){
nodes.forEach((node)->{
String nodeName = node.getClass().getSimpleName();
String nodeName = node.getClass().getSimpleName().toLowerCase();

switch(nodeName){
case "GeneratorButton":
case "button":
node.setOnMouseClicked(event -> {
System.out.println("fullscreen "+fullScreen);
fullScreen = !fullScreen;
Expand Down
Loading