Merge remote-tracking branch 'remotes/origin/master' into Game_Controller

This commit is contained in:
hba56
2017-07-24 11:58:01 +12:00
218 changed files with 8957 additions and 6977 deletions
+3 -56
View File
@@ -15,69 +15,16 @@
<url>https://eng-git.canterbury.ac.nz/SENG302-2016/team-7</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-referencing</artifactId>
<version>9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>com.github.bfsmith</groupId>
<artifactId>geotimezone</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>seng302</groupId>
<artifactId>network</artifactId>
<artifactId>racevisionGame</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>opengeo</id>
<name>OpenGeo Maven Repository</name>
<url>http://repo.opengeo.org</url>
</repository>
</repositories>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
@@ -99,7 +46,7 @@
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>seng302.App</Main-Class>
<Main-Class>visualiser.app.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
</manifestEntries>
@@ -163,4 +110,4 @@
</plugin>
</plugins>
</reporting>
</project>
</project>
-40
View File
@@ -1,40 +0,0 @@
package seng302;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import seng302.gameController.InputChecker;
public class App extends Application {
/**
* Entry point for running the programme
*
* @param args for starting the programme
*/
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) throws Exception {
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
Platform.exit();
System.exit(0);
}
});
FXMLLoader loader = new FXMLLoader(getClass().getResource("/scenes/main.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root, 1200, 800);
stage.setScene(scene);
stage.setTitle("RaceVision - Team 7");
stage.show();
}
}
@@ -1,97 +0,0 @@
package seng302.Controllers;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import seng302.RaceConnection;
import java.io.IOException;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Controls the connection that the VIsualiser can connect to.
*/
public class ConnectionController extends Controller {
@FXML
private AnchorPane connectionWrapper;
@FXML
private TableView connectionTable;
@FXML
private TableColumn<RaceConnection, String> hostnameColumn;
@FXML
private TableColumn<RaceConnection, String> statusColumn;
@FXML
private Button connectButton;
@FXML
private TextField urlField;
@FXML
private TextField portField;
private ObservableList<RaceConnection> connections;
@Override
public void initialize(URL location, ResourceBundle resources) {
// TODO - replace with config file
connections = FXCollections.observableArrayList();
connections.add(new RaceConnection("livedata.americascup.com", 4941));
connections.add(new RaceConnection("localhost", 4942));
connectionTable.setItems(connections);
hostnameColumn.setCellValueFactory(cellData -> cellData.getValue().hostnameProperty());
statusColumn.setCellValueFactory(cellData -> cellData.getValue().statusProperty());
connectionTable.getSelectionModel().selectedItemProperty().addListener((obs, prev, curr) -> {
if (curr != null && ((RaceConnection)curr).check()) connectButton.setDisable(false);
else connectButton.setDisable(true);
});
connectButton.setDisable(true);
}
/**
* Sets current status of all connections.
*/
public void checkConnections() {
for(RaceConnection connection: connections) {
connection.check();
}
}
public AnchorPane startWrapper(){
return connectionWrapper;
}
/**
* Connects to host currently selected in table. Button enabled only if host is ready.
*/
public void connectSocket() {
try{
RaceConnection connection = (RaceConnection)connectionTable.getSelectionModel().getSelectedItem();
Socket socket = new Socket(connection.getHostname(), connection.getPort());
connectionWrapper.setVisible(false);
parent.enterLobby(socket);
} catch (IOException e) { /* Never reached */ }
}
/**
* adds a new connection
*/
public void addConnection(){
String hostName = urlField.getText();
String portString = portField.getText();
try{
int port = Integer.parseInt(portString);
connections.add(new RaceConnection(hostName, port));
}catch(NumberFormatException e){
System.err.println("Port number entered is not a number");
}
}
}
@@ -1,32 +0,0 @@
package seng302.Controllers;
import javafx.fxml.Initializable;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Controller parent for app controllers.
* Created by fwy13 on 15/03/2017.
*/
public abstract class Controller implements Initializable {
protected MainController parent;
/**
* Sets the parent of the application
*
* @param parent controller
*/
public void setParent(MainController parent) {
this.parent = parent;
}
/**
* Initialisation class that is run on start up.
*
* @param location resources location
* @param resources resources bundle
*/
@Override
public abstract void initialize(URL location, ResourceBundle resources);
}
@@ -1,64 +0,0 @@
package seng302.Controllers;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.AnchorPane;
import seng302.Model.Boat;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Finish Screen for when the race finishs.
*/
public class FinishController extends Controller {
@FXML
AnchorPane finishWrapper;
@FXML
TableView<Boat> boatInfoTable;
@FXML
TableColumn<Boat, String> boatRankColumn;
@FXML
TableColumn<Boat, String> boatNameColumn;
@FXML
Label raceWinnerLabel;
/**
* Sets up the finish table
* @param boats Boats to display
*/
private void setFinishTable(ObservableList<Boat> boats){
boatInfoTable.setItems(boats);
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
boatRankColumn.setCellValueFactory(cellData -> cellData.getValue().positionProperty());
raceWinnerLabel.setText("Winner: "+ boatNameColumn.getCellObservableValue(0).getValue());
raceWinnerLabel.setWrapText(true);
}
@Override
public void initialize(URL location, ResourceBundle resources){
}
/**
* Display the table
* @param boats boats to display on the table.
*/
public void enterFinish(ObservableList<Boat> boats){
finishWrapper.setVisible(true);
setFinishTable(boats);
}
}
@@ -1,60 +0,0 @@
package seng302.Controllers;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
import seng302.Model.Boat;
import seng302.Model.RaceClock;
import seng302.VisualiserInput;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Controller that everything is overlayed onto. This makes it so that changing scenes does not resize your stage.
*/
public class MainController extends Controller {
@FXML private StartController startController;
@FXML private RaceController raceController;
@FXML private ConnectionController connectionController;
@FXML private FinishController finishController;
public void beginRace(VisualiserInput visualiserInput, RaceClock raceClock) {
raceController.startRace(visualiserInput, raceClock);
}
public void enterLobby(Socket socket) {
startController.enterLobby(socket);
}
public void enterFinish(ObservableList<Boat> boats) { finishController.enterFinish(boats); }
/**
* Main Controller for the applications will house the menu and the displayed pane.
*
* @param location of resources
* @param resources bundle
*/
@Override
public void initialize(URL location, ResourceBundle resources) {
startController.setParent(this);
raceController.setParent(this);
connectionController.setParent(this);
finishController.setParent(this);
AnchorPane.setTopAnchor(startController.startWrapper(), 0.0);
AnchorPane.setBottomAnchor(startController.startWrapper(), 0.0);
AnchorPane.setLeftAnchor(startController.startWrapper(), 0.0);
AnchorPane.setRightAnchor(startController.startWrapper(), 0.0);
AnchorPane.setTopAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setBottomAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setLeftAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setRightAnchor(connectionController.startWrapper(), 0.0);
AnchorPane.setTopAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setBottomAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setLeftAnchor(finishController.finishWrapper, 0.0);
AnchorPane.setRightAnchor(finishController.finishWrapper, 0.0);
}
}
@@ -1,200 +0,0 @@
package seng302.Controllers;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import seng302.Mock.StreamedRace;
import seng302.Model.*;
import seng302.VisualiserInput;
import java.net.URL;
import java.util.ResourceBundle;
/**
* Created by fwy13 on 15/03/2017.
*/
public class RaceController extends Controller {
private ResizableRaceCanvas raceMap;
private ResizableRaceMap raceBoundaries;
private RaceClock raceClock;
private Sparkline sparkline;
private int legNum;
@FXML GridPane canvasBase;
@FXML Pane arrow;
@FXML SplitPane race;
@FXML StackPane arrowPane;
@FXML Label timer;
@FXML Label FPS;
@FXML Label timeZone;
@FXML CheckBox showFPS;
@FXML TableView<Boat> boatInfoTable;
@FXML TableColumn<Boat, String> boatPlacingColumn;
@FXML TableColumn<Boat, String> boatTeamColumn;
@FXML TableColumn<Boat, String> boatMarkColumn;
@FXML TableColumn<Boat, String> boatSpeedColumn;
@FXML LineChart<Number, Number> sparklineChart;
@FXML AnchorPane annotationPane;
/**
* Updates the ResizableRaceCanvas (raceMap) with most recent data
*
* @param boats boats that are to be displayed in the race
* @param boatMarkers Markers for boats
* @see ResizableRaceCanvas
*/
public void updateMap(ObservableList<Boat> boats, ObservableList<Marker> boatMarkers) {
raceMap.setBoats(boats);
raceMap.setBoatMarkers(boatMarkers);
raceMap.update();
raceBoundaries.draw();
//stop if the visualiser is no longer running
}
/**
* Updates the array listened by the TableView (boatInfoTable) that displays the boat information.
*
* @param race Race to listen to.
*/
public void setInfoTable(StreamedRace race) {
boatInfoTable.setItems(race.getStartingBoats());
boatTeamColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
boatSpeedColumn.setCellValueFactory(cellData -> cellData.getValue().getVelocityProp());
boatMarkColumn.setCellValueFactory(cellData -> cellData.getValue().getCurrentLegName());
boatPlacingColumn.setCellValueFactory(cellData -> cellData.getValue().positionProperty());
}
@Override
public void initialize(URL location, ResourceBundle resources) {
//listener for fps
showFPS.selectedProperty().addListener((ov, old_val, new_val) -> {
if (showFPS.isSelected()) {
FPS.setVisible(true);
} else {
FPS.setVisible(false);
}
});
}
/**
* Creates and sets initial display for Sparkline for race positions.
* @param boats boats to display on the sparkline
*/
public void createSparkLine(ObservableList<Boat> boats){
sparkline = new Sparkline(boats, legNum, sparklineChart);
}
/**
* Updates the sparkline to display current boat positions.
* @param boatsInRace used for current boat positions.
*/
public void updateSparkline(ObservableList<Boat> boatsInRace){
sparkline.updateSparkline(boatsInRace);
}
/**
* Initializes and runs the race, based on the user's chosen scale factor
* Currently uses an example racecourse
*
* @param visualiserInput input from network
* @param raceClock The RaceClock to use for the race's countdown/elapsed duration + timezone.
*/
public void startRace(VisualiserInput visualiserInput, RaceClock raceClock) {
legNum = visualiserInput.getCourse().getLegs().size()-1;
makeArrow();
raceMap = new ResizableRaceCanvas(visualiserInput.getCourse());
raceMap.setMouseTransparent(true);
raceMap.widthProperty().bind(canvasBase.widthProperty());
raceMap.heightProperty().bind(canvasBase.heightProperty());
raceMap.draw();
raceMap.setVisible(true);
raceMap.setArrow(arrow.getChildren().get(0));
canvasBase.getChildren().add(0, raceMap);
raceBoundaries = new ResizableRaceMap(visualiserInput.getCourse());
raceBoundaries.setMouseTransparent(true);
raceBoundaries.widthProperty().bind(canvasBase.widthProperty());
raceBoundaries.heightProperty().bind(canvasBase.heightProperty());
raceBoundaries.draw();
raceBoundaries.setVisible(true);
canvasBase.getChildren().add(0, raceBoundaries);
race.setVisible(true);
timeZone.setText(raceClock.getTimeZone());
//RaceClock.duration isn't necessarily being changed in the javaFX thread, so we need to runlater the update.
raceClock.durationProperty().addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> {
timer.setText(newValue);
});
});
this.raceClock = raceClock;
raceMap.setRaceClock(raceClock);
StreamedRace newRace = new StreamedRace(visualiserInput, this);
initializeFPS();
// set up annotation displays
new Annotations(annotationPane, raceMap);
new Thread((newRace)).start();
}
/**
* Finish Race View
* @param boats boats there are in the race.
*/
public void finishRace(ObservableList<Boat> boats){
race.setVisible(false);
parent.enterFinish(boats);
}
/**
* Set the value for the fps label
*
* @param fps fps that the label will be updated to
*/
public void setFrames(String fps) {
FPS.setText((fps));
}
/**
* Set up FPS display at bottom of screen
*/
private void initializeFPS() {
showFPS.setVisible(true);
showFPS.selectedProperty().addListener((ov, old_val, new_val) -> {
if (showFPS.isSelected()) {
FPS.setVisible(true);
} else {
FPS.setVisible(false);
}
});
}
private void makeArrow() {
arrowPane.getChildren().add(arrow);
}
public RaceClock getRaceClock() {
return raceClock;
}
}
@@ -1,212 +0,0 @@
package seng302.Controllers;
import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import seng302.Mock.StreamedCourse;
import seng302.Model.Boat;
import seng302.Model.RaceClock;
import seng302.VisualiserInput;
import java.io.IOException;
import java.net.Socket;
import java.net.URL;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.ResourceBundle;
/**
* Controller to for waiting for the race to start
*/
public class StartController extends Controller implements Observer {
@FXML private GridPane start;
@FXML private AnchorPane startWrapper;
@FXML private Label raceTitleLabel;
@FXML private Label raceStartLabel;
@FXML private TableView<Boat> boatNameTable;
@FXML private TableColumn<Boat, String> boatNameColumn;
@FXML private TableColumn<Boat, String> boatCodeColumn;
@FXML private Label timeZoneTime;
@FXML private Label timer;
@FXML private Label raceStatusLabel;
//@FXML Button fifteenMinButton;
private RaceClock raceClock;
private StreamedCourse raceData;
private int raceStat;
private VisualiserInput visualiserInput;
///Tracks whether the race has been started (that is, has startRaceNoScaling() be called).
private boolean hasRaceStarted = false;
//Tracks whether or not a clock has been created and setup, which occurs after receiving enough information.
private boolean hasCreatedClock = false;
/**
* Begins the race with a scale factor of 1
*/
private void startRaceNoScaling() {
//while(visualiserInput.getRaceStatus() == null);//TODO probably remove this.
countdownTimer();
}
@Override
public void initialize(URL location, ResourceBundle resources){
raceData = new StreamedCourse();
raceData.addObserver(this);
}
public AnchorPane startWrapper(){
return startWrapper;
}
/**
* Initiliases the tables that are to be shown on the pane
*/
private void initialiseTables() {
List<Boat> boats = raceData.getBoats();
ObservableList<Boat> observableBoats = FXCollections.observableArrayList(boats);
boatNameTable.setItems(observableBoats);
boatNameColumn.setCellValueFactory(cellData -> cellData.getValue().getName());
boatCodeColumn.setCellValueFactory(new PropertyValueFactory<>("abbrev"));
}
/**
* Countdown timer until race starts.
*/
private void countdownTimer() {
new AnimationTimer() {
@Override
public void handle(long arg0) {
raceStat = visualiserInput.getRaceStatus().getRaceStatus();
raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus());
if (raceStat==2 || raceStat == 3) {
stop();
startWrapper.setVisible(false);
start.setVisible(false);
parent.beginRace(visualiserInput, raceClock);
}
}
}.start();
}
/**
* Sets the clock that displays the time of at the current race venue.
*/
private void setRaceClock() {
raceClock = new RaceClock(raceData.getZonedDateTime());
raceClock.timeStringProperty().addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> {
timeZoneTime.setText(newValue);
});
});
//TEMP REMOVE
//timeZoneTime.textProperty().bind(raceClock.timeStringProperty());
raceClock.run();
}
/**
* Sets the time that the race is going to start.
*/
private void setStartingTime() {
String dateFormat = "'Starting time:' HH:mm dd/MM/YYYY";
Platform.runLater(()-> {
long utcTime = visualiserInput.getRaceStatus().getExpectedStartTime();
raceClock.setStartingTime(raceClock.getLocalTime(utcTime));
raceStartLabel.setText(DateTimeFormatter.ofPattern(dateFormat).format(raceClock.getStartingTime()));
raceClock.durationProperty().addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> {
timer.setText(newValue);
});
});
});
}
/**
* set the current time, may be used to update the time on the clock.
*/
private void setCurrentTime() {
Platform.runLater(()->
raceClock.setUTCTime(visualiserInput.getRaceStatus().getCurrentTime())
);
}
@Override
public void update(Observable o, Object arg) {
if(o instanceof StreamedCourse) {
StreamedCourse streamedCourse = (StreamedCourse) o;
if(streamedCourse.hasReadBoats()) {
initialiseTables();
}
if(streamedCourse.hasReadRegatta()) {
Platform.runLater(() -> raceTitleLabel.setText(streamedCourse.getRegattaName()));
}
if (streamedCourse.hasReadCourse()) {
Platform.runLater(() -> {
if (!this.hasCreatedClock) {
this.hasCreatedClock = true;
setRaceClock();
if (visualiserInput.getRaceStatus() == null) {
return;//TEMP BUG FIX if the race isn't sending race status messages (our mock currently doesn't), then it would block the javafx thread with the previous while loop.
}// TODO - replace with observer on VisualiserInput
setStartingTime();
setCurrentTime();
}
});
}
//TODO this is a somewhat temporary fix for when not all of the race data (boats, course, regatta) is received in time.
//Previously, startRaceNoScaling was called in the enterLobby function after the visualiserInput was started, but when connecting to the official data source it sometimes didn't send all of the race data, causing startRaceNoScaling to start, even though we didn't have enough information to start it.
if (streamedCourse.hasReadBoats() && streamedCourse.hasReadCourse() && streamedCourse.hasReadRegatta()) {
Platform.runLater(() -> {
if (!this.hasRaceStarted) {
if(visualiserInput.getRaceStatus() == null) {
}
else {
this.hasRaceStarted = true;
startRaceNoScaling();
}
}
});
}
}
}
/**
* Show starting information for a race given a socket.
* @param socket network source of information
*/
public void enterLobby(Socket socket) {
startWrapper.setVisible(true);
try {
visualiserInput = new VisualiserInput(socket, raceData);
new Thread(visualiserInput).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -1,74 +0,0 @@
package seng302;
/**
* GPS Coordinate for the world map.
* It is converted to a {@link seng302.GraphCoordinate GraphCoordinate} via
* the {@link seng302.RaceMap RaceMap} to display objects in their relative
* positions on the {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
*/
public class GPSCoordinate {
private final double latitude;
private final double longitude;
/**
* Constructor Method
*
* @param latitude latitude the coordinate is located at.
* @param longitude Longitude that the coordinate is located at.
*/
public GPSCoordinate(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
/**
* Gets the Latitude that the Coordinate is at.
*
* @return Returns the latitude of the Coordinate.
*/
public double getLatitude() {
return latitude;
}
/**
* Gets the Longitude that the Coordinate is at.
*
* @return Returns the longitude of the Coordinate.
*/
public double getLongitude() {
return longitude;
}
/**
* To String method of the Coordinate in the form Latitude: $f, Longitude: $f.
*
* @return A String representation of the GPSCoordinate Class.
*/
public String toString() {
return String.format("Latitude: %f, Longitude: %f", latitude, longitude);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GPSCoordinate that = (GPSCoordinate) o;
if (Math.abs(this.latitude - latitude) > 1e-6) return false;
return (Math.abs(this.longitude - longitude) < 1e-6);
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(latitude);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(longitude);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}
@@ -1,42 +0,0 @@
package seng302;
/**
* It is a coordinate representing a location on the
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
* It has been converted from a {@link seng302.GPSCoordinate GPSCoordinate}
* to display objects in their relative positions.
*/
public class GraphCoordinate {
private final int x;
private final int y;
/**
* Constructor method.
*
* @param x X coordinate.
* @param y Y coordinate.
*/
public GraphCoordinate(int x, int y) {
this.x = x;
this.y = y;
}
/**
* Returns the X coordinate.
*
* @return x axis Coordinate.
*/
public int getX() {
return x;
}
/**
* Returns the Y coordinate.
*
* @return y axis Coordinate.
*/
public int getY() {
return y;
}
}
@@ -1,157 +0,0 @@
package seng302.Mock;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import seng302.Model.Boat;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* XML Reader that reads in a file and initializes
* {@link seng302.Mock.StreamedBoat StreamedBoat}s that will be participating
* in a race.
*/
public class BoatXMLReader extends XMLReader {
private final Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
private Map<Integer, StreamedBoat> participants = new HashMap<>();
/**
* Constructor for Boat XML Reader
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
this(filePath, true);
}
/**
* Constructor for Boat XML Reader
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
super(filePath);
if (read) {
read();
}
}
/**
* Constructor for Boat XML Reader
* @param xmlString sting to read
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public BoatXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException {
super(xmlString);
read();
}
public void read() {
readSettings();
readShapes();
readBoats();
}
/**
* Reads boats settings.
* INFORMATION FROM HERE IS IGNORED FOR NOW
*/
private void readSettings() {
}
/**
* Reads different kinds of boat.
* INFORMATION FROM HERE IS IGNORED FOR NOW
*/
private void readShapes() {
}
/**
* Reads the boats in the race
*/
private void readBoats() {
Element nBoats = (Element) doc.getElementsByTagName("Boats").item(0);
for (int i = 0; i < nBoats.getChildNodes().getLength(); i++) {
Node boat = nBoats.getChildNodes().item(i);
if (boat.getNodeName().equals("Boat") && boat.getAttributes().getNamedItem("Type").getTextContent().equals("Yacht")) {
readSingleBoat(boat);
}
}
}
/**
* Reads the information about one boat
* Ignored values: ShapeID, StoweName, HullNum, Skipper, Type
* @param boat The node to read boat data from.
*/
private void readSingleBoat(Node boat) {
StreamedBoat streamedBoat;
String country = null;
int sourceID = Integer.parseInt(boat.getAttributes().getNamedItem("SourceID").getTextContent());
String boatName = boat.getAttributes().getNamedItem("BoatName").getTextContent();
String shortName = boat.getAttributes().getNamedItem("ShortName").getTextContent();
if (exists(boat, "Country")) country = boat.getAttributes().getNamedItem("Country").getTextContent();
// Ignore all non participating boats
if (participants.containsKey(sourceID)) {
if (!streamedBoatMap.containsKey(sourceID)) {
if (country != null) {
streamedBoat = new StreamedBoat(sourceID, boatName, country);
} else {
streamedBoat = new StreamedBoat(sourceID, boatName, shortName);
}
streamedBoatMap.put(sourceID, streamedBoat);
// Override boat with new boat
participants.put(sourceID, streamedBoat);
}
for (int i = 0; i < boat.getChildNodes().getLength(); i++) {
Node GPSposition = boat.getChildNodes().item(i);
if (GPSposition.getNodeName().equals("GPSposition"))
readBoatPositionInformation(sourceID, GPSposition);
}
}
}
/**
* Reads the positional information about a boat
* Ignored values: FlagPosition, MastTop, Z value of GPSPosition
* @param sourceID The source ID of the boat.
* @param GPSposition The relative GPS position of the boat.
*/
private void readBoatPositionInformation(int sourceID, Node GPSposition) {
// TODO Get relative point before implementing. (GPSposition is based
// off a relative point).
}
/**
* Sets the participants
* @param participants boats participating the race mapped by their source ID's
*/
public void setParticipants(Map<Integer, StreamedBoat> participants) {
this.participants = participants;
}
public List<Boat> getBoats() {
return new ArrayList<>(streamedBoatMap.values());
}
}
@@ -1,166 +0,0 @@
package seng302.Mock;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.GPSCoordinate;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
/**
* Created by jjg64 on 19/04/17.
*/
public class RegattaXMLReader extends XMLReader {
private int regattaID;
private String regattaName;
private int raceID = 0;
private String courseName;
private double centralLatitude;
private double centralLongitude;
private double centralAltitude;
private float utcOffset;
private float magneticVariation;
/**
* Constructor for Regatta XML
*
* @param filePath path of the file
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
public RegattaXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
this(filePath, true);
}
/**
* Constructor for Regatta XML
*
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
*/
private RegattaXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
super(filePath);
if (read) {
read();
}
}
/**
* Alternate Constructor that takes in an inputstream instead
* @param xmlString Input stream of the XML
* @throws IOException Error with input
* @throws SAXException Error with XML Format
* @throws ParserConfigurationException Error with XMl contents
*/
public RegattaXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException {
super(xmlString);
read();
}
/**
* Read the XML
*/
private void read() {
NodeList attributeConfig = doc.getElementsByTagName("RegattaConfig");
Element attributes = (Element) attributeConfig.item(0);
makeRegatta(attributes);
}
/**
* Extracts the information from the attributes
* @param attributes attributes to extract information form.
*/
private void makeRegatta(Element attributes) {
this.regattaID = Integer.parseInt(getTextValueOfNode(attributes, "RegattaID"));
this.regattaName = getTextValueOfNode(attributes, "RegattaName");
this.courseName = getTextValueOfNode(attributes, "CourseName");
this.centralLatitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLatitude"));
this.centralLongitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralLongitude"));
this.centralAltitude = Double.parseDouble(getTextValueOfNode(attributes, "CentralAltitude"));
this.utcOffset = Float.parseFloat(getTextValueOfNode(attributes, "UtcOffset"));
this.magneticVariation = Float.parseFloat(getTextValueOfNode(attributes, "MagneticVariation"));
}
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);
}
}
@@ -1,36 +0,0 @@
package seng302.Mock;
import seng302.Model.Boat;
/**
* Boats that are been received.
*/
public class StreamedBoat extends Boat {
private final int sourceID;
private boolean dnf = false;
private void init() {
this.velocity = 0;
}
/**
* COnstructor
* @param sourceID ID of the BOat
* @param name Name of the Boat
* @param abbrev Boat's name shortened.
*/
public StreamedBoat(int sourceID, String name, String abbrev) {
super(name, abbrev);
this.sourceID = sourceID;
this.init();
}
public StreamedBoat(int sourceID) {
this(sourceID, "None", "None");
}
public int getSourceID() {
return sourceID;
}
}
@@ -1,106 +0,0 @@
package seng302.Mock;
import seng302.GPSCoordinate;
import seng302.Model.Boat;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.RaceDataSource;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Observable;
/**
* COurse that the is being received.
*/
public class StreamedCourse extends Observable implements RaceDataSource {
private StreamedCourseXMLReader streamedCourseXMLReader = null;
private BoatXMLReader boatXMLReader = null;
private RegattaXMLReader regattaXMLReader = null;
private double windDirection = 0;
public StreamedCourse() {}
/**
* Read and set the new XML that has been received.
* @param boatXMLReader new XMl of the boats.
*/
public void setBoatXMLReader(BoatXMLReader boatXMLReader) {
this.boatXMLReader = boatXMLReader;
if (streamedCourseXMLReader != null && boatXMLReader != null) {
this.boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants());
boatXMLReader.read();
}
setChanged();
notifyObservers();
}
public StreamedCourseXMLReader getStreamedCourseXMLReader() {
return streamedCourseXMLReader;
}
/**
* Read and sets the new Course that has been received
* @param streamedCourseXMLReader COurse XML that has been received
*/
public void setStreamedCourseXMLReader(StreamedCourseXMLReader streamedCourseXMLReader) {
this.streamedCourseXMLReader = streamedCourseXMLReader;
if (streamedCourseXMLReader != null && boatXMLReader != null) {
boatXMLReader.setParticipants(streamedCourseXMLReader.getParticipants());
boatXMLReader.read();
}
}
/**
* Reads and sets the new Regatta that has been received
* @param regattaXMLReader Regatta XMl that has been received.
*/
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
this.regattaXMLReader = regattaXMLReader;
setChanged();
notifyObservers();
}
public void setWindDirection(double windDirection) {
this.windDirection = windDirection;
}
public double getWindDirection() {
return windDirection;
}
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() {
return boatXMLReader.getBoats();
}
public List<Leg> getLegs() {
return streamedCourseXMLReader.getLegs();
}
public List<Marker> getMarkers() { return streamedCourseXMLReader.getMarkers(); }
public List<GPSCoordinate> getBoundary() {
return streamedCourseXMLReader.getBoundary();
}
public ZonedDateTime getZonedDateTime() {
return streamedCourseXMLReader.getRaceStartTime();
}
public GPSCoordinate getMapTopLeft() {
return streamedCourseXMLReader.getMapTopLeft();
}
public GPSCoordinate getMapBottomRight() {
return streamedCourseXMLReader.getMapBottomRight();
}
}
@@ -1,7 +0,0 @@
package seng302.Mock;
/**
* Created by cbt24 on 25/04/17.
*/
public class StreamedCourseXMLException extends Throwable {
}
@@ -1,291 +0,0 @@
package seng302.Mock;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import seng302.GPSCoordinate;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* XML Read for the Course that is being received
*/
public class StreamedCourseXMLReader extends XMLReader {
private static final double COORDINATEPADDING = 0.000;
private GPSCoordinate mapTopLeft, mapBottomRight;
private final List<GPSCoordinate> boundary = new ArrayList<>();
private final Map<Integer,Element> compoundMarks = new HashMap<>();
private final Map<Integer, StreamedBoat> participants = new HashMap<>();
private final List<Leg> legs = new ArrayList<>();
private final List<Marker> markers = new ArrayList<>();
private ZonedDateTime creationTimeDate;
private ZonedDateTime raceStartTime;
private int raceID;
private String raceType;
private boolean postpone;
/**
* Constructor for Streamed Race XML
* @param filePath file path to read
* @param read whether or not to read and store the files straight away.
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException, StreamedCourseXMLException {
super(filePath);
if (read) {
read();
}
}
/**
* Constructor for Streamed Race XML
* @param xmlString string to read
* @throws IOException error
* @throws SAXException error
* @throws ParserConfigurationException error
* @throws StreamedCourseXMLException error
*/
public StreamedCourseXMLReader(InputStream xmlString) throws IOException, SAXException, ParserConfigurationException, StreamedCourseXMLException {
super(xmlString);
read();
}
/**
* reads
* @throws StreamedCourseXMLException error
*/
private void read() throws StreamedCourseXMLException {
readRace();
readParticipants();
readCourse();
}
/**
* reads a race
*/
private void readRace() {
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
Element settings = (Element) doc.getElementsByTagName("Race").item(0);
NamedNodeMap raceTimeTag = doc.getElementsByTagName("RaceStartTime").item(0).getAttributes();
if (raceTimeTag.getNamedItem("Time") != null) dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
raceID = Integer.parseInt(getTextValueOfNode(settings, "RaceID"));
raceType = getTextValueOfNode(settings, "RaceType");
creationTimeDate = ZonedDateTime.parse(getTextValueOfNode(settings, "CreationTimeDate"), dateFormat);
if (raceTimeTag.getNamedItem("Time") != null) raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Time").getTextContent(), dateFormat);
else raceStartTime = ZonedDateTime.parse(raceTimeTag.getNamedItem("Start").getTextContent(), dateFormat);
postpone = Boolean.parseBoolean(raceTimeTag.getNamedItem("Postpone").getTextContent());
}
/**
* Reads the participants of the race.
*/
private void readParticipants() {
Element nParticipants = (Element) doc.getElementsByTagName("Participants").item(0);
nParticipants.getChildNodes().getLength();
for (int i = 0; i < nParticipants.getChildNodes().getLength(); i++) {
int sourceID;
Node yacht = nParticipants.getChildNodes().item(i);
if (yacht.getNodeName().equals("Yacht")) {
if (exists(yacht, "SourceID")) {
sourceID = Integer.parseInt(yacht.getAttributes().getNamedItem("SourceID").getTextContent());
participants.put(sourceID, new StreamedBoat(sourceID));
}
}
}
}
/**
* reads a course
* @throws StreamedCourseXMLException error
*/
private void readCourse() throws StreamedCourseXMLException {
readCompoundMarks();
readCompoundMarkSequence();
readCourseLimit();
}
/**
* Indexes CompoundMark elements by their ID for use in generating the course, and populates list of Markers.
* @throws StreamedCourseXMLException if a CompoundMark element contains an unhandled number of compoundMarks.
* @see seng302.Model.Marker
*/
private void readCompoundMarks() throws StreamedCourseXMLException {
Element nCourse = (Element) doc.getElementsByTagName("Course").item(0);
for(int i = 0; i < nCourse.getChildNodes().getLength(); i++) {
Node compoundMark = nCourse.getChildNodes().item(i);
if(compoundMark.getNodeName().equals("CompoundMark")) {
int compoundMarkID = getCompoundMarkID((Element) compoundMark);
compoundMarks.put(compoundMarkID, (Element)compoundMark);
markers.add(getMarker(compoundMarkID));
}
}
}
/**
* Generates a Marker from the CompoundMark element with given ID.
* @param compoundMarkID index of required CompoundMark element
* @return generated Marker
* @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of compoundMarks
* @see seng302.Model.Marker
*/
private Marker getMarker(int compoundMarkID) throws StreamedCourseXMLException {
Element compoundMark = compoundMarks.get(compoundMarkID);
NodeList nMarks = compoundMark.getElementsByTagName("Mark");
Marker marker;
switch(nMarks.getLength()) {
case 1: marker = new Marker(getCoordinate((Element)nMarks.item(0)),getSourceId((Element)nMarks.item(0))); break;
case 2: marker = new Marker(getCoordinate((Element)nMarks.item(0)), getCoordinate((Element)nMarks.item(1)),
getSourceId((Element)nMarks.item(0)), getSourceId((Element)nMarks.item(1))); break;
default: throw new StreamedCourseXMLException();
}
return marker;
}
/**
* Extracts the GPS Coordinates from a XMl Element
* @param mark Element to Extract from
* @return the GPS coordinate that it reflects
*/
private GPSCoordinate getCoordinate(Element mark) {
double lat = Double.parseDouble(mark.getAttribute("TargetLat"));
double lon = Double.parseDouble(mark.getAttribute("TargetLng"));
return new GPSCoordinate(lat,lon);
}
/**
* Extracts the SourceID from a XML ELement
* @param mark Element to Extract from
* @return the Source ID of the Extracted Element.
*/
private int getSourceId(Element mark) {
String sourceId = mark.getAttribute("SourceID");
if (sourceId.isEmpty()){
return 0;
}
return Integer.parseInt(sourceId);
}
/**
* Reads "compoundMarkID" attribute of CompoundMark or Corner element
* @param element with "compoundMarkID" attribute
* @return value of "compoundMarkID" attribute
*/
private int getCompoundMarkID(Element element) {
return Integer.parseInt(element.getAttribute("CompoundMarkID"));
}
/**
* Reads "name" attribute of CompoundMark element with corresponding CompoundMarkID
* @param compoundMarkID unique ID for CompoundMark element
* @return value of "name" attribute
*/
private String getCompoundMarkName(int compoundMarkID) {
return compoundMarks.get(compoundMarkID).getAttribute("Name");
}
/**
* Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements.
* @throws StreamedCourseXMLException if markers cannot be resolved from CompoundMark
*/
private void readCompoundMarkSequence() throws StreamedCourseXMLException {
Element nCompoundMarkSequence = (Element) doc.getElementsByTagName("CompoundMarkSequence").item(0);
NodeList nCorners = nCompoundMarkSequence.getElementsByTagName("Corner");
Element markXML = (Element)nCorners.item(0);
Marker lastMarker = getMarker(getCompoundMarkID(markXML));
String legName = getCompoundMarkName(getCompoundMarkID(markXML));
for(int i = 1; i < nCorners.getLength(); i++) {
markXML = (Element)nCorners.item(i);
Marker currentMarker = getMarker(getCompoundMarkID(markXML));
legs.add(new Leg(legName, lastMarker, currentMarker, i-1));
lastMarker = currentMarker;
legName = getCompoundMarkName(getCompoundMarkID(markXML));
}
}
/**
* Reads the course boundary limitations of the course recieved.
*/
private void readCourseLimit() {
Element nCourseLimit = (Element) doc.getElementsByTagName("CourseLimit").item(0);
for(int i = 0; i < nCourseLimit.getChildNodes().getLength(); i++) {
Node limit = nCourseLimit.getChildNodes().item(i);
if (limit.getNodeName().equals("Limit")) {
double lat = Double.parseDouble(limit.getAttributes().getNamedItem("Lat").getTextContent());
double lon = Double.parseDouble(limit.getAttributes().getNamedItem("Lon").getTextContent());
boundary.add(new GPSCoordinate(lat, lon));
}
}
double maxLatitude = boundary.stream().max(Comparator.comparingDouble(GPSCoordinate::getLatitude)).get().getLatitude() + COORDINATEPADDING;
double maxLongitude = boundary.stream().max(Comparator.comparingDouble(GPSCoordinate::getLongitude)).get().getLongitude() + COORDINATEPADDING;
double minLatitude = boundary.stream().min(Comparator.comparingDouble(GPSCoordinate::getLatitude)).get().getLatitude() + COORDINATEPADDING;
double minLongitude = boundary.stream().min(Comparator.comparingDouble(GPSCoordinate::getLongitude)).get().getLongitude() + COORDINATEPADDING;
mapTopLeft = new GPSCoordinate(minLatitude, minLongitude);
mapBottomRight = new GPSCoordinate(maxLatitude, maxLongitude);
}
public List<GPSCoordinate> getBoundary() {
return boundary;
}
public GPSCoordinate getMapTopLeft() {
return mapTopLeft;
}
public GPSCoordinate getMapBottomRight() {
return mapBottomRight;
}
public List<Leg> getLegs() {
return legs;
}
public List<Marker> getMarkers() { return markers; }
public Double getPadding() {
return COORDINATEPADDING;
}
public ZonedDateTime getRaceStartTime() {
return raceStartTime;
}
public int getRaceID() {
return raceID;
}
public String getRaceType() {
return raceType;
}
public boolean isPostpone() {
return postpone;
}
public Map<Integer, StreamedBoat> getParticipants() {
return participants;
}
}
@@ -1,285 +0,0 @@
package seng302.Mock;
import javafx.animation.AnimationTimer;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seng302.Controllers.FinishController;
import seng302.Controllers.RaceController;
import seng302.GPSCoordinate;
import seng302.Model.Boat;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.Networking.Messages.BoatLocation;
import seng302.Networking.Messages.BoatStatus;
import seng302.Networking.Messages.Enums.BoatStatusEnum;
import seng302.VisualiserInput;
import java.util.List;
/**
* The Class used to view the race streamed.
*/
public class StreamedRace implements Runnable {
private final VisualiserInput visualiserInput;
private final ObservableList<Boat> startingBoats;
private final ObservableList<Marker> boatMarkers;
private final List<Leg> legs;
private RaceController controller;
protected FinishController finishController;
private int boatsFinished = 0;
private long totalTimeElapsed;
private int lastFPS = 20;
public StreamedRace(VisualiserInput visualiserInput, RaceController controller) {
StreamedCourse course = visualiserInput.getCourse();
this.startingBoats = FXCollections.observableArrayList(course.getBoats());
this.boatMarkers = FXCollections.observableArrayList(course.getMarkers());
this.legs = course.getLegs();
this.legs.add(new Leg("Finish", this.legs.size()));
this.controller = controller;
if (startingBoats != null && startingBoats.size() > 0) {
initialiseBoats();
}
this.visualiserInput = visualiserInput;
}
private void initialiseBoats() {
Leg officialStart = legs.get(0);
String name = officialStart.getName();
Marker endCompoundMark = officialStart.getEndMarker();
for (Boat boat : startingBoats) {
if (boat != null) {
Leg startLeg = new Leg(name, 0);
startLeg.setEndMarker(endCompoundMark);
boat.setCurrentLeg(startLeg, controller.getRaceClock());
boat.setTimeSinceLastMark(controller.getRaceClock().getTime());
}
}
}
/**
* Checks if the boat cannot finish the race
* @return True if boat cannot finish the race
*/
protected boolean doNotFinish() {
// DNF is no longer random and is now determined by a dnf packet
return false;
}
/**
* Checks the position of the boat.
*
* @param boat Boat that the position is to be updated for.
* @param timeElapsed Time that has elapse since the start of the the race.
*/
private void checkPosition(Boat boat, long timeElapsed) {
boolean legChanged = false;
StreamedCourse raceData = visualiserInput.getCourse();
BoatStatus boatStatusMessage = visualiserInput.getBoatStatusMap().get(boat.getSourceID());
if (boatStatusMessage != null) {
BoatStatusEnum boatStatusEnum = BoatStatusEnum.fromByte(boatStatusMessage.getBoatStatus());
int legNumber = boatStatusMessage.getLegNumber();
if (legNumber >= 1 && legNumber < legs.size()) {
if (boat.getCurrentLeg() != legs.get(legNumber)){
boat.setCurrentLeg(legs.get(legNumber), controller.getRaceClock());
legChanged = true;
}
}
if (boatStatusEnum == BoatStatusEnum.RACING) {
boat.addTrackPoint(boat.getCurrentPosition());
} else if (boatStatusEnum == BoatStatusEnum.DNF) {
boat.setDnf(true);
} else if (boatStatusEnum == BoatStatusEnum.FINISHED || legNumber == raceData.getLegs().size()) {
boatsFinished++;
boat.setTimeFinished(timeElapsed);
boat.setFinished(true);
}
}
if (legChanged) {
//Update the boat display table in the GUI to reflect the leg change
updatePositions();
controller.updateSparkline(startingBoats);
}
}
/**
* Updates the boat's gps coordinates
*
* @param boat to be updated
*/
private void updatePosition(Boat boat) {
int sourceID = boat.getSourceID();
BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID);
BoatStatus boatStatus = visualiserInput.getBoatStatusMessage(sourceID);
if(boatLocation != null) {
double lat = boatLocation.getLatitudeDouble();
double lon = boatLocation.getLongitudeDouble();
boat.setCurrentPosition(new GPSCoordinate(lat, lon));
boat.setHeading(boatLocation.getHeadingDegrees());
boat.setEstTime(convertEstTime(boatStatus.getEstTimeAtNextMark(), boatLocation.getTime()));
double MMPS_TO_KN = 0.001944;
boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN);
}
}
/**
* Updates the boat's gps coordinates
*
* @param mark to be updated
*/
private void updateMarker(Marker mark) {
int sourceID = mark.getSourceId1();
BoatLocation boatLocation1 = visualiserInput.getBoatLocationMessage(sourceID);
if(boatLocation1 != null) {
double lat = boatLocation1.getLatitudeDouble();
double lon = boatLocation1.getLongitudeDouble();
mark.setCurrentPosition1(new GPSCoordinate(lat, lon));
}
int sourceID2 = mark.getSourceId2();
BoatLocation boatLocation2 = visualiserInput.getBoatLocationMessage(sourceID2);
if(boatLocation2 != null) {
double lat = boatLocation2.getLatitudeDouble();
double lon = boatLocation2.getLongitudeDouble();
mark.setCurrentPosition2(new GPSCoordinate(lat, lon));
}
}
public void setController(RaceController controller) {
this.controller = controller;
}
/**
* Runnable for the thread.
*/
public void run() {
setControllerListeners();
Platform.runLater(() -> controller.createSparkLine(startingBoats));
initialiseBoats();
startRaceStream();
}
/**
* Update the calculated fps to the fps label
*
* @param fps The new calculated fps value
*/
private void updateFPS(int fps) {
Platform.runLater(() -> controller.setFrames("FPS: " + fps));
}
/**
* 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 startRaceStream() {
System.setProperty("javafx.animation.fullspeed", "true");
new AnimationTimer() {
final long timeRaceStarted = System.currentTimeMillis(); //start time of loop
int fps = 0; //init fps value
long timeCurrent = System.currentTimeMillis(); //current time
@Override
public void handle(long arg0) {
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
//Check if the race has actually started.
if (visualiserInput.getRaceStatus().isStarted()) {
//Set all boats to started.
for (Boat boat : startingBoats) {
boat.setStarted(true);
}
}
for (Boat boat : startingBoats) {
if (boat != null && !boat.isFinished()) {
updatePosition(boat);
checkPosition(boat, totalTimeElapsed);
}
}
for (Marker mark: boatMarkers){
if (mark != null){
updateMarker(mark);
}
}
if (visualiserInput.getRaceStatus().isFinished()) {
controller.finishRace(startingBoats);
stop();
}
controller.updateMap(startingBoats, boatMarkers);
fps++;
if ((System.currentTimeMillis() - timeCurrent) > 1000) {
updateFPS(fps);
lastFPS = fps;
fps = 0;
timeCurrent = System.currentTimeMillis();
}
}
}.start();
}
/**
* Update position of boats in race, no position if on starting leg or DNF.
*/
private void updatePositions() {
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
for(Boat boat: startingBoats) {
if(boat != null) {
boat.setPosition(Integer.toString(startingBoats.indexOf(boat) + 1));
if (boat.isDnf() || !boat.isStarted() || boat.getCurrentLeg().getLegNumber() < 0)
boat.setPosition("-");
}
}
}
/**
* Update call for the controller.
*/
private void setControllerListeners() {
if (controller != null) controller.setInfoTable(this);
}
/**
* Returns the boats that have started the race.
*
* @return ObservableList of Boat class that participated in the race.
* @see ObservableList
* @see Boat
*/
public ObservableList<Boat> getStartingBoats() {
return startingBoats;
}
/**
* Takes an estimated time an event will occur, and converts it to the
* number of seconds before the event will occur.
*
* @param estTimeMillis estimated time in milliseconds
* @return int difference between time the race started and the estimated time
*/
private int convertEstTime(long estTimeMillis, long currentTime) {
long estElapsedMillis = estTimeMillis - currentTime;
int estElapsedSecs = Math.round(estElapsedMillis/1000);
return estElapsedSecs;
}
}
@@ -1,284 +0,0 @@
package seng302.Model;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.layout.AnchorPane;
import java.util.HashMap;
import java.util.Map;
/**
* Class that processes user selected annotation visibility options to
* display the requested information on the
* {@link seng302.Model.ResizableRaceMap ResizbleRaceMap}. These are displayed
* via the {@link seng302.Controllers.RaceController RaceController}. <br>
* Annotation options for a {@link seng302.Model.Boat Boat} include: its name,
* abbreviation, speed, the time since it passed the last
* {@link seng302.Model.Marker Marker}, estimated time to the next marker,
* and a path it has travelled made up of
* {@link seng302.Model.TrackPoint TrackPoint}s.
*/
public class Annotations {
private ResizableRaceCanvas raceMap;
// checkable objects in the anchor pane
private Map<String, CheckBox> checkBoxes = new HashMap<>();
private Map<String, Toggle> annoToggles = new HashMap<>();
// maps of selected and saved annotations
private Map<String, Boolean> importantAnno = new HashMap<>();
private Map<String, Boolean> annoShownBeforeHide = new HashMap<>();
// string values match the fx:id value of check boxes
private static String nameCheckAnno = "showName";
private static String abbrevCheckAnno = "showAbbrev";
private static String speedCheckAnno = "showSpeed";
private static String pathCheckAnno = "showBoatPath";
private static String timeCheckAnno = "showTime";
private static String estTimeCheckAnno = "showEstTime";
// string values match the fx:id value of radio buttons
private static String noBtn = "noBtn";
private static String hideBtn = "hideAnnoRBtn";
private static String showBtn = "showAnnoRBtn";
private static String partialBtn = "partialAnnoRBtn";
private static String importantBtn = "importantAnnoRBtn";
private Boolean selectShow = false;
private String buttonChecked;
private String prevBtnChecked;
@FXML Button saveAnnoBtn;
/**
* Constructor to set up and display initial annotations
* @param annotationPane javaFX pane containing annotation options
* @param raceMap the canvas to update annotation displays
*/
public Annotations(AnchorPane annotationPane, ResizableRaceCanvas raceMap){
this.raceMap = raceMap;
for (Node child : annotationPane.getChildren()) {
// collect all check boxes into a map
if (child.getClass()==CheckBox.class){
checkBoxes.put(child.getId(), (CheckBox)child);
}
// collect annotation toggle radio buttons into a map
else if (child.getClass()== RadioButton.class){
//annotationGroup.getToggles().add((RadioButton)child);
annoToggles.put(child.getId(), (RadioButton)child);
}
else if (child.getClass() == Button.class){
saveAnnoBtn = (Button)child;
}
}
initializeAnnotations();
}
/**
* Set up initial boat annotations and shows all data.
* Defines partial annotations.
* Creates listeners for when the user selects a different annotation
* visibility.
*/
public void initializeAnnotations() {
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet())
{ annoShownBeforeHide.put(checkBox.getKey(), true); }
addCheckBoxListeners();
addSaveAnnoListener();
addAnnoToggleListeners();
annoToggles.get(showBtn).setSelected(true);
}
/**
* Creates listeners for each checkbox so the annotation display is
* updated when a user selects a different level of annotation visibility.
*/
private void addCheckBoxListeners(){
//listener for show name in annotation
checkBoxes.get(nameCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoName();
storeCurrentAnnotationState(nameCheckAnno, new_val);
raceMap.update();
}
});
//listener for show abbreviation for annotation
checkBoxes.get(abbrevCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoAbbrev();
storeCurrentAnnotationState(abbrevCheckAnno, new_val);
raceMap.update();
}
});
//listener for show boat path for annotation
checkBoxes.get(pathCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleBoatPath();
storeCurrentAnnotationState(pathCheckAnno, new_val);
raceMap.update();
}
});
//listener to show speed for annotation
checkBoxes.get(speedCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoSpeed();
storeCurrentAnnotationState(speedCheckAnno, new_val);
raceMap.update();
}
});
//listener to show time for annotation
checkBoxes.get(timeCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoTime();
storeCurrentAnnotationState(timeCheckAnno, new_val);
raceMap.update();
}
});
//listener to show estimated time for annotation
checkBoxes.get(estTimeCheckAnno).selectedProperty()
.addListener((ov, old_val, new_val) -> {
if (old_val != new_val) {
raceMap.toggleAnnoEstTime();
storeCurrentAnnotationState(estTimeCheckAnno, new_val);
raceMap.update();
}
});
}
/**
* Creates a listener so the system knows when to save a users currently
* selected annotation options as important for future use.
*/
private void addSaveAnnoListener(){
//listener to save currently selected annotations as important
saveAnnoBtn.setOnAction(event -> {
importantAnno.clear();
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
importantAnno.put(checkBox.getKey(),
checkBox.getValue().isSelected());
}
});
}
/**
* Creates listeners for each visibility option so that the annotation
* display is updated when a user selects a different level of annotation
* visibility.
*/
private void addAnnoToggleListeners(){
//listener for hiding all annotations
RadioButton hideAnnoRBtn = (RadioButton)annoToggles.get(hideBtn);
hideAnnoRBtn.setOnAction((e)->{
buttonChecked = hideBtn;
selectShow = false;
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
checkBox.getValue().setSelected(false);
}
raceMap.update();
buttonChecked = noBtn;
prevBtnChecked = hideBtn;
selectShow = true;
});
//listener for showing previously visible annotations
RadioButton showAnnoRBTN = (RadioButton)annoToggles.get(showBtn);
showAnnoRBTN.setOnAction((e)->{
if (selectShow) {
buttonChecked = showBtn;
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
checkBox.getValue().setSelected(
annoShownBeforeHide.get(checkBox.getKey()));
}
raceMap.update();
buttonChecked = noBtn;
prevBtnChecked = showBtn;
}
selectShow = true;
});
//listener for showing a predetermined subset of annotations
RadioButton partialAnnoRBTN = (RadioButton)annoToggles.get(partialBtn);
partialAnnoRBTN.setOnAction((e)->{
selectShow = false;
buttonChecked = partialBtn;
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
// the checkbox defaults for partial annotations
if (checkBox.getKey().equals(abbrevCheckAnno)
|| checkBox.getKey().equals(speedCheckAnno)){
checkBox.getValue().setSelected(true);
}
else { checkBox.getValue().setSelected(false); }
}
raceMap.update();
buttonChecked = noBtn;
prevBtnChecked = partialBtn;
selectShow = true;
});
//listener for showing all saved important annotations
RadioButton importantAnnoRBTN = (RadioButton)annoToggles.get(importantBtn);
importantAnnoRBTN.setOnAction((e) ->{
selectShow = false;
buttonChecked = importantBtn;
if (importantAnno.size()>0){
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
checkBox.getValue().setSelected
(importantAnno.get(checkBox.getKey()));
}
}
buttonChecked = noBtn;
prevBtnChecked = importantBtn;
selectShow = true;
});
}
/**
* Updates the current state of an annotation so that when a user
* deselects the hidden visibility option, the previous annotations will
* be displayed again.
* @param dictionaryAnnotationKey annotation checkbox
* @param selected boolean value representing the state of the checkbox
*/
private void storeCurrentAnnotationState(String dictionaryAnnotationKey, boolean selected){
if (buttonChecked != hideBtn) {
//if we are checking the box straight out of hide instead of using the radio buttons
annoShownBeforeHide.put(dictionaryAnnotationKey, selected);
if (prevBtnChecked == hideBtn && buttonChecked == noBtn){
storeCurrentAnnotationDictionary();
}
if (buttonChecked == noBtn) {
selectShow = false;
annoToggles.get(showBtn).setSelected(true);
}
}
}
/**
* Stores all current annotation states so that when a user
* deselects the hidden visibility option, the previous annotations will
* be displayed again.
*/
private void storeCurrentAnnotationDictionary(){
for (Map.Entry<String, CheckBox> checkBox : checkBoxes.entrySet()){
annoShownBeforeHide.put(checkBox.getKey(),
checkBox.getValue().isSelected());
}
}
}
@@ -1,272 +0,0 @@
package seng302.Model;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.geotools.referencing.GeodeticCalculator;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D;
import java.time.ZonedDateTime;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* This class is used to represent and store information about a boat which may
* travel around in a race. It is displayed on the
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas} via the
* {@link seng302.Controllers.RaceController RaceController}.
*/
public class Boat {
private final StringProperty name;
protected double velocity;
private final StringProperty velocityProp;
private final String abbrev;
private GPSCoordinate currentPosition;
protected double heading;
private Leg currentLeg;
private final StringProperty currentLegName;
private boolean finished = false;
private long timeFinished;
private final StringProperty position;
private boolean started = false;
private boolean dnf = false;
private int sourceID;
private int estTime;
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
private long nextValidTime = 0;
private ZonedDateTime timeSinceLastMark;
/**
* Boat initializer which keeps all of the information of the boat.
*
* @param name Name of the Boat.
* @param velocity Speed in m/s that the boat travels at.
* @param abbrev nam abbreviation
*/
public Boat(String name, double velocity, String abbrev) {
this.velocity = velocity;
this.velocityProp = new SimpleStringProperty(String.valueOf(Math.round(velocity)));
this.abbrev = abbrev;
this.name = new SimpleStringProperty(name);
currentLegName = new SimpleStringProperty("");
position = new SimpleStringProperty("-");
}
/**
* Boat initializer which keeps all of the information of the boat.
*
* @param name Name of the Boat.
* @param abbrev nam abbreviation
*/
protected Boat(String name, String abbrev) {
this(name, 0, abbrev);
}
/**
* Returns the position of the end of the boat's wake, which is 180 degrees
* from the boat's heading, and whose length is proportional to the boat's
* speed.
*
* @return GPSCoordinate of wake endpoint.
*/
public GPSCoordinate getWake() {
double reverseHeading = getHeading() - 180;
double wakeScale = 5;
double distance = wakeScale * getVelocity();
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(
new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude())
);
calc.setDirection(reverseHeading, distance);
Point2D endpoint = calc.getDestinationGeographicPoint();
return new GPSCoordinate(endpoint.getY(), endpoint.getX());
}
/**
* Adds a new point to boat's track.
* @param coordinate of point on track
* @see seng302.Model.TrackPoint
*/
public void addTrackPoint(GPSCoordinate coordinate) {
Boolean added = System.currentTimeMillis() >= nextValidTime;
long currentTime = System.currentTimeMillis();
if (added && this.started) {
float trackPointTimeInterval = 5000;
nextValidTime = currentTime + (long) trackPointTimeInterval;
int TRACK_POINT_LIMIT = 10;
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
}
}
/**
* Returns the boat's sampled track between start of race and current time.
* @return queue of track points
* @see seng302.Model.TrackPoint
*/
public Queue<TrackPoint> getTrack() {
return track;
}
/**
* @return Name of the boat
*/
public StringProperty getName() {
return name;
}
/**
* Sets the boat name
*
* @param name of boat
*/
public void setName(String name) {
this.name.setValue(name);
}
/**
* @return Speed of the boat.
*/
public double getVelocity() {
return velocity;
}
/**
* Sets the speed of the boat in knots.
*
* @param velocity speed in knots
*/
public void setVelocity(double velocity) {
this.velocity = velocity;
this.velocityProp.setValue(String.valueOf(Math.round(velocity)));
}
/**
* Print method prints the name of the boat
*
* @return Name of the boat.
*/
public String toString() {
return getName().getValue();
}
/**
* @return Velocity String Property of the boat
*/
public StringProperty getVelocityProp() {
return velocityProp;
}
/**
* @return Abbreviation of the boat
*/
public String getAbbrev() {
return abbrev;
}
public GPSCoordinate getCurrentPosition() {
return currentPosition;
}
public void setCurrentPosition(GPSCoordinate currentPosition) {
this.currentPosition = currentPosition;
}
public double getHeading() {
return heading;
}
public void setHeading(double heading) {
this.heading = heading;
}
public Leg getCurrentLeg() {
return currentLeg;
}
public void setCurrentLeg(Leg currentLeg, RaceClock raceClock) {
this.currentLeg = currentLeg;
this.currentLegName.setValue(currentLeg.getName());
this.setTimeSinceLastMark(raceClock.getTime());
}
public boolean isFinished() {
return finished;
}
public void setFinished(boolean finished) {
this.finished = finished;
}
public long getTimeFinished() {
return timeFinished;
}
public void setTimeFinished(long timeFinished) {
this.timeFinished = timeFinished;
}
public StringProperty positionProperty() {
return position;
}
public void setPosition(String position) {
this.position.set(position);
}
public boolean isStarted() {
return started;
}
public void setStarted(boolean started) {
this.started = started;
}
/**
* @return Name of boat's current leg
*/
public StringProperty getCurrentLegName() {
return currentLegName;
}
public int getSourceID() {
return this.sourceID;
}
public boolean isDnf() {
return dnf;
}
public void setDnf(boolean dnf) {
this.dnf = dnf;
}
public ZonedDateTime getTimeSinceLastMark() {
return timeSinceLastMark;
}
public void setTimeSinceLastMark(ZonedDateTime timeSinceLastMark) {
this.timeSinceLastMark = timeSinceLastMark;
}
public void setEstTime(int estTime) { this.estTime = estTime; }
public String getFormattedEstTime() {
if (estTime < 0) {
return " -";
}
if (estTime <= 60) {
return " " + estTime + "s";
} else {
int seconds = estTime % 60;
int minutes = (estTime - seconds) / 60;
return String.format(" %dm %ds", minutes, seconds);
}
}
}
@@ -1,311 +0,0 @@
//package seng302.Model;
//
//import javafx.beans.property.SimpleStringProperty;
//import javafx.beans.property.StringProperty;
//import javafx.scene.paint.Color;
//import org.geotools.referencing.GeodeticCalculator;
//import seng302.GPSCoordinate;
//
//import java.awt.geom.Point2D;
//import java.util.Queue;
//import java.util.concurrent.ConcurrentLinkedQueue;
//
///**
// * Boat in the Race extends {@link seng302.Model.Boat Boat}.
// * The extended properties are related to the boats current race position.
// * @See seng302.Model.Boat
// */
//public class BoatInRace extends Boat {
//
// private Leg currentLeg;
// private double scaledVelocity;
// private double distanceTravelledInLeg;
// private GPSCoordinate currentPosition;
// private long timeFinished;
// private Color colour;
// private boolean finished = false;
// private final StringProperty currentLegName;
// private boolean started = false;
// private final StringProperty position;
// private double heading;
// private static final double WAKE_SCALE = 10;
//
// private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
// private long nextValidTime = 0;
//
// private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
// private static float trackPointTimeInterval = 5000; // every 1 seconds
//
// /**
// * Constructor method.
// *
// * @param name Name of the boat.
// * @param velocity Speed that the boat travels.
// * @param colour Colour the boat will be displayed as on the map
// * @param abbrev of boat
// */
// public BoatInRace(String name, double velocity, Color colour, String abbrev) {
// super(name, velocity, abbrev);
// setColour(colour);
// currentLegName = new SimpleStringProperty("");
// position = new SimpleStringProperty("-");
// }
//
// /**
// * Calculates the azimuth of the travel via map coordinates of the raceMarkers
// *
// * @return the direction that the boat is heading towards in degrees (-180 to 180).
// */
// public double calculateAzimuth() {
//
// GeodeticCalculator calc = new GeodeticCalculator();
// GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
// GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
//
// calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
// calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
//
// return calc.getAzimuth();
// }
//
// /**
// * Converts an azimuth to a bearing
// *
// * @param azimuth azimuth value to be converted
// * @return the bearings in degrees (0 to 360).
// */
// private static double calculateHeading(double azimuth) {
// if (azimuth >= 0) {
// return azimuth;
// } else {
// return azimuth + 360;
// }
// }
//
// public double getHeading() {
// return heading;
// }
//
// public void setHeading(double heading) {
// this.heading = heading;
// }
//
// /**
// * Calculates the bearing of the travel via map coordinates of the raceMarkers
// *
// * @return the direction that the boat is heading towards in degrees (0 to 360).
// */
// public double calculateHeading() {
// double azimuth = calculateAzimuth();
// return calculateHeading(azimuth);
// }
//
// /**
// * Returns the position of the end of the boat's wake, which is 180 degrees
// * from the boat's heading, and whose length is proportional to the boat's
// * speed.
// *
// * @return GPSCoordinate of wake endpoint.
// */
// public GPSCoordinate getWake() {
// double reverseHeading = getHeading() - 180;
// double distance = WAKE_SCALE * getVelocity();
//
// GeodeticCalculator calc = new GeodeticCalculator();
// calc.setStartingGeographicPoint(
// new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude())
// );
// calc.setDirection(reverseHeading, distance);
// Point2D endpoint = calc.getDestinationGeographicPoint();
// return new GPSCoordinate(endpoint.getY(), endpoint.getX());
// }
//
// /**
// * @return Scaled velocity of the boat
// */
// public double getScaledVelocity() {
// return scaledVelocity;
// }
//
// /**
// * Sets the boat's scaled velocity
// *
// * @param velocity of boat
// */
// public void setScaledVelocity(double velocity) {
// this.scaledVelocity = velocity;
// }
//
// /**
// * @return Returns the current position of the boat in a GPSCoordinate Class.
// * @see GPSCoordinate
// */
// public GPSCoordinate getCurrentPosition() {
// return currentPosition;
// }
//
// /**
// * Sets the current position on the GPS that the boat.
// *
// * @param position GPSCoordinate of the position that the boat is currently on.
// * @see GPSCoordinate
// */
// public void setCurrentPosition(GPSCoordinate position) {
// this.currentPosition = position;
// }
//
// /**
// * @return Returns the time that the boat finished the race.
// */
// public long getTimeFinished() {
// return timeFinished;
// }
//
// /**
// * Sets the time that the boat finished the race.
// *
// * @param timeFinished Time the boat finished the race.
// */
// public void setTimeFinished(long timeFinished) {
// this.timeFinished = timeFinished;
// }
//
// /**
// * @return Returns the colour of the boat.
// */
// public Color getColour() {
// return colour;
// }
//
// /**
// * Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas.
// *
// * @param colour Colour that the boat is to be set to.
// * @see ResizableRaceCanvas
// */
// private void setColour(Color colour) {
// this.colour = colour;
// }
//
// /**
// * Gets the current leg that the boat is on.
// *
// * @return returns the leg the boat is on in a Leg class
// * @see Leg
// */
// public Leg getCurrentLeg() {
// return currentLeg;
// }
//
// /**
// * Sets the boat's current leg.
// *
// * @param currentLeg Leg class that the boat is currently on.
// * @see Leg
// */
// public void setCurrentLeg(Leg currentLeg) {
// this.currentLeg = currentLeg;
// this.currentLegName.setValue(currentLeg.getName());
// }
//
// /**
// * @return Name of boat's current leg
// */
// public StringProperty getCurrentLegName() {
// return currentLegName;
// }
//
// /**
// * Gets the distance travelled by the boat in the leg.
// *
// * @return Returns the value in nautical miles (1.852km) that the boat has traversed.
// */
// public double getDistanceTravelledInLeg() {
// return distanceTravelledInLeg;
// }
//
// /**
// * Sets the distance travelled by the boat in the leg in nautical miles (1.852km)
// *
// * @param distanceTravelledInLeg Distance travelled by the boat in nautical miles.
// */
// public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
// this.distanceTravelledInLeg = distanceTravelledInLeg;
// }
//
// /**
// * @return true if boat has finished, false if not
// */
// public boolean isFinished() {
// return this.finished;
// }
//
// /**
// * Sets whether boat is finished or not
// *
// * @param bool is finished value
// */
// public void setFinished(boolean bool) {
// this.finished = bool;
// }
//
// public boolean isStarted() {
// return started;
// }
//
// public void setStarted(boolean started) {
// this.started = started;
// }
//
// public String getPosition() {
// return position.get();
// }
//
// public StringProperty positionProperty() {
// return position;
// }
//
// public void setPosition(String position) {
// this.position.set(position);
// }
//
// /**
// * Adds a new point to boat's track.
// * @param coordinate of point on track
// * @see seng302.Model.TrackPoint
// */
// public void addTrackPoint(GPSCoordinate coordinate) {
// Boolean added = System.currentTimeMillis() >= nextValidTime;
// long currentTime = System.currentTimeMillis();
// if (added && this.started) {
// nextValidTime = currentTime + (long) trackPointTimeInterval;
// int TRACK_POINT_LIMIT = 10;
// track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
// }
// }
//
// /**
// * Returns the boat's sampled track between start of race and current time.
// * @return queue of track points
// * @see seng302.Model.TrackPoint
// */
// public Queue<TrackPoint> getTrack() {
// return track;
// }
//
// /**
// * Get base track point time interval
// * @return base track point time interval
// */
// public static float getBaseTrackPointTimeInterval() {
// return BASE_TRACK_POINT_TIME_INTERVAL;
// }
//
// /**
// * Set track point time interval
// * @param value track point time interval value
// */
// public static void setTrackPointTimeInterval(float value) {
// trackPointTimeInterval = value;
// }
//}
@@ -1,208 +0,0 @@
//package seng302.Model;
//
//import org.geotools.referencing.GeodeticCalculator;
//import seng302.Constants;
//import seng302.Controllers.RaceController;
//import seng302.GPSCoordinate;
//import seng302.RaceDataSource;
//
//import java.awt.geom.Point2D;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//import java.util.Random;
//
///**
// * Created by cbt24 on 6/03/17.
// *
// * @deprecated
// */
//public class ConstantVelocityRace extends Race {
//
// private int dnfChance = 0; //%percentage chance a boat fails at each checkpoint
//
// /**
// * Initializer for a constant velocity race without standard data source
// *
// * @param startingBoats in race
// * @param legs in race
// * @param controller for graphics
// * @param scaleFactor of timer
// */
// public ConstantVelocityRace(List<BoatInRace> startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
// super(startingBoats, legs, controller, scaleFactor);
// }
//
// /**
// * Initializer for legacy tests
// *
// * @param startingBoats in race
// * @param legs in race
// * @param controller for graphics
// * @param scaleFactor of timer
// *
// * @deprecated Please use {@link #ConstantVelocityRace(List, List, RaceController, int) } for future tests.
// */
// public ConstantVelocityRace(BoatInRace[] startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
// super(Arrays.asList(startingBoats), legs, controller, scaleFactor);
// }
//
// /**
// * Initializer for constant velocity race with standard data source
// * @param raceData for race
// * @param controller for graphics
// * @param scaleFactor of timer
// */
// public ConstantVelocityRace(RaceDataSource raceData, RaceController controller, int scaleFactor) {
// super(raceData, controller, scaleFactor);
// }
//
// public void initialiseBoats() {
// Leg officialStart = legs.get(0);
// String name = officialStart.getName();
// CompoundMark endMarker = officialStart.getEndCompoundMark();
//
// BoatInRace.setTrackPointTimeInterval(BoatInRace.getBaseTrackPointTimeInterval() / scaleFactor);
//
// ArrayList<CompoundMark> startMarkers = getSpreadStartingPositions();
// for (int i = 0; i < startingBoats.size(); i++) {
// BoatInRace boat = startingBoats.get(i);
// if (boat != null) {
// boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
// Leg startLeg = new Leg(name, 0);
// boat.setCurrentPosition(startMarkers.get(i).getAverageGPSCoordinate());
// startLeg.setStartCompoundMark(startMarkers.get(i));
// startLeg.setEndCompoundMark(endMarker);
// startLeg.calculateDistance();
// boat.setCurrentLeg(startLeg);
// boat.setHeading(boat.calculateHeading());
// }
// }
// }
//
// /**
// * Creates a list of starting positions for the different boats, so they do not appear cramped at the start line
// *
// * @return list of starting positions
// */
// public ArrayList<CompoundMark> getSpreadStartingPositions() {
//
// int nBoats = startingBoats.size();
// CompoundMark marker = legs.get(0).getStartCompoundMark();
//
// GeodeticCalculator initialCalc = new GeodeticCalculator();
// initialCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
// initialCalc.setDestinationGeographicPoint(marker.getMark2().getLongitude(), marker.getMark2().getLatitude());
//
// double azimuth = initialCalc.getAzimuth();
// double distanceBetweenMarkers = initialCalc.getOrthodromicDistance();
// double distanceBetweenBoats = distanceBetweenMarkers / (nBoats + 1);
//
// GeodeticCalculator positionCalc = new GeodeticCalculator();
// positionCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
// ArrayList<CompoundMark> positions = new ArrayList<>();
//
// for (int i = 0; i < nBoats; i++) {
// positionCalc.setDirection(azimuth, distanceBetweenBoats);
// Point2D position = positionCalc.getDestinationGeographicPoint();
// positions.add(new CompoundMark(new GPSCoordinate(position.getY(), position.getX())));
//
// positionCalc = new GeodeticCalculator();
// positionCalc.setStartingGeographicPoint(position);
// }
// return positions;
// }
//
// /**
// * Sets the chance each boat has of failing at a gate or marker
// * @param chance percentage chance a boat has of failing per checkpoint.
// */
// protected void setDnfChance(int chance) {
// if (chance >= 0 && chance <= 100) {
// dnfChance = chance;
// }
// }
//
// protected boolean doNotFinish() {
// Random rand = new Random();
// return rand.nextInt(100) < dnfChance;
// }
//
// /**
// * Calculates the distance a boat has travelled and updates its current position according to this value.
// *
// * @param boat to be updated
// * @param millisecondsElapsed since last update
// */
// protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
//
// //distanceTravelled = velocity (nm p hr) * time taken to update loop
// double distanceTravelled = (boat.getScaledVelocity() * millisecondsElapsed) / 3600000;
//
// double totalDistanceTravelled = distanceTravelled + boat.getDistanceTravelledInLeg();
//
// boolean finish = boat.getCurrentLeg().getName().equals("Finish");
// if (!finish) {
// boat.setHeading(boat.calculateHeading());
// //update boat's distance travelled
// boat.setDistanceTravelledInLeg(totalDistanceTravelled);
// //Calculate boat's new position by adding the distance travelled onto the start point of the leg
// boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartCompoundMark().getAverageGPSCoordinate(),
// totalDistanceTravelled, boat.calculateAzimuth()));
// }
// }
//
// protected void checkPosition(BoatInRace boat, long timeElapsed) {
// if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()) {
// //boat has passed onto new leg
// if (boat.getCurrentLeg().getName().equals("Finish")) {
// //boat has finished
// boatsFinished++;
// boat.setFinished(true);
// boat.setTimeFinished(timeElapsed);
// } else if (doNotFinish()) {
// boatsFinished++;
// boat.setFinished(true);
// boat.setCurrentLeg(new Leg("DNF", -1));
// boat.setVelocity(0);
// boat.setScaledVelocity(0);
// } else {
// //Calculate how much the boat overshot the marker by
// boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance());
// //Move boat on to next leg
// Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1);
//
// boat.setCurrentLeg(nextLeg);
// //Add overshoot distance into the distance travelled for the next leg
// boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
// }
// //Update the boat display table in the GUI to reflect the leg change
// updatePositions();
// }
// }
//
// /**
// * Calculates the boats next GPS position based on its distance travelled and heading
// *
// * @param oldCoordinates GPS coordinates of the boat's starting position
// * @param distanceTravelled distance in nautical miles
// * @param azimuth boat's current direction. Value between -180 and 180
// * @return The boat's new coordinate
// */
// public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
//
// //Find new coordinate using current heading and distance
//
// GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
// //Load start point into calculator
// Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
// geodeticCalculator.setStartingGeographicPoint(startPoint);
// //load direction and distance tranvelled into calculator
// geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
// //get new point
// Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
//
// return new GPSCoordinate(endPoint.getY(), endPoint.getX());
// }
//
//}
@@ -1,106 +0,0 @@
package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import seng302.GPSCoordinate;
/**
* This class represents a leg, which is a portion of a race between two
* {@link seng302.Model.Marker Marker}s. A leg is used to identify a
* {@link seng302.Model.Boat Boat}'s progress through a race.
*/
public class Leg {
private final String name; //nautical miles
private double distance;
private Marker startMarker;
private Marker endMarker;
private final int legNumber;
// 1 nautical mile = 1852 meters
public static final int NM_TO_METERS = 1852;
/**
* Leg Initializer
*
* @param name Name of the Leg
* @param start marker
* @param end marker
* @param number Leg's position in race
*/
public Leg(String name, Marker start, Marker end, int number) {
this.name = name;
this.startMarker = start;
this.endMarker = end;
this.legNumber = number;
calculateDistance();
}
/**
* Construction Method
*
* @param name Name of the Leg
* @param number leg number
*/
public Leg(String name, int number) {
this.name = name;
this.legNumber = number;
}
/**
* Returns the name of the Leg
*
* @return Returns the name of the Leg
*/
public String getName() {
return name;
}
/**
* Get the distance in nautical miles
*
* @return Returns the total distance of the leg.
*/
public double getDistance() {
return distance;
}
/**
* Returns the leg number that the leg exists in the Race
*
* @return Returns the Leg
*/
public int getLegNumber() {
return legNumber;
}
public Marker getStartMarker() {
return startMarker;
}
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public Marker getEndMarker() {
return endMarker;
}
public void setEndMarker(Marker endMarker) {
this.endMarker = endMarker;
}
/**
* Calculates the distance that the legs are in nautical miles (1.852 km).
*/
private void calculateDistance() {
GeodeticCalculator calc = new GeodeticCalculator();
//Load start and end of leg
GPSCoordinate startMarker = this.startMarker.getAverageGPSCoordinate();
GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate();
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
this.distance = calc.getOrthodromicDistance() / NM_TO_METERS;
}
}
@@ -1,105 +0,0 @@
package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D;
/**
* A marker on a race course that a boat can pass, to be displayed on the
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}. This is
* displayed via the {@link seng302.Controllers.RaceController RaceController}.
* <br>Markers are also used to calculate a {@link seng302.Model.Leg Leg}
* distance.
*/
public class Marker {
private final GPSCoordinate averageGPSCoordinate;
private GPSCoordinate mark1;
private GPSCoordinate mark2;
private final int sourceId1;
private final int sourceId2;
public Marker(GPSCoordinate mark1, int sourceId) {
this(mark1, mark1, sourceId, sourceId);
}
public Marker(GPSCoordinate mark1, GPSCoordinate mark2, int sourceId1, int sourceId2) {
this.mark1 = mark1;
this.mark2 = mark2;
this.averageGPSCoordinate = calculateAverage();
this.sourceId1 = sourceId1;
this.sourceId2 = sourceId2;
}
/**
*
* @param mark1 Mark coordinates.
*/
public Marker(GPSCoordinate mark1) {
this(mark1, mark1, 0,0);
}
/**
*
* @param mark1 Mark one coordinate
* @param mark2 Mark two coordinate
*/
public Marker(GPSCoordinate mark1, GPSCoordinate mark2) {
this(mark1, mark2, 0,0);
}
public GPSCoordinate getMark1() {
return mark1;
}
public GPSCoordinate getMark2() {
return mark2;
}
/**
* Returns true if mark consists of two points, e.g. it is a gate.
* @return boolean
*/
public boolean isCompoundMark() {
return mark1 != mark2;
}
public GPSCoordinate getAverageGPSCoordinate() {
return averageGPSCoordinate;
}
private GPSCoordinate calculateAverage() {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(mark1.getLongitude(), mark1.getLatitude());
calc.setDestinationGeographicPoint(mark2.getLongitude(), mark2.getLatitude());
double azimuth = calc.getAzimuth();
double distance = calc.getOrthodromicDistance();
GeodeticCalculator middleCalc = new GeodeticCalculator();
middleCalc.setStartingGeographicPoint(mark1.getLongitude(), mark1.getLatitude());
middleCalc.setDirection(azimuth, distance / 2);
Point2D middlePoint = middleCalc.getDestinationGeographicPoint();
return new GPSCoordinate(middlePoint.getY(), middlePoint.getX());
}
public void setCurrentPosition1(GPSCoordinate gpsCoordinate){
mark1 = gpsCoordinate;
}
public void setCurrentPosition2(GPSCoordinate gpsCoordinate){
mark2 = gpsCoordinate;
}
public int getSourceId1() {
return sourceId1;
}
public int getSourceId2() {
return sourceId2;
}
}
@@ -1,133 +0,0 @@
package seng302.Model;
import com.github.bfsmith.geotimezone.TimeZoneLookup;
import com.github.bfsmith.geotimezone.TimeZoneResult;
import javafx.animation.AnimationTimer;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import seng302.GPSCoordinate;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;
/**
* This class is used to implement a clock which keeps track of and
* displays times relevant to a race. This is displayed on the
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas} via the
* {@link seng302.Controllers.RaceController RaceController} and the
* {@link seng302.Controllers.StartController StartController}.
*/
public class RaceClock implements Runnable {
private long lastTime;
private final ZoneId zoneId;
private ZonedDateTime time;
private ZonedDateTime startingTime;
private final StringProperty timeString;
private StringProperty duration;
public RaceClock(ZonedDateTime zonedDateTime) {
this.zoneId = zonedDateTime.getZone();
this.timeString = new SimpleStringProperty();
this.duration = new SimpleStringProperty();
this.time = zonedDateTime;
setTime(time);
}
public static ZonedDateTime getCurrentZonedDateTime(GPSCoordinate gpsCoordinate) {
TimeZoneLookup timeZoneLookup = new TimeZoneLookup();
TimeZoneResult timeZoneResult = timeZoneLookup.getTimeZone(gpsCoordinate.getLatitude(), gpsCoordinate.getLongitude());
ZoneId zone = ZoneId.of(timeZoneResult.getResult());
return LocalDateTime.now(zone).atZone(zone);
}
public void run() {
new AnimationTimer() {
@Override
public void handle(long now) {
updateTime();
}
}.start();
}
/**
* Sets time to arbitrary zoned time.
*
* @param time arbitrary time with timezone.
*/
private void setTime(ZonedDateTime time) {
this.time = time;
this.timeString.set(DateTimeFormatter.ofPattern("HH:mm:ss dd/MM/YYYY Z").format(time));
this.lastTime = System.currentTimeMillis();
if(startingTime != null) {
long seconds = Duration.between(startingTime.toLocalDateTime(), time.toLocalDateTime()).getSeconds();
if(seconds < 0)
duration.set(String.format("Starting in: %02d:%02d:%02d", -seconds/3600, -(seconds%3600)/60, -seconds%60));
else
duration.set(String.format("Time: %02d:%02d:%02d", seconds/3600, (seconds%3600)/60, seconds%60));
}
}
/**
* Sets time to given UTC time in seconds from Unix epoch, preserving timezone.
* @param time UTC time
*/
public void setUTCTime(long time) {
Date utcTime = new Date(time);
setTime(utcTime.toInstant().atZone(this.zoneId));
}
public ZonedDateTime getStartingTime() {
return startingTime;
}
public void setStartingTime(ZonedDateTime startingTime) {
this.startingTime = startingTime;
}
/**
* Get ZonedDateTime corresponding to local time zone and given UTC time.
* @param time time in mills
* @return local date time
*/
public ZonedDateTime getLocalTime(long time) {
Date utcTime = new Date(time);
return utcTime.toInstant().atZone(this.zoneId);
}
/**
* Updates time by duration elapsed since last update.
*/
private void updateTime() {
this.time = this.time.plus(Duration.of(System.currentTimeMillis() - this.lastTime, ChronoUnit.MILLIS));
this.lastTime = System.currentTimeMillis();
setTime(time);
}
public String getDuration() {
return duration.get();
}
public StringProperty durationProperty() {
return duration;
}
public String getTimeZone() {
return zoneId.toString();
}
public ZonedDateTime getTime() {
return time;
}
public StringProperty timeStringProperty() {
return timeString;
}
}
@@ -1,55 +0,0 @@
package seng302.Model;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
/**
* The abstract class for the resizable race canvases.
*/
public abstract class ResizableCanvas extends Canvas {
protected final GraphicsContext gc;
public ResizableCanvas(){
this.gc = this.getGraphicsContext2D();
// Redraw canvas when size changes.
widthProperty().addListener(evt -> draw());
heightProperty().addListener(evt -> draw());
}
abstract void draw();
/**
* Set the Canvas to resizable.
*
* @return That the Canvas is resizable.
*/
@Override
public boolean isResizable() {
return true;
}
/**
* Returns the preferred width of the Canvas
*
* @param width of canvas
* @return Returns the width of the Canvas
*/
@Override
public double prefWidth(double width) {
return getWidth();
}
/**
* Returns the preferred height of the Canvas
*
* @param height of canvas
* @return Returns the height of the Canvas
*/
@Override
public double prefHeight(double height) {
return getHeight();
}
}
@@ -1,393 +0,0 @@
package seng302.Model;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate;
import seng302.GraphCoordinate;
import seng302.Mock.StreamedCourse;
import seng302.RaceDataSource;
import seng302.RaceMap;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.*;
/**
* This JavaFX Canvas is used to update and display details for a
* {@link seng302.RaceMap RaceMap} via the
* {@link seng302.Controllers.RaceController RaceController}.<br>
* It fills it's parent and cannot be downsized. <br>
* Details displayed include:
* {@link seng302.Model.Boat Boats} (and their
* {@link seng302.Model.TrackPoint TrackPoint}s),
* {@link seng302.Model.Marker Markers}, a
* {@link seng302.Model.RaceClock RaceClock}, a wind direction arrow and
* various user selected {@link seng302.Model.Annotations Annotations}.
*/
public class ResizableRaceCanvas extends ResizableCanvas {
private RaceMap map;
private List<Boat> boats;
private List<Marker> boatMarkers;
private boolean annoName = true;
private boolean annoAbbrev = true;
private boolean annoSpeed = true;
private boolean annoPath = true;
private boolean annoEstTime = true;
private boolean annoTimeSinceLastMark = true;
private List<Color> colours;
private final List<Marker> markers;
private final RaceDataSource raceData;
private Map<Integer, Color> boatColours = new HashMap<>();
private Node arrow;
private RaceClock raceClock;
public ResizableRaceCanvas(RaceDataSource raceData) {
super();
double lat1 = raceData.getMapTopLeft().getLatitude();
double long1 = raceData.getMapTopLeft().getLongitude();
double lat2 = raceData.getMapBottomRight().getLatitude();
double long2 = raceData.getMapBottomRight().getLongitude();
setMap(new RaceMap(lat1, long1, lat2, long2, (int) getWidth(), (int) getHeight()));
this.markers = raceData.getMarkers();
makeColours();
this.raceData = raceData;
}
/**
* Sets the boats that are to be displayed in this race.
*
* @param boats in race
*/
public void setBoats(List<Boat> boats) {
this.boats = boats;
mapBoatColours();
}
/**
* Sets the boat markers that are to be displayed in this race.
*
* @param boatMarkers in race
*/
public void setBoatMarkers(ObservableList<Marker> boatMarkers) {
this.boatMarkers = boatMarkers;
}
/**
* Sets the RaceMap that the RaceCanvas is to be displaying for.
*
* @param map race map
*/
private void setMap(RaceMap map) {
this.map = map;
}
private void displayBoat(Boat boat, double angle, Color colour) {
if (boat.getCurrentPosition() != null) {
GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition());
double[] x = {pos.getX() - 6, pos.getX(), pos.getX() + 6};
double[] y = {pos.getY() + 12, pos.getY() - 12, pos.getY() + 12};
gc.setFill(colour);
gc.save();
rotate(angle, pos.getX(), pos.getY());
gc.fillPolygon(x, y, 3);
gc.restore();
}
}
/**
* Displays a line on the map with rectangles on the starting and ending point of the line.
*
* @param graphCoordinateA Starting Point of the line in GraphCoordinate.
* @param graphCoordinateB End Point of the line in GraphCoordinate.
* @param paint Colour the line is to coloured.
* @see GraphCoordinate
* @see Color
* @see Paint
*/
private void displayLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint) {
gc.setStroke(paint);
gc.setFill(paint);
gc.fillOval(graphCoordinateA.getX() - 3, graphCoordinateA.getY() - 3, 6, 6);
gc.fillOval(graphCoordinateB.getX() - 3, graphCoordinateB.getY() - 3, 6, 6);
gc.strokeLine(graphCoordinateA.getX(), graphCoordinateA.getY(), graphCoordinateB.getX(), graphCoordinateB.getY());
}
/**
* Display a point on the Canvas
*
* @param graphCoordinate Coordinate that the point is to be displayed at.
* @param paint Colour that the boat is to be coloured.
* @see GraphCoordinate
* @see Paint
* @see Color
*/
private void displayPoint(GraphCoordinate graphCoordinate, Paint paint) {
gc.setFill(paint);
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10);
}
/**
* Displays an arrow representing wind direction on the Canvas
*
* @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
* @see GraphCoordinate
*/
private void displayWindArrow(double angle) {
angle = angle % 360;
// show direction wind is coming from
if (angle<180){angle = angle + 180;}
else {angle = angle - 180;}
if (arrow != null && arrow.getRotate() != angle) {
arrow.setRotate(angle);
}
}
/**
* Rotates things on the canvas Note: this must be called in between gc.save() and gc.restore() else they will rotate everything
*
* @param angle Bearing angle to rotate at in degrees
* @param px Pivot point x of rotation.
* @param py Pivot point y of rotation.
*/
private void rotate(double angle, double px, double py) {
Rotate r = new Rotate(angle, px, py);
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
}
/**
* Display given name and speed of boat at a graph coordinate
*
* @param name name of the boat
* @param abbrev abbreviation of the boat name
* @param speed speed of the boat
* @param coordinate coordinate the text appears
* @param timeSinceLastMark time since the last mark was passed
*/
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, String estTime, ZonedDateTime timeSinceLastMark) {
String text = "";
//Check name toggle value
if (annoName){
text += String.format("%s ", name);
}
//Check abbreviation toggle value
if (annoAbbrev){
text += String.format("%s ", abbrev);
}
//Check speed toggle value
if (annoSpeed){
text += String.format("%.2fkn ", speed);
}
if (annoEstTime) {
text += estTime;
}
//Check time since last mark toggle value
if(annoTimeSinceLastMark){
Duration timeSince = Duration.between(timeSinceLastMark, raceClock.getTime());
text += String.format(" %ds ", timeSince.getSeconds());
}
//String text = String.format("%s, %2$.2fkn", name, speed);
long xCoord = coordinate.getX() + 20;
long yCoord = coordinate.getY();
if (xCoord + (text.length() * 7) >= getWidth()) {
xCoord -= text.length() * 7;
}
if (yCoord - (text.length() * 2) <= 0) {
yCoord += 30;
}
gc.fillText(text, xCoord, yCoord);
}
/**
* Draws race map with up to date data.
*/
public void update() {
this.draw();
this.updateBoats();
}
/**
* Draw race markers
*/
private void drawMarkers() {
for(Marker marker: markers) {
GraphCoordinate mark1 = this.map.convertGPS(marker.getMark1());
// removed drawing of lines between the marks as only
// the start and finish line should have a line drawn
if(marker.isCompoundMark()) {
GraphCoordinate mark2 = this.map.convertGPS(marker.getMark2());
displayPoint(mark1, Color.LIMEGREEN);
displayPoint(mark2, Color.LIMEGREEN);
} else {
displayPoint(mark1, Color.GREEN);
}
}
}
/**
* Draws the Race Map
*/
public void draw() {
double width = getWidth();
double height = getHeight();
gc.clearRect(0, 0, width, height);
if (map == null) {
return;//TODO this should return a exception in the future
}
this.map.setHeight((int) height);
this.map.setWidth((int) width);
gc.setLineWidth(2);
updateBoats();
drawMarkers();
//display wind direction arrow - specify origin point and angle - angle now set to random angle
if (raceData instanceof StreamedCourse) {
displayWindArrow(((StreamedCourse) raceData).getWindDirection());
} else {
displayWindArrow(150);
}
}
/**
* Toggle name display in annotation
*/
public void toggleAnnoName() {
annoName = !annoName;
}
/**
* Toggle boat path display in annotation
*/
public void toggleBoatPath() {
annoPath = !annoPath;
}
public void toggleAnnoEstTime() {
annoEstTime = !annoEstTime;
}
/**
* Toggle boat time display in annotation
*/
public void toggleAnnoTime() { annoTimeSinceLastMark = !annoTimeSinceLastMark;}
/**
* Toggle abbreviation display in annotation
*/
public void toggleAnnoAbbrev() {
annoAbbrev = !annoAbbrev;
}
/**
* Toggle speed display in annotation
*/
public void toggleAnnoSpeed() {
annoSpeed = !annoSpeed;
}
/**
* Draws boats while race in progress, when leg heading is set.
*/
private void updateBoats() {
if (boats != null) {
if (boatColours.size() < boats.size()) mapBoatColours();
for (Boat boat : boats) {
boolean finished = boat.getCurrentLeg().getName().equals("Finish") || boat.getCurrentLeg().getName().equals("DNF");
boolean isStart = boat.isStarted();
int sourceID = boat.getSourceID();
if (!finished && isStart) {
displayBoat(boat, boat.getHeading(), boatColours.get(sourceID));
GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition());
GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake());
displayLine(wakeFrom, wakeTo, boatColours.get(sourceID));
} else if (!isStart) {
displayBoat(boat, boat.getHeading(), boatColours.get(sourceID));
} else {
displayBoat(boat, 0, boatColours.get(sourceID));
}
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
if (boat.isStarted() == false) {
boat.setTimeSinceLastMark(raceClock.getTime());
}
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
//TODO this needs to be fixed.
drawTrack(boat, boatColours.get(sourceID));
}
}
}
/**
* Draws all track points for a given boat. Colour is set by boat, opacity by track point.
* @param boat whose track is displayed
* @param colour The color to use for the track.
* @see seng302.Model.TrackPoint
*/
private void drawTrack(Boat boat, Color colour) {
if (annoPath) {
for (TrackPoint point : boat.getTrack()) {
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
gc.setFill(new Color(colour.getRed(), colour.getGreen(), colour.getBlue(), point.getAlpha()));
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), 5, 5);
}
}
}
/**
* makes colours
*/
private void makeColours() {
colours = new ArrayList<>(Arrays.asList(
Color.BLUEVIOLET,
Color.BLACK,
Color.RED,
Color.ORANGE,
Color.DARKOLIVEGREEN,
Color.LIMEGREEN,
Color.PURPLE,
Color.DARKGRAY,
Color.YELLOW
));
}
public void setArrow(Node arrow) {
this.arrow = arrow;
}
public void setRaceClock(RaceClock raceClock) {
this.raceClock = raceClock;
}
private void mapBoatColours() {
int currentColour = 0;
for (Boat boat : boats) {
if (!boatColours.containsKey(boat.getSourceID())) {
boatColours.put(boat.getSourceID(), colours.get(currentColour));
}
currentColour = (currentColour + 1) % colours.size();
}
}
}
@@ -1,94 +0,0 @@
package seng302.Model;
import javafx.scene.paint.Color;
import seng302.GPSCoordinate;
import seng302.GraphCoordinate;
import seng302.RaceDataSource;
import seng302.RaceMap;
import java.util.List;
/**
* This JavaFX Canvas is used to generate the size of a
* {@link seng302.RaceMap RaceMap} using co-ordinates from a
* {@link seng302.RaceDataSource RaceDataSource}. This is done via the
* {@link seng302.Controllers.RaceController RaceController}.
*/
public class ResizableRaceMap extends ResizableCanvas {
private RaceMap map;
private final List<GPSCoordinate> raceBoundaries;
private double[] xpoints = {};
private double[] ypoints = {};
/**
* Constructor
* @param raceData Race which it is taking its information to be displayed from
*/
public ResizableRaceMap(RaceDataSource raceData){
super();
raceBoundaries = raceData.getBoundary();
double lat1 = raceData.getMapTopLeft().getLatitude();
double long1 = raceData.getMapTopLeft().getLongitude();
double lat2 = raceData.getMapBottomRight().getLatitude();
double long2 = raceData.getMapBottomRight().getLongitude();
setMap(new RaceMap(lat1, long1, lat2, long2, (int) getWidth(), (int) getHeight()));
//draw();
}
/**
* Sets the map race that it is supposed to be viewing.
* @param map the map to be set
*/
private void setMap(RaceMap map) {
this.map = map;
}
/**
* Draw boundary of the race.
*/
private void drawBoundaries() {
if (this.raceBoundaries == null) {
return;
}
gc.setFill(Color.AQUA);
setRaceBoundCoordinates();
gc.setLineWidth(1);
gc.fillPolygon(xpoints, ypoints, xpoints.length);
}
/**
* Sets the coordinately of the race boundaries
*/
private void setRaceBoundCoordinates() {
xpoints = new double[this.raceBoundaries.size()];
ypoints = new double[this.raceBoundaries.size()];
for (int i = 0; i < raceBoundaries.size(); i++) {
GraphCoordinate coord = map.convertGPS(raceBoundaries.get(i));
xpoints[i] = coord.getX();
ypoints[i] = coord.getY();
}
}
/**
* Draw update for the canvas
*/
public void draw(){
double width = getWidth();
double height = getHeight();
gc.clearRect(0, 0, width, height);
if (map == null) {
return;//TODO this should return a exception in the future
}
this.map.setHeight((int) height);
this.map.setWidth((int) width);
gc.setLineWidth(2);
drawBoundaries();
}
}
@@ -1,179 +0,0 @@
package seng302.Model;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.paint.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Class to process and modify a sparkline display. This display keeps visual
* track of {@link seng302.Model.Boat Boats}s in a race and their current
* placing position as they complete each {@link seng302.Model.Leg Leg} by
* passing a course {@link seng302.Model.Marker Marker}. <br>
* This sparkline is displayed using the
* {@link seng302.Controllers.RaceController RaceController}.
*/
public class Sparkline {
private ArrayList<String> colours;
private ArrayList<Boat> startBoats = new ArrayList<>();
private Map<Integer, String> boatColours = new HashMap<>();
private Integer legNum;
private Integer sparkLineNumber = 0;
@FXML LineChart<Number, Number> sparklineChart;
@FXML NumberAxis xAxis;
@FXML NumberAxis yAxis;
/**
* Constructor to set up initial sparkline (LineChart) object
* @param boats boats to display on the sparkline
* @param legNum total number of legs in the race
* @param sparklineChart javaFX LineChart for the sparkline
*/
public Sparkline(ObservableList<Boat> boats, Integer legNum,
LineChart<Number,Number> sparklineChart) {
this.sparklineChart = sparklineChart;
this.legNum = legNum;
this.yAxis = (NumberAxis)sparklineChart.getYAxis();
this.xAxis = (NumberAxis)sparklineChart.getXAxis();
startBoats.addAll(boats);
makeColours();
mapBoatColours();
createSparkline();
}
/**
* Creates and sets initial display for Sparkline for race positions.
* A data series for each boat in the race is added.
* Position numbers are displayed.
*/
public void createSparkline(){
// NOTE: Y axis is in negatives to display correct positions
// all boats start in 'last' place
for (int i=0; i<startBoats.size(); i++){
XYChart.Series<Number, Number> series = new XYChart.Series();
series.getData().add(new XYChart.Data(0, -startBoats.size()));
series.getData().add(new XYChart.Data(0, -startBoats.size()));
sparklineChart.getData().add(series);
sparklineChart.getData().get(i).getNode().setStyle("-fx-stroke: " +
""+boatColours.get(startBoats.get(i).getSourceID())+";");
}
sparklineChart.setCreateSymbols(false);
// set x axis details
xAxis.setAutoRanging(false);
xAxis.setTickMarkVisible(false);
xAxis.setTickLabelsVisible(false);
xAxis.setMinorTickVisible(false);
xAxis.setUpperBound((startBoats.size()+1)*legNum);
xAxis.setTickUnit((startBoats.size()+1)*legNum);
// set y axis details
yAxis.setLowerBound(-(startBoats.size()+1));
yAxis.setUpperBound(0);
yAxis.setAutoRanging(false);
yAxis.setLabel("Position in Race");
yAxis.setTickUnit(1);
yAxis.setTickMarkVisible(false);
yAxis.setMinorTickVisible(false);
// hide minus number from displaying on axis
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis) {
@Override
public String toString(Number value) {
if ((Double)value == 0.0
|| (Double)value < -startBoats.size()){
return "";
}
else {
return String.format("%7.0f", -value.doubleValue());
}
}
});
}
/**
* Updates the sparkline to display current boat positions.
* New points are plotted to represent each boat when required.
* @param boatsInRace current position of the boats in race
*/
public void updateSparkline(ObservableList<Boat> boatsInRace){
int placingVal = boatsInRace.size();
sparkLineNumber++;
for (int i = boatsInRace.size() - 1; i >= 0; i--){
for (int j = startBoats.size() - 1; j >= 0; j--){
if (boatsInRace.get(i)==startBoats.get(j)){
// when a boat is on its first leg
if (boatsInRace.get(i).getCurrentLeg().getLegNumber()==0){
// adjust boats latest point on X axis
sparklineChart.getData().get(j).getData().get(1)
.setXValue(sparkLineNumber);
}
// when a boat first enters its second leg
else if (boatsInRace.get(i).getCurrentLeg().getLegNumber
()==1 && sparklineChart.getData().get(j).getData
().size()==2){
// adjust boats position from start mark
sparklineChart.getData().get(j).getData().get(1)
.setYValue(-placingVal);
sparklineChart.getData().get(j).getData().get(1)
.setXValue(sparkLineNumber);
sparklineChart.getData().get(j).getData().add(new XYChart.Data<>
(sparkLineNumber, -placingVal));
}
// plot new point for boats current position
else {
sparklineChart.getData().get(j).getData().add
(new XYChart.Data<>(sparkLineNumber, -placingVal));
}
placingVal-=1;
}
}
}
}
private void makeColours() {
colours = new ArrayList<>(Arrays.asList(
colourToHex(Color.BLUEVIOLET),
colourToHex(Color.BLACK),
colourToHex(Color.RED),
colourToHex(Color.ORANGE),
colourToHex(Color.DARKOLIVEGREEN),
colourToHex(Color.LIMEGREEN),
colourToHex(Color.PURPLE),
colourToHex(Color.DARKGRAY),
colourToHex(Color.YELLOW)
));
}
private String colourToHex(Color color) {
return String.format( "#%02X%02X%02X",
(int)( color.getRed() * 255 ),
(int)( color.getGreen() * 255 ),
(int)( color.getBlue() * 255 ) );
}
private void mapBoatColours() {
int currentColour = 0;
for (Boat boat : startBoats) {
if (!boatColours.containsKey(boat.getSourceID())) {
boatColours.put(boat.getSourceID(), colours.get(currentColour));
}
currentColour = (currentColour + 1) % colours.size();
}
}
}
@@ -1,60 +0,0 @@
package seng302.Model;
import seng302.GPSCoordinate;
/**
* A TrackPoint is a point plotted to display the track a
* {@link seng302.Model.Boat Boat} has travelled in a race. <br>
* TrackPoints are displayed on a
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}, via the
* {@link seng302.Controllers.RaceController RaceController}. <br>
* Track points can be made visible or hidden via the RaceController's
* {@link seng302.Model.Annotations Annotations}.
*/
public class TrackPoint {
private final GPSCoordinate coordinate;
private final long timeAdded;
private final long expiry;
private final double minAlpha;
/**
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry.
*
* @param coordinate position of point on physical race map
* @param timeAdded system clock at time of addition
* @param expiry time to minimum opacity after added
*/
public TrackPoint(GPSCoordinate coordinate, long timeAdded, long expiry) {
this.coordinate = coordinate;
this.timeAdded = timeAdded;
this.expiry = expiry;
this.minAlpha = 0.1;
}
/**
* Gets the position of the point on physical race map.
*
* @return GPS coordinate of point
*/
public GPSCoordinate getCoordinate() {
return coordinate;
}
/**
* Gets opacity of point scaled by age in proportion to expiry, between 1 and minimum opacity inclusive.
*
* @return greater of minimum opacity and scaled opacity
*/
public double getAlpha() {
return Double.max(minAlpha, 1.0 - (double) (System.currentTimeMillis() - timeAdded) / expiry);
}
/**
* Gets time point was added to track.
*
* @return system clock at time of addition
*/
public long getTimeAdded() {
return timeAdded;
}
}
@@ -1,57 +0,0 @@
package seng302;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
/**
* Created by cbt24 on 3/05/17.
*/
public class RaceConnection {
private final StringProperty hostname;
private final int port;
private final StringProperty status;
public RaceConnection(String hostname, int port) {
this.hostname = new SimpleStringProperty(hostname);
this.port = port;
this.status = new SimpleStringProperty("");
check();
}
/**
* Tries to create a socket to hostname and port, indicates status after test.
* @return true if socket can connect
*/
@SuppressWarnings("unused")
public boolean check() {
InetSocketAddress i = new InetSocketAddress(hostname.get(), port);
try (Socket s = new Socket()){
s.connect(i, 5000);
status.set("Ready");
return true;
} catch (IOException e) {}
status.set("Offline");
return false;
}
public String getHostname() {
return hostname.get();
}
public StringProperty hostnameProperty() {
return hostname;
}
public int getPort() {
return port;
}
public StringProperty statusProperty() {
return status;
}
}
@@ -1,26 +0,0 @@
package seng302;
import seng302.Model.Boat;
import seng302.Model.Leg;
import seng302.Model.Marker;
import java.time.ZonedDateTime;
import java.util.List;
/**
* An object that holds relevant data for a race. <br>
* Information includes: {@link seng302.Model.Boat Boat}s,
* {@link seng302.Model.Leg Leg}s, {@link seng302.Model.Marker Marker}s and
* the {@link seng302.GPSCoordinate GPSCoordinate}s to create a
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
*/
public interface RaceDataSource {
List<Boat> getBoats();
List<Leg> getLegs();
List<Marker> getMarkers();
List<GPSCoordinate> getBoundary();
ZonedDateTime getZonedDateTime();
GPSCoordinate getMapTopLeft();
GPSCoordinate getMapBottomRight();
}
@@ -1,76 +0,0 @@
package seng302;
/**
* The base size of the map to be used for the
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap} and
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}. It is used
* to convert {@link seng302.GPSCoordinate GPSCoordinate}s to relative
* {@link seng302.GraphCoordinate GraphCoordinate}s.
*/
public class RaceMap {
private final double x1;
private final double x2;
private final double y1;
private final double y2;
private int width, height;
/**
* Constructor Method.
*
* @param x1 Longitude of the top left point.
* @param y1 Latitude of the top left point.
* @param x2 Longitude of the top right point.
* @param y2 Latitude of the top right point.
* @param width width that the Canvas the race is to be drawn on is.
* @param height height that the Canvas the race is to be drawn on is.
*/
public RaceMap(double y1, double x1, double y2, double x2, int height, int width) {
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
this.width = width;
this.height = height;
}
/**
* Converts GPS coordinates to coordinates for container
*
* @param lat GPS latitude
* @param lon GPS longitude
* @return GraphCoordinate (pair of doubles)
* @see GraphCoordinate
*/
private GraphCoordinate convertGPS(double lat, double lon) {
int difference = Math.abs(width - height);
int size = width;
if (width > height) {
size = height;
return new GraphCoordinate((int) ((size * (lon - x1) / (x2 - x1)) + difference / 2), (int) (size - (size * (lat - y1) / (y2 - y1))));
} else {
return new GraphCoordinate((int) (size * (lon - x1) / (x2 - x1)), (int) ((size - (size * (lat - y1) / (y2 - y1))) + difference / 2));
}
//return new GraphCoordinate((int) (width * (lon - x1) / (x2 - x1)), (int) (height - (height * (lat - y1) / (y2 - y1))));
}
/**
* Converts the GPS Coordinate to GraphCoordinates
*
* @param coordinate GPSCoordinate representation of Latitude and Longitude.
* @return GraphCoordinate that the GPS is coordinates are to be displayed on the map.
* @see GraphCoordinate
* @see GPSCoordinate
*/
public GraphCoordinate convertGPS(GPSCoordinate coordinate) {
return convertGPS(coordinate.getLatitude(), coordinate.getLongitude());
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
}
@@ -1,434 +0,0 @@
package seng302;
import javafx.application.Platform;
import org.xml.sax.SAXException;
import seng302.Mock.*;
import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.Exceptions.InvalidMessageException;
import seng302.Networking.Messages.*;
import javax.xml.parsers.ParserConfigurationException;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
/**
* TCP client which receives packets/messages from a race data source
* (e.g., mock source, official source), and exposes them to any observers.
* @see seng302.Mock.StreamedCourse
*/
public class VisualiserInput implements Runnable {
///Timestamp of the last heartbeat.
private long lastHeartbeatTime = -1;
///Sequence number of the last heartbeat.
private long lastHeartbeatSequenceNum = -1;
///The socket that we have connected to.
private Socket connectionSocket;
///Object to store parsed course data. //TODO comment?
private StreamedCourse course;
///The last RaceStatus message received.
private RaceStatus raceStatus;
///A map of the last BoatStatus message received, for each boat.
private final Map<Integer, BoatStatus> boatStatusMap = new HashMap<>();
///A map of the last BoatLocation message received, for each boat.
private final Map<Integer, BoatLocation> boatLocationMap = new HashMap<>();
///The last AverageWind message received.
private AverageWind averageWind;
///The last CourseWinds message received.
private CourseWinds courseWinds;
///A map of the last MarkRounding message received, for each boat.
private final Map<Integer, MarkRounding> markRoundingMap = new HashMap<>();
///InputStream (from the socket).
private DataInputStream inStream;
/**
* Ctor.
* @param socket Socket from which we will receive race data.
* @param course TODO comment?
* @throws IOException If there is something wrong with the socket's input stream.
*/
public VisualiserInput(Socket socket, StreamedCourse course) throws IOException {
this.connectionSocket = socket;
//We wrap a DataInputStream around the socket's InputStream because it has the stream.readFully(buffer) function, which is a blocking read until the buffer has been filled.
this.inStream = new DataInputStream(connectionSocket.getInputStream());
this.course = course;
this.lastHeartbeatTime = System.currentTimeMillis();
}
/**
* Provides StreamedCourse container for fixed course data.
* @return Course for current VisualiserInput instance.
* @see seng302.Mock.StreamedCourse
*/
public StreamedCourse getCourse() {
return course;
}
/**
* Returns the last boat location message associated with the given boat source ID.
* @param sourceID Unique global identifier for the boat.
* @return The most recent location message.
*/
public BoatLocation getBoatLocationMessage(int sourceID) {
return boatLocationMap.get(sourceID);
}
public BoatStatus getBoatStatusMessage(int sourceID) {
return boatStatusMap.get(sourceID);
}
/**
* Calculates the time since last heartbeat, in milliseconds.
* @return Time since last heartbeat, in milliseconds..
*/
private double timeSinceHeartbeat() {
long now = System.currentTimeMillis();
return (now - lastHeartbeatTime);
}
/**
* Returns the boat locations map. Maps from Integer (Boat ID) to BoatLocation.
* @return Map of boat locations.
*/
public Map<Integer, BoatLocation> getBoatLocationMap() {
return boatLocationMap;
}
/**
* Gets the status of the race.
* @return The status of the race.
*/
public RaceStatus getRaceStatus() {
return raceStatus;
}
/**
* Returns the boat statuses map. Maps from Integer (Boat ID) to BoatStatus.
* @return Map of boat statuses.
*/
public Map<Integer, BoatStatus> getBoatStatusMap() {
return boatStatusMap;
}
/**
* Returns the average wind of the race.
* @return Average wind in the race.
*/
public AverageWind getAverageWind() {
return averageWind;
}
/**
* Returns winds in the course.
* @return Winds that are in the course.
*/
public CourseWinds getCourseWinds() {
return courseWinds;
}
/**
* Returns the mark roundings map. Maps from Integer (Boat ID) to MarkRounding.
* @return Map of mark roundings.
*/
public Map<Integer, MarkRounding> getMarkRoundingMap() {
return markRoundingMap;
}
/**
* Sets the wind direction for the current course.
* @param direction The new wind direction for the course.
*/
private void setCourseWindDirection(double direction) {
this.course.setWindDirection(direction);
}
/**
* Reads and returns the next message as an array of bytes from the socket. Use getNextMessage() to get the actual message object instead.
* @return Encoded binary message bytes.
* @throws IOException Thrown when an error occurs while reading from the socket.
*/
private byte[] getNextMessageBytes() throws IOException {
inStream.mark(0);
short CRCLength = 4;
short headerLength = 15;
//Read the header of the next message.
byte[] headerBytes = new byte[headerLength];
inStream.readFully(headerBytes);
//Read the message body length.
byte[] messageBodyLengthBytes = Arrays.copyOfRange(headerBytes, headerLength - 2, headerLength);
short messageBodyLength = bytesToShort(messageBodyLengthBytes);
//Read the message body.
byte[] messageBodyBytes = new byte[messageBodyLength];
inStream.readFully(messageBodyBytes);
//Read the message CRC.
byte[] messageCRCBytes = new byte[CRCLength];
inStream.readFully(messageCRCBytes);
//Put the head + body + crc into one large array.
ByteBuffer messageBytes = ByteBuffer.allocate(headerBytes.length + messageBodyBytes.length + messageCRCBytes.length);
messageBytes.put(headerBytes);
messageBytes.put(messageBodyBytes);
messageBytes.put(messageCRCBytes);
return messageBytes.array();
}
/**
* Reads and returns the next message object from the socket.
* @return The message object. Use instanceof for concrete type.
* @throws IOException Thrown when an error occurs while reading from the socket.
* @throws InvalidMessageException Thrown when the message is invalid in some way.
*/
private AC35Data getNextMessage() throws IOException, InvalidMessageException
{
//Get the next message from the socket as a block of bytes.
byte[] messageBytes = this.getNextMessageBytes();
//Decode the binary message into an appropriate message object.
BinaryMessageDecoder decoder = new BinaryMessageDecoder(messageBytes);
return decoder.decode();
}
/**
* Main loop which reads messages from the socket, and exposes them.
*/
public void run(){
boolean receiverLoop = true;
//receiver loop that gets the input
while (receiverLoop) {
//If no heartbeat has been received in more the heartbeat period
//then the connection will need to be restarted.
//System.out.println("time since last heartbeat: " + timeSinceHeartbeat());//TEMP REMOVE
long heartBeatPeriod = 10 * 1000;
if (timeSinceHeartbeat() > heartBeatPeriod) {
System.out.println("Connection has stopped, trying to reconnect.");
//Attempt to reconnect the socket.
try {//This attempt doesn't really work. Under what circumstances would
this.connectionSocket = new Socket(this.connectionSocket.getInetAddress(), this.connectionSocket.getPort());
//this.connectionSocket.connect(this.connectionSocket.getRemoteSocketAddress());
//Reset the heartbeat timer.
this.lastHeartbeatTime = System.currentTimeMillis();
}
catch (IOException e) {
System.err.println("Unable to reconnect.");
//Wait 500ms. Ugly hack, should refactor.
long waitPeriod = 500;
long waitTimeStart = System.currentTimeMillis() + waitPeriod;
while (System.currentTimeMillis() < waitTimeStart){
//Nothing. Busyloop.
}
//Swallow the exception.
continue;
}
}
//Reads the next message.
AC35Data message;
try {
message = this.getNextMessage();
}
catch (InvalidMessageException | IOException e) {
//Prints exception to stderr, and iterate loop (that is, read the next message).
System.err.println("Unable to read message: " + e.getMessage());
try {
inStream.reset();
} catch (IOException e1) {
e1.printStackTrace();
}
//Continue to the next loop iteration/message.
continue;
}/*
//Add it to message queue.
this.messagesReceivedQueue.add(message);*/
//Checks which message is being received and does what is needed for that message.
//Heartbeat.
if (message instanceof Heartbeat) {
Heartbeat heartbeat = (Heartbeat) message;
//Check that the heartbeat number is greater than the previous value, and then set the last heartbeat time.
if (heartbeat.getSequenceNumber() > this.lastHeartbeatSequenceNum) {
lastHeartbeatTime = System.currentTimeMillis();
lastHeartbeatSequenceNum = heartbeat.getSequenceNumber();
//System.out.println("HeartBeat Message! " + lastHeartbeatSequenceNum);
}
}
//RaceStatus.
else if (message instanceof RaceStatus) {
RaceStatus raceStatus = (RaceStatus) message;
//System.out.println("Race Status Message");
this.raceStatus = raceStatus;
for (BoatStatus boatStatus: this.raceStatus.getBoatStatuses()) {
this.boatStatusMap.put(boatStatus.getSourceID(), boatStatus);
}
setCourseWindDirection(raceStatus.getScaledWindDirection());
}
//DisplayTextMessage.
/*else if (message instanceof DisplayTextMessage) {
//System.out.println("Display Text Message");
//No decoder for this.
}*/
//XMLMessage.
else if (message instanceof XMLMessage) {
XMLMessage xmlMessage = (XMLMessage) message;
//System.out.println("XML Message!");
Platform.runLater(()-> {
if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRegatta) {
//System.out.println("Setting Regatta");
try {
course.setRegattaXMLReader(new RegattaXMLReader(xmlMessage.getXmlMessage()));
}
//TODO REFACTOR should put all of these exceptions behind a RegattaXMLReaderException.
catch (IOException | SAXException | ParserConfigurationException e) {
System.err.println("Error creating RegattaXMLReader: " + e.getMessage());
//Continue to the next loop iteration/message.
}
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeRace) {
//System.out.println("Setting Course");
try {
course.setStreamedCourseXMLReader(new StreamedCourseXMLReader(xmlMessage.getXmlMessage()));
}
//TODO REFACTOR should put all of these exceptions behind a StreamedCourseXMLReaderException.
catch (IOException | SAXException | ParserConfigurationException | StreamedCourseXMLException e) {
System.err.println("Error creating StreamedCourseXMLReader: " + e.getMessage());
//Continue to the next loop iteration/message.
}
} else if (xmlMessage.getXmlMsgSubType() == XMLMessage.XMLTypeBoat) {
//System.out.println("Setting Boats");
try {
course.setBoatXMLReader(new BoatXMLReader(xmlMessage.getXmlMessage()));
}
//TODO REFACTOR should put all of these exceptions behind a BoatXMLReaderException.
catch (IOException | SAXException | ParserConfigurationException e) {
System.err.println("Error creating BoatXMLReader: " + e.getMessage());
//Continue to the next loop iteration/message.
}
}
});
}
//RaceStartStatus.
else if (message instanceof RaceStartStatus) {
//System.out.println("Race Start Status Message");
}
//YachtEventCode.
/*else if (message instanceof YachtEventCode) {
YachtEventCode yachtEventCode = (YachtEventCode) message;
//System.out.println("Yacht Event Code!");
//No decoder for this.
}*/
//YachtActionCode.
/*else if (message instanceof YachtActionCode) {
YachtActionCode yachtActionCode = (YachtActionCode) message;
//System.out.println("Yacht Action Code!");
//No decoder for this.
}*/
//ChatterText.
/*else if (message instanceof ChatterText) {
ChatterText chatterText = (ChatterText) message;
//System.out.println("Chatter Text Message!");
//No decoder for this.
}*/
//BoatLocation.
else if (message instanceof BoatLocation) {
BoatLocation boatLocation = (BoatLocation) message;
//System.out.println("Boat Location!");
if (this.boatLocationMap.containsKey(boatLocation.getSourceID())) {
//If our boatlocation map already contains a boat location message for this boat, check that the new message is actually for a later timestamp (i.e., newer).
if (boatLocation.getTime() > this.boatLocationMap.get(boatLocation.getSourceID()).getTime()){
//If it is, replace the old message.
this.boatLocationMap.put(boatLocation.getSourceID(), boatLocation);
}
}else{
//If the map _doesn't_ already contain a message for this boat, insert the message.
this.boatLocationMap.put(boatLocation.getSourceID(), boatLocation);
}
}
//MarkRounding.
else if (message instanceof MarkRounding) {
MarkRounding markRounding = (MarkRounding) message;
//System.out.println("Mark Rounding Message!");
if (this.markRoundingMap.containsKey(markRounding.getSourceID())) {
//If our markRoundingMap already contains a mark rounding message for this boat, check that the new message is actually for a later timestamp (i.e., newer).
if (markRounding.getTime() > this.markRoundingMap.get(markRounding.getSourceID()).getTime()){
//If it is, replace the old message.
this.markRoundingMap.put(markRounding.getSourceID(), markRounding);
}
}else{
//If the map _doesn't_ already contain a message for this boat, insert the message.
this.markRoundingMap.put(markRounding.getSourceID(), markRounding);
}
}
//CourseWinds.
else if (message instanceof CourseWinds) {
//System.out.println("Course Wind Message!");
this.courseWinds = (CourseWinds) message;
}
//AverageWind.
else if (message instanceof AverageWind) {
//System.out.println("Average Wind Message!");
this.averageWind = (AverageWind) message;
}
//Unrecognised message.
else {
System.out.println("Broken Message!");
}
}
}
}
@@ -1,52 +0,0 @@
package seng302;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.io.InputStream;
/**
* The abstract class for reading in XML race data.
*/
public abstract class XMLReader {
protected Document doc;
protected XMLReader(String filePath) throws ParserConfigurationException, IOException, SAXException {
InputStream fXmlFile = getClass().getClassLoader().getResourceAsStream(filePath);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
}
protected XMLReader(InputStream xmlInput) throws ParserConfigurationException, IOException, SAXException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
doc = dBuilder.parse(xmlInput);
}
public Document getDocument() {
return doc;
}
protected String getTextValueOfNode(Element n, String tagName) {
return n.getElementsByTagName(tagName).item(0).getTextContent();
}
protected boolean exists(Node node, String attribute) {
return node.getAttributes().getNamedItem(attribute) != null;
}
public String getAttribute(Element n, String attr) {
return n.getAttribute(attr);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

@@ -1,251 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<BoatConfig>
<Modified>2012-05-17T07:49:40+0200</Modified>
<Version>12</Version>
<Settings>
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>
<Boat Type="RC" SourceID="121" ShapeID="0" HullNum="RG01" StoweName="PRO" ShortName="PRO"
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="122" ShapeID="1" HullNum="LC05" StoweName="CON" ShortName="Constellation"
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="123" ShapeID="1" HullNum="LC04" StoweName="MIS" ShortName="Mischief"
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat SourceID="125" ShapeID="1" StoweName="VOL" HullNum="LC01" ShortName="Volunteer"
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="126" ShapeID="1" HullNum="LC13" StoweName="MS2" ShortName="Defender"
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" StoweName="KOR" ShortName="TEAM KOREA"
BoatName="TEAM KOREA" Country="KOR">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Race>
<RaceID>11080703</RaceID>
<RaceType>Match</RaceType>
<CreationTimeDate>2011-08-06T13:25:00-0000</CreationTimeDate>
<RaceStartTime Time="2011-08-06T13:30:00-0700" Postpone="false"/>
<Participants>
<Yacht SourceID="101" Entry="Port"/>
<Yacht SourceID="108" Entry="Stbd"/>
</Participants>
<Course>
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="-36.83" TargetLng="174.83" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="-36.84" TargetLng="174.81" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="-36.63566590" TargetLng="174.88543944" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="M2">
<Mark Name="M2" TargetLat="-36.83" TargetLng="174.80" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="Gate">
<Mark SeqID="1" Name="G1" TargetLat="-36.63566590" TargetLng="174.97205159" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="-36.64566590" TargetLng="174.98205159" SourceID="105"/>
</CompoundMark>
</Course>
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Stbd" ZoneSize="6"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="6"/>
<Corner SeqID="5" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
</CompoundMarkSequence>
<CourseLimit>
<Limit SeqID="1" Lat="-36.8325" Lon="174.8325"/>
<Limit SeqID="2" Lat="-36.82883" Lon="174.81983"/>
<Limit SeqID="3" Lat="-36.82067" Lon="174.81983"/>
<Limit SeqID="4" Lat="-36.811" Lon="174.8265"/>
<Limit SeqID="5" Lat="-36.81033" Lon="174.83833"/>
<Limit SeqID="6" Lat="-36.81533" Lon="174.8525"/>
<Limit SeqID="7" Lat="-36.81533" Lon="174.86733"/>
<Limit SeqID="8" Lat="-36.81633" Lon="174.88217"/>
<Limit SeqID="9" Lat="-36.83383" Lon="174.87117"/>
<Limit SeqID="10" Lat="-36.83417" Lon="174.84767"/>
</CourseLimit>
</Race>
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RegattaConfig>
<RegattaID>3</RegattaID>
<RegattaName>New Zealand Test</RegattaName>
<CourseName>North Head</CourseName>
<CentralLatitude>-36.82791529</CentralLatitude>
<CentralLongitude>174.81218919</CentralLongitude>
<CentralAltitude>0.00</CentralAltitude>
<UtcOffset>12</UtcOffset>
<MagneticVariation>14.1</MagneticVariation>
</RegattaConfig>
@@ -1,119 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<BoatConfig>
<Modified>2017-04-19T15:49:40+1200</Modified>
<Version>1</Version>
<Settings>
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" ShortName="USA"
BoatName="ORACLE TEAM USA" Country="USA">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="102" ShapeID="4" HullNum="AC4502" ShortName="GBR"
BoatName="Land Rover BAR" Country="United Kingdom">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="103" ShapeID="4" HullNum="AC4503" ShortName="JPN"
BoatName="SoftBank Team Japan" Country="Japan">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="104" ShapeID="4" HullNum="AC4504" ShortName="FRA"
BoatName="Groupama Team France" Country="France">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="105" ShapeID="4" HullNum="AC4505" ShortName="SWE"
BoatName="Artemis Racing" Country="Sweden">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="106" ShapeID="4" HullNum="AC4506" ShortName="NZL"
BoatName="Emirates Team New Zealand" Country="New Zealand">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>
@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Race>
<RaceID>17041901</RaceID>
<RaceType>Fleet</RaceType>
<CreationTimeDate>2017-04-19T15:30:00+1200</CreationTimeDate>
<RaceStartTime Time="2019-06-01T13:30:00-0400" Postpone="false"/>
<Participants>
<Yacht SourceID="001" Entry="Port"/>
<Yacht SourceID="002" Entry="Port"/>
<Yacht SourceID="003" Entry="Port"/>
<Yacht SourceID="004" Entry="Port"/>
<Yacht SourceID="005" Entry="Port"/>
<Yacht SourceID="006" Entry="Port"/>
</Participants>
<Course>
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.296577" TargetLng="-64.854304" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.293771" TargetLng="-64.855242" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="32.293039" TargetLng="-64.843983" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="WindwardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.284680" TargetLng="-64.850045" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="32.280164" TargetLng="-64.847591" SourceID="105"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="LeewardGate">
<Mark SeqID="1" Name="G1" TargetLat="32.309693" TargetLng="-64.835249" SourceID="106"/>
<Mark SeqID="2" Name="G2" TargetLat="32.308046" TargetLng="-64.831785" SourceID="107"/>
</CompoundMark>
<CompoundMark CompoundMarkID="5" Name="FinishLine">
<Mark SeqID="1" Name="PRO" TargetLat="32.317379" TargetLng="-64.839291" SourceID="108"/>
<Mark SeqID="2" Name="PIN" TargetLat="32.317257" TargetLng="-64.836260" SourceID="109"/>
</CompoundMark>
</Course>
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="5" CompoundMarkID="5" Rounding="SP" ZoneSize="3"/>
</CompoundMarkSequence>
<CourseLimit>
<Limit SeqID="1" Lat="32.313922" Lon="-64.837168"/>
<Limit SeqID="2" Lat="32.317379" Lon="-64.839291"/>
<Limit SeqID="3" Lat="32.317911" Lon="-64.836996"/>
<Limit SeqID="4" Lat="32.317257" Lon="-64.836260"/>
<Limit SeqID="5" Lat="32.304273" Lon="-64.822834"/>
<Limit SeqID="6" Lat="32.279097" Lon="-64.841545"/>
<Limit SeqID="7" Lat="32.279604" Lon="-64.849871"/>
<Limit SeqID="8" Lat="32.289545" Lon="-64.854162"/>
<Limit SeqID="9" Lat="32.290198" Lon="-64.858711"/>
<Limit SeqID="10" Lat="32.297164" Lon="-64.856394"/>
<Limit SeqID="11" Lat="32.296148" Lon="-64.849184"/>
</CourseLimit>
</Race>
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RegattaConfig>
<RegattaID>1</RegattaID>
<RegattaName>Seng302 Mock Test</RegattaName>
<CourseName>Bermuda AC35</CourseName>
<CentralLatitude>-32.296577</CentralLatitude>
<CentralLongitude>64.854304</CentralLongitude>
<CentralAltitude>0.00</CentralAltitude>
<UtcOffset>-4</UtcOffset>
<MagneticVariation>-14.78</MagneticVariation>
</RegattaConfig>
@@ -1,269 +0,0 @@
<race>
<raceId>5326</raceId>
<boats>
<boat>
<name>ORACLE TEAM USA</name>
<speed>20</speed>
<abbr>USA</abbr>
<colour>BLUEVIOLET</colour>
</boat>
<boat>
<name>Land Rover BAR</name>
<speed>30</speed>
<abbr>GBR</abbr>
<colour>BLACK</colour>
</boat>
<boat>
<name>SoftBank Team Japan</name>
<speed>25</speed>
<abbr>JPN</abbr>
<colour>RED</colour>
</boat>
<boat>
<name>Groupama Team France</name>
<speed>20</speed>
<abbr>FRA</abbr>
<colour>ORANGE</colour>
</boat>
<boat>
<name>Artemis Racing</name>
<speed>29</speed>
<abbr>SWE</abbr>
<colour>DARKOLIVEGREEN</colour>
</boat>
<boat>
<name>Emirates Team New Zealand</name>
<speed>62</speed>
<abbr>NZL</abbr>
<colour>LIMEGREEN</colour>
</boat>
</boats>
<legs>
<leg>
<name>Start to Mark 1</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.296577</latitude>
<longitude>-64.854304</longitude>
</coordinate>
<coordinate>
<latitude>32.293771</latitude>
<longitude>-64.855242</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Mark 1 to Leeward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Leeward Gate to Windward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Windward Gate to Leeward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Leeward Gate to Finish</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
</legs>
<course>
<boundaries>
<coordinate>
<latitude>32.313922</latitude>
<longitude>-64.837168</longitude>
</coordinate>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317911</latitude>
<longitude>-64.836996</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
<coordinate>
<latitude>32.304273</latitude>
<longitude>-64.822834</longitude>
</coordinate>
<coordinate>
<latitude>32.279097</latitude>
<longitude>-64.841545</longitude>
</coordinate>
<coordinate>
<latitude>32.279604</latitude>
<longitude>-64.849871</longitude>
</coordinate>
<coordinate>
<latitude>32.289545</latitude>
<longitude>-64.854162</longitude>
</coordinate>
<coordinate>
<latitude>32.290198</latitude>
<longitude>-64.858711</longitude>
</coordinate>
<coordinate>
<latitude>32.297164</latitude>
<longitude>-64.856394</longitude>
</coordinate>
<coordinate>
<latitude>32.296148</latitude>
<longitude>-64.849184</longitude>
</coordinate>
</boundaries>
<compoundMark>
<name>Start Line</name>
<coordinate>
<latitude>32.296577</latitude>
<longitude>-64.854304</longitude>
</coordinate>
<coordinate>
<latitude>32.293771</latitude>
<longitude>-64.855242</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Mark</name>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Windward Gate</name>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Leeward Gate</name>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Finish Line</name>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
</compoundMark>
</course>
</race>
@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.image.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<Pane fx:id="compass" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="125.0" prefWidth="125.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<StackPane fx:id="arrow" prefHeight="125.0" prefWidth="125.0">
<children>
<ImageView fitHeight="75.0" fitWidth="75.0">
<image>
<Image url="@../images/arrow.png" />
</image>
</ImageView>
</children>
</StackPane>
<Circle fill="#1f93ff00" layoutX="63.0" layoutY="63.0" radius="60.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="3.0" />
<Label layoutX="55.0" layoutY="1.0" text="N">
<font>
<Font name="System Bold" size="18.0" />
</font>
</Label>
<Label layoutX="42.0" layoutY="99.0" text="Wind">
<font>
<Font name="System Bold" size="16.0" />
</font>
</Label>
</children>
</Pane>
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.ConnectionController">
<children>
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="600.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="600.0" minWidth="10.0" prefWidth="600.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="182.0" minHeight="10.0" prefHeight="182.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="434.0" minHeight="10.0" prefHeight="434.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="174.0" minHeight="10.0" prefHeight="174.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="80.0" minHeight="50.0" prefHeight="80.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TableView fx:id="connectionTable" prefHeight="200.0" prefWidth="1080.0" GridPane.columnSpan="2" GridPane.rowIndex="1">
<columns>
<TableColumn fx:id="hostnameColumn" prefWidth="453.99998474121094" text="Host" />
<TableColumn fx:id="statusColumn" prefWidth="205.0" text="Status" />
</columns>
<GridPane.margin>
<Insets left="50.0" right="50.0" />
</GridPane.margin>
</TableView>
<Button mnemonicParsing="false" onAction="#checkConnections" text="Refresh" GridPane.halignment="RIGHT" GridPane.rowIndex="3">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</Button>
<Button fx:id="connectButton" mnemonicParsing="false" onAction="#connectSocket" text="Connect" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowIndex="3">
<GridPane.margin>
<Insets left="20.0" />
</GridPane.margin>
</Button>
<Label text="Welcome to RaceVision" GridPane.columnSpan="2" GridPane.halignment="CENTER">
<font>
<Font size="36.0" />
</font>
</Label>
<GridPane GridPane.columnSpan="2" GridPane.rowIndex="2">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TextField fx:id="urlField" GridPane.rowIndex="1">
<GridPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</GridPane.margin>
</TextField>
<TextField fx:id="portField" GridPane.columnIndex="1" GridPane.rowIndex="1">
<GridPane.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</GridPane.margin>
</TextField>
<Button mnemonicParsing="false" onAction="#addConnection" text="Add New Connection" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
<Label text="Host Name:" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
<Label text="Port:" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.valignment="BOTTOM" />
</children>
</GridPane>
</children>
</GridPane>
</children>
</AnchorPane>
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="finishWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.FinishController">
<children>
<GridPane fx:id="start" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="250.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="116.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="261.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="53.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TableView fx:id="boatInfoTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<placeholder>
<Label text="Initial lineup..." />
</placeholder>
<columns>
<TableColumn fx:id="boatRankColumn" prefWidth="120.0" style="-fx-font-size: 16;" text="Ranking" />
<TableColumn fx:id="boatNameColumn" prefWidth="367.0" style="-fx-font-size: 16;" text="Team" />
</columns>
</TableView>
<Label fx:id="raceFinishLabel" alignment="CENTER" text="Race Finished" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.halignment="CENTER">
<font>
<Font size="36.0" />
</font>
</Label>
<Label fx:id="raceWinnerLabel" alignment="CENTER" maxWidth="1.7976931348623157E308" text="Winner" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
</children>
</GridPane>
</children>
</AnchorPane>
@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController">
<children>
<fx:include fx:id="race" source="race.fxml" />
<fx:include fx:id="start" source="start.fxml" />
<fx:include fx:id="connection" source="connect.fxml" />
<fx:include fx:id="finish" source="finish.fxml" />
</children>
</AnchorPane>
@@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.chart.LineChart?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?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.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
<items>
<GridPane fx:id="canvasBase">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<fx:include fx:id="arrow" source="arrow.fxml" />
<Pane prefHeight="200.0" prefWidth="400.0" GridPane.halignment="LEFT" GridPane.valignment="TOP">
<children>
<Accordion>
<panes>
<TitledPane animated="false" prefHeight="395.0" prefWidth="222.0" text="Annotation Control">
<content>
<AnchorPane fx:id="annotationPane" minHeight="0.0" minWidth="0.0">
<children>
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false" selected="true" text="Show Boat Name" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false" selected="true" text="Show Boat Abbreviation" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="25.0" />
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0" />
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="75.0" />
<CheckBox fx:id="showTime" mnemonicParsing="false" selected="true" text="Show Boat Leg Time" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" />
<CheckBox fx:id="showEstTime" mnemonicParsing="false" selected="true" text="Show Est. Time to Next Mark" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" />
<Separator layoutX="19.6" layoutY="175.6" prefHeight="0.0" prefWidth="200.0" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="150.0" />
<Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="150.0" />
<RadioButton fx:id="hideAnnoRBtn" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="175.0">
<toggleGroup>
<ToggleGroup fx:id="annoToggleGroup" />
</toggleGroup></RadioButton>
<RadioButton fx:id="showAnnoRBtn" mnemonicParsing="false" text="Visible" toggleGroup="$annoToggleGroup" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="200.0" />
<RadioButton fx:id="partialAnnoRBtn" mnemonicParsing="false" text="Partial" toggleGroup="$annoToggleGroup" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="225.0" />
<RadioButton fx:id="importantAnnoRBtn" mnemonicParsing="false" text="Important" toggleGroup="$annoToggleGroup" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="250.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="126.0" mnemonicParsing="false" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="275.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
<TitledPane animated="false" text="FPS Control">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<CheckBox fx:id="showFPS" layoutX="-14.0" layoutY="13.0" mnemonicParsing="false" selected="true" text="Show FPS" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</Pane>
<Label fx:id="timer" layoutX="45.0" layoutY="146.0" maxHeight="20.0" text="0:0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" GridPane.halignment="RIGHT" GridPane.valignment="BOTTOM">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Label>
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" GridPane.halignment="LEFT" GridPane.valignment="BOTTOM">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Label>
<Label fx:id="timeZone" text="Label" GridPane.halignment="RIGHT" GridPane.valignment="BOTTOM">
<GridPane.margin>
<Insets bottom="20.0" />
</GridPane.margin>
<font>
<Font name="System Bold" size="15.0" />
</font>
</Label>
<StackPane fx:id="arrowPane" alignment="TOP_RIGHT" mouseTransparent="true" prefHeight="150.0" prefWidth="150.0" snapToPixel="false" />
</children>
</GridPane>
<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="265.0" prefWidth="242.0" AnchorPane.bottomAnchor="164.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" />
<TableColumn fx:id="boatMarkColumn" prefWidth="130.0" text="Mark" />
<TableColumn fx:id="boatSpeedColumn" prefWidth="75.0" text="Speed" />
</columns>
</TableView>
<AnchorPane layoutY="265.0" prefHeight="167.0" prefWidth="178.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<children>
<LineChart fx:id="sparklineChart" layoutX="-211.0" layoutY="-186.0" mouseTransparent="true" prefHeight="167.0" prefWidth="178.0" titleSide="LEFT" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<xAxis>
<NumberAxis side="BOTTOM" fx:id="xAxis" />
</xAxis>
<yAxis>
<NumberAxis fx:id="yAxis" side="LEFT" />
</yAxis>
</LineChart>
</children>
</AnchorPane>
</children>
</AnchorPane>
</items>
</SplitPane>
@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController">
<children>
<GridPane fx:id="start" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="372.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="394.0" minWidth="10.0" prefWidth="250.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="416.0" minWidth="10.0" prefWidth="200.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="241.0" minHeight="10.0" prefHeight="116.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="383.0" minHeight="10.0" prefHeight="48.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="261.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="369.0" minHeight="10.0" prefHeight="38.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="53.5" vgrow="SOMETIMES" />
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
<placeholder>
<Label text="Initial lineup..." />
</placeholder>
<columns>
<TableColumn fx:id="boatNameColumn" prefWidth="360.0" style="-fx-font-size: 16;" text="Team Name" />
<TableColumn fx:id="boatCodeColumn" prefWidth="133.0" style="-fx-font-size: 16;" text="Code" />
</columns>
</TableView>
<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="raceStartLabel" text="Starting time..." 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>
<Label fx:id="raceStatusLabel" alignment="CENTER" text="Race Status:" textAlignment="CENTER" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
</children>
</GridPane>
</children>
</AnchorPane>
@@ -1,47 +0,0 @@
//package seng302.Mock;
//
//import org.junit.Before;
//import org.junit.Test;
//
//import java.util.HashMap;
//import java.util.Map;
//
//import static org.junit.Assert.assertEquals;
//
///**
// * Created by jjg64 on 21/04/17.
// */
//public class BoatsXMLTest {
// private BoatXMLReader boatXMLReader;
//
// @Before
// public void setup() {
// try {
// boatXMLReader = new BoatXMLReader("mockXML/boatXML/boatTest.xml", false);
// } catch (Exception e) {
// e.printStackTrace();
// //fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
// }
// }
//
// @Test
// public void testInvalidParticipant() {
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
// inputParticipants.put(420, new StreamedBoat(420));
// boatXMLReader.setParticipants(inputParticipants);
// boatXMLReader.read();
// assertEquals(boatXMLReader.getBoats().size(), 0);
// }
//
// @Test
// public void testValidParticipant() {
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
// inputParticipants.put(101, new StreamedBoat(101));
// boatXMLReader.setParticipants(inputParticipants);
// boatXMLReader.read();
// assertEquals(boatXMLReader.getBoats().size(), 1);
// StreamedBoat boat = (StreamedBoat) boatXMLReader.getBoats().get(0);
// assertEquals(boat.getSourceID(), 101);
// }
//
//}
@@ -1,26 +0,0 @@
//package seng302.Mock;
//
//import org.junit.Test;
//import org.xml.sax.SAXException;
//
//import javax.xml.parsers.ParserConfigurationException;
//import java.io.IOException;
//import java.text.ParseException;
//
///**
// * Created by jjg64 on 1/05/17.
// */
//public class FailBoatXMLTest {
// private final String path = "mockXML/boatXML/";
//
// @Test(expected = NumberFormatException.class)
// public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
// new BoatXMLReader(path + "invalidSourceID.xml");
// }
//
// @Test(expected = NullPointerException.class)
// public void insufficientInformation() throws SAXException, ParserConfigurationException, ParseException, IOException {
// new BoatXMLReader(path + "insufficientInformation.xml");
// }
//
//}
@@ -1,36 +0,0 @@
package seng302.Mock;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* Created by jjg64 on 19/04/17.
* Tests RegattaXMLReader
*/
public class RegattaXMLTest {
private RegattaXMLReader regatta;
@Before
public void findFile() {
try {
regatta = new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml");
} catch (Exception e) {
fail("Cannot find mockXML/regattaXML/regattaTest.xml in the resources folder");
}
}
@Test
public void correctValuesTest() {
assertEquals(regatta.getRegattaID(), 3);
assertEquals(regatta.getRegattaName(), "New Zealand Test");
assertEquals(regatta.getCourseName(), "North Head");
assertEquals(regatta.getCentralLatitude(), -36.82791529, 0.00000001);
assertEquals(regatta.getCentralLongitude(), 174.81218919, 0.00000001);
assertEquals(regatta.getCentralAltitude(), 0.00, 0.00000001);
assertEquals(regatta.getUtcOffset(), 12.0, 0.001);
assertEquals(regatta.getMagneticVariation(), 14.1, 0.001);
}
}
@@ -1,98 +0,0 @@
package seng302.Mock;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import seng302.GPSCoordinate;
import seng302.Model.Leg;
import seng302.Model.Marker;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Tests only work on the current version of mockXML/raceXML/raceTest.xml
*/
public class StreamedRaceTest {
private StreamedCourseXMLReader streamedCourseXMLReader;
private List<GPSCoordinate> boundary;
@Before
public void setup() {
try {
streamedCourseXMLReader = new StreamedCourseXMLReader("mockXML/raceXML/raceTest.xml", true);
boundary = streamedCourseXMLReader.getBoundary();
} catch (Exception | StreamedCourseXMLException e) {
e.printStackTrace();
//fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
}
}
@Test
public void testAllBoundaryPointsRead() {
assertEquals(boundary.size(), 10);
}
@Test
public void testBoundaryPointData() {
// First point
assertEquals(boundary.get(0).getLatitude(), -36.8325, 1e-6);
assertEquals(boundary.get(0).getLongitude(), 174.8325, 1e-6);
// Last point
assertEquals(boundary.get(boundary.size() - 1).getLatitude(), -36.83417, 1e-6);
assertEquals(boundary.get(boundary.size() - 1).getLongitude(), 174.84767, 1e-6);
}
@Test
public void testMapEdges() {
double maxLatitude = streamedCourseXMLReader.getMapBottomRight().getLatitude() - streamedCourseXMLReader.getPadding();
double maxLongitude = streamedCourseXMLReader.getMapBottomRight().getLongitude() - streamedCourseXMLReader.getPadding();
double minLatitude = streamedCourseXMLReader.getMapTopLeft().getLatitude() - streamedCourseXMLReader.getPadding();
double minLongitude = streamedCourseXMLReader.getMapTopLeft().getLongitude() - streamedCourseXMLReader.getPadding();
assertEquals(maxLatitude, -36.81033, 1e-6);
assertEquals(maxLongitude, 174.88217, 1e-6);
assertEquals(minLatitude, -36.83417, 1e-6);
assertEquals(minLongitude, 174.81983, 1e-6);
}
@Test
public void testRaceSettings() {
}
@Test
public void correctLegSequence() {
List<Leg> legs = streamedCourseXMLReader.getLegs();
String[] expectedNames = {
"StartLine",
"M1",
"M2",
"Gate"
};
for(int i = 0; i < legs.size(); i++) {
assertEquals(expectedNames[i], legs.get(i).getName());
}
}
/**
* raceTest.xml is not compliant with this test. Markers are positioned far out of bounds.
*/
@Test
@Ignore
public void markersWithinRaceBoundaries() {
GPSCoordinate topLeft = streamedCourseXMLReader.getMapTopLeft();
GPSCoordinate bottomRight = streamedCourseXMLReader.getMapBottomRight();
for(Marker compoundMark : streamedCourseXMLReader.getMarkers()) {
GPSCoordinate centre = compoundMark.getAverageGPSCoordinate();
assertTrue(centre.getLatitude() < bottomRight.getLatitude());
assertTrue(centre.getLatitude() > topLeft.getLatitude());
assertTrue(centre.getLongitude() > bottomRight.getLongitude());
assertTrue(centre.getLongitude() < topLeft.getLongitude());
}
}
}
@@ -1,149 +0,0 @@
package seng302.Model;
/**
* Tests various aspects of a boat in race perform correctly.
*/
public class BoatInRaceTest {
// TODO change this test to use Boat and not BoatInRace ??
// TODO delete BoatInRace class
// private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
// private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
//
//
// @Test
// public void calculateDueNorthAzimuthReturns0() {
//
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
// }
//
// @Test
// public void calculateDueSouthAzimuthReturns180() {
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
// }
//
//
// @Test
// public void calculateDueEastAzimuthReturns90() {
//
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(0, 50));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
// }
//
//
// @Test
// public void calculateDueWestAzimuthReturnsNegative90() {
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(0, -50));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
//
// }
//
// @Test
// public void calculateDueNorthHeadingReturns0() {
//
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
// }
//
//
// @Test
// public void calculateDueEastHeadingReturns90() {
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(0, 50));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
// }
//
// @Test
// public void calculateDueSouthHeadingReturns180() {
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
// }
//
// @Test
// public void calculateDueWestHeadingReturns270() {
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(0, -50));
// Leg start = new Leg("Start", startMarker, endMarker, 0);
// TEST_BOAT.setCurrentLeg(start);
// assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
// }
//
// @Test
// public void createNewBoatCratesInstanceOfSuperClass() {
//
// BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt");
// testBoat.setName("Name can change");
// assertTrue(testBoat instanceof Boat);
// assertTrue(testBoat.getCurrentLeg() == null);
// assertTrue(testBoat.getCurrentPosition() == null);
// assertTrue(testBoat.toString().contains("Name can change"));
// assertEquals(testBoat.getVelocity(), 20.0);
// assertTrue(testBoat.getVelocityProp().toString().contains("20"));
// assertTrue(testBoat.getAbbrev().equals("tt"));
// assertTrue(testBoat.getColour().equals(Color.ALICEBLUE));
// assertFalse(testBoat.isFinished());
// }
//
//
// @Test
// public void getWakeAtProperHeading() throws Exception {
// BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
//
// // Construct leg of 0 degrees
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
// boat.setCurrentLeg(leg0deg);
// boat.setCurrentPosition(new GPSCoordinate(0, 0));
//
// assertEquals(0, boat.calculateHeading(), 1e-8);
//
// // Construct leg from wake - heading should be 180 degrees
// Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0);
// boat.setCurrentLeg(leg180deg);
//
// assertEquals(180, boat.calculateHeading(), 1e-8);
// }
//
//
// @Test
// public void getWakeProportionalToVelocity() throws Exception {
// BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
//
// // Construct leg of 0 degrees at 0 N
// Marker startMarker = new Marker(ORIGIN_COORDS);
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
// boat.setCurrentLeg(leg0deg);
// boat.setCurrentPosition(new GPSCoordinate(0, 0));
//
// // Get latitude of endpoint of wake at 10 kn (longitude is 0)
// double endpointAt10Kn = boat.getWake().getLatitude();
//
// // Latitude of endpoint at 20 kn should be twice endpoint at 10 kn
// boat.setVelocity(20);
// assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
// }
}
@@ -1,140 +0,0 @@
//package seng302.Model;
//
//
//import javafx.scene.paint.Color;
//import org.geotools.referencing.GeodeticCalculator;
//import org.junit.Test;
//import seng302.Constants;
//import seng302.GPSCoordinate;
//
//import java.lang.reflect.Array;
//import java.util.ArrayList;
//
//import static org.junit.Assert.assertEquals;
//
///**
// * Created by esa46 on 16/03/17.
// */
//public class ConstantVelocityRaceTest {
//
// CompoundMark START_MARKER = new CompoundMark(new GPSCoordinate(0, 0));
// CompoundMark END_MARKER = new CompoundMark(new GPSCoordinate(10, 10));
// Leg START_LEG = new Leg("Start", START_MARKER, END_MARKER, 0);
//
// int ONE_HOUR = 3600000; //1 hour in milliseconds
//
//
// private ArrayList<Leg> generateLegsArray() {
// ArrayList<Leg> legs = new ArrayList<>();
// legs.add(START_LEG);
// return legs;
// }
//
// @Test
// public void updatePositionChangesDistanceTravelled() {
// ArrayList<Leg> legs = generateLegsArray();
// BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
// boat.setCurrentLeg(legs.get(0));
// boat.setDistanceTravelledInLeg(0);
// BoatInRace[] boats = new BoatInRace[]{boat};
//
// ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1);
//
// race.updatePosition(boat, ONE_HOUR);
// assertEquals(boat.getDistanceTravelledInLeg(), boat.getVelocity(), 1e-8);
// }
//
//
// @Test
// public void updatePositionHandlesNoChangeToDistanceTravelled() {
//
// ArrayList<Leg> legs = generateLegsArray();
// BoatInRace boat = new BoatInRace("Test", 0, Color.ALICEBLUE, "tt");
// boat.setCurrentLeg(legs.get(0));
// boat.setDistanceTravelledInLeg(0);
// BoatInRace[] boats = new BoatInRace[]{boat};
//
// ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1);
//
// race.updatePosition(boat, ONE_HOUR);
// assertEquals(boat.getDistanceTravelledInLeg(), 0, 1e-8);
// }
//
// @Test
// public void changesToDistanceTravelledAreAdditive() {
//
// ArrayList<Leg> legs = generateLegsArray();
// BoatInRace boat = new BoatInRace("Test", 5, Color.ALICEBLUE, "tt");
// boat.setCurrentLeg(legs.get(0));
// boat.setDistanceTravelledInLeg(50);
// BoatInRace[] boats = new BoatInRace[]{boat};
//
// ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1);
//
// race.updatePosition(boat, ONE_HOUR);
// assertEquals(boat.getDistanceTravelledInLeg(), boat.getVelocity() + 50, 1e-8);
// }
//
// @Test
// public void travelling10nmNorthGivesCorrectNewCoordinates() {
// GPSCoordinate oldPos = new GPSCoordinate(0, 0);
// GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 0);
//
// GeodeticCalculator calc = new GeodeticCalculator();
// calc.setStartingGeographicPoint(0, 0);
// calc.setDirection(0, 10 * Constants.NMToMetersConversion);
//
// assertEquals(newPos.getLongitude(), 0, 1e-8);
// assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8);
// assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8);
// }
//
//
// @Test
// public void travelling10nmEastGivesCorrectNewCoordinates() {
// GPSCoordinate oldPos = new GPSCoordinate(0, 0);
// GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 90);
//
// GeodeticCalculator calc = new GeodeticCalculator();
// calc.setStartingGeographicPoint(0, 0);
// calc.setDirection(90, 10 * Constants.NMToMetersConversion);
//
//
// assertEquals(newPos.getLatitude(), 0, 1e-8);
// assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8);
// assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8);
// }
//
//
// @Test
// public void travelling10nmWestGivesCorrectNewCoordinates() {
// GPSCoordinate oldPos = new GPSCoordinate(0, 0);
// GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, -90);
//
// GeodeticCalculator calc = new GeodeticCalculator();
// calc.setStartingGeographicPoint(0, 0);
// calc.setDirection(-90, 10 * Constants.NMToMetersConversion);
//
//
// assertEquals(newPos.getLatitude(), 0, 1e-8);
// assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8);
// assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8);
// }
//
//
// @Test
// public void travelling10nmSouthGivesCorrectNewCoordinates() {
// GPSCoordinate oldPos = new GPSCoordinate(0, 0);
// GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 180);
//
// GeodeticCalculator calc = new GeodeticCalculator();
// calc.setStartingGeographicPoint(0, 0);
// calc.setDirection(180, 10 * Constants.NMToMetersConversion);
//
//
// assertEquals(newPos.getLongitude(), 0, 1e-8);
// assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8);
// assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8);
// }
//
//}
@@ -1,78 +0,0 @@
package seng302.Model;
import org.geotools.referencing.GeodeticCalculator;
import org.junit.Test;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals;
import static seng302.Model.Leg.NM_TO_METERS;
/**
* Tests that using a start and end mark initialises the correct leg between
* the markers.
*/
public class LegTest {
private final Marker ORIGIN_Marker = new Marker(new GPSCoordinate(0, 0));
@Test
public void calculateDistanceHandles5nmNorth() {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0);
calc.setDirection(0, 5 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
assertEquals(test.getDistance(), 5, 1e-8);
}
@Test
public void calculateDistanceHandles12nmEast() {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0);
calc.setDirection(90, 12 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
assertEquals(test.getDistance(), 12, 1e-8);
}
@Test
public void calculateDistanceHandlesHalfnmSouth() {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0);
calc.setDirection(180, 0.5 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
assertEquals(test.getDistance(), 0.5, 1e-8);
}
@Test
public void calculateDistanceHandlesPoint1nmWest() {
GeodeticCalculator calc = new GeodeticCalculator();
calc.setStartingGeographicPoint(0, 0);
calc.setDirection(-90, 0.1 * NM_TO_METERS);
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
assertEquals(test.getDistance(), 0.1, 1e-8);
}
@Test
public void calculateDistanceHandlesZeroDifference() {
Leg test = new Leg("Test", ORIGIN_Marker, ORIGIN_Marker, 0);
assertEquals(test.getDistance(), 0, 1e-8);
}
private Marker getEndMarker(Point2D point) {
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
return new Marker(coords);
}
}
@@ -1,57 +0,0 @@
package seng302.Model;
import org.junit.Test;
import seng302.GPSCoordinate;
import static org.junit.Assert.assertTrue;
/**
* Created by esa46 on 29/03/17.
*/
public class MarkerTest {
private final GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
@Test
public void averageOfSingleMarkAtOriginIsSingleMark() {
Marker testMark = new Marker(ORIGIN_COORD);
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
}
@Test
public void averageOfSingleMarkIsSingleMark() {
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
Marker testMark = new Marker(testCoord);
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
}
@Test
public void averageLatOfTwoMarksIsAccurate() {
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
}
@Test
public void averageLongOfTwoMarksIsAccurate() {
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
}
@Test
public void averageLatAndLongOfTwoMarksIsAccurate() {
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
Marker testMark = new Marker(testCoord1, testCoord2);
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
}
}
@@ -1,8 +0,0 @@
package seng302.Model;
/**
* Created by esa46 on 15/03/17.
*/
public class RaceTest {
}
@@ -1,37 +0,0 @@
package seng302;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Created by connortaylorbrown on 3/05/17.
*/
public class RaceConnectionTest {
private RaceConnection onlineConnection;
private RaceConnection offlineConnection;
@Before
public void setUp() {
onlineConnection = new RaceConnection("livedata.americascup.com", 4941);
offlineConnection = new RaceConnection("localhost", 4942);
}
/**
* Host is not online for CI, ignore when committing.
*/
@Test
@Ignore
public void onlineConnectionStatusReady() {
assertTrue(onlineConnection.check());
}
@Test
public void offlineConnectionStatusOffline() {
assertFalse(offlineConnection.check());
}
}
@@ -1,251 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<BoatConfig>
<Modified>2012-05-17T07:49:40+0200</Modified>
<Version>12</Version>
<Settings>
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>
<Boat Type="RC" SourceID="121" ShapeID="0" HullNum="RG01" StoweName="PRO" ShortName="PRO"
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="122" ShapeID="1" HullNum="LC05" StoweName="CON" ShortName="Constellation"
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="123" ShapeID="1" HullNum="LC04" StoweName="MIS" ShortName="Mischief"
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat SourceID="125" ShapeID="1" StoweName="VOL" HullNum="LC01" ShortName="Volunteer"
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="126" ShapeID="1" HullNum="LC13" StoweName="MS2" ShortName="Defender"
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" StoweName="KOR" ShortName="TEAM KOREA"
BoatName="TEAM KOREA" Country="KOR">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>
@@ -1,249 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<BoatConfig>
<Modified>2012-05-17T07:49:40+0200</Modified>
<Version>12</Version>
<Settings>
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>
<Boat Type="RC" SourceID="121" ShapeID="0" HullNum="RG01" StoweName="PRO" ShortName="PRO"
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="122" ShapeID="1" HullNum="LC05" StoweName="CON" ShortName="Constellation"
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="123" ShapeID="1" HullNum="LC04" StoweName="MIS" ShortName="Mischief"
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat SourceID="125" ShapeID="1" StoweName="VOL" HullNum="LC01" ShortName="Volunteer"
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="126" ShapeID="1" HullNum="LC13" StoweName="MS2" ShortName="Defender"
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="101">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>
@@ -1,251 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<BoatConfig>
<Modified>2012-05-17T07:49:40+0200</Modified>
<Version>12</Version>
<Settings>
<RaceBoatType Type="AC45"/>
<BoatDimension BoatLength="14.019" HullLength="13.449"/>
<ZoneSize MarkZoneSize="40.347" CourseZoneSize="40.347"/>
<ZoneLimits Limit1="200" Limit2="100" Limit3="40.347" Limit4="0" Limit5="-100"/>
</Settings>
<BoatShapes>
<BoatShape ShapeID="0">
<Vertices>
<Vtx Seq="1" Y="0" X="-2.659"/>
<Vtx Seq="2" Y="18.359" X="-2.659"/>
<Vtx Seq="3" Y="18.359" X="2.659"/>
<Vtx Seq="4" Y="0" X="2.659"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="1">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.278"/>
<Vtx Seq="2" Y="8.876" X="-1.278"/>
<Vtx Seq="3" Y="8.876" X="1.278"/>
<Vtx Seq="4" Y="0" X="1.278"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="2">
<Vertices>
<Vtx Seq="1" Y="0" X="-1.1"/>
<Vtx Seq="2" Y="8.3" X="-1.1"/>
<Vtx Seq="3" Y="8.3" X="1.1"/>
<Vtx Seq="4" Y="0" X="1.1"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="3">
<Vertices>
<Vtx Seq="1" Y="0" X="-0.75"/>
<Vtx Seq="2" Y="3" X="-0.75"/>
<Vtx Seq="3" Y="3" X="0.75"/>
<Vtx Seq="4" Y="0" X="0.75"/>
</Vertices>
</BoatShape>
<BoatShape ShapeID="4">
<Vertices>
<Vtx Seq="1" Y="0" X="-3.46"/>
<Vtx Seq="2" Y="13.449" X="-3.46"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="13.449" X="3.46"/>
<Vtx Seq="5" Y="0" X="3.46"/>
</Vertices>
<Catamaran>
<Vtx Seq="1" Y="1.769" X="-2.752"/>
<Vtx Seq="2" Y="0" X="-2.813"/>
<Vtx Seq="3" Y="0" X="-3.34"/>
<Vtx Seq="4" Y="5.351" X="-3.46"/>
<Vtx Seq="5" Y="10.544" X="-3.387"/>
<Vtx Seq="6" Y="13.449" X="-3.075"/>
<Vtx Seq="7" Y="10.851" X="-2.793"/>
<Vtx Seq="8" Y="6.669" X="-2.699"/>
<Vtx Seq="9" Y="6.669" X="2.699"/>
<Vtx Seq="10" Y="10.851" X="2.793"/>
<Vtx Seq="11" Y="13.449" X="3.075"/>
<Vtx Seq="12" Y="10.544" X="3.387"/>
<Vtx Seq="13" Y="5.351" X="3.46"/>
<Vtx Seq="14" Y="0" X="3.34"/>
<Vtx Seq="15" Y="0" X="2.813"/>
<Vtx Seq="16" Y="1.769" X="2.752"/>
</Catamaran>
<Bowsprit>
<Vtx Seq="1" Y="6.669" X="-0.2"/>
<Vtx Seq="2" Y="11.377" X="-0.2"/>
<Vtx Seq="3" Y="14.019" X="0"/>
<Vtx Seq="4" Y="11.377" X="0.2"/>
<Vtx Seq="5" Y="6.669" X="0.2"/>
</Bowsprit>
<Trampoline>
<Vtx Seq="1" Y="2" X="-2.699"/>
<Vtx Seq="2" Y="6.438" X="-2.699"/>
<Vtx Seq="3" Y="6.438" X="2.699"/>
<Vtx Seq="4" Y="2" X="2.699"/>
</Trampoline>
</BoatShape>
<BoatShape ShapeID="5"/>
</BoatShapes>
<Boats>
<Boat Type="RC" SourceID="afdhg" ShapeID="0" HullNum="RG01" StoweName="PRO" ShortName="PRO"
BoatName="Regardless">
<GPSposition Z="6.840" Y="7.800" X="0.000"/>
<FlagPosition Z="0.000" Y="7.800" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="122" ShapeID="1" HullNum="LC05" StoweName="CON" ShortName="Constellation"
BoatName="Constellation">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="123" ShapeID="1" HullNum="LC04" StoweName="MIS" ShortName="Mischief"
BoatName="Mischief">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="124" ShapeID="1" HullNum="LC03" ShortName="Atalanta" BoatName="Atalanta">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat SourceID="125" ShapeID="1" StoweName="VOL" HullNum="LC01" ShortName="Volunteer"
BoatName="Volunteer">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="126" ShapeID="1" HullNum="LC13" StoweName="MS2" ShortName="Defender"
BoatName="Defender">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Mark" SourceID="128" ShapeID="1" HullNum="LC01" ShortName="Shamrock" BoatName="Shamrock">
<GPSposition Z="5.334" Y="3.804" X="0.000"/>
<FlagPosition Z="0.000" Y="3.426" X="0.000"/>
</Boat>
<Boat Type="Yacht" SourceID="101" ShapeID="4" HullNum="AC4501" StoweName="KOR" ShortName="TEAM KOREA"
BoatName="TEAM KOREA" Country="KOR">
<GPSposition Z="1.738" Y="0.625" X="0.001"/>
<MastTop Z="21.496" Y="4.233" X="0.000"/>
</Boat>
</Boats>
</BoatConfig>
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Race>
<RaceID>11080703</RaceID>
<RaceType>Match</RaceType>
<CreationTimeDate>2011-08-06T13:25:00-0000</CreationTimeDate>
<RaceStartTime Time="2011-08-06T13:30:00-0700" Postpone="false"/>
<Participants>
<Yacht SourceID="107" Entry="Port"/>
<Yacht SourceID="108" Entry="Stbd"/>
</Participants>
<Course>
<CompoundMark CompoundMarkID="1" Name="StartLine">
<Mark SeqID="1" Name="PRO" TargetLat="-36.83" TargetLng="174.83" SourceID="101"/>
<Mark SeqID="2" Name="PIN" TargetLat="-36.84" TargetLng="174.81" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="2" Name="M1">
<Mark Name="M1" TargetLat="-36.63566590" TargetLng="174.88543944" SourceID="103"/>
</CompoundMark>
<CompoundMark CompoundMarkID="3" Name="M2">
<Mark Name="M2" TargetLat="-36.83" TargetLng="174.80" SourceID="102"/>
</CompoundMark>
<CompoundMark CompoundMarkID="4" Name="Gate">
<Mark SeqID="1" Name="G1" TargetLat="-36.63566590" TargetLng="174.97205159" SourceID="104"/>
<Mark SeqID="2" Name="G2" TargetLat="-36.64566590" TargetLng="174.98205159" SourceID="105"/>
</CompoundMark>
</Course>
<CompoundMarkSequence>
<Corner SeqID="1" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3"/>
<Corner SeqID="3" CompoundMarkID="3" Rounding="Stbd" ZoneSize="6"/>
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="6"/>
<Corner SeqID="5" CompoundMarkID="1" Rounding="SP" ZoneSize="3"/>
</CompoundMarkSequence>
<CourseLimit>
<Limit SeqID="1" Lat="-36.8325" Lon="174.8325"/>
<Limit SeqID="2" Lat="-36.82883" Lon="174.81983"/>
<Limit SeqID="3" Lat="-36.82067" Lon="174.81983"/>
<Limit SeqID="4" Lat="-36.811" Lon="174.8265"/>
<Limit SeqID="5" Lat="-36.81033" Lon="174.83833"/>
<Limit SeqID="6" Lat="-36.81533" Lon="174.8525"/>
<Limit SeqID="7" Lat="-36.81533" Lon="174.86733"/>
<Limit SeqID="8" Lat="-36.81633" Lon="174.88217"/>
<Limit SeqID="9" Lat="-36.83383" Lon="174.87117"/>
<Limit SeqID="10" Lat="-36.83417" Lon="174.84767"/>
</CourseLimit>
</Race>
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RegattaConfig>
<RegattaID>3</RegattaID>
<RegattaName>New Zealand Test</RegattaName>
<CourseName>North Head</CourseName>
<CentralLatitude>-36.82791529</CentralLatitude>
<CentralLongitude>174.81218919</CentralLongitude>
<CentralAltitude>0.00</CentralAltitude>
<UtcOffset>12</UtcOffset>
<MagneticVariation>14.1</MagneticVariation>
</RegattaConfig>
@@ -1,268 +0,0 @@
<race>
<boats>
<boat>
<name>ORACLE TEAM USA</name>
<speed>20</speed>
<abbr>USA</abbr>
<colour>BLUEVIOLET</colour>
</boat>
<boat>
<name>Land Rover BAR</name>
<speed>30</speed>
<abbr>GBR</abbr>
<colour>BLACK</colour>
</boat>
<boat>
<name>SoftBank Team Japan</name>
<speed>25</speed>
<abbr>JPN</abbr>
<colour>RED</colour>
</boat>
<boat>
<name>Groupama Team France</name>
<speed>20</speed>
<abbr>FRA</abbr>
<colour>ORANGE</colour>
</boat>
<boat>
<name>Artemis Racing</name>
<speed>29</speed>
<abbr>SWE</abbr>
<colour>DARKOLIVEGREEN</colour>
</boat>
<boat>
<name>Emirates Team New Zealand</name>
<speed>62</speed>
<abbr>NZL</abbr>
<colour>LIMEGREEN</colour>
</boat>
</boats>
<legs>
<leg>
<name>Start to Mark 1</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.296577</latitude>
<longitude>-64.854304</longitude>
</coordinate>
<coordinate>
<latitude>32.293771</latitude>
<longitude>-64.855242</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Mark 1 to Leeward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Leeward Gate to Windward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Windward Gate to Leeward Gate</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
<leg>
<name>Leeward Gate to Finish</name>
<start>
<compoundMark>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
</start>
<finish>
<compoundMark>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
</compoundMark>
</finish>
</leg>
</legs>
<course>
<boundaries>
<coordinate>
<latitude>32.313922</latitude>
<longitude>-64.837168</longitude>
</coordinate>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317911</latitude>
<longitude>-64.836996</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
<coordinate>
<latitude>32.304273</latitude>
<longitude>-64.822834</longitude>
</coordinate>
<coordinate>
<latitude>32.279097</latitude>
<longitude>-64.841545</longitude>
</coordinate>
<coordinate>
<latitude>32.279604</latitude>
<longitude>-64.849871</longitude>
</coordinate>
<coordinate>
<latitude>32.289545</latitude>
<longitude>-64.854162</longitude>
</coordinate>
<coordinate>
<latitude>32.290198</latitude>
<longitude>-64.858711</longitude>
</coordinate>
<coordinate>
<latitude>32.297164</latitude>
<longitude>-64.856394</longitude>
</coordinate>
<coordinate>
<latitude>32.296148</latitude>
<longitude>-64.849184</longitude>
</coordinate>
</boundaries>
<compoundMark>
<name>Start Line</name>
<coordinate>
<latitude>32.296577</latitude>
<longitude>-64.854304</longitude>
</coordinate>
<coordinate>
<latitude>32.293771</latitude>
<longitude>-64.855242</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Mark</name>
<coordinate>
<latitude>32.293039</latitude>
<longitude>-64.843983</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Windward Gate</name>
<coordinate>
<latitude>32.284680</latitude>
<longitude>-64.850045</longitude>
</coordinate>
<coordinate>
<latitude>32.280164</latitude>
<longitude>-64.847591</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Leeward Gate</name>
<coordinate>
<latitude>32.309693</latitude>
<longitude>-64.835249</longitude>
</coordinate>
<coordinate>
<latitude>32.308046</latitude>
<longitude>-64.831785</longitude>
</coordinate>
</compoundMark>
<compoundMark>
<name>Finish Line</name>
<coordinate>
<latitude>32.317379</latitude>
<longitude>-64.839291</longitude>
</coordinate>
<coordinate>
<latitude>32.317257</latitude>
<longitude>-64.836260</longitude>
</coordinate>
</compoundMark>
</course>
</race>