Began work on ConnectionController for selecting active hosts on startup via GUI.

#story[782]
main
cbt24 9 years ago
parent 577dea2a56
commit ad58407021

@ -22,9 +22,9 @@ public class App extends Application {
}
public void start(Stage stage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/scenes/main.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/scenes/connect.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root, 1200, 800);
Scene scene = new Scene(root, 600, 400);
stage.setScene(scene);
stage.show();
}

@ -0,0 +1,21 @@
package seng302.Controllers;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
import javax.swing.text.TableView;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Created by cbt24 on 3/05/17.
*/
public class ConnectionController extends Controller {
@FXML
TableView connectionTable;
@Override
public void initialize(URL location, ResourceBundle resources) {
}
}

@ -16,6 +16,8 @@ public class MainController extends Controller {
StartController startController;
@FXML
RaceController raceController;
@FXML
ConnectionController connectionController;
public void beginRace(VisualiserInput visualiserInput) {
raceController.startRace(visualiserInput);
@ -32,6 +34,7 @@ public class MainController extends Controller {
public void initialize(URL location, ResourceBundle resources) {
startController.setParent(this);
raceController.setParent(this);
connectionController.setParent(this);
AnchorPane.setTopAnchor(startController.startWrapper(), 0.0);
AnchorPane.setBottomAnchor(startController.startWrapper(), 0.0);
AnchorPane.setLeftAnchor(startController.startWrapper(), 0.0);

@ -1,5 +1,6 @@
package seng302.Mock;
import javafx.animation.AnimationTimer;
import javafx.collections.FXCollections;
import org.geotools.referencing.GeodeticCalculator;
import seng302.*;
@ -12,6 +13,7 @@ import seng302.Networking.Utils.Enums.BoatStatus;
import seng302.Networking.Utils.BoatLocationMessage;
import java.awt.geom.Point2D;
import java.time.Instant;
import java.util.*;
/**
@ -99,4 +101,39 @@ public class StreamedRace extends Race {
boat.setCurrentPosition(coordinate);
}
@Override
protected void countdownTimer() {
new AnimationTimer() {
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
long hours;
long timeLeft;
@Override
public void handle(long arg0) {
long currentTime = Instant.now().getEpochSecond();
long startTime = visualiserInput.getRaceStatus().getExpectedStartTime();
timeLeft = startTime - currentTime;
System.out.println(timeLeft);
if (timeLeft <= 0 && controller != null) {
updateTime("Race is starting...");
stop();
simulateRace();
} else {
currentTimeInSeconds = (timeLeft*scaleFactor) / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
hours = minutes / 60;
minutes = minutes % 60;
if (controller != null) {
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
}
}
currentTime = System.currentTimeMillis();
}
}.start();
}
}

@ -27,11 +27,10 @@ public abstract class Race implements Runnable {
protected RaceController controller;
protected int boatsFinished = 0;
protected long totalTimeElapsed;
private int lastFPS = 20;
protected int scaleFactor;
protected int PRERACE_TIME = 0; //time in milliseconds to pause during pre-race
private int lastFPS = 20;
private int PRERACE_TIME = 0; //time in milliseconds to pause during pre-race
private boolean timerEnabled = true; //boolean to determine if timer is ran
/**
@ -196,7 +195,7 @@ public abstract class Race implements Runnable {
* Starts the Race Simulation, playing the race start to finish with the timescale.
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
*/
private void simulateRace() {
protected final void simulateRace() {
System.setProperty("javafx.animation.fullspeed", "true");

@ -0,0 +1,14 @@
package seng302;
/**
* Created by cbt24 on 3/05/17.
*/
public class RaceConnection {
private String hostname;
private int port;
public RaceConnection(String hostname, int port) {
this.hostname = hostname;
this.port = port;
}
}

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="seng302.Controllers.ConnectionController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="192.0" minWidth="10.0" prefWidth="50.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="444.0" minWidth="10.0" prefWidth="444.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="144.0" minWidth="10.0" prefWidth="56.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="129.0" minHeight="10.0" prefHeight="61.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="283.0" minHeight="10.0" prefHeight="239.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="114.0" minHeight="10.0" prefHeight="89.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TableView prefHeight="500.0" prefWidth="900.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
<columns>
<TableColumn prefWidth="217.0" text="Address" />
<TableColumn prefWidth="226.0" text="Status" />
</columns>
</TableView>
<Label text="RaceVision" GridPane.columnIndex="1" GridPane.halignment="CENTER">
<font>
<Font size="24.0" />
</font>
</Label>
<Button disable="true" mnemonicParsing="false" text="Connect" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
</children>
</GridPane>
Loading…
Cancel
Save