Display name of race in lobby.
- Moved Regatta properties and accessors to RegattaXMLReader - StartController update now tolerates any permutation of types of XML messages #story[782]
This commit is contained in:
@@ -34,6 +34,7 @@ public class StartController extends Controller implements Observer {
|
|||||||
|
|
||||||
@FXML private GridPane start;
|
@FXML private GridPane start;
|
||||||
@FXML private AnchorPane startWrapper;
|
@FXML private AnchorPane startWrapper;
|
||||||
|
@FXML private Label raceTitleLabel;
|
||||||
|
|
||||||
@FXML private TableView<Boat> boatNameTable;
|
@FXML private TableView<Boat> boatNameTable;
|
||||||
@FXML private TableColumn<Boat, String> boatNameColumn;
|
@FXML private TableColumn<Boat, String> boatNameColumn;
|
||||||
@@ -140,15 +141,14 @@ public class StartController extends Controller implements Observer {
|
|||||||
@Override
|
@Override
|
||||||
public void update(Observable o, Object arg) {
|
public void update(Observable o, Object arg) {
|
||||||
if(o instanceof StreamedCourse) {
|
if(o instanceof StreamedCourse) {
|
||||||
if(((StreamedCourse) o).getBoats() != null) {
|
if(((StreamedCourse) o).hasReadBoats()) {
|
||||||
initialiseTables();
|
initialiseTables();
|
||||||
}
|
}
|
||||||
if (((StreamedCourse) o).getZonedDateTime() != null) {
|
if(((StreamedCourse)o).hasReadRegatta()) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> raceTitleLabel.setText(((StreamedCourse)o).getRegattaName()));
|
||||||
{
|
|
||||||
setRaceClock();
|
|
||||||
}
|
}
|
||||||
});
|
if (((StreamedCourse) o).hasReadCourse()) {
|
||||||
|
Platform.runLater(() -> setRaceClock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import seng302.GPSCoordinate;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jjg64 on 19/04/17.
|
* Created by jjg64 on 19/04/17.
|
||||||
|
* @deprecated use the RegattaXMLReader
|
||||||
*/
|
*/
|
||||||
public class Regatta {
|
public class Regatta {
|
||||||
int regattaID;
|
int regattaID;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
import seng302.XMLReader;
|
import seng302.XMLReader;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
@@ -15,6 +16,15 @@ import java.io.InputStream;
|
|||||||
*/
|
*/
|
||||||
public class RegattaXMLReader extends XMLReader {
|
public class RegattaXMLReader extends XMLReader {
|
||||||
private Regatta regatta;
|
private Regatta regatta;
|
||||||
|
int regattaID;
|
||||||
|
String regattaName;
|
||||||
|
int raceID = 0;
|
||||||
|
String courseName;
|
||||||
|
double centralLatitude;
|
||||||
|
double centralLongitude;
|
||||||
|
double centralAltitude;
|
||||||
|
float utcOffset;
|
||||||
|
float magneticVariation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for Regatta XML
|
* Constructor for Regatta XML
|
||||||
@@ -59,20 +69,93 @@ public class RegattaXMLReader extends XMLReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void makeRegatta(Element attributes) {
|
private void makeRegatta(Element attributes) {
|
||||||
int regattaID = Integer.parseInt(getTextValueOfNode(attributes, "RegattaID"));
|
this.regattaID = Integer.parseInt(getTextValueOfNode(attributes, "RegattaID"));
|
||||||
String regattaName = getTextValueOfNode(attributes, "RegattaName");
|
this.regattaName = getTextValueOfNode(attributes, "RegattaName");
|
||||||
String courseName = getTextValueOfNode(attributes, "CourseName");
|
this.courseName = getTextValueOfNode(attributes, "CourseName");
|
||||||
double centralLatitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLatitude"));
|
this.centralLatitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLatitude"));
|
||||||
double centralLongitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLongitude"));
|
this.centralLongitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLongitude"));
|
||||||
System.out.println(String.format("central lat %s long %s", centralLatitude, centralLongitude));
|
this.centralAltitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralAltitude"));
|
||||||
double centralAltitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralAltitude"));
|
this.utcOffset = Float.parseFloat(getTextValueOfNode(attributes, "UtcOffset"));
|
||||||
float utcOffset = Float.parseFloat(getTextValueOfNode(attributes, "UtcOffset"));
|
this.magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation"));
|
||||||
float magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation"));
|
|
||||||
|
|
||||||
regatta = new Regatta(regattaID, regattaName, courseName, centralLatitude, centralLongitude, centralAltitude, utcOffset, magneticVariation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Regatta getRegatta() {
|
public Regatta getRegatta() {
|
||||||
return regatta;
|
return regatta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRegattaID() {
|
||||||
|
return regattaID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegattaID(int ID) {
|
||||||
|
this.regattaID = ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegattaName() {
|
||||||
|
return regattaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegattaName(String regattaName) {
|
||||||
|
this.regattaName = regattaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRaceID() {
|
||||||
|
return raceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRaceID(int raceID) {
|
||||||
|
this.raceID = raceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCourseName() {
|
||||||
|
return courseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCourseName(String courseName) {
|
||||||
|
this.courseName = courseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCentralLatitude() {
|
||||||
|
return centralLatitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCentralLatitude(double centralLatitude) {
|
||||||
|
this.centralLatitude = centralLatitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCentralLongitude() {
|
||||||
|
return centralLongitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCentralLongitude(double centralLongitude) {
|
||||||
|
this.centralLongitude = centralLongitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCentralAltitude() {
|
||||||
|
return centralAltitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCentralAltitude(double centralAltitude) {
|
||||||
|
this.centralAltitude = centralAltitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getUtcOffset() {
|
||||||
|
return utcOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUtcOffset(float utcOffset) {
|
||||||
|
this.utcOffset = utcOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMagneticVariation() {
|
||||||
|
return magneticVariation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMagneticVariation(float magneticVariation) {
|
||||||
|
this.magneticVariation = magneticVariation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GPSCoordinate getGPSCoordinate() {
|
||||||
|
return new GPSCoordinate(centralLatitude, centralLongitude);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,18 @@ public class StreamedCourse extends Observable implements RaceDataSource {
|
|||||||
|
|
||||||
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
|
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
|
||||||
this.regattaXMLReader = regattaXMLReader;
|
this.regattaXMLReader = regattaXMLReader;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasReadRegatta() { return regattaXMLReader != null; }
|
||||||
|
|
||||||
|
public boolean hasReadBoats() { return boatXMLReader != null; }
|
||||||
|
|
||||||
|
public boolean hasReadCourse() { return streamedCourseXMLReader != null; }
|
||||||
|
|
||||||
|
public String getRegattaName() { return regattaXMLReader.getRegattaName(); }
|
||||||
|
|
||||||
public List<Boat> getBoats() {
|
public List<Boat> getBoats() {
|
||||||
return boatXMLReader.getBoats();
|
return boatXMLReader.getBoats();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
|
||||||
|
|
||||||
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
|
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
|
||||||
<children>
|
<children>
|
||||||
@@ -30,11 +29,6 @@
|
|||||||
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Text fx:id="raceTitleLabel" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5" GridPane.halignment="CENTER">
|
|
||||||
<font>
|
|
||||||
<Font size="36.0" />
|
|
||||||
</font>
|
|
||||||
</Text>
|
|
||||||
<Button fx:id="fifteenMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" text="Start" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
<Button fx:id="fifteenMinButton" maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" text="Start" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
||||||
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
|
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
|
||||||
<placeholder>
|
<placeholder>
|
||||||
@@ -48,6 +42,11 @@
|
|||||||
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="Local time..." GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="Local time..." GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER" />
|
||||||
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
|
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" />
|
||||||
<Label fx:id="raceStartLabel" text="Starting time..." visible="false" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
|
<Label fx:id="raceStartLabel" text="Starting time..." visible="false" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" />
|
||||||
|
<Label fx:id="raceTitleLabel" text="Welcome to RaceVision" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.halignment="CENTER">
|
||||||
|
<font>
|
||||||
|
<Font size="36.0" />
|
||||||
|
</font>
|
||||||
|
</Label>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
Reference in New Issue
Block a user