Merge branch 'Development' into new_issue#19
# Conflicts: # racevisionGame/src/main/java/visualiser/Controllers/RaceController.java # racevisionGame/src/main/java/visualiser/app/App.java
This commit is contained in:
@@ -65,6 +65,11 @@ public class RaceController extends Controller {
|
|||||||
*/
|
*/
|
||||||
private Sparkline sparkline;
|
private Sparkline sparkline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* state of the info table
|
||||||
|
*/
|
||||||
|
private boolean infoTableShow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The arrow controller.
|
* The arrow controller.
|
||||||
*/
|
*/
|
||||||
@@ -109,10 +114,14 @@ public class RaceController extends Controller {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
KeyFactory keyFactory = KeyFactory.getFactory();
|
KeyFactory keyFactory = KeyFactory.getFactory();
|
||||||
|
infoTableShow = true;
|
||||||
|
|
||||||
// Initialise keyboard handler
|
// Initialise keyboard handler
|
||||||
race.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
race.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||||
String codeString = event.getCode().toString();
|
String codeString = event.getCode().toString();
|
||||||
|
|
||||||
|
if (codeString.equals("TAB")){toggleTable();}
|
||||||
|
|
||||||
ControlKey controlKey = keyFactory.getKey(codeString);
|
ControlKey controlKey = keyFactory.getKey(codeString);
|
||||||
if(controlKey != null) {
|
if(controlKey != null) {
|
||||||
try {
|
try {
|
||||||
@@ -473,4 +482,23 @@ public class RaceController extends Controller {
|
|||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void toggleTable() {
|
||||||
|
if (infoTableShow){
|
||||||
|
race.setDividerPositions(0.4);
|
||||||
|
|
||||||
|
arrowPane.setScaleX(0.5);
|
||||||
|
arrowPane.setScaleY(0.5);
|
||||||
|
arrowPane.setTranslateX(0 + (arrowPane.getScene().getWidth()/4)*0.4);
|
||||||
|
arrowPane.setTranslateY(0 - arrowPane.getScene().getHeight()/4);
|
||||||
|
}else{
|
||||||
|
race.setDividerPositions(1);
|
||||||
|
|
||||||
|
arrowPane.setScaleX(1);
|
||||||
|
arrowPane.setScaleY(1);
|
||||||
|
arrowPane.setTranslateX(0);
|
||||||
|
arrowPane.setTranslateY(0);
|
||||||
|
}
|
||||||
|
infoTableShow = !infoTableShow;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import javafx.scene.control.Button;
|
|||||||
import javafx.scene.control.RadioButton;
|
import javafx.scene.control.RadioButton;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import visualiser.app.App;
|
import visualiser.app.App;
|
||||||
|
|
||||||
@@ -82,4 +83,25 @@ public class TitleController extends Controller {
|
|||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when control button is pressed. New pop up window displaying controls
|
||||||
|
*/
|
||||||
|
public void controlBtnPressed(){
|
||||||
|
FXMLLoader loader = new FXMLLoader();
|
||||||
|
loader.setLocation(getClass().getResource("/visualiser/scenes/controls.fxml"));
|
||||||
|
Parent layout;
|
||||||
|
try {
|
||||||
|
layout = loader.load();
|
||||||
|
Scene scene = new Scene(layout);
|
||||||
|
Stage popupStage = new Stage();
|
||||||
|
popupStage.setTitle("Game Controls");
|
||||||
|
popupStage.initModality(Modality.WINDOW_MODAL);
|
||||||
|
popupStage.setScene(scene);
|
||||||
|
popupStage.showAndWait();
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,47 @@
|
|||||||
package visualiser.app;
|
package visualiser.app;
|
||||||
|
|
||||||
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.concurrent.Task;
|
||||||
|
import javafx.concurrent.Worker;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.geometry.Rectangle2D;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.ProgressBar;
|
||||||
|
import javafx.scene.effect.DropShadow;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.stage.Screen;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
import javafx.stage.WindowEvent;
|
import javafx.stage.WindowEvent;
|
||||||
|
import javafx.util.Duration;
|
||||||
import visualiser.Controllers.MainController;
|
import visualiser.Controllers.MainController;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
|
|
||||||
|
|
||||||
private static Stage stage;
|
private static Stage stage;
|
||||||
|
private Pane splashLayout;
|
||||||
|
private ProgressBar loadProgress;
|
||||||
|
private Label progressText;
|
||||||
|
private static final int SPLASH_WIDTH = 676;
|
||||||
|
private static final int SPLASH_HEIGHT = 227;
|
||||||
|
|
||||||
public static App app;
|
public static App app;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,14 +53,114 @@ public class App extends Application {
|
|||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
ImageView splash = new ImageView(new Image(
|
||||||
|
getClass().getClassLoader().getResourceAsStream("images/splashScreen.png")
|
||||||
|
));
|
||||||
|
loadProgress = new ProgressBar();
|
||||||
|
loadProgress.setPrefWidth(SPLASH_WIDTH - 20);
|
||||||
|
progressText = new Label("Preparing application . . .");
|
||||||
|
splashLayout = new VBox();
|
||||||
|
splashLayout.getChildren().addAll(splash, loadProgress, progressText);
|
||||||
|
progressText.setAlignment(Pos.CENTER);
|
||||||
|
splashLayout.setStyle(
|
||||||
|
"-fx-padding: 5; " +
|
||||||
|
"-fx-background-color: cornsilk; " +
|
||||||
|
"-fx-border-width:5; " +
|
||||||
|
"-fx-border-color: " +
|
||||||
|
"linear-gradient(" +
|
||||||
|
"to bottom, " +
|
||||||
|
"chocolate, " +
|
||||||
|
"derive(chocolate, 50%)" +
|
||||||
|
");"
|
||||||
|
);
|
||||||
|
splashLayout.setEffect(new DropShadow());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that displays the visualiser, starting with the title screen.
|
* Method that sets up and displays the splash screen
|
||||||
* @param stage the stage to be displayed.
|
* @param initStage the inital stage
|
||||||
* @throws Exception if something wrong with title screen.
|
* @throws Exception if something wrong with title screen.
|
||||||
*/
|
*/
|
||||||
public void start(Stage stage) throws Exception {
|
public void start(Stage initStage) throws Exception {
|
||||||
|
final Task<ObservableList<String>> boatTask = new Task<ObservableList<String>>() {
|
||||||
|
@Override
|
||||||
|
protected ObservableList<String> call() throws InterruptedException {
|
||||||
|
ObservableList<String> addedFilling =
|
||||||
|
FXCollections.<String>observableArrayList();
|
||||||
|
ObservableList<String> burgerFilling =
|
||||||
|
FXCollections.observableArrayList(
|
||||||
|
"Buns", "Patties", "Lettuce", "Onions", "Tomato",
|
||||||
|
"Sauces"
|
||||||
|
);
|
||||||
|
|
||||||
|
updateMessage("Preparing ingredients . . .");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
for (int i = 0; i < burgerFilling.size(); i++) {
|
||||||
|
Thread.sleep(800);
|
||||||
|
updateProgress(i + 1, burgerFilling.size());
|
||||||
|
String nextFilling = burgerFilling.get(i);
|
||||||
|
addedFilling.add(nextFilling);
|
||||||
|
updateMessage("Adding the " + nextFilling + " . . .");
|
||||||
|
}
|
||||||
|
Thread.sleep(400);
|
||||||
|
updateMessage("Burger's done!");
|
||||||
|
|
||||||
|
return addedFilling;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
showSplash(
|
||||||
|
initStage,
|
||||||
|
boatTask,
|
||||||
|
() -> {
|
||||||
|
try {
|
||||||
|
showMainStage();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
new Thread(boatTask).start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get main stage
|
||||||
|
* @return main stage
|
||||||
|
*/
|
||||||
|
public static Stage getStage() {
|
||||||
|
return App.stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set main stage
|
||||||
|
* @param stage stage to set main stage
|
||||||
|
*/
|
||||||
|
public static void setStage(Stage stage) {
|
||||||
App.stage = stage;
|
App.stage = stage;
|
||||||
App.app = this;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the main stage after the splash screen
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private void showMainStage() throws Exception {
|
||||||
|
stage = new Stage(StageStyle.DECORATED);
|
||||||
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("/visualiser/scenes/main.fxml"));
|
||||||
|
Parent root = loader.load();
|
||||||
|
stage.setResizable(false);
|
||||||
|
MainController mc = (MainController) loader.getController();
|
||||||
|
mc.enterTitle();
|
||||||
|
Scene scene = new Scene(root);
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle("RaceVision - Team 7");
|
||||||
|
stage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/SailIcon.png")));
|
||||||
|
mc.startCss();
|
||||||
|
setStage(stage);
|
||||||
|
stage.show();
|
||||||
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(WindowEvent event) {
|
public void handle(WindowEvent event) {
|
||||||
@@ -41,37 +168,50 @@ public class App extends Application {
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
loadStart(App.stage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiation
|
* Show the splash screen
|
||||||
* @param stage
|
* @param initStage Initial stage
|
||||||
* @throws IOException
|
* @param task
|
||||||
|
* @param initCompletionHandler
|
||||||
*/
|
*/
|
||||||
public void loadStart(Stage stage) throws IOException {
|
private void showSplash(
|
||||||
FXMLLoader loader = new FXMLLoader(App.class.getResource("/visualiser/scenes/main.fxml"));
|
final Stage initStage,
|
||||||
Parent root = loader.load();
|
Task<?> task,
|
||||||
stage.setResizable(false);
|
InitCompletionHandler initCompletionHandler
|
||||||
MainController mc = (MainController) loader.getController();
|
) {
|
||||||
mc.enterTitle();
|
progressText.textProperty().bind(task.messageProperty());
|
||||||
Scene scene = new Scene(root);
|
loadProgress.progressProperty().bind(task.progressProperty());
|
||||||
|
task.stateProperty().addListener((observableValue, oldState, newState) -> {
|
||||||
|
if (newState == Worker.State.SUCCEEDED) {
|
||||||
|
loadProgress.progressProperty().unbind();
|
||||||
|
loadProgress.setProgress(1);
|
||||||
|
initStage.toFront();
|
||||||
|
FadeTransition fadeSplash = new FadeTransition(Duration.seconds(2), splashLayout);
|
||||||
|
fadeSplash.setFromValue(1.0);
|
||||||
|
fadeSplash.setToValue(0.0);
|
||||||
|
fadeSplash.setOnFinished(actionEvent -> initStage.hide());
|
||||||
|
fadeSplash.play();
|
||||||
|
|
||||||
|
initCompletionHandler.complete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
stage.setScene(scene);
|
Scene splashScene = new Scene(splashLayout, Color.TRANSPARENT);
|
||||||
stage.setTitle("RaceVision - Team 7");
|
final Rectangle2D bounds = Screen.getPrimary().getBounds();
|
||||||
stage.getIcons().add(new Image(App.class.getClassLoader().getResourceAsStream("images/SailIcon.png")));
|
initStage.setScene(splashScene);
|
||||||
mc.startCss();
|
initStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
|
||||||
setStage(stage);
|
initStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
|
||||||
stage.show();
|
initStage.initStyle(StageStyle.TRANSPARENT);
|
||||||
|
initStage.setAlwaysOnTop(true);
|
||||||
|
initStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stage getStage() {
|
/**
|
||||||
return App.stage;
|
* InnitCompletionHandler interface
|
||||||
}
|
*/
|
||||||
|
public interface InitCompletionHandler {
|
||||||
public static void setStage(Stage stage) {
|
void complete();
|
||||||
App.stage = stage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 600 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.image.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="350.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<ImageView fitHeight="385.0" fitWidth="600.0" layoutY="-2.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="-1.9456787109375" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-2.0">
|
||||||
|
<image>
|
||||||
|
<Image url="@../images/game_controls.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.geometry.*?>
|
|
||||||
<?import javafx.scene.chart.*?>
|
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.chart.LineChart?>
|
<?import javafx.scene.chart.LineChart?>
|
||||||
<?import javafx.scene.chart.NumberAxis?>
|
<?import javafx.scene.chart.NumberAxis?>
|
||||||
@@ -26,7 +22,7 @@
|
|||||||
<?import javafx.scene.layout.StackPane?>
|
<?import javafx.scene.layout.StackPane?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<SplitPane fx:id="race" dividerPositions="0.7" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceController">
|
<SplitPane fx:id="race" dividerPositions="1.0" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.RaceController">
|
||||||
<items>
|
<items>
|
||||||
<GridPane fx:id="canvasBase">
|
<GridPane fx:id="canvasBase">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
</Text>
|
</Text>
|
||||||
<RadioButton fx:id="nightModeRD" layoutX="681.0" layoutY="168.0" mnemonicParsing="false" onAction="#setNightMode" text="Night Mode" />
|
<RadioButton fx:id="nightModeRD" layoutX="681.0" layoutY="168.0" mnemonicParsing="false" onAction="#setNightMode" text="Night Mode" />
|
||||||
<RadioButton fx:id="dayModeRD" layoutX="574.0" layoutY="168.0" mnemonicParsing="false" onAction="#setDayMode" selected="true" text="Day Mode" />
|
<RadioButton fx:id="dayModeRD" layoutX="574.0" layoutY="168.0" mnemonicParsing="false" onAction="#setDayMode" selected="true" text="Day Mode" />
|
||||||
|
<Button layoutX="28.0" layoutY="152.0" mnemonicParsing="false" onAction="#controlBtnPressed" text="Controls" />
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
<Pane prefHeight="20.0" prefWidth="20.0" style="-fx-background-color: #6be6ff;" GridPane.columnSpan="4" GridPane.rowSpan="4">
|
<Pane prefHeight="20.0" prefWidth="20.0" style="-fx-background-color: #6be6ff;" GridPane.columnSpan="4" GridPane.rowSpan="4">
|
||||||
|
|||||||
Reference in New Issue
Block a user