Renamed some directories, optimized imports, general code clean up

#story[778]
main
Erika Savell 9 years ago
parent 073102d1a3
commit 83dfe1a60c

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -88,7 +88,8 @@
<version>2.4.3</version> <version>2.4.3</version>
<configuration> <configuration>
<transformers> <transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries> <manifestEntries>
<Main-Class>seng302.App</Main-Class> <Main-Class>seng302.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK> <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>

@ -4,8 +4,10 @@ package seng302;
import javafx.application.Application; import javafx.application.Application;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource; import seng302.DataInput.RaceDataSource;
import seng302.Mock.RegattaDataSource; import seng302.DataInput.RaceXMLReader;
import seng302.DataInput.RegattaDataSource;
import seng302.DataInput.RegattaXMLReader;
import seng302.Model.Event; import seng302.Model.Event;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;

@ -1,8 +1,5 @@
package seng302; package seng302;
import javafx.scene.paint.Color;
import seng302.Model.BoatInRace;
/** /**
* Constants that are used throughout the program * Constants that are used throughout the program
* Created by Erika on 19-Mar-17. * Created by Erika on 19-Mar-17.

@ -3,11 +3,9 @@ package seng302.Data;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import seng302.Exceptions.InvalidBoatDataException; import seng302.Exceptions.InvalidBoatDataException;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -24,8 +22,8 @@ import java.util.List;
*/ */
public class BoatData { public class BoatData {
private List<BoatInRace> boatData;
Document doc; Document doc;
private List<BoatInRace> boatData;
public BoatData(List<BoatInRace> boatData) { public BoatData(List<BoatInRace> boatData) {
@ -34,6 +32,7 @@ public class BoatData {
/** /**
* Creates an AC35 officially formatted xml description of boats competing in a race * Creates an AC35 officially formatted xml description of boats competing in a race
*
* @return String containing xml-formatted boats description * @return String containing xml-formatted boats description
*/ */
public String createXML() { public String createXML() {
@ -76,6 +75,7 @@ public class BoatData {
/** /**
* Runs through competing boats, creating an element for each * Runs through competing boats, creating an element for each
*
* @param boatsElement boats element to be added to * @param boatsElement boats element to be added to
*/ */
private void appendIndividualBoats(Element boatsElement) { private void appendIndividualBoats(Element boatsElement) {
@ -97,6 +97,7 @@ public class BoatData {
/** /**
* Creates and appends type attribute of a boat * Creates and appends type attribute of a boat
*
* @param boat element being added to * @param boat element being added to
*/ */
private void appendType(Element boat) { private void appendType(Element boat) {
@ -108,6 +109,7 @@ public class BoatData {
/** /**
* Creates and appends sourceID attribute of a boat * Creates and appends sourceID attribute of a boat
*
* @param boat element being added to * @param boat element being added to
* @param i boat number * @param i boat number
*/ */
@ -120,6 +122,7 @@ public class BoatData {
/** /**
* Creates and appends shapeID attribute of a boat * Creates and appends shapeID attribute of a boat
*
* @param boat element being added to * @param boat element being added to
*/ */
private void appendShapeID(Element boat) { private void appendShapeID(Element boat) {
@ -131,6 +134,7 @@ public class BoatData {
/** /**
* Creates and appends hull name attribute of a boat * Creates and appends hull name attribute of a boat
*
* @param boat element being added to * @param boat element being added to
*/ */
private void appendHullNum(Element boat) { private void appendHullNum(Element boat) {
@ -142,6 +146,7 @@ public class BoatData {
/** /**
* Creates and appends stow name attribute of a boat * Creates and appends stow name attribute of a boat
*
* @param boat element being added to * @param boat element being added to
* @param i boat number * @param i boat number
*/ */
@ -154,6 +159,7 @@ public class BoatData {
/** /**
* Creates and appends short name attribute of a boat * Creates and appends short name attribute of a boat
*
* @param boat element being added to * @param boat element being added to
* @param i boat number * @param i boat number
*/ */
@ -166,6 +172,7 @@ public class BoatData {
/** /**
* Creates and appends boat name attribute of a boat * Creates and appends boat name attribute of a boat
*
* @param boat element being added to * @param boat element being added to
* @param i boat number * @param i boat number
*/ */
@ -178,6 +185,7 @@ public class BoatData {
/** /**
* Creates and appends gps attributes of a boat * Creates and appends gps attributes of a boat
*
* @param boat element being added to * @param boat element being added to
* @param i boat number * @param i boat number
*/ */

@ -2,11 +2,11 @@ package seng302.Data;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import seng302.DataInput.RaceDataSource;
import seng302.Exceptions.InvalidRaceDataException; import seng302.Exceptions.InvalidRaceDataException;
import seng302.GPSCoordinate;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Marker; import seng302.Model.Marker;
import seng302.Mock.RaceDataSource;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -36,6 +36,7 @@ public class RaceData {
/** /**
* Creates an AC35 officially formatted xml description of a race. * Creates an AC35 officially formatted xml description of a race.
*
* @return String containing xml-formatted race description * @return String containing xml-formatted race description
*/ */
public String createXML() { public String createXML() {
@ -158,6 +159,7 @@ public class RaceData {
/** /**
* Creates a mark element for insertion in a coumpound mark element * Creates a mark element for insertion in a coumpound mark element
*
* @param marker GPS coordinates of the mark * @param marker GPS coordinates of the mark
* @return Element mark element * @return Element mark element
*/ */
@ -170,6 +172,7 @@ public class RaceData {
/** /**
* Creates a compound marker holding one or two marks,and a sequence number * Creates a compound marker holding one or two marks,and a sequence number
*
* @param marker marker * @param marker marker
* @param i sequence number * @param i sequence number
* @return Element compound mark element * @return Element compound mark element
@ -190,6 +193,7 @@ public class RaceData {
/** /**
* Creates a corner element * Creates a corner element
*
* @param i sequence number * @param i sequence number
* @return Element corner element * @return Element corner element
*/ */

@ -2,8 +2,8 @@ package seng302.Data;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import seng302.DataInput.RegattaDataSource;
import seng302.Exceptions.InvalidRegattaDataException; import seng302.Exceptions.InvalidRegattaDataException;
import seng302.Mock.RegattaDataSource;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -32,6 +32,7 @@ public class RegattaData {
/** /**
* Creates an AC35 officially formatted xml description of a regatta * Creates an AC35 officially formatted xml description of a regatta
*
* @return String containing xml-formatted regatta description * @return String containing xml-formatted regatta description
*/ */
public String createXML() { public String createXML() {

@ -1,7 +1,7 @@
package seng302.Mock; package seng302.DataInput;
import seng302.GPSCoordinate;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Leg; import seng302.Model.Leg;
import seng302.Model.Marker; import seng302.Model.Marker;
@ -12,14 +12,20 @@ import java.util.List;
*/ */
public interface RaceDataSource { public interface RaceDataSource {
List<BoatInRace> getBoats(); List<BoatInRace> getBoats();
List<Leg> getLegs(); List<Leg> getLegs();
List<GPSCoordinate> getBoundary(); List<GPSCoordinate> getBoundary();
List<Marker> getMarkers(); List<Marker> getMarkers();
String getRaceId(); String getRaceId();
String getRaceType(); String getRaceType();
GPSCoordinate getMark(); GPSCoordinate getMark();
GPSCoordinate getMapTopLeft(); GPSCoordinate getMapTopLeft();
GPSCoordinate getMapBottomRight(); GPSCoordinate getMapBottomRight();
} }

@ -1,11 +1,11 @@
package seng302; package seng302.DataInput;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.GPSCoordinate;
import seng302.Model.Leg; import seng302.Model.Leg;
import seng302.Model.Marker; import seng302.Model.Marker;
@ -18,6 +18,7 @@ import java.util.List;
* Created by fwy13 on 26/03/2017. * Created by fwy13 on 26/03/2017.
*/ */
public class RaceXMLReader extends XMLReader implements RaceDataSource { public class RaceXMLReader extends XMLReader implements RaceDataSource {
private static double COORDINATEPADDING = 0.0005;
private String raceID; private String raceID;
private List<BoatInRace> boats = new ArrayList<>(); private List<BoatInRace> boats = new ArrayList<>();
private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system. private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
@ -25,11 +26,11 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2; private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
private GPSCoordinate mapTopLeft, mapBottomRight; private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>(); private List<GPSCoordinate> boundary = new ArrayList<>();
private static double COORDINATEPADDING = 0.0005;
private List<Marker> markers = new ArrayList<>(); private List<Marker> markers = new ArrayList<>();
/** /**
* Constractor for Race XML * Constractor for Race XML
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -41,6 +42,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* COnstructor for Race XML * COnstructor for Race XML
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error
@ -95,7 +97,6 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
} }
/** /**
* Read all the boats in the XML file * Read all the boats in the XML file
*/ */
@ -198,6 +199,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return * @return
*/ */
@ -207,6 +209,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag * @param startIndex index in the node that has the coordinate tag
* @return * @return
@ -217,6 +220,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag * @param startIndex index in the node that has the coordinate tag
* @param nodeIndex coordinate index * @param nodeIndex coordinate index
@ -230,6 +234,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a changes a marker to GPS coordinates into a marker * gets a changes a marker to GPS coordinates into a marker
*
* @param markerNode marker to turn into coordinates * @param markerNode marker to turn into coordinates
* @return * @return
*/ */
@ -250,6 +255,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return * @return
*/ */
@ -259,6 +265,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in * @param startIndex the index the tag containing the coordinate should be in
* @return * @return
@ -269,6 +276,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in * @param startIndex the index the tag containing the coordinate should be in
* @param nodeIndex The coordinate index * @param nodeIndex The coordinate index
@ -349,9 +357,13 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
return mapBottomRight; return mapBottomRight;
} }
public String getRaceId() { return raceID; } public String getRaceId() {
return raceID;
}
public List<Marker> getMarkers() { return markers; } public List<Marker> getMarkers() {
return markers;
}
public String getRaceType() { public String getRaceType() {
return "FLEET"; return "FLEET";

@ -1,4 +1,4 @@
package seng302.Mock; package seng302.DataInput;
import seng302.Model.Regatta; import seng302.Model.Regatta;

@ -1,11 +1,9 @@
package seng302; package seng302.DataInput;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Mock.RegattaDataSource;
import seng302.Model.Regatta; import seng302.Model.Regatta;
import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException; import java.io.IOException;
@ -18,6 +16,7 @@ public class RegattaXMLReader extends XMLReader implements RegattaDataSource {
/** /**
* Constructor for Regatta XML * Constructor for Regatta XML
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -29,6 +28,7 @@ public class RegattaXMLReader extends XMLReader implements RegattaDataSource {
/** /**
* Constructor for Regatta XML * Constructor for Regatta XML
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error

@ -1,4 +1,4 @@
package seng302; package seng302.DataInput;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;

@ -7,15 +7,12 @@ package seng302.Exceptions;
/** /**
* An exception thrown when we cannot generate Boats.xml and send an XML message. * An exception thrown when we cannot generate Boats.xml and send an XML message.
*/ */
public class InvalidBoatDataException extends RuntimeException public class InvalidBoatDataException extends RuntimeException {
{
public InvalidBoatDataException() public InvalidBoatDataException() {
{
} }
public InvalidBoatDataException(String message) public InvalidBoatDataException(String message) {
{
super(message); super(message);
} }
} }

@ -7,14 +7,11 @@ package seng302.Exceptions;
/** /**
* Exception thrown when we cannot generate Race.xml data, and send an XML message. * Exception thrown when we cannot generate Race.xml data, and send an XML message.
*/ */
public class InvalidRaceDataException extends RuntimeException public class InvalidRaceDataException extends RuntimeException {
{ public InvalidRaceDataException() {
public InvalidRaceDataException()
{
} }
public InvalidRaceDataException(String message) public InvalidRaceDataException(String message) {
{
super(message); super(message);
} }
} }

@ -7,14 +7,11 @@ package seng302.Exceptions;
/** /**
* An exception thrown when a Regatta.xml message cannot be generated and sent. * An exception thrown when a Regatta.xml message cannot be generated and sent.
*/ */
public class InvalidRegattaDataException extends RuntimeException public class InvalidRegattaDataException extends RuntimeException {
{ public InvalidRegattaDataException() {
public InvalidRegattaDataException()
{
} }
public InvalidRegattaDataException(String message) public InvalidRegattaDataException(String message) {
{
super(message); super(message);
} }
} }

@ -52,8 +52,6 @@ public class Boat {
return velocity; return velocity;
} }
public int getSourceID() { return sourceID; }
/** /**
* Sets the speed of the boat in knots. * Sets the speed of the boat in knots.
* *
@ -64,6 +62,10 @@ public class Boat {
this.velocityProp.setValue(String.valueOf(Math.round(velocity))); this.velocityProp.setValue(String.valueOf(Math.round(velocity)));
} }
public int getSourceID() {
return sourceID;
}
/** /**
* Print method prints the name of the boat * Print method prints the name of the boat
* *

@ -5,11 +5,8 @@ import javafx.beans.property.StringProperty;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
/** /**
* Boat in the Race extends Boat. * Boat in the Race extends Boat.
@ -49,6 +46,20 @@ public class BoatInRace extends Boat {
position = new SimpleStringProperty("-"); position = new SimpleStringProperty("-");
} }
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
/** /**
* Calculates the azimuth of the travel via map coordinates of the raceMarkers * Calculates the azimuth of the travel via map coordinates of the raceMarkers
* *
@ -66,20 +77,6 @@ public class BoatInRace extends Boat {
return calc.getAzimuth(); return calc.getAzimuth();
} }
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
public double getHeading() { public double getHeading() {
return heading; return heading;
} }
@ -258,17 +255,17 @@ public class BoatInRace extends Boat {
return position.get(); return position.get();
} }
public StringProperty positionProperty() {
return position;
}
public void setPosition(String position) { public void setPosition(String position) {
this.position.set(position); this.position.set(position);
} }
public StringProperty positionProperty() {
return position;
}
/** /**
* Returns the current sequence number, and increments the internal value, such that that next call will return a value 1 larger than the current call. * Returns the current sequence number, and increments the internal value, such that that next call will return a value 1 larger than the current call.
*
* @return Current sequence number. * @return Current sequence number.
*/ */
public long getNextSequenceNumber() { public long getNextSequenceNumber() {

@ -3,12 +3,11 @@ package seng302.Model;
import seng302.Data.BoatData; import seng302.Data.BoatData;
import seng302.Data.RaceData; import seng302.Data.RaceData;
import seng302.Data.RegattaData; import seng302.Data.RegattaData;
import seng302.DataInput.RaceDataSource;
import seng302.Mock.RegattaDataSource; import seng302.DataInput.RegattaDataSource;
import seng302.Exceptions.InvalidBoatDataException; import seng302.Exceptions.InvalidBoatDataException;
import seng302.Exceptions.InvalidRaceDataException; import seng302.Exceptions.InvalidRaceDataException;
import seng302.Exceptions.InvalidRegattaDataException; import seng302.Exceptions.InvalidRegattaDataException;
import seng302.Mock.RaceDataSource;
/** /**
@ -24,8 +23,7 @@ public class Event {
this.regattaDataSource = regattaData; this.regattaDataSource = regattaData;
} }
public void start() public void start() {
{
System.out.println("\nREGATTA DATA\n");//TEMP REMOVE debug System.out.println("\nREGATTA DATA\n");//TEMP REMOVE debug
sendRegattaData(); sendRegattaData();
System.out.println("\nRACE DATA\n");//TEMP REMOVE debug System.out.println("\nRACE DATA\n");//TEMP REMOVE debug
@ -49,8 +47,7 @@ public class Event {
} }
public void sendRaceData() throws InvalidRaceDataException public void sendRaceData() throws InvalidRaceDataException {
{
RaceData raceData = new RaceData(raceDataSource); RaceData raceData = new RaceData(raceDataSource);
//Serialize race data to an XML as a string. //Serialize race data to an XML as a string.
String xmlString = raceData.createXML(); String xmlString = raceData.createXML();
@ -58,8 +55,7 @@ public class Event {
System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call System.out.println(xmlString); // to be replaced by TCPClient.send(xmlString) type function call
} }
public void sendBoatData() throws InvalidBoatDataException public void sendBoatData() throws InvalidBoatDataException {
{
BoatData boatData = new BoatData(raceDataSource.getBoats()); BoatData boatData = new BoatData(raceDataSource.getBoats());
//Serialize race data to an XML as a string. //Serialize race data to an XML as a string.
String xmlString = boatData.createXML(); String xmlString = boatData.createXML();

@ -1,4 +1,4 @@
package seng302; package seng302.Model;
/** /**
* GPS Coordinate for the world map. * GPS Coordinate for the world map.

@ -2,7 +2,6 @@ package seng302.Model;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate;
/** /**
* Created by cbt24 on 6/03/17. * Created by cbt24 on 6/03/17.
@ -74,16 +73,14 @@ public class Leg {
return startMarker; return startMarker;
} }
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public Marker getEndMarker() { public Marker getEndMarker() {
return endMarker; return endMarker;
} }
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public void setEndMarker(Marker endMarker) { public void setEndMarker(Marker endMarker) {
this.endMarker = endMarker; this.endMarker = endMarker;
} }

@ -1,7 +1,6 @@
package seng302.Model; package seng302.Model;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import seng302.GPSCoordinate;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;

@ -2,17 +2,13 @@ package seng302.Model;
import javafx.animation.AnimationTimer; import javafx.animation.AnimationTimer;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate; import seng302.DataInput.RaceDataSource;
import seng302.Mock.RaceDataSource;
import seng302.RaceEventMessages.BoatLocationMessage; import seng302.RaceEventMessages.BoatLocationMessage;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,12 +25,11 @@ public class Race implements Runnable {
protected List<Leg> legs; protected List<Leg> legs;
protected int boatsFinished = 0; protected int boatsFinished = 0;
protected long totalTimeElapsed; protected long totalTimeElapsed;
private int lastFPS = 20;
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
protected int heartbeat = 0; protected int heartbeat = 0;
protected int scaleFactor; protected int scaleFactor;
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
private int lastFPS = 20;
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
/** /**
* Initailiser for Race * Initailiser for Race
@ -60,6 +55,30 @@ public class Race implements Runnable {
this(raceData.getBoats(), raceData.getLegs(), scaleFactor); this(raceData.getBoats(), raceData.getLegs(), scaleFactor);
} }
/**
* 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());
}
/** /**
* Runnable for the thread. * Runnable for the thread.
*/ */
@ -73,6 +92,7 @@ public class Race implements Runnable {
AnimationTimer heartbeatTimer = new AnimationTimer() { AnimationTimer heartbeatTimer = new AnimationTimer() {
long currentHeartbeatTime = System.currentTimeMillis(); long currentHeartbeatTime = System.currentTimeMillis();
long endHeartbeatTime = System.currentTimeMillis() + 5000; long endHeartbeatTime = System.currentTimeMillis() + 5000;
@Override @Override
public void handle(long now) { public void handle(long now) {
if (currentHeartbeatTime >= endHeartbeatTime) { if (currentHeartbeatTime >= endHeartbeatTime) {
@ -294,6 +314,7 @@ public class Race implements Runnable {
/** /**
* Sets the chance each boat has of failing at a gate or marker * Sets the chance each boat has of failing at a gate or marker
*
* @param chance percentage chance a boat has of failing per checkpoint. * @param chance percentage chance a boat has of failing per checkpoint.
*/ */
protected void setDnfChance(int chance) { protected void setDnfChance(int chance) {
@ -360,30 +381,6 @@ public class Race implements Runnable {
} }
} }
/**
* 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());
}
/** /**
* Returns the boats that have started the race. * Returns the boats that have started the race.
* *

@ -4,7 +4,6 @@ import com.github.bfsmith.geotimezone.TimeZoneLookup;
import com.github.bfsmith.geotimezone.TimeZoneResult; import com.github.bfsmith.geotimezone.TimeZoneResult;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import seng302.GPSCoordinate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;

@ -1,10 +1,7 @@
package seng302.Networking.MessageDecoders; package seng302.Networking.MessageDecoders;
import seng302.Model.BoatInRace;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
/** /**

@ -1,7 +1,6 @@
package seng302.Networking.MessageEncoders; package seng302.Networking.MessageEncoders;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays; import java.util.Arrays;
/** /**

@ -7,8 +7,7 @@ package seng302.Networking.Utils;
/** /**
* Represents the information in a boat location message (AC streaming spec: 4.9). * Represents the information in a boat location message (AC streaming spec: 4.9).
*/ */
public class BoatLocationMessage public class BoatLocationMessage {
{
///Version number of the message - is always 1. ///Version number of the message - is always 1.
private byte messageVersionNumber = 1; private byte messageVersionNumber = 1;
@ -78,12 +77,12 @@ public class BoatLocationMessage
/** /**
* Ctor. * Ctor.
*/ */
public BoatLocationMessage() public BoatLocationMessage() {
{
} }
/** /**
* Ctor, with all parameters. * Ctor, with all parameters.
*
* @param messageVersionNumber * @param messageVersionNumber
* @param time * @param time
* @param sourceID * @param sourceID
@ -107,8 +106,7 @@ public class BoatLocationMessage
* @param currentSet * @param currentSet
* @param rudderAngle * @param rudderAngle
*/ */
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
this.time = time; this.time = time;
this.sourceID = sourceID; this.sourceID = sourceID;
@ -137,173 +135,139 @@ public class BoatLocationMessage
//Getters and setters for message properties. //Getters and setters for message properties.
public byte getMessageVersionNumber() public byte getMessageVersionNumber() {
{
return messageVersionNumber; return messageVersionNumber;
} }
public void setMessageVersionNumber(byte messageVersionNumber) public void setMessageVersionNumber(byte messageVersionNumber) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
} }
public long getTime() public long getTime() {
{
return time; return time;
} }
public void setTime(long time) public void setTime(long time) {
{
this.time = time; this.time = time;
} }
public int getSourceID() public int getSourceID() {
{
return sourceID; return sourceID;
} }
public void setSourceID(int sourceID) public void setSourceID(int sourceID) {
{
this.sourceID = sourceID; this.sourceID = sourceID;
} }
public int getSequenceNumber() public int getSequenceNumber() {
{
return sequenceNumber; return sequenceNumber;
} }
public void setSequenceNumber(int sequenceNumber) public void setSequenceNumber(int sequenceNumber) {
{
this.sequenceNumber = sequenceNumber; this.sequenceNumber = sequenceNumber;
} }
public byte getDeviceType() public byte getDeviceType() {
{
return deviceType; return deviceType;
} }
public void setDeviceType(byte deviceType) public void setDeviceType(byte deviceType) {
{
this.deviceType = deviceType; this.deviceType = deviceType;
} }
public int getLatitude() public int getLatitude() {
{
return latitude; return latitude;
} }
public void setLatitude(int latitude) public void setLatitude(int latitude) {
{
this.latitude = latitude; this.latitude = latitude;
} }
public int getLongitude() public int getLongitude() {
{
return longitude; return longitude;
} }
public void setLongitude(int longitude) public void setLongitude(int longitude) {
{
this.longitude = longitude; this.longitude = longitude;
} }
public int getAltitude() public int getAltitude() {
{
return altitude; return altitude;
} }
public void setAltitude(int altitude) public void setAltitude(int altitude) {
{
this.altitude = altitude; this.altitude = altitude;
} }
public int getHeading() public int getHeading() {
{
return heading; return heading;
} }
public void setHeading(int heading) public void setHeading(int heading) {
{
this.heading = heading; this.heading = heading;
} }
public short getPitch() public short getPitch() {
{
return pitch; return pitch;
} }
public void setPitch(short pitch) public void setPitch(short pitch) {
{
this.pitch = pitch; this.pitch = pitch;
} }
public short getRoll() public short getRoll() {
{
return roll; return roll;
} }
public void setRoll(short roll) public void setRoll(short roll) {
{
this.roll = roll; this.roll = roll;
} }
public int getBoatSpeed() public int getBoatSpeed() {
{
return boatSpeed; return boatSpeed;
} }
public void setBoatSpeed(int boatSpeed) public void setBoatSpeed(int boatSpeed) {
{
this.boatSpeed = boatSpeed; this.boatSpeed = boatSpeed;
} }
public int getBoatCOG() public int getBoatCOG() {
{
return boatCOG; return boatCOG;
} }
public void setBoatCOG(int boatCOG) public void setBoatCOG(int boatCOG) {
{
this.boatCOG = boatCOG; this.boatCOG = boatCOG;
} }
public int getBoatSOG() public int getBoatSOG() {
{
return boatSOG; return boatSOG;
} }
public void setBoatSOG(int boatSOG) public void setBoatSOG(int boatSOG) {
{
this.boatSOG = boatSOG; this.boatSOG = boatSOG;
} }
public int getApparentWindSpeed() public int getApparentWindSpeed() {
{
return apparentWindSpeed; return apparentWindSpeed;
} }
public void setApparentWindSpeed(int apparentWindSpeed) public void setApparentWindSpeed(int apparentWindSpeed) {
{
this.apparentWindSpeed = apparentWindSpeed; this.apparentWindSpeed = apparentWindSpeed;
} }
public short getApparentWindAngle() public short getApparentWindAngle() {
{
return apparentWindAngle; return apparentWindAngle;
} }
public void setApparentWindAngle(short apparentWindAngle) public void setApparentWindAngle(short apparentWindAngle) {
{
this.apparentWindAngle = apparentWindAngle; this.apparentWindAngle = apparentWindAngle;
} }
public int getTrueWindSpeed() public int getTrueWindSpeed() {
{
return trueWindSpeed; return trueWindSpeed;
} }
public void setTrueWindSpeed(int trueWindSpeed) public void setTrueWindSpeed(int trueWindSpeed) {
{
this.trueWindSpeed = trueWindSpeed; this.trueWindSpeed = trueWindSpeed;
} }
@ -315,43 +279,35 @@ public class BoatLocationMessage
this.trueWindDirection = trueWindDirection; this.trueWindDirection = trueWindDirection;
} }
public short getTrueWindAngle() public short getTrueWindAngle() {
{
return trueWindAngle; return trueWindAngle;
} }
public void setTrueWindAngle(short trueWindAngle) public void setTrueWindAngle(short trueWindAngle) {
{
this.trueWindAngle = trueWindAngle; this.trueWindAngle = trueWindAngle;
} }
public int getCurrentDrift() public int getCurrentDrift() {
{
return currentDrift; return currentDrift;
} }
public void setCurrentDrift(int currentDrift) public void setCurrentDrift(int currentDrift) {
{
this.currentDrift = currentDrift; this.currentDrift = currentDrift;
} }
public int getCurrentSet() public int getCurrentSet() {
{
return currentSet; return currentSet;
} }
public void setCurrentSet(int currentSet) public void setCurrentSet(int currentSet) {
{
this.currentSet = currentSet; this.currentSet = currentSet;
} }
public short getRudderAngle() public short getRudderAngle() {
{
return rudderAngle; return rudderAngle;
} }
public void setRudderAngle(short rudderAngle) public void setRudderAngle(short rudderAngle) {
{
this.rudderAngle = rudderAngle; this.rudderAngle = rudderAngle;
} }
} }

@ -10,7 +10,9 @@ public enum MessageType {
private byte value; private byte value;
private MessageType(int value) { this.value = (byte)value; } private MessageType(int value) {
this.value = (byte) value;
}
public byte getValue() { public byte getValue() {
return value; return value;

@ -9,22 +9,7 @@ import seng302.Constants;
/** /**
* Represents the information in a boat location message (AC streaming spec: 4.9). * Represents the information in a boat location message (AC streaming spec: 4.9).
*/ */
public class BoatLocationMessage public class BoatLocationMessage {
{
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
///Time of the event - milliseconds since jan 1 1970. Proper type is 6 byte int.
private long time;
///Source ID of the boat.
private int sourceID;
///Sequence number of the message.
private long sequenceNumber;
///Device type of the message (physical source of the message).
private byte deviceType;
public static final byte Unknown = 0; public static final byte Unknown = 0;
public static final byte RacingYacht = 1; public static final byte RacingYacht = 1;
public static final byte CommitteeBoat = 2; public static final byte CommitteeBoat = 2;
@ -39,8 +24,16 @@ public class BoatLocationMessage
public static final byte WeatherStation = 11; public static final byte WeatherStation = 11;
public static final byte Helicopter = 12; public static final byte Helicopter = 12;
public static final byte DataProcessingApplication = 13; public static final byte DataProcessingApplication = 13;
///Version number of the message - is always 1.
private byte messageVersionNumber = 1;
///Time of the event - milliseconds since jan 1 1970. Proper type is 6 byte int.
private long time;
///Source ID of the boat.
private int sourceID;
///Sequence number of the message.
private long sequenceNumber;
///Device type of the message (physical source of the message).
private byte deviceType;
///Latitude of the boat. ///Latitude of the boat.
private int latitude; private int latitude;
@ -93,12 +86,12 @@ public class BoatLocationMessage
/** /**
* Ctor. Default. * Ctor. Default.
*/ */
public BoatLocationMessage() public BoatLocationMessage() {
{
} }
/** /**
* Ctor, with all parameters. * Ctor, with all parameters.
*
* @param messageVersionNumber * @param messageVersionNumber
* @param time * @param time
* @param sourceID * @param sourceID
@ -121,8 +114,7 @@ public class BoatLocationMessage
* @param currentSet * @param currentSet
* @param rudderAngle * @param rudderAngle
*/ */
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, long sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, long sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
this.time = time; this.time = time;
this.sourceID = sourceID; this.sourceID = sourceID;
@ -149,342 +141,289 @@ public class BoatLocationMessage
//Getters and setters for message properties. //Getters and setters for message properties.
/**
* Converts a double representing a latitude or longitude coordinate to an int, as required by the streaming spec format.
*
* @param coordinate Latitude or longitude to convert. Double.
* @return int representation of coordinate.
*/
public static int convertCoordinateDoubleToInt(double coordinate) {
int coordinateInt = (int) ((coordinate / 180.0) * 2147483648.0);
return coordinateInt;
}
/**
* Converts an int representing a latitude or longitude coordinate to a double, as required by the streaming spec format.
*
* @param coordinate Latitude or longitude to convert. int.
* @return double representation of coordinate.
*/
public static double convertCoordinateIntToDouble(int coordinate) {
double coordinateDouble = (double) ((coordinate * 180.0) / 2147483648.0);
return coordinateDouble;
}
/**
* Converts an int representing a heading to a double, as required by the streaming spec format.
*
* @param heading Heading to convert. int.
* @return double representation of heading.
*/
public static double convertHeadingIntToDouble(int heading) {
double headingDouble = (double) ((heading * 360.0) / 65536.0);
return headingDouble;
}
/**
* Converts a double representing a heading to an int, as required by the streaming spec format.
*
* @param heading Heading to convert. double.
* @return int representation of heading.
*/
public static int convertHeadingDoubleToInt(double heading) {
int headingInt = (int) ((heading / 360.0) * 65536.0);
return headingInt;
}
/**
* Converts a short representing the wind's true angle to a double, as required by the streaming spec format.
*
* @param angle Angle to convert. short.
* @return double representation of heading.
*/
public static double convertTrueWindAngleShortToDouble(short angle) {
double angleDouble = (double) ((angle * 180.0) / 32768.0);
return angleDouble;
}
/**
* Converts a double representing the wind's true angle to a short, as required by the streaming spec format.
*
* @param angle Angle to convert. double.
* @return short representation of heading.
*/
public static short convertTrueWindAngleShortToDouble(double angle) {
short angleShort = (short) ((angle / 180.0) * 32768.0);
return angleShort;
}
/**
* Converts a double representing the speed of a boat in knots to an int in millimeters per second, as required by the streaming spec format.
*
* @param speed Speed in knots, stored as a double.
* @return Speed in millimeters per second, stored as an int (using only the two least significant bytes).
*/
public static int convertBoatSpeedDoubleToInt(double speed) {
//Calculate meters per second.
double metersPerSecond = speed * Constants.KnotsToMetersPerSecondConversionFactor;
//Calculate millimeters per second.
double millimetersPerSecond = metersPerSecond * 1000.0;
//Convert to an int.
int millimetersPerSecondInt = (int) Math.round(millimetersPerSecond);
return millimetersPerSecondInt;
}
/**
* Converts an int representing the speed of a boat in millimeters per second to a double in knots, as required by the streaming spec format.
*
* @param speed Speed in millimeters per second, stored as an int.
* @return Speed in knots, stored as a double.
*/
public static double convertBoatSpeedIntToDouble(int speed) {
//Calculate meters per second.
double metersPerSecond = speed / 1000.0;
//Calculate knots.
double knots = metersPerSecond / Constants.KnotsToMetersPerSecondConversionFactor;
return knots;
}
public byte getMessageVersionNumber() public byte getMessageVersionNumber() {
{
return messageVersionNumber; return messageVersionNumber;
} }
public void setMessageVersionNumber(byte messageVersionNumber) public void setMessageVersionNumber(byte messageVersionNumber) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
} }
public long getTime() public long getTime() {
{
return time; return time;
} }
public void setTime(long time) public void setTime(long time) {
{
this.time = time; this.time = time;
} }
public int getSourceID() public int getSourceID() {
{
return sourceID; return sourceID;
} }
public void setSourceID(int sourceID) public void setSourceID(int sourceID) {
{
this.sourceID = sourceID; this.sourceID = sourceID;
} }
public long getSequenceNumber() public long getSequenceNumber() {
{
return sequenceNumber; return sequenceNumber;
} }
public void setSequenceNumber(long sequenceNumber) public void setSequenceNumber(long sequenceNumber) {
{
this.sequenceNumber = sequenceNumber; this.sequenceNumber = sequenceNumber;
} }
public byte getDeviceType() public byte getDeviceType() {
{
return deviceType; return deviceType;
} }
public void setDeviceType(byte deviceType) public void setDeviceType(byte deviceType) {
{
this.deviceType = deviceType; this.deviceType = deviceType;
} }
public int getLatitude() public int getLatitude() {
{
return latitude; return latitude;
} }
public void setLatitude(int latitude) public void setLatitude(int latitude) {
{
this.latitude = latitude; this.latitude = latitude;
} }
public int getLongitude() public int getLongitude() {
{
return longitude; return longitude;
} }
public void setLongitude(int longitude) public void setLongitude(int longitude) {
{
this.longitude = longitude; this.longitude = longitude;
} }
public int getAltitude() public int getAltitude() {
{
return altitude; return altitude;
} }
public void setAltitude(int altitude) public void setAltitude(int altitude) {
{
this.altitude = altitude; this.altitude = altitude;
} }
public int getHeading() public int getHeading() {
{
return heading; return heading;
} }
public void setHeading(int heading) public void setHeading(int heading) {
{
this.heading = heading; this.heading = heading;
} }
public short getPitch() public short getPitch() {
{
return pitch; return pitch;
} }
public void setPitch(short pitch) public void setPitch(short pitch) {
{
this.pitch = pitch; this.pitch = pitch;
} }
public short getRoll() public short getRoll() {
{
return roll; return roll;
} }
public void setRoll(short roll) public void setRoll(short roll) {
{
this.roll = roll; this.roll = roll;
} }
public int getBoatSpeed() public int getBoatSpeed() {
{
return boatSpeed; return boatSpeed;
} }
public void setBoatSpeed(int boatSpeed) public void setBoatSpeed(int boatSpeed) {
{
this.boatSpeed = boatSpeed; this.boatSpeed = boatSpeed;
} }
public int getBoatCOG() public int getBoatCOG() {
{
return boatCOG; return boatCOG;
} }
public void setBoatCOG(int boatCOG) public void setBoatCOG(int boatCOG) {
{
this.boatCOG = boatCOG; this.boatCOG = boatCOG;
} }
public int getBoatSOG() public int getBoatSOG() {
{
return boatSOG; return boatSOG;
} }
public void setBoatSOG(int boatSOG) public void setBoatSOG(int boatSOG) {
{
this.boatSOG = boatSOG; this.boatSOG = boatSOG;
} }
public int getApparentWindSpeed() public int getApparentWindSpeed() {
{
return apparentWindSpeed; return apparentWindSpeed;
} }
public void setApparentWindSpeed(int apparentWindSpeed) public void setApparentWindSpeed(int apparentWindSpeed) {
{
this.apparentWindSpeed = apparentWindSpeed; this.apparentWindSpeed = apparentWindSpeed;
} }
public short getApparentWindAngle() public short getApparentWindAngle() {
{
return apparentWindAngle; return apparentWindAngle;
} }
public void setApparentWindAngle(short apparentWindAngle) public void setApparentWindAngle(short apparentWindAngle) {
{
this.apparentWindAngle = apparentWindAngle; this.apparentWindAngle = apparentWindAngle;
} }
public int getTrueWindSpeed() public int getTrueWindSpeed() {
{
return trueWindSpeed; return trueWindSpeed;
} }
public void setTrueWindSpeed(int trueWindSpeed) public void setTrueWindSpeed(int trueWindSpeed) {
{
this.trueWindSpeed = trueWindSpeed; this.trueWindSpeed = trueWindSpeed;
} }
public short getTrueWindAngle() public short getTrueWindAngle() {
{
return trueWindAngle; return trueWindAngle;
} }
public void setTrueWindAngle(short trueWindAngle) public void setTrueWindAngle(short trueWindAngle) {
{
this.trueWindAngle = trueWindAngle; this.trueWindAngle = trueWindAngle;
} }
public int getCurrentDrift() public int getCurrentDrift() {
{
return currentDrift; return currentDrift;
} }
public void setCurrentDrift(int currentDrift) public void setCurrentDrift(int currentDrift) {
{
this.currentDrift = currentDrift; this.currentDrift = currentDrift;
} }
public int getCurrentSet() public int getCurrentSet() {
{
return currentSet; return currentSet;
} }
public void setCurrentSet(int currentSet) public void setCurrentSet(int currentSet) {
{
this.currentSet = currentSet; this.currentSet = currentSet;
} }
public short getRudderAngle() public short getRudderAngle() {
{
return rudderAngle; return rudderAngle;
} }
public void setRudderAngle(short rudderAngle) public void setRudderAngle(short rudderAngle) {
{
this.rudderAngle = rudderAngle; this.rudderAngle = rudderAngle;
} }
/**
* Converts a double representing a latitude or longitude coordinate to an int, as required by the streaming spec format.
* @param coordinate Latitude or longitude to convert. Double.
* @return int representation of coordinate.
*/
public static int convertCoordinateDoubleToInt(double coordinate)
{
int coordinateInt = (int) ((coordinate / 180.0) * 2147483648.0);
return coordinateInt;
}
/**
* Converts an int representing a latitude or longitude coordinate to a double, as required by the streaming spec format.
* @param coordinate Latitude or longitude to convert. int.
* @return double representation of coordinate.
*/
public static double convertCoordinateIntToDouble(int coordinate)
{
double coordinateDouble = (double) ((coordinate * 180.0) / 2147483648.0);
return coordinateDouble;
}
/**
* Converts an int representing a heading to a double, as required by the streaming spec format.
* @param heading Heading to convert. int.
* @return double representation of heading.
*/
public static double convertHeadingIntToDouble(int heading)
{
double headingDouble = (double) ((heading * 360.0) / 65536.0);
return headingDouble;
}
/**
* Converts a double representing a heading to an int, as required by the streaming spec format.
* @param heading Heading to convert. double.
* @return int representation of heading.
*/
public static int convertHeadingDoubleToInt(double heading)
{
int headingInt = (int) ((heading / 360.0) * 65536.0);
return headingInt;
}
/**
* Converts a short representing the wind's true angle to a double, as required by the streaming spec format.
* @param angle Angle to convert. short.
* @return double representation of heading.
*/
public static double convertTrueWindAngleShortToDouble(short angle)
{
double angleDouble = (double) ((angle * 180.0) / 32768.0);
return angleDouble;
}
/**
* Converts a double representing the wind's true angle to a short, as required by the streaming spec format.
* @param angle Angle to convert. double.
* @return short representation of heading.
*/
public static short convertTrueWindAngleShortToDouble(double angle)
{
short angleShort = (short) ((angle / 180.0) * 32768.0);
return angleShort;
}
/**
* Converts a double representing the speed of a boat in knots to an int in millimeters per second, as required by the streaming spec format.
* @param speed Speed in knots, stored as a double.
* @return Speed in millimeters per second, stored as an int (using only the two least significant bytes).
*/
public static int convertBoatSpeedDoubleToInt(double speed)
{
//Calculate meters per second.
double metersPerSecond = speed * Constants.KnotsToMetersPerSecondConversionFactor;
//Calculate millimeters per second.
double millimetersPerSecond = metersPerSecond * 1000.0;
//Convert to an int.
int millimetersPerSecondInt = (int)Math.round(millimetersPerSecond);
return millimetersPerSecondInt;
}
/**
* Converts an int representing the speed of a boat in millimeters per second to a double in knots, as required by the streaming spec format.
* @param speed Speed in millimeters per second, stored as an int.
* @return Speed in knots, stored as a double.
*/
public static double convertBoatSpeedIntToDouble(int speed)
{
//Calculate meters per second.
double metersPerSecond = speed / 1000.0;
//Calculate knots.
double knots = metersPerSecond / Constants.KnotsToMetersPerSecondConversionFactor;
return knots;
}
@Override @Override
public String toString() public String toString() {
{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("Message version number: "); builder.append("Message version number: ");

@ -3,14 +3,13 @@ package seng302.Data;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Mock.RaceDataSource; import seng302.DataInput.RaceDataSource;
import seng302.RaceXMLReader; import seng302.DataInput.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException; import java.io.IOException;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.fail;
/** /**
* Created by esa46 on 25/04/17. * Created by esa46 on 25/04/17.

@ -2,12 +2,10 @@ package seng302.Mock;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import seng302.DataInput.RegattaXMLReader;
import seng302.Model.Regatta; import seng302.Model.Regatta;
import seng302.RegattaXMLReader;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
/** /**
* Created by jjg64 on 19/04/17. * Created by jjg64 on 19/04/17.

@ -1,14 +1,9 @@
package seng302.Model; package seng302.Model;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import seng302.GPSCoordinate;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.*;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
/** /**
* Created by esa46 on 22/03/17. * Created by esa46 on 22/03/17.

@ -3,9 +3,7 @@ package seng302.Model;
import org.geotools.referencing.GeodeticCalculator; import org.geotools.referencing.GeodeticCalculator;
import org.junit.Test; import org.junit.Test;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate;
import java.awt.*;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertEquals;

@ -2,7 +2,6 @@ package seng302.Model;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import seng302.GPSCoordinate;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

@ -3,15 +3,8 @@ package seng302.Model;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.GPSCoordinate;
import seng302.Mock.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -36,7 +29,8 @@ public class RaceTest {
boats.add(boat2); boats.add(boat2);
ArrayList<Leg> legs = new ArrayList<>(); ArrayList<Leg> legs = new ArrayList<>();
legs.add(START_LEG); legs.add(FINISH_LEG); legs.add(START_LEG);
legs.add(FINISH_LEG);
Race race = new Race(boats, legs, 5); Race race = new Race(boats, legs, 5);
race.setDnfChance(0); race.setDnfChance(0);

@ -2,18 +2,14 @@ package seng302.Model;/**
* Created by Gondr on 26/03/2017. * Created by Gondr on 26/03/2017.
*/ */
import static org.junit.Assert.*;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import seng302.DataInput.RaceXMLReader;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*;
public class RaceXMLTest { public class RaceXMLTest {
RaceXMLReader raceXMLReader; RaceXMLReader raceXMLReader;

@ -2,8 +2,6 @@ package seng302.Networking;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.BinaryMesageEncoder;
import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.MessageDecoders.XMLMessageDecoder; import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import seng302.Networking.Utils.MessageType; import seng302.Networking.Utils.MessageType;

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
import seng302.Networking.Utils.BoatLocationMessage;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.BoatLocationMessage;
/** /**

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.CourseWindDecoder;
import seng302.Networking.Utils.CourseWind;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.CourseWind;
import java.util.ArrayList; import java.util.ArrayList;

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.RaceStartStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
/** /**

@ -5,7 +5,6 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.Leg; import seng302.Model.Leg;
import seng302.Networking.MessageDecoders.RaceStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import java.util.ArrayList; import java.util.ArrayList;

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.BufferedReader; import java.io.BufferedReader;

@ -4,7 +4,9 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.*; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/** /**
* Created by hba56 on 19/04/17. * Created by hba56 on 19/04/17.

@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
@ -90,7 +90,8 @@
<version>2.4.3</version> <version>2.4.3</version>
<configuration> <configuration>
<transformers> <transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries> <manifestEntries>
<Main-Class>seng302.App</Main-Class> <Main-Class>seng302.App</Main-Class>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK> <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>

@ -1,7 +1,6 @@
package seng302.Controllers; package seng302.Controllers;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import seng302.App;
import java.net.URL; import java.net.URL;
import java.util.ResourceBundle; import java.util.ResourceBundle;

@ -1,11 +1,8 @@
package seng302.Controllers; package seng302.Controllers;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import java.net.URL; import java.net.URL;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -14,16 +11,16 @@ import java.util.ResourceBundle;
* Created by fwy13 on 15/03/2017. * Created by fwy13 on 15/03/2017.
*/ */
public class MainController extends Controller { public class MainController extends Controller {
@FXML StartController startController; @FXML
@FXML RaceController raceController; StartController startController;
@FXML
RaceController raceController;
public void beginRace(int scaleFactor, RaceDataSource raceData) { public void beginRace(int scaleFactor, RaceDataSource raceData) {
raceController.startRace(scaleFactor, raceData); raceController.startRace(scaleFactor, raceData);
} }
/** /**
* Main Controller for the applications will house the menu and the displayed pane. * Main Controller for the applications will house the menu and the displayed pane.
* *

@ -1,25 +1,19 @@
package seng302.Controllers; package seng302.Controllers;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import org.xml.sax.SAXException;
import seng302.Mock.StreamedRace; import seng302.Mock.StreamedRace;
import seng302.Model.*; import seng302.Model.BoatInRace;
import seng302.Model.Race;
import seng302.Model.RaceClock;
import seng302.Model.ResizableRaceCanvas;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
/** /**
@ -28,16 +22,11 @@ import java.util.ResourceBundle;
public class RaceController extends Controller { public class RaceController extends Controller {
@FXML @FXML
GridPane canvasBase; GridPane canvasBase;
//user saved data for annotation display
private ArrayList<Boolean> presetAnno;
ResizableRaceCanvas raceMap; ResizableRaceCanvas raceMap;
@FXML @FXML
SplitPane race; SplitPane race;
@FXML @FXML
CheckBox showFPS; CheckBox showFPS;
@FXML @FXML
CheckBox showBoatPath; CheckBox showBoatPath;
@FXML @FXML
@ -48,7 +37,6 @@ public class RaceController extends Controller {
Label FPS; Label FPS;
@FXML @FXML
Label timeZone; Label timeZone;
@FXML @FXML
CheckBox showName; CheckBox showName;
@FXML @FXML
@ -59,7 +47,6 @@ public class RaceController extends Controller {
Button saveAnno; Button saveAnno;
@FXML @FXML
Button showSetAnno; Button showSetAnno;
@FXML @FXML
TableView<BoatInRace> boatInfoTable; TableView<BoatInRace> boatInfoTable;
@FXML @FXML
@ -70,6 +57,8 @@ public class RaceController extends Controller {
TableColumn<BoatInRace, String> boatMarkColumn; TableColumn<BoatInRace, String> boatMarkColumn;
@FXML @FXML
TableColumn<BoatInRace, String> boatSpeedColumn; TableColumn<BoatInRace, String> boatSpeedColumn;
//user saved data for annotation display
private ArrayList<Boolean> presetAnno;
/** /**
* Updates the ResizableRaceCanvas (raceMap) with most recent data * Updates the ResizableRaceCanvas (raceMap) with most recent data

@ -17,7 +17,6 @@ import seng302.Mock.*;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.RaceClock; import seng302.Model.RaceClock;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException; import java.io.IOException;
@ -31,20 +30,28 @@ import java.util.ResourceBundle;
*/ */
public class StartController extends Controller { public class StartController extends Controller {
@FXML private GridPane start; @FXML
@FXML private AnchorPane startWrapper; Button oneMinButton;
@FXML
@FXML private TableView<BoatInRace> boatNameTable; Button fiveMinButton;
@FXML private TableColumn<BoatInRace, String> boatNameColumn; @FXML
@FXML private TableColumn<BoatInRace, String> boatCodeColumn; Button fifteenMinButton;
@FXML private Label timeZoneTime; @FXML
@FXML private Label timer; private GridPane start;
@FXML private int PRERACE_TIME = 15000; @FXML
private AnchorPane startWrapper;
@FXML Button oneMinButton; @FXML
@FXML Button fiveMinButton; private TableView<BoatInRace> boatNameTable;
@FXML Button fifteenMinButton; @FXML
private TableColumn<BoatInRace, String> boatNameColumn;
@FXML
private TableColumn<BoatInRace, String> boatCodeColumn;
@FXML
private Label timeZoneTime;
@FXML
private Label timer;
@FXML
private int PRERACE_TIME = 15000;
private RaceClock raceClock; private RaceClock raceClock;
private RaceDataSource raceData; private RaceDataSource raceData;

@ -3,13 +3,11 @@ package seng302.Mock;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.XMLReader; import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.ElementType;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
@ -17,13 +15,14 @@ import java.util.*;
* Created by Joseph on 24/04/2017. * Created by Joseph on 24/04/2017.
*/ */
public class BoatXMLReader extends XMLReader { public class BoatXMLReader extends XMLReader {
private static int currentColourIndex = 0;
Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>(); Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
Map<Integer, StreamedBoat> participants = new HashMap<>(); Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Color> colours; private List<Color> colours;
private static int currentColourIndex = 0;
/** /**
* Constructor for Boat XML Reader * Constructor for Boat XML Reader
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -36,6 +35,7 @@ public class BoatXMLReader extends XMLReader {
/** /**
* Constructor for Boat XML Reader * Constructor for Boat XML Reader
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error
@ -98,7 +98,8 @@ public class BoatXMLReader extends XMLReader {
String shortName = null; String shortName = null;
String country = null; String country = null;
if (exists(boat, "Type")) type = boat.getAttributes().getNamedItem("Type").getTextContent(); if (exists(boat, "Type")) type = boat.getAttributes().getNamedItem("Type").getTextContent();
if (exists(boat, "SourceID")) sourceID = Integer.parseInt(boat.getAttributes().getNamedItem("SourceID").getTextContent()); if (exists(boat, "SourceID"))
sourceID = Integer.parseInt(boat.getAttributes().getNamedItem("SourceID").getTextContent());
if (exists(boat, "BoatName")) boatName = boat.getAttributes().getNamedItem("BoatName").getTextContent(); if (exists(boat, "BoatName")) boatName = boat.getAttributes().getNamedItem("BoatName").getTextContent();
if (exists(boat, "ShortName")) shortName = boat.getAttributes().getNamedItem("ShortName").getTextContent(); if (exists(boat, "ShortName")) shortName = boat.getAttributes().getNamedItem("ShortName").getTextContent();
if (exists(boat, "Country")) country = boat.getAttributes().getNamedItem("Country").getTextContent(); if (exists(boat, "Country")) country = boat.getAttributes().getNamedItem("Country").getTextContent();

@ -3,7 +3,6 @@ package seng302.Mock;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.RaceDataSource;
import seng302.XMLReader; import seng302.XMLReader;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -17,6 +16,7 @@ public class RegattaXMLReader extends XMLReader {
/** /**
* Constructor for Regatta XML * Constructor for Regatta XML
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -28,6 +28,7 @@ public class RegattaXMLReader extends XMLReader {
/** /**
* Constructor for Regatta XML * Constructor for Regatta XML
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error

@ -1,8 +1,6 @@
package seng302.Mock; package seng302.Mock;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import seng302.GPSCoordinate;
import seng302.Model.Boat;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
/** /**
@ -27,8 +25,9 @@ public class StreamedBoat extends BoatInRace {
/** /**
* Overridden to ignore this function * Overridden to ignore this function
* @deprecated *
* @return 0 * @return 0
* @deprecated
*/ */
public double getScaledVelocity() { public double getScaledVelocity() {
return 0; return 0;
@ -36,8 +35,9 @@ public class StreamedBoat extends BoatInRace {
/** /**
* Overridden to ignore this function * Overridden to ignore this function
* @deprecated *
* @param velocity of boat * @param velocity of boat
* @deprecated
*/ */
public void setScaledVelocity(double velocity) { public void setScaledVelocity(double velocity) {
} }

@ -7,7 +7,8 @@ import seng302.Model.RaceClock;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.*; import java.util.ArrayList;
import java.util.List;
/** /**
* Created by jjg64 on 21/04/17. * Created by jjg64 on 21/04/17.
@ -42,14 +43,14 @@ public class StreamedCourse implements RaceDataSource {
} }
} }
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
this.regattaXMLReader = regattaXMLReader;
}
public RegattaXMLReader getRegattaXMLReader() { public RegattaXMLReader getRegattaXMLReader() {
return regattaXMLReader; return regattaXMLReader;
} }
public void setRegattaXMLReader(RegattaXMLReader regattaXMLReader) {
this.regattaXMLReader = regattaXMLReader;
}
public List<BoatInRace> getBoats() { public List<BoatInRace> getBoats() {
return new ArrayList<>(boatXMLReader.getStreamedBoatMap().values()); return new ArrayList<>(boatXMLReader.getStreamedBoatMap().values());
} }

@ -22,19 +22,20 @@ import java.util.*;
*/ */
public class StreamedCourseXMLReader extends XMLReader { public class StreamedCourseXMLReader extends XMLReader {
private static double COORDINATEPADDING = 0.0005; private static double COORDINATEPADDING = 0.0005;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private Map<Integer,Element> marks = new HashMap<>();
private Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Leg> legs = new ArrayList<>();
Date creationTimeDate; Date creationTimeDate;
Date raceStartTime; Date raceStartTime;
int raceID; int raceID;
String raceType; String raceType;
boolean postpone; boolean postpone;
private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>();
private Map<Integer, Element> marks = new HashMap<>();
private Map<Integer, StreamedBoat> participants = new HashMap<>();
private List<Leg> legs = new ArrayList<>();
/** /**
* Constructor for Streamed Race XML * Constructor for Streamed Race XML
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -46,6 +47,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/** /**
* Constructor for Streamed Race XML * Constructor for Streamed Race XML
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error
@ -112,6 +114,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/** /**
* Generates a Marker from the CompoundMark element with given ID. * Generates a Marker from the CompoundMark element with given ID.
*
* @param compoundMarkID index of required CompoundMark element * @param compoundMarkID index of required CompoundMark element
* @return generated Marker * @return generated Marker
* @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of marks * @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of marks
@ -123,9 +126,14 @@ public class StreamedCourseXMLReader extends XMLReader {
Marker marker; Marker marker;
switch (nMarks.getLength()) { switch (nMarks.getLength()) {
case 1: marker = new Marker(getCoordinate((Element)nMarks.item(0))); break; case 1:
case 2: marker = new Marker(getCoordinate((Element)nMarks.item(0)), getCoordinate((Element)nMarks.item(1))); break; marker = new Marker(getCoordinate((Element) nMarks.item(0)));
default: throw new StreamedCourseXMLException(); break;
case 2:
marker = new Marker(getCoordinate((Element) nMarks.item(0)), getCoordinate((Element) nMarks.item(1)));
break;
default:
throw new StreamedCourseXMLException();
} }
return marker; return marker;
@ -139,6 +147,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/** /**
* Reads "compoundMarkID" attribute of CompoundMark or Corner element * Reads "compoundMarkID" attribute of CompoundMark or Corner element
*
* @param element with "compoundMarkID" attribute * @param element with "compoundMarkID" attribute
* @return value of "compoundMarkID" attribute * @return value of "compoundMarkID" attribute
*/ */
@ -148,6 +157,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/** /**
* Reads "name" attribute of CompoundMark element with corresponding CompoundMarkID * Reads "name" attribute of CompoundMark element with corresponding CompoundMarkID
*
* @param compoundMarkID unique ID for CompoundMark element * @param compoundMarkID unique ID for CompoundMark element
* @return value of "name" attribute * @return value of "name" attribute
*/ */
@ -157,6 +167,7 @@ public class StreamedCourseXMLReader extends XMLReader {
/** /**
* Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements. * Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements.
*
* @throws StreamedCourseXMLException if markers cannot be resolved from CompoundMark * @throws StreamedCourseXMLException if markers cannot be resolved from CompoundMark
*/ */
private void readCompoundMarkSequence() throws StreamedCourseXMLException { private void readCompoundMarkSequence() throws StreamedCourseXMLException {

@ -1,14 +1,10 @@
package seng302.Mock; package seng302.Mock;
import javafx.collections.FXCollections;
import seng302.Controllers.RaceController; import seng302.Controllers.RaceController;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.Leg;
import seng302.Model.Race; import seng302.Model.Race;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import java.util.*;
/** /**
* Created by jjg64 on 21/04/17. * Created by jjg64 on 21/04/17.
*/ */
@ -26,6 +22,7 @@ public class StreamedRace extends Race {
/** /**
* Checks if the boat cannot finish the race * Checks if the boat cannot finish the race
*
* @return True if boat cannot finish the race * @return True if boat cannot finish the race
*/ */
protected boolean doNotFinish() { protected boolean doNotFinish() {

@ -17,8 +17,10 @@ import java.util.concurrent.ConcurrentLinkedQueue;
*/ */
public class BoatInRace extends Boat { public class BoatInRace extends Boat {
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
protected static float trackPointTimeInterval = 5000; // every 1 seconds
protected final int TRACK_POINT_LIMIT = 10;
protected Leg currentLeg; protected Leg currentLeg;
private double scaledVelocity;
protected double distanceTravelledInLeg; protected double distanceTravelledInLeg;
protected GPSCoordinate currentPosition; protected GPSCoordinate currentPosition;
protected long timeFinished; protected long timeFinished;
@ -28,14 +30,10 @@ public class BoatInRace extends Boat {
protected boolean started = false; protected boolean started = false;
protected StringProperty position; protected StringProperty position;
protected double heading; protected double heading;
protected Queue<TrackPoint> track = new ConcurrentLinkedQueue<>(); protected Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
protected long nextValidTime = 0; protected long nextValidTime = 0;
protected static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
protected static float trackPointTimeInterval = 5000; // every 1 seconds
protected final int TRACK_POINT_LIMIT = 10;
protected boolean trackVisible = true; protected boolean trackVisible = true;
private double scaledVelocity;
/** /**
* Constructor method. * Constructor method.
@ -66,6 +64,38 @@ public class BoatInRace extends Boat {
position = new SimpleStringProperty("-"); position = new SimpleStringProperty("-");
} }
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
/**
* 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;
}
/** /**
* Calculates the azimuth of the travel via map coordinates of the raceMarkers * Calculates the azimuth of the travel via map coordinates of the raceMarkers
* *
@ -83,20 +113,6 @@ public class BoatInRace extends Boat {
return calc.getAzimuth(); return calc.getAzimuth();
} }
/**
* Converts an azimuth to a bearing
*
* @param azimuth azimuth value to be converted
* @return the bearings in degrees (0 to 360).
*/
public static double calculateHeading(double azimuth) {
if (azimuth >= 0) {
return azimuth;
} else {
return azimuth + 360;
}
}
public double getHeading() { public double getHeading() {
return heading; return heading;
} }
@ -276,16 +292,17 @@ public class BoatInRace extends Boat {
return position.get(); return position.get();
} }
public StringProperty positionProperty() {
return position;
}
public void setPosition(String position) { public void setPosition(String position) {
this.position.set(position); this.position.set(position);
} }
public StringProperty positionProperty() {
return position;
}
/** /**
* Adds a new point to boat's track. * Adds a new point to boat's track.
*
* @param coordinate of point on track * @param coordinate of point on track
* @return whether add is successful * @return whether add is successful
* @see seng302.Model.TrackPoint * @see seng302.Model.TrackPoint
@ -302,6 +319,7 @@ public class BoatInRace extends Boat {
/** /**
* Returns the boat's sampled track between start of race and current time. * Returns the boat's sampled track between start of race and current time.
*
* @return queue of track points * @return queue of track points
* @see seng302.Model.TrackPoint * @see seng302.Model.TrackPoint
*/ */
@ -311,6 +329,7 @@ public class BoatInRace extends Boat {
/** /**
* Returns whether track is visible * Returns whether track is visible
*
* @return true if visible * @return true if visible
*/ */
public boolean isTrackVisible() { public boolean isTrackVisible() {
@ -319,25 +338,10 @@ public class BoatInRace extends Boat {
/** /**
* Sets track visibility. * Sets track visibility.
*
* @param trackVisible visible if true. * @param trackVisible visible if true.
*/ */
public void setTrackVisible(boolean trackVisible) { public void setTrackVisible(boolean trackVisible) {
this.trackVisible = trackVisible; this.trackVisible = trackVisible;
} }
/**
* 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;
}
} }

@ -40,7 +40,6 @@ public class ConstantVelocityRace extends Race {
* @param legs in race * @param legs in race
* @param controller for graphics * @param controller for graphics
* @param scaleFactor of timer * @param scaleFactor of timer
*
* @deprecated Please use {@link #ConstantVelocityRace(List, List, RaceController, int) } for future tests. * @deprecated Please use {@link #ConstantVelocityRace(List, List, RaceController, int) } for future tests.
*/ */
public ConstantVelocityRace(BoatInRace[] startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) { public ConstantVelocityRace(BoatInRace[] startingBoats, List<Leg> legs, RaceController controller, int scaleFactor) {
@ -49,6 +48,7 @@ public class ConstantVelocityRace extends Race {
/** /**
* Initialiser for constant velocity race with standard data source * Initialiser for constant velocity race with standard data source
*
* @param raceData for race * @param raceData for race
* @param controller for graphics * @param controller for graphics
* @param scaleFactor of timer * @param scaleFactor of timer
@ -57,6 +57,30 @@ public class ConstantVelocityRace extends Race {
super(raceData, controller, scaleFactor); super(raceData, controller, scaleFactor);
} }
/**
* 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());
}
public void initialiseBoats() { public void initialiseBoats() {
Leg officialStart = legs.get(0); Leg officialStart = legs.get(0);
String name = officialStart.getName(); String name = officialStart.getName();
@ -115,6 +139,7 @@ public class ConstantVelocityRace extends Race {
/** /**
* Sets the chance each boat has of failing at a gate or marker * Sets the chance each boat has of failing at a gate or marker
*
* @param chance percentage chance a boat has of failing per checkpoint. * @param chance percentage chance a boat has of failing per checkpoint.
*/ */
protected void setDnfChance(int chance) { protected void setDnfChance(int chance) {
@ -181,28 +206,4 @@ public class ConstantVelocityRace extends Race {
} }
} }
/**
* 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());
}
} }

@ -74,16 +74,14 @@ public class Leg {
return startMarker; return startMarker;
} }
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public Marker getEndMarker() { public Marker getEndMarker() {
return endMarker; return endMarker;
} }
public void setStartMarker(Marker startMarker) {
this.startMarker = startMarker;
}
public void setEndMarker(Marker endMarker) { public void setEndMarker(Marker endMarker) {
this.endMarker = endMarker; this.endMarker = endMarker;
} }

@ -5,16 +5,11 @@ import javafx.animation.AnimationTimer;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import org.geotools.referencing.GeodeticCalculator;
import seng302.Controllers.RaceController; import seng302.Controllers.RaceController;
import seng302.GPSCoordinate;
import seng302.RaceDataSource; import seng302.RaceDataSource;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random;
/** /**
* Parent class for races * Parent class for races
@ -27,11 +22,9 @@ public abstract class Race implements Runnable {
protected RaceController controller; protected RaceController controller;
protected int boatsFinished = 0; protected int boatsFinished = 0;
protected long totalTimeElapsed; protected long totalTimeElapsed;
private int lastFPS = 20;
protected int scaleFactor; protected int scaleFactor;
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
private int lastFPS = 20;
private boolean timerEnabled = true; //boolean to determine if timer is ran private boolean timerEnabled = true; //boolean to determine if timer is ran
/** /**
@ -66,6 +59,7 @@ public abstract class Race implements Runnable {
/** /**
* Checks if the boat cannot finish the race * Checks if the boat cannot finish the race
*
* @return True if boat cannot finish the race * @return True if boat cannot finish the race
*/ */
protected abstract boolean doNotFinish(); protected abstract boolean doNotFinish();

@ -12,7 +12,6 @@ import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAmount;
/** /**
* Created by Gondr on 19/04/2017. * Created by Gondr on 19/04/2017.
@ -39,6 +38,7 @@ public class RaceClock {
/** /**
* Sets time to arbitrary zoned time. * Sets time to arbitrary zoned time.
*
* @param time arbitrary time with timezone. * @param time arbitrary time with timezone.
*/ */
public void setTime(ZonedDateTime time) { public void setTime(ZonedDateTime time) {

@ -7,10 +7,8 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint; import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate; import javafx.scene.transform.Rotate;
import seng302.*; import seng302.*;
import seng302.Controllers.RaceController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -19,6 +17,7 @@ import java.util.List;
* Created by fwy13 on 17/03/17. * Created by fwy13 on 17/03/17.
*/ */
public class ResizableRaceCanvas extends Canvas { public class ResizableRaceCanvas extends Canvas {
double[] xpoints = {}, ypoints = {};
private GraphicsContext gc; private GraphicsContext gc;
private RaceMap map; private RaceMap map;
private List<BoatInRace> boats; private List<BoatInRace> boats;
@ -28,7 +27,6 @@ public class ResizableRaceCanvas extends Canvas {
private boolean annoSpeed = true; private boolean annoSpeed = true;
private boolean annoPath = true; private boolean annoPath = true;
private ArrayList<GPSCoordinate> raceBoundaries; private ArrayList<GPSCoordinate> raceBoundaries;
double[] xpoints = {}, ypoints = {};
public ResizableRaceCanvas(RaceDataSource raceData) { public ResizableRaceCanvas(RaceDataSource raceData) {
gc = this.getGraphicsContext2D(); gc = this.getGraphicsContext2D();
@ -345,6 +343,7 @@ public class ResizableRaceCanvas extends Canvas {
/** /**
* Draws all track points for a given boat. Colour is set by boat, opacity by track point. * Draws all track points for a given boat. Colour is set by boat, opacity by track point.
*
* @param boat whose track is displayed * @param boat whose track is displayed
* @see seng302.Model.TrackPoint * @see seng302.Model.TrackPoint
*/ */

@ -13,6 +13,7 @@ public class TrackPoint {
/** /**
* Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry. * 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 coordinate position of point on physical race map
* @param timeAdded system clock at time of addition * @param timeAdded system clock at time of addition
* @param expiry time to minimum opacity after added * @param expiry time to minimum opacity after added
@ -26,6 +27,7 @@ public class TrackPoint {
/** /**
* Gets the position of the point on physical race map. * Gets the position of the point on physical race map.
*
* @return GPS coordinate of point * @return GPS coordinate of point
*/ */
public GPSCoordinate getCoordinate() { public GPSCoordinate getCoordinate() {
@ -34,6 +36,7 @@ public class TrackPoint {
/** /**
* Gets opacity of point scaled by age in proportion to expiry, between 1 and minimum opacity inclusive. * 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 * @return greater of minimum opacity and scaled opacity
*/ */
public double getAlpha() { public double getAlpha() {
@ -42,6 +45,7 @@ public class TrackPoint {
/** /**
* Gets time point was added to track. * Gets time point was added to track.
*
* @return system clock at time of addition * @return system clock at time of addition
*/ */
public long getTimeAdded() { public long getTimeAdded() {

@ -1,10 +1,7 @@
package seng302.Networking.MessageDecoders; package seng302.Networking.MessageDecoders;
import seng302.Model.BoatInRace;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
/** /**

@ -1,7 +1,6 @@
package seng302.Networking.MessageEncoders; package seng302.Networking.MessageEncoders;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays; import java.util.Arrays;
/** /**

@ -7,8 +7,7 @@ package seng302.Networking.Utils;
/** /**
* Represents the information in a boat location message (AC streaming spec: 4.9). * Represents the information in a boat location message (AC streaming spec: 4.9).
*/ */
public class BoatLocationMessage public class BoatLocationMessage {
{
///Version number of the message - is always 1. ///Version number of the message - is always 1.
private byte messageVersionNumber = 1; private byte messageVersionNumber = 1;
@ -78,12 +77,12 @@ public class BoatLocationMessage
/** /**
* Ctor. * Ctor.
*/ */
public BoatLocationMessage() public BoatLocationMessage() {
{
} }
/** /**
* Ctor, with all parameters. * Ctor, with all parameters.
*
* @param messageVersionNumber * @param messageVersionNumber
* @param time * @param time
* @param sourceID * @param sourceID
@ -107,8 +106,7 @@ public class BoatLocationMessage
* @param currentSet * @param currentSet
* @param rudderAngle * @param rudderAngle
*/ */
public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) public BoatLocationMessage(byte messageVersionNumber, long time, int sourceID, int sequenceNumber, byte deviceType, int latitude, int longitude, int altitude, int heading, short pitch, short roll, int boatSpeed, int boatCOG, int boatSOG, int apparentWindSpeed, short apparentWindAngle, int trueWindSpeed, short trueWindDirection, short trueWindAngle, int currentDrift, int currentSet, short rudderAngle) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
this.time = time; this.time = time;
this.sourceID = sourceID; this.sourceID = sourceID;
@ -137,173 +135,139 @@ public class BoatLocationMessage
//Getters and setters for message properties. //Getters and setters for message properties.
public byte getMessageVersionNumber() public byte getMessageVersionNumber() {
{
return messageVersionNumber; return messageVersionNumber;
} }
public void setMessageVersionNumber(byte messageVersionNumber) public void setMessageVersionNumber(byte messageVersionNumber) {
{
this.messageVersionNumber = messageVersionNumber; this.messageVersionNumber = messageVersionNumber;
} }
public long getTime() public long getTime() {
{
return time; return time;
} }
public void setTime(long time) public void setTime(long time) {
{
this.time = time; this.time = time;
} }
public int getSourceID() public int getSourceID() {
{
return sourceID; return sourceID;
} }
public void setSourceID(int sourceID) public void setSourceID(int sourceID) {
{
this.sourceID = sourceID; this.sourceID = sourceID;
} }
public int getSequenceNumber() public int getSequenceNumber() {
{
return sequenceNumber; return sequenceNumber;
} }
public void setSequenceNumber(int sequenceNumber) public void setSequenceNumber(int sequenceNumber) {
{
this.sequenceNumber = sequenceNumber; this.sequenceNumber = sequenceNumber;
} }
public byte getDeviceType() public byte getDeviceType() {
{
return deviceType; return deviceType;
} }
public void setDeviceType(byte deviceType) public void setDeviceType(byte deviceType) {
{
this.deviceType = deviceType; this.deviceType = deviceType;
} }
public int getLatitude() public int getLatitude() {
{
return latitude; return latitude;
} }
public void setLatitude(int latitude) public void setLatitude(int latitude) {
{
this.latitude = latitude; this.latitude = latitude;
} }
public int getLongitude() public int getLongitude() {
{
return longitude; return longitude;
} }
public void setLongitude(int longitude) public void setLongitude(int longitude) {
{
this.longitude = longitude; this.longitude = longitude;
} }
public int getAltitude() public int getAltitude() {
{
return altitude; return altitude;
} }
public void setAltitude(int altitude) public void setAltitude(int altitude) {
{
this.altitude = altitude; this.altitude = altitude;
} }
public int getHeading() public int getHeading() {
{
return heading; return heading;
} }
public void setHeading(int heading) public void setHeading(int heading) {
{
this.heading = heading; this.heading = heading;
} }
public short getPitch() public short getPitch() {
{
return pitch; return pitch;
} }
public void setPitch(short pitch) public void setPitch(short pitch) {
{
this.pitch = pitch; this.pitch = pitch;
} }
public short getRoll() public short getRoll() {
{
return roll; return roll;
} }
public void setRoll(short roll) public void setRoll(short roll) {
{
this.roll = roll; this.roll = roll;
} }
public int getBoatSpeed() public int getBoatSpeed() {
{
return boatSpeed; return boatSpeed;
} }
public void setBoatSpeed(int boatSpeed) public void setBoatSpeed(int boatSpeed) {
{
this.boatSpeed = boatSpeed; this.boatSpeed = boatSpeed;
} }
public int getBoatCOG() public int getBoatCOG() {
{
return boatCOG; return boatCOG;
} }
public void setBoatCOG(int boatCOG) public void setBoatCOG(int boatCOG) {
{
this.boatCOG = boatCOG; this.boatCOG = boatCOG;
} }
public int getBoatSOG() public int getBoatSOG() {
{
return boatSOG; return boatSOG;
} }
public void setBoatSOG(int boatSOG) public void setBoatSOG(int boatSOG) {
{
this.boatSOG = boatSOG; this.boatSOG = boatSOG;
} }
public int getApparentWindSpeed() public int getApparentWindSpeed() {
{
return apparentWindSpeed; return apparentWindSpeed;
} }
public void setApparentWindSpeed(int apparentWindSpeed) public void setApparentWindSpeed(int apparentWindSpeed) {
{
this.apparentWindSpeed = apparentWindSpeed; this.apparentWindSpeed = apparentWindSpeed;
} }
public short getApparentWindAngle() public short getApparentWindAngle() {
{
return apparentWindAngle; return apparentWindAngle;
} }
public void setApparentWindAngle(short apparentWindAngle) public void setApparentWindAngle(short apparentWindAngle) {
{
this.apparentWindAngle = apparentWindAngle; this.apparentWindAngle = apparentWindAngle;
} }
public int getTrueWindSpeed() public int getTrueWindSpeed() {
{
return trueWindSpeed; return trueWindSpeed;
} }
public void setTrueWindSpeed(int trueWindSpeed) public void setTrueWindSpeed(int trueWindSpeed) {
{
this.trueWindSpeed = trueWindSpeed; this.trueWindSpeed = trueWindSpeed;
} }
@ -315,43 +279,35 @@ public class BoatLocationMessage
this.trueWindDirection = trueWindDirection; this.trueWindDirection = trueWindDirection;
} }
public short getTrueWindAngle() public short getTrueWindAngle() {
{
return trueWindAngle; return trueWindAngle;
} }
public void setTrueWindAngle(short trueWindAngle) public void setTrueWindAngle(short trueWindAngle) {
{
this.trueWindAngle = trueWindAngle; this.trueWindAngle = trueWindAngle;
} }
public int getCurrentDrift() public int getCurrentDrift() {
{
return currentDrift; return currentDrift;
} }
public void setCurrentDrift(int currentDrift) public void setCurrentDrift(int currentDrift) {
{
this.currentDrift = currentDrift; this.currentDrift = currentDrift;
} }
public int getCurrentSet() public int getCurrentSet() {
{
return currentSet; return currentSet;
} }
public void setCurrentSet(int currentSet) public void setCurrentSet(int currentSet) {
{
this.currentSet = currentSet; this.currentSet = currentSet;
} }
public short getRudderAngle() public short getRudderAngle() {
{
return rudderAngle; return rudderAngle;
} }
public void setRudderAngle(short rudderAngle) public void setRudderAngle(short rudderAngle) {
{
this.rudderAngle = rudderAngle; this.rudderAngle = rudderAngle;
} }
} }

@ -10,7 +10,9 @@ public enum MessageType {
private byte value; private byte value;
private MessageType(int value) { this.value = (byte)value; } private MessageType(int value) {
this.value = (byte) value;
}
public byte getValue() { public byte getValue() {
return value; return value;

@ -11,10 +11,14 @@ import java.util.List;
*/ */
public interface RaceDataSource { public interface RaceDataSource {
List<BoatInRace> getBoats(); List<BoatInRace> getBoats();
List<Leg> getLegs(); List<Leg> getLegs();
List<GPSCoordinate> getBoundary(); List<GPSCoordinate> getBoundary();
ZonedDateTime getZonedDateTime(); ZonedDateTime getZonedDateTime();
GPSCoordinate getMapTopLeft(); GPSCoordinate getMapTopLeft();
GPSCoordinate getMapBottomRight(); GPSCoordinate getMapBottomRight();
} }

@ -4,7 +4,10 @@ import javafx.scene.paint.Color;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import seng302.Model.*; import seng302.Model.BoatInRace;
import seng302.Model.Leg;
import seng302.Model.Marker;
import seng302.Model.RaceClock;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException; import java.io.IOException;
@ -16,16 +19,17 @@ import java.util.List;
* Created by fwy13 on 26/03/2017. * Created by fwy13 on 26/03/2017.
*/ */
public class RaceXMLReader extends XMLReader implements RaceDataSource { public class RaceXMLReader extends XMLReader implements RaceDataSource {
private static double COORDINATEPADDING = 0.0005;
private List<BoatInRace> boats = new ArrayList<>(); private List<BoatInRace> boats = new ArrayList<>();
private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system. private Color[] colors = {Color.BLUEVIOLET, Color.BLACK, Color.RED, Color.ORANGE, Color.DARKOLIVEGREEN, Color.LIMEGREEN};//TODO make this established in xml or come up with a better system.
private List<Leg> legs = new ArrayList<>(); private List<Leg> legs = new ArrayList<>();
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2; private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
private GPSCoordinate mapTopLeft, mapBottomRight; private GPSCoordinate mapTopLeft, mapBottomRight;
private List<GPSCoordinate> boundary = new ArrayList<>(); private List<GPSCoordinate> boundary = new ArrayList<>();
private static double COORDINATEPADDING = 0.0005;
/** /**
* Constractor for Race XML * Constractor for Race XML
*
* @param filePath path of the file * @param filePath path of the file
* @throws IOException error * @throws IOException error
* @throws SAXException error * @throws SAXException error
@ -37,6 +41,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* COnstructor for Race XML * COnstructor for Race XML
*
* @param filePath file path to read * @param filePath file path to read
* @param read whether or not to read and store the files straight away. * @param read whether or not to read and store the files straight away.
* @throws IOException error * @throws IOException error
@ -168,6 +173,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return * @return
*/ */
@ -177,6 +183,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag * @param startIndex index in the node that has the coordinate tag
* @return * @return
@ -187,6 +194,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a marker from the XML file * gets a marker from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex index in the node that has the coordinate tag * @param startIndex index in the node that has the coordinate tag
* @param nodeIndex coordinate index * @param nodeIndex coordinate index
@ -200,6 +208,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a changes a marker to GPS coordinates into a marker * gets a changes a marker to GPS coordinates into a marker
*
* @param markerNode marker to turn into coordinates * @param markerNode marker to turn into coordinates
* @return * @return
*/ */
@ -220,6 +229,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @return * @return
*/ */
@ -229,6 +239,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in * @param startIndex the index the tag containing the coordinate should be in
* @return * @return
@ -239,6 +250,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
/** /**
* gets a coordinates from the XML file * gets a coordinates from the XML file
*
* @param start base nodelist this should be the tag that contains <coordinate></coordinate> * @param start base nodelist this should be the tag that contains <coordinate></coordinate>
* @param startIndex the index the tag containing the coordinate should be in * @param startIndex the index the tag containing the coordinate should be in
* @param nodeIndex The coordinate index * @param nodeIndex The coordinate index

@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.geometry.*?> <AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="main" xmlns="http://javafx.com/javafx/8"
<?import javafx.geometry.Insets?> fx:controller="seng302.Controllers.MainController">
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.MainController">
<children> <children>
<fx:include source="race.fxml" fx:id="race"/> <fx:include source="race.fxml" fx:id="race"/>
<fx:include source="start.fxml" fx:id="start"/> <fx:include source="start.fxml" fx:id="start"/>

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.Font?>
<SplitPane xmlns:fx="http://javafx.com/fxml/1" fx:id="race" dividerPositions="0.7" visible="false" AnchorPane.bottomAnchor="0.0"
<SplitPane fx:id="race" dividerPositions="0.7" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController"> AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns="http://javafx.com/javafx/8" fx:controller="seng302.Controllers.RaceController">
<items> <items>
<GridPane fx:id="canvasBase"> <GridPane fx:id="canvasBase">
<columnConstraints> <columnConstraints>
@ -25,13 +24,28 @@
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="240.0" prefWidth="200.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="240.0" prefWidth="200.0">
<children> <children>
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="104.0" /> <CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true"
<CheckBox fx:id="showAnnotations" layoutX="-2.0" layoutY="14.0" mnemonicParsing="false" selected="true" text="Show Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" /> text="Show Boat Paths" AnchorPane.leftAnchor="0.0"
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false" selected="true" text="Show Boat Name" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="26.0" /> AnchorPane.topAnchor="104.0"/>
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false" selected="true" text="Show Boat Abbreviation" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="52.0" /> <CheckBox fx:id="showAnnotations" layoutX="-2.0" layoutY="14.0"
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="78.0" /> mnemonicParsing="false" selected="true"
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Annotation" AnchorPane.topAnchor="130.0" /> text="Show Annotations" AnchorPane.leftAnchor="0.0"
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0" mnemonicParsing="false" text="Show Set Annotation" AnchorPane.topAnchor="160.0" /> AnchorPane.topAnchor="0.0"/>
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false"
selected="true" text="Show Boat Name"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="26.0"/>
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false"
selected="true" text="Show Boat Abbreviation"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="52.0"/>
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false"
selected="true" text="Show Boat Speed"
AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="78.0"/>
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0"
mnemonicParsing="false" prefWidth="154.0" text="Save Annotation"
AnchorPane.topAnchor="130.0"/>
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0"
mnemonicParsing="false" text="Show Set Annotation"
AnchorPane.topAnchor="160.0"/>
</children> </children>
</AnchorPane> </AnchorPane>
</content> </content>
@ -40,7 +54,9 @@
<content> <content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children> <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" /> <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> </children>
</AnchorPane> </AnchorPane>
</content> </content>
@ -49,12 +65,15 @@
</Accordion> </Accordion>
</children> </children>
</Pane> </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"> <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>
<Font name="System Bold" size="15.0"/> <Font name="System Bold" size="15.0"/>
</font> </font>
</Label> </Label>
<Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" GridPane.halignment="LEFT" GridPane.valignment="BOTTOM"> <Label fx:id="FPS" text="FPS: 0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
GridPane.halignment="LEFT" GridPane.valignment="BOTTOM">
<font> <font>
<Font name="System Bold" size="15.0"/> <Font name="System Bold" size="15.0"/>
</font> </font>
@ -69,9 +88,12 @@
</Label> </Label>
</children> </children>
</GridPane> </GridPane>
<AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0" GridPane.columnIndex="1"> <AnchorPane layoutX="450.0" minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="200.0"
GridPane.columnIndex="1">
<children> <children>
<TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="-62.0" AnchorPane.topAnchor="0.0"> <TableView fx:id="boatInfoTable" layoutX="-2.0" prefHeight="600.0" prefWidth="264.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="-2.0" AnchorPane.rightAnchor="-62.0"
AnchorPane.topAnchor="0.0">
<columns> <columns>
<TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place"/> <TableColumn fx:id="boatPlacingColumn" prefWidth="50.0" text="Place"/>
<TableColumn fx:id="boatTeamColumn" prefWidth="100.0" text="Team"/> <TableColumn fx:id="boatTeamColumn" prefWidth="100.0" text="Team"/>

@ -1,20 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.Label?> <?import javafx.scene.layout.*?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?> <?import javafx.scene.text.Text?>
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" fx:id="startWrapper" maxHeight="1.7976931348623157E308"
<AnchorPane fx:id="startWrapper" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.StartController"> maxWidth="1.7976931348623157E308" xmlns="http://javafx.com/javafx/8"
fx:controller="seng302.Controllers.StartController">
<children> <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"> <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>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" prefWidth="200.0"/> <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="372.0" minWidth="10.0" prefWidth="200.0"/>
@ -31,27 +27,39 @@
<RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES"/> <RowConstraints maxHeight="191.5" minHeight="10.0" prefHeight="82.0" vgrow="SOMETIMES"/>
</rowConstraints> </rowConstraints>
<children> <children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5" GridPane.halignment="CENTER"> <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to RaceVision" GridPane.columnSpan="5"
GridPane.halignment="CENTER">
<font> <font>
<Font size="36.0"/> <Font size="36.0"/>
</font> </font>
</Text> </Text>
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace1Min" prefWidth="100.0" fx:id="oneMinButton" text="1 Minute" GridPane.columnIndex="1" GridPane.halignment="RIGHT" GridPane.rowIndex="4"> <Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace1Min"
prefWidth="100.0" fx:id="oneMinButton" text="1 Minute" GridPane.columnIndex="1"
GridPane.halignment="RIGHT" GridPane.rowIndex="4">
<GridPane.margin> <GridPane.margin>
<Insets/> <Insets/>
</GridPane.margin> </GridPane.margin>
</Button> </Button>
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling" prefWidth="100.0" fx:id="fifteenMinButton" text="15 Minutes" GridPane.columnIndex="3" GridPane.halignment="LEFT" GridPane.rowIndex="4" /> <Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRaceNoScaling"
<Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace5Min" prefWidth="100.0" fx:id="fiveMinButton" text="5 Minutes" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="4" /> prefWidth="100.0" fx:id="fifteenMinButton" text="15 Minutes" GridPane.columnIndex="3"
<Label text="Select Race Duration:" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" /> GridPane.halignment="LEFT" GridPane.rowIndex="4"/>
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1"> <Button maxWidth="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#startRace5Min"
prefWidth="100.0" fx:id="fiveMinButton" text="5 Minutes" GridPane.columnIndex="2"
GridPane.halignment="CENTER" GridPane.rowIndex="4"/>
<Label text="Select Race Duration:" GridPane.columnIndex="2" GridPane.halignment="CENTER"
GridPane.rowIndex="3"/>
<TableView fx:id="boatNameTable" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1"
GridPane.columnSpan="3" GridPane.rowIndex="1">
<columns> <columns>
<TableColumn fx:id="boatNameColumn" prefWidth="360.0" style="-fx-font-size: 16;" text="Team Name" /> <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"/> <TableColumn fx:id="boatCodeColumn" prefWidth="133.0" style="-fx-font-size: 16;" text="Code"/>
</columns> </columns>
</TableView> </TableView>
<Label fx:id="timeZoneTime" contentDisplay="CENTER" text="timeZoneTime" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER" /> <Label fx:id="timeZoneTime" contentDisplay="CENTER" text="timeZoneTime" GridPane.columnIndex="2"
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" /> GridPane.halignment="CENTER" GridPane.rowIndex="2" GridPane.valignment="CENTER"/>
<Label fx:id="timer" text=" " GridPane.columnIndex="2" GridPane.halignment="CENTER"
GridPane.rowIndex="5"/>
</children> </children>
</GridPane> </GridPane>
</children> </children>

@ -2,11 +2,7 @@ package seng302.Mock;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

@ -3,9 +3,7 @@ package seng302.Mock;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.*;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;
/** /**
* Created by jjg64 on 19/04/17. * Created by jjg64 on 19/04/17.

@ -8,7 +8,6 @@ import seng302.Model.Leg;
import java.util.List; import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/** /**
* Tests only work on the current version of mockXML/raceXML/raceTest.xml * Tests only work on the current version of mockXML/raceXML/raceTest.xml

@ -1,14 +1,10 @@
package seng302.Model; package seng302.Model;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import seng302.GPSCoordinate; import seng302.GPSCoordinate;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.*;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
/** /**
* Created by esa46 on 22/03/17. * Created by esa46 on 22/03/17.

@ -7,7 +7,6 @@ import org.junit.Test;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate; import seng302.GPSCoordinate;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

@ -5,7 +5,6 @@ import org.junit.Test;
import seng302.Constants; import seng302.Constants;
import seng302.GPSCoordinate; import seng302.GPSCoordinate;
import java.awt.*;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertEquals;

@ -1,15 +1,5 @@
package seng302.Model; package seng302.Model;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import seng302.RaceDataSource;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
/** /**
* Created by esa46 on 15/03/17. * Created by esa46 on 15/03/17.
*/ */

@ -2,17 +2,13 @@ package seng302.Model;/**
* Created by Gondr on 26/03/2017. * Created by Gondr on 26/03/2017.
*/ */
import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException;
import seng302.RaceXMLReader; import seng302.RaceXMLReader;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*;
public class RaceXMLTest { public class RaceXMLTest {
RaceXMLReader raceXMLReader; RaceXMLReader raceXMLReader;

@ -2,8 +2,6 @@ package seng302.Networking;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.BinaryMesageEncoder;
import seng302.Networking.BinaryMessageDecoder;
import seng302.Networking.MessageDecoders.XMLMessageDecoder; import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import seng302.Networking.Utils.MessageType; import seng302.Networking.Utils.MessageType;

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
import seng302.Networking.Utils.BoatLocationMessage;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.BoatLocationMessage;
/** /**

@ -2,9 +2,8 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.CourseWindDecoder;
import seng302.Networking.Utils.CourseWind;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import seng302.Networking.Utils.CourseWind;
import java.util.ArrayList; import java.util.ArrayList;

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.RaceStartStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
/** /**

@ -5,7 +5,6 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Model.BoatInRace; import seng302.Model.BoatInRace;
import seng302.Model.Leg; import seng302.Model.Leg;
import seng302.Networking.MessageDecoders.RaceStatusDecoder;
import seng302.Networking.MessageEncoders.RaceVisionByteEncoder; import seng302.Networking.MessageEncoders.RaceVisionByteEncoder;
import java.util.ArrayList; import java.util.ArrayList;

@ -2,7 +2,6 @@ package seng302.Networking.MessageDecoders;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageDecoders.XMLMessageDecoder;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.BufferedReader; import java.io.BufferedReader;

@ -4,7 +4,9 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import seng302.Networking.MessageEncoders.XMLMessageEncoder; import seng302.Networking.MessageEncoders.XMLMessageEncoder;
import java.io.*; import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/** /**
* Created by hba56 on 19/04/17. * Created by hba56 on 19/04/17.

Loading…
Cancel
Save