Implemented base UI and abstract controller for parent coupling
-Added Controller abstract class that all JavaFX controllers are to be a child of. -Added MainController in case in the future we need a menu. -Added mainpane.fxml as a base pane that we can mount the future menu on. -Added RaceController so where the race will be made and displayed. -Added racepane.fxml which includes a Canvas and a tableview -Added loadPane() function to the mainApp which will swap the pane the app is currently on. #story[9]
This commit is contained in:
Generated
+4
-1
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="OPTION_SCOPE" value="protected" />
|
||||
@@ -25,7 +28,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
|
||||
@@ -1,11 +1,27 @@
|
||||
package seng302;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
import seng302.Controllers.Controller;
|
||||
import seng302.Controllers.MainController;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class App
|
||||
public class App extends Application
|
||||
{
|
||||
Stage primaryStage;
|
||||
BorderPane mainContainer;
|
||||
Scene mainScene;
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
launch(args);
|
||||
/* SPRINT 1 Leftovers
|
||||
int timescale = 0; // Scale 5 min to 1 min, 1min = 200 5 min = 1000
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
@@ -40,6 +56,44 @@ public class App
|
||||
};
|
||||
|
||||
Race race = new ConstantVelocityRace(boats, marks, timescale);
|
||||
race.simulateRace();
|
||||
race.simulateRace();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
this.primaryStage = primaryStage;
|
||||
|
||||
//load the first container
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//mainpane.fxml");
|
||||
mainContainer = (BorderPane) loader.load(in);
|
||||
mainScene = new Scene(mainContainer, 800, 600);
|
||||
primaryStage.setScene(mainScene);
|
||||
primaryStage.sizeToScene();
|
||||
MainController mainController = (MainController) loader.getController();
|
||||
mainController.setParent(this);
|
||||
in.close();
|
||||
//add the center
|
||||
loadPane("racepane.fxml");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
public void loadPane(String fxmlName) throws Exception{
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
InputStream in = getClass().getClassLoader().getResourceAsStream("scenes//"+fxmlName);
|
||||
Parent page;
|
||||
try {
|
||||
page = (Parent) loader.load(in);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
mainContainer.getChildren().remove(mainContainer.getCenter());
|
||||
mainContainer.setCenter(page);
|
||||
Controller controller = (Controller) loader.getController();
|
||||
controller.setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package seng302.Controllers;
|
||||
|
||||
import javafx.fxml.Initializable;
|
||||
import seng302.App;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 15/03/2017.
|
||||
*/
|
||||
public abstract class Controller implements Initializable{
|
||||
protected App parent;
|
||||
|
||||
public void setParent(App parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadPane(String fxmlName) throws Exception {
|
||||
this.parent.loadPane(fxmlName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void initialize(URL location, ResourceBundle resources);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package seng302.Controllers;
|
||||
|
||||
import javafx.fxml.Initializable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 15/03/2017.
|
||||
*/
|
||||
public class MainController extends Controller {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package seng302.Controllers;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.control.TableView;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 15/03/2017.
|
||||
*/
|
||||
public class RaceController extends Controller{
|
||||
@FXML
|
||||
Canvas raceMap;
|
||||
@FXML
|
||||
TableView boatInfoTable;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<BorderPane fx:id="mainPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController" />
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.canvas.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
|
||||
<children>
|
||||
<SplitPane fx:id="racePane" dividerPositions="0.75" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<items>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
|
||||
<children>
|
||||
<Canvas fx:id="raceMap" height="400.0" width="446.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
|
||||
<children>
|
||||
<TableView fx:id="boatInfoTable" prefHeight="400.0" prefWidth="146.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columns>
|
||||
<TableColumn prefWidth="75.0" text="C1" />
|
||||
<TableColumn prefWidth="75.0" text="C2" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user