Added TitledPane and Checkbox to GUI.
-Checkbox is used to control the visibility of the FPS counter #story [20]
This commit is contained in:
@@ -2,15 +2,12 @@ package seng302.Controllers;
|
||||
|
||||
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.SplitPane;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TitledPane;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
@@ -39,6 +36,9 @@ public class RaceController extends Controller{
|
||||
@FXML
|
||||
SplitPane ongoingRacePane;
|
||||
|
||||
@FXML
|
||||
CheckBox showFPS;
|
||||
|
||||
|
||||
@FXML
|
||||
Label timer;
|
||||
@@ -116,6 +116,7 @@ public class RaceController extends Controller{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes and runs the race, based on the user's chosen scale factor
|
||||
* Currently uses an example racecourse
|
||||
@@ -125,6 +126,7 @@ public class RaceController extends Controller{
|
||||
private void startRace(int scaleFactor) {
|
||||
BoatInRace[] boats = generateAC35Competitors();
|
||||
raceMap = new ResizableRaceCanvas();
|
||||
raceMap.setMouseTransparent(true);
|
||||
raceMap.widthProperty().bind(canvasBase.widthProperty());
|
||||
raceMap.heightProperty().bind(canvasBase.heightProperty());
|
||||
raceMap.setBoats(boats);
|
||||
@@ -138,6 +140,17 @@ public class RaceController extends Controller{
|
||||
ArrayList<Leg> legs = generateBermudaCourseLegs();
|
||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this, scaleFactor);
|
||||
|
||||
showFPS.setVisible(true);
|
||||
showFPS.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||
public void changed(ObservableValue<? extends Boolean> ov,
|
||||
Boolean old_val, Boolean new_val) {
|
||||
if (showFPS.isSelected()){
|
||||
FPS.setVisible(true);
|
||||
} else {
|
||||
FPS.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new Thread((race)).start();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
this.boats = boats;
|
||||
}
|
||||
|
||||
|
||||
public ResizableRaceCanvas(RaceMap map) {
|
||||
this.map = map;
|
||||
gc = this.getGraphicsContext2D();
|
||||
@@ -160,7 +161,6 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
gc.clearRect(0, 0, width, height);
|
||||
//System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
|
||||
this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int) width, (int) height);
|
||||
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
@@ -244,4 +244,5 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
public double prefHeight(double height) {
|
||||
return getHeight();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="seng302.Controllers.RaceController">
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
|
||||
<children>
|
||||
<GridPane fx:id="startScreen" prefHeight="600.0" prefWidth="780.0">
|
||||
<columnConstraints>
|
||||
@@ -23,20 +25,15 @@
|
||||
<RowConstraints maxHeight="178.0" minHeight="10.0" prefHeight="178.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Select Your Race Scaling:" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="1">
|
||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Select Your Race Scaling:" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<font>
|
||||
<Font size="23.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button mnemonicParsing="false" onAction="#startRace1Min" text="15x faster" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2"/>
|
||||
<Button mnemonicParsing="false" onAction="#startRaceNoScaling" text="No scaling"
|
||||
GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||
<Button mnemonicParsing="false" onAction="#startRace5Min" text="3x faster" GridPane.columnIndex="2"
|
||||
GridPane.rowIndex="2"/>
|
||||
<Label alignment="CENTER" text="Race will take ~1 minute" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="3">
|
||||
<Button mnemonicParsing="false" onAction="#startRace1Min" text="15x faster" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Button mnemonicParsing="false" onAction="#startRaceNoScaling" text="No scaling" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||
<Button mnemonicParsing="false" onAction="#startRace5Min" text="3x faster" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||
<Label alignment="CENTER" text="Race will take ~1 minute" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
@@ -44,8 +41,7 @@
|
||||
<Font size="10.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label alignment="CENTER" layoutX="99.0" layoutY="407.0" text="Race will take ~5 minutes"
|
||||
GridPane.columnIndex="2" GridPane.rowIndex="3">
|
||||
<Label alignment="CENTER" layoutX="99.0" layoutY="407.0" text="Race will take ~5 minutes" GridPane.columnIndex="2" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font size="10.0" />
|
||||
</font>
|
||||
@@ -53,8 +49,7 @@
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
</Label>
|
||||
<Label alignment="CENTER" layoutX="279.0" layoutY="407.0" text="Race will take ~15 minutes"
|
||||
GridPane.columnIndex="3" GridPane.rowIndex="3">
|
||||
<Label alignment="CENTER" layoutX="279.0" layoutY="407.0" text="Race will take ~15 minutes" GridPane.columnIndex="3" GridPane.rowIndex="3">
|
||||
<font>
|
||||
<Font size="10.0" />
|
||||
</font>
|
||||
@@ -64,21 +59,26 @@
|
||||
</Label>
|
||||
</children>
|
||||
</GridPane>
|
||||
<SplitPane fx:id="ongoingRacePane" dividerPositions="0.70" visible="false" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<SplitPane fx:id="ongoingRacePane" dividerPositions="0.7" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<items>
|
||||
<AnchorPane fx:id="canvasBase" prefHeight="581.0" prefWidth="537.0">
|
||||
<children>
|
||||
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" text="0:0" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0"/>
|
||||
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" />
|
||||
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" text="0:0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" />
|
||||
<TitledPane fx:id="userControl" animated="false" text="User Control" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<children>
|
||||
<CheckBox fx:id="showFPS" mnemonicParsing="false" selected="true" text="Show FPS" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0"
|
||||
GridPane.columnIndex="1">
|
||||
</content>
|
||||
</TitledPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0" GridPane.columnIndex="1">
|
||||
<children>
|
||||
<TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0"
|
||||
AnchorPane.rightAnchor="-62.0" AnchorPane.topAnchor="0.0">
|
||||
<TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="-62.0" AnchorPane.topAnchor="0.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place" />
|
||||
<TableColumn fx:id="boatTeamColumn" prefWidth="100.0" text="Team" />
|
||||
|
||||
Reference in New Issue
Block a user