Fixed JavaDoc, spelling errors, and redundant classes
- Removed some default templates (eg: created by X) - Wrote JavaDoc for classes that had none - Made JavaDoc more clear for classes - Linked JavaDoc to other classes - Minor spelling errors fixed - BoatInRace and BoatInRaceTest commented out (to be removed) #story[1003]
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
package seng302.DataInput;
|
package seng302.DataInput;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hba56 on 10/05/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import seng302.Exceptions.InvalidPolarFileException;
|
import seng302.Exceptions.InvalidPolarFileException;
|
||||||
import seng302.Model.Bearing;
|
import seng302.Model.Bearing;
|
||||||
import seng302.Model.Polars;
|
import seng302.Model.Polars;
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Exceptions;
|
package seng302.Exceptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 25-Apr-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Exceptions;
|
package seng302.Exceptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 10-May-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception thrown when we cannot parse a polar data file.
|
* An exception thrown when we cannot parse a polar data file.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Exceptions;
|
package seng302.Exceptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 25-Apr-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class GPSCoordinate {
|
|||||||
/**
|
/**
|
||||||
* Calculates min and max values and passed it to calculate if coordinate is in the boundary
|
* Calculates min and max values and passed it to calculate if coordinate is in the boundary
|
||||||
* @param coordinate coordinate of interest
|
* @param coordinate coordinate of interest
|
||||||
* @param boundary List of points which make a boundry
|
* @param boundary List of points which make a boundary
|
||||||
* @return true if coordinate is in the boundary
|
* @return true if coordinate is in the boundary
|
||||||
*/
|
*/
|
||||||
public static boolean isInsideBoundary(GPSCoordinate coordinate, List<GPSCoordinate> boundary) {
|
public static boolean isInsideBoundary(GPSCoordinate coordinate, List<GPSCoordinate> boundary) {
|
||||||
@@ -139,7 +139,7 @@ public class GPSCoordinate {
|
|||||||
/**
|
/**
|
||||||
* Helper function to find if a point is in a boundary
|
* Helper function to find if a point is in a boundary
|
||||||
* @param boundaryA The first coordinate of the boundary.
|
* @param boundaryA The first coordinate of the boundary.
|
||||||
* @param boundaryB The second coordinate of the bounary.
|
* @param boundaryB The second coordinate of the boundary.
|
||||||
* @param coordinate The coordinate to test.
|
* @param coordinate The coordinate to test.
|
||||||
* @return true if a line from the point intersects the two boundary points
|
* @return true if a line from the point intersects the two boundary points
|
||||||
*/
|
*/
|
||||||
@@ -307,7 +307,7 @@ public class GPSCoordinate {
|
|||||||
List<Pair<GPSCoordinate, GPSCoordinate>> shrunkEdges = new ArrayList<>();
|
List<Pair<GPSCoordinate, GPSCoordinate>> shrunkEdges = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
//We need to invert some of our opertations depending if the boundary is clockwise or anti-clockwise.
|
//We need to invert some of our operations depending if the boundary is clockwise or anti-clockwise.
|
||||||
boolean isClockwise = GPSCoordinate.isClockwisePolygon(boundary);
|
boolean isClockwise = GPSCoordinate.isClockwisePolygon(boundary);
|
||||||
double clockwiseScaleFactor = 0;
|
double clockwiseScaleFactor = 0;
|
||||||
|
|
||||||
@@ -318,8 +318,8 @@ public class GPSCoordinate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Starting at a vertex, face anti-clockwise along an adjacent edge.
|
Starting at a vertex, face anti-clockwise along an adjacent edge.
|
||||||
Replace the edge with a new, parallel edge placed at distance d to the "left" of the old one.
|
Replace the edge with a new, parallel edge placed at distance d to the "left" of the old one.
|
||||||
Repeat for all edges.
|
Repeat for all edges.
|
||||||
Find the intersections of the new edges to get the new vertices.
|
Find the intersections of the new edges to get the new vertices.
|
||||||
@@ -337,11 +337,11 @@ public class GPSCoordinate {
|
|||||||
Bearing bearing = GPSCoordinate.calculateBearing(firstPoint, secondPoint);
|
Bearing bearing = GPSCoordinate.calculateBearing(firstPoint, secondPoint);
|
||||||
|
|
||||||
//Calculate angle perpendicular to bearing.
|
//Calculate angle perpendicular to bearing.
|
||||||
Bearing perpindicularBearing = Bearing.fromDegrees(bearing.degrees() + (90d * clockwiseScaleFactor));
|
Bearing perpendicularBearing = Bearing.fromDegrees(bearing.degrees() + (90d * clockwiseScaleFactor));
|
||||||
|
|
||||||
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
|
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
|
||||||
GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing));
|
GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing));
|
||||||
GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing));
|
GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing));
|
||||||
|
|
||||||
//Add edge to list.
|
//Add edge to list.
|
||||||
shrunkEdges.add(new Pair<>(firstPointTranslated, secondPointTranslated));
|
shrunkEdges.add(new Pair<>(firstPointTranslated, secondPointTranslated));
|
||||||
@@ -357,11 +357,11 @@ public class GPSCoordinate {
|
|||||||
Bearing bearing = GPSCoordinate.calculateBearing(firstPoint, secondPoint);
|
Bearing bearing = GPSCoordinate.calculateBearing(firstPoint, secondPoint);
|
||||||
|
|
||||||
//Calculate angle perpendicular to bearing.
|
//Calculate angle perpendicular to bearing.
|
||||||
Bearing perpindicularBearing = Bearing.fromDegrees(bearing.degrees() + (90d * clockwiseScaleFactor));
|
Bearing perpendicularBearing = Bearing.fromDegrees(bearing.degrees() + (90d * clockwiseScaleFactor));
|
||||||
|
|
||||||
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
|
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
|
||||||
GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing));
|
GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing));
|
||||||
GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing));
|
GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing));
|
||||||
|
|
||||||
//Add edge to list.
|
//Add edge to list.
|
||||||
shrunkEdges.add(new Pair<>(firstPointTranslated, secondPointTranslated));
|
shrunkEdges.add(new Pair<>(firstPointTranslated, secondPointTranslated));
|
||||||
@@ -460,13 +460,13 @@ public class GPSCoordinate {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a list of coordinates describes a boundary polygon in clockwise or anti-clockwise order.
|
* Determines if a list of coordinates describes a boundary polygon in clockwise or anti-clockwise order.
|
||||||
* @param boundary The list of coodinates.
|
* @param boundary The list of coordinates.
|
||||||
* @return True if clockwise, false if anti-clockwise.
|
* @return True if clockwise, false if anti-clockwise.
|
||||||
*/
|
*/
|
||||||
public static boolean isClockwisePolygon(List<GPSCoordinate> boundary) {
|
public static boolean isClockwisePolygon(List<GPSCoordinate> boundary) {
|
||||||
|
|
||||||
/** From https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
|
/* From https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
|
||||||
* sum all pairs (x2 − x1)(y2 + y1)
|
sum all pairs (x2 − x1)(y2 + y1)
|
||||||
point[0] = (5,0) edge[0]: (6-5)(4+0) = 4
|
point[0] = (5,0) edge[0]: (6-5)(4+0) = 4
|
||||||
point[1] = (6,4) edge[1]: (4-6)(5+4) = -18
|
point[1] = (6,4) edge[1]: (4-6)(5+4) = -18
|
||||||
point[2] = (4,5) edge[2]: (1-4)(5+5) = -30
|
point[2] = (4,5) edge[2]: (1-4)(5+5) = -30
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import javafx.util.Pair;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hba56 on 10/05/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates an entire polar table. Has a function to calculate VMG.
|
* Encapsulates an entire polar table. Has a function to calculate VMG.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 10-May-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class encapsulates VMG - that is, velocity made good. It has a speed component and a bearing component.
|
* This class encapsulates VMG - that is, velocity made good. It has a speed component and a bearing component.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import static org.testng.Assert.*;
|
|||||||
public class PolarParserTest {
|
public class PolarParserTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
/**
|
/*
|
||||||
* Tests if we can parse a polar data file (stored in a string), and create a polar table.
|
Tests if we can parse a polar data file (stored in a string), and create a polar table.
|
||||||
*/
|
*/
|
||||||
public void testParse() throws Exception {
|
public void testParse() throws Exception {
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import java.nio.ByteBuffer;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hba56 on 21/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to decode/convert a byte array into a messageBody object, descended from AC35Data.
|
* This class can be used to decode/convert a byte array into a messageBody object, descended from AC35Data.
|
||||||
*/
|
*/
|
||||||
@@ -187,7 +183,7 @@ public class BinaryMessageDecoder {
|
|||||||
return mrDecoder.getMarkRounding();
|
return mrDecoder.getMarkRounding();
|
||||||
|
|
||||||
case COURSEWIND:
|
case COURSEWIND:
|
||||||
//System.out.println("Couse Wind Message!");
|
//System.out.println("Course Wind Message!");
|
||||||
CourseWindDecoder cwDecoder = new CourseWindDecoder(messageBody);
|
CourseWindDecoder cwDecoder = new CourseWindDecoder(messageBody);
|
||||||
return new CourseWinds(cwDecoder.getMessageVersionNumber(), cwDecoder.getByteWindID(), cwDecoder.getLoopMessages());
|
return new CourseWinds(cwDecoder.getMessageVersionNumber(), cwDecoder.getByteWindID(), cwDecoder.getLoopMessages());
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import static seng302.Networking.Utils.ByteConverter.intToBytes;
|
|||||||
import static seng302.Networking.Utils.ByteConverter.longToBytes;
|
import static seng302.Networking.Utils.ByteConverter.longToBytes;
|
||||||
import static seng302.Networking.Utils.ByteConverter.shortToBytes;
|
import static seng302.Networking.Utils.ByteConverter.shortToBytes;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hba56 on 21/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to encode/convert a byte array message body, plus header data into a byte array containing the entire message, ready to send.
|
* This class can be used to encode/convert a byte array message body, plus header data into a byte array containing the entire message, ready to send.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Networking.Exceptions;
|
package seng302.Networking.Exceptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 07-May-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception which is thrown when a message is read, but it is invalid in some way (CRC is wrong, sync bytes, etc...).
|
* Exception which is thrown when a message is read, but it is invalid in some way (CRC is wrong, sync bytes, etc...).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
package seng302.Networking.Messages;
|
package seng302.Networking.Messages;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by fwy13 on 25/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import seng302.Networking.Messages.Enums.MessageType;
|
import seng302.Networking.Messages.Enums.MessageType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Networking.Messages;
|
package seng302.Networking.Messages;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by f123 on 21-Apr-17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import seng302.Networking.Messages.Enums.MessageType;
|
import seng302.Networking.Messages.Enums.MessageType;
|
||||||
import seng302.Networking.Utils.AC35UnitConverter;
|
import seng302.Networking.Utils.AC35UnitConverter;
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ package seng302.Networking.Messages.Enums;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by esa46 on 28/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration that encapsulates the various statuses a boat can have.
|
* Enumeration that encapsulates the various statuses a boat can have.
|
||||||
*/
|
*/
|
||||||
@@ -46,8 +42,8 @@ public enum BoatStatusEnum {
|
|||||||
private static final Map<Byte, BoatStatusEnum> byteToStatusMap = new HashMap<>();
|
private static final Map<Byte, BoatStatusEnum> byteToStatusMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Static initialization block. Initializes the byteToStatusMap.
|
Static initialization block. Initializes the byteToStatusMap.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
for (BoatStatusEnum type : BoatStatusEnum.values()) {
|
for (BoatStatusEnum type : BoatStatusEnum.values()) {
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package seng302.Networking.Messages.Enums;
|
package seng302.Networking.Messages.Enums;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hba56 on 21/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -49,8 +45,8 @@ public enum MessageType {
|
|||||||
private static final Map<Byte, MessageType> byteToTypeMap = new HashMap<>();
|
private static final Map<Byte, MessageType> byteToTypeMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Static initialization block. Initializes the byteToTypeMap.
|
Static initialization block. Initializes the byteToTypeMap.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
for (MessageType type : MessageType.values()) {
|
for (MessageType type : MessageType.values()) {
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ public enum RaceStatusEnum {
|
|||||||
private static final Map<Byte, RaceStatusEnum> byteToStatusMap = new HashMap<>();
|
private static final Map<Byte, RaceStatusEnum> byteToStatusMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Static initialization block. Initializes the byteToStatusMap.
|
Static initialization block. Initializes the byteToStatusMap.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
for (RaceStatusEnum type : RaceStatusEnum.values()) {
|
for (RaceStatusEnum type : RaceStatusEnum.values()) {
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public enum RaceTypeEnum {
|
|||||||
private static final Map<Byte, RaceTypeEnum> byteToStatusMap = new HashMap<>();
|
private static final Map<Byte, RaceTypeEnum> byteToStatusMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Static initialization block. Initializes the byteToStatusMap.
|
Static initialization block. Initializes the byteToStatusMap.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
for (RaceTypeEnum type : RaceTypeEnum.values()) {
|
for (RaceTypeEnum type : RaceTypeEnum.values()) {
|
||||||
|
|||||||
@@ -2,10 +2,6 @@ package seng302.Networking.Messages;
|
|||||||
|
|
||||||
import seng302.Networking.Messages.Enums.MessageType;
|
import seng302.Networking.Messages.Enums.MessageType;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by fwy13 on 25/04/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Heartbeat message.
|
* Represents a Heartbeat message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package seng302;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GPS Coordinate for the world map.
|
* GPS Coordinate for the world map.
|
||||||
* Created by esa46 on 15/03/17.
|
* It is converted to a {@link seng302.GraphCoordinate GraphCoordinate} via
|
||||||
|
* the {@link seng302.RaceMap RaceMap} to display objects in their relative
|
||||||
|
* positions on the {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
|
||||||
*/
|
*/
|
||||||
public class GPSCoordinate {
|
public class GPSCoordinate {
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Graph Coordinate that is to be displayed on the Canvas
|
* It is a coordinate representing a location on the
|
||||||
* Created by cbt24 on 15/03/17.
|
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
|
||||||
|
* It has been converted from a {@link seng302.GPSCoordinate GPSCoordinate}
|
||||||
|
* to display objects in their relative positions.
|
||||||
*/
|
*/
|
||||||
public class GraphCoordinate {
|
public class GraphCoordinate {
|
||||||
private final int x;
|
private final int x;
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Read that reads the Boats that are goign to participate in the Race
|
* XML Reader that reads in a file and initializes
|
||||||
|
* {@link seng302.Mock.StreamedBoat StreamedBoat}s that will be participating
|
||||||
|
* in a race.
|
||||||
*/
|
*/
|
||||||
public class BoatXMLReader extends XMLReader {
|
public class BoatXMLReader extends XMLReader {
|
||||||
private final Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
|
private final Map<Integer, StreamedBoat> streamedBoatMap = new HashMap<>();
|
||||||
@@ -123,7 +125,8 @@ public class BoatXMLReader extends XMLReader {
|
|||||||
|
|
||||||
for (int i = 0; i < boat.getChildNodes().getLength(); i++) {
|
for (int i = 0; i < boat.getChildNodes().getLength(); i++) {
|
||||||
Node GPSPosition = boat.getChildNodes().item(i);
|
Node GPSPosition = boat.getChildNodes().item(i);
|
||||||
if (GPSPosition.getNodeName().equals("GPSposition")) readBoatPositionInformation(sourceID, GPSPosition);
|
if (GPSPosition.getNodeName().equals("GPSPosition"))
|
||||||
|
readBoatPositionInformation(sourceID, GPSPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,12 +134,13 @@ public class BoatXMLReader extends XMLReader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the positional information about a boat
|
* Reads the positional information about a boat
|
||||||
* Ignored values: FlagPosition, MastTop, Z value of GPSposition
|
* Ignored values: FlagPosition, MastTop, Z value of GPSPosition
|
||||||
* @param sourceID The source ID of the boat.
|
* @param sourceID The source ID of the boat.
|
||||||
* @param GPSPosition The relative GPS position of the boat.
|
* @param GPSPosition The relative GPS position of the boat.
|
||||||
*/
|
*/
|
||||||
private void readBoatPositionInformation(int sourceID, Node GPSPosition) {
|
private void readBoatPositionInformation(int sourceID, Node GPSPosition) {
|
||||||
// TODO Get relative point before implementing. (GPSposition is based off a relative point).
|
// TODO Get relative point before implementing. (GPSPosition is based
|
||||||
|
// off a relative point).
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -268,9 +268,10 @@ public class StreamedRace implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes an estimated time an event will occur, and converts it to the number of seconds before the event will occur.
|
* Takes an estimated time an event will occur, and converts it to the
|
||||||
|
* number of seconds before the event will occur.
|
||||||
*
|
*
|
||||||
* @param estTimeMillis
|
* @param estTimeMillis estimated time in milliseconds
|
||||||
* @return int difference between time the race started and the estimated time
|
* @return int difference between time the race started and the estimated time
|
||||||
*/
|
*/
|
||||||
private int convertEstTime(long estTimeMillis, long currentTime) {
|
private int convertEstTime(long estTimeMillis, long currentTime) {
|
||||||
|
|||||||
@@ -13,7 +13,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that processes user selected annotation visibility options to
|
* Class that processes user selected annotation visibility options to
|
||||||
* display the requested information on the race map.
|
* display the requested information on the
|
||||||
|
* {@link seng302.Model.ResizableRaceMap ResizbleRaceMap}. These are displayed
|
||||||
|
* via the {@link seng302.Controllers.RaceController RaceController}. <br>
|
||||||
|
* Annotation options for a {@link seng302.Model.Boat Boat} include: its name,
|
||||||
|
* abbreviation, speed, the time since it passed the last
|
||||||
|
* {@link seng302.Model.Marker Marker}, estimated time to the next marker,
|
||||||
|
* and a path it has travelled made up of
|
||||||
|
* {@link seng302.Model.TrackPoint TrackPoint}s.
|
||||||
*/
|
*/
|
||||||
public class Annotations {
|
public class Annotations {
|
||||||
private ResizableRaceCanvas raceMap;
|
private ResizableRaceCanvas raceMap;
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import java.util.Queue;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 3/03/17.
|
* This class is used to represent and store information about a boat which may
|
||||||
|
* travel around in a race. It is displayed on the
|
||||||
|
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas} via the
|
||||||
|
* {@link seng302.Controllers.RaceController RaceController}.
|
||||||
*/
|
*/
|
||||||
public class Boat {
|
public class Boat {
|
||||||
|
|
||||||
|
|||||||
@@ -1,310 +1,311 @@
|
|||||||
package seng302.Model;
|
//package seng302.Model;
|
||||||
|
//
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
//import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
//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.GPSCoordinate;
|
//import seng302.GPSCoordinate;
|
||||||
|
//
|
||||||
import java.awt.geom.Point2D;
|
//import java.awt.geom.Point2D;
|
||||||
import java.util.Queue;
|
//import java.util.Queue;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
//import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* Boat in the Race extends Boat.
|
// * Boat in the Race extends {@link seng302.Model.Boat Boat}.
|
||||||
* Created by esa46 on 15/03/17.
|
// * The extended properties are related to the boats current race position.
|
||||||
*/
|
// * @See seng302.Model.Boat
|
||||||
public class BoatInRace extends Boat {
|
// */
|
||||||
|
//public class BoatInRace extends Boat {
|
||||||
private Leg currentLeg;
|
//
|
||||||
private double scaledVelocity;
|
// private Leg currentLeg;
|
||||||
private double distanceTravelledInLeg;
|
// private double scaledVelocity;
|
||||||
private GPSCoordinate currentPosition;
|
// private double distanceTravelledInLeg;
|
||||||
private long timeFinished;
|
// private GPSCoordinate currentPosition;
|
||||||
private Color colour;
|
// private long timeFinished;
|
||||||
private boolean finished = false;
|
// private Color colour;
|
||||||
private final StringProperty currentLegName;
|
// private boolean finished = false;
|
||||||
private boolean started = false;
|
// private final StringProperty currentLegName;
|
||||||
private final StringProperty position;
|
// private boolean started = false;
|
||||||
private double heading;
|
// private final StringProperty position;
|
||||||
private static final double WAKE_SCALE = 10;
|
// private double heading;
|
||||||
|
// private static final double WAKE_SCALE = 10;
|
||||||
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
//
|
||||||
private long nextValidTime = 0;
|
// private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
||||||
|
// private long nextValidTime = 0;
|
||||||
private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
//
|
||||||
private static float trackPointTimeInterval = 5000; // every 1 seconds
|
// private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
||||||
|
// private static float trackPointTimeInterval = 5000; // every 1 seconds
|
||||||
/**
|
//
|
||||||
* Constructor method.
|
// /**
|
||||||
*
|
// * Constructor method.
|
||||||
* @param name Name of the boat.
|
// *
|
||||||
* @param velocity Speed that the boat travels.
|
// * @param name Name of the boat.
|
||||||
* @param colour Colour the boat will be displayed as on the map
|
// * @param velocity Speed that the boat travels.
|
||||||
* @param abbrev of boat
|
// * @param colour Colour the boat will be displayed as on the map
|
||||||
*/
|
// * @param abbrev of boat
|
||||||
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
// */
|
||||||
super(name, velocity, abbrev);
|
// public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
||||||
setColour(colour);
|
// super(name, velocity, abbrev);
|
||||||
currentLegName = new SimpleStringProperty("");
|
// setColour(colour);
|
||||||
position = new SimpleStringProperty("-");
|
// currentLegName = new SimpleStringProperty("");
|
||||||
}
|
// position = new SimpleStringProperty("-");
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Calculates the azimuth of the travel via map coordinates of the raceMarkers
|
// /**
|
||||||
*
|
// * Calculates the azimuth of the travel via map coordinates of the raceMarkers
|
||||||
* @return the direction that the boat is heading towards in degrees (-180 to 180).
|
// *
|
||||||
*/
|
// * @return the direction that the boat is heading towards in degrees (-180 to 180).
|
||||||
public double calculateAzimuth() {
|
// */
|
||||||
|
// public double calculateAzimuth() {
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
//
|
||||||
GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
// GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
// GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
||||||
|
// GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
||||||
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
//
|
||||||
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
// calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
||||||
|
// calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
||||||
return calc.getAzimuth();
|
//
|
||||||
}
|
// return calc.getAzimuth();
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Converts an azimuth to a bearing
|
// /**
|
||||||
*
|
// * Converts an azimuth to a bearing
|
||||||
* @param azimuth azimuth value to be converted
|
// *
|
||||||
* @return the bearings in degrees (0 to 360).
|
// * @param azimuth azimuth value to be converted
|
||||||
*/
|
// * @return the bearings in degrees (0 to 360).
|
||||||
private static double calculateHeading(double azimuth) {
|
// */
|
||||||
if (azimuth >= 0) {
|
// private static double calculateHeading(double azimuth) {
|
||||||
return azimuth;
|
// if (azimuth >= 0) {
|
||||||
} else {
|
// return azimuth;
|
||||||
return azimuth + 360;
|
// } else {
|
||||||
}
|
// return azimuth + 360;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
public double getHeading() {
|
//
|
||||||
return heading;
|
// public double getHeading() {
|
||||||
}
|
// return heading;
|
||||||
|
// }
|
||||||
public void setHeading(double heading) {
|
//
|
||||||
this.heading = heading;
|
// public void setHeading(double heading) {
|
||||||
}
|
// this.heading = heading;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Calculates the bearing of the travel via map coordinates of the raceMarkers
|
// /**
|
||||||
*
|
// * Calculates the bearing of the travel via map coordinates of the raceMarkers
|
||||||
* @return the direction that the boat is heading towards in degrees (0 to 360).
|
// *
|
||||||
*/
|
// * @return the direction that the boat is heading towards in degrees (0 to 360).
|
||||||
public double calculateHeading() {
|
// */
|
||||||
double azimuth = calculateAzimuth();
|
// public double calculateHeading() {
|
||||||
return calculateHeading(azimuth);
|
// double azimuth = calculateAzimuth();
|
||||||
}
|
// return calculateHeading(azimuth);
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Returns the position of the end of the boat's wake, which is 180 degrees
|
// /**
|
||||||
* from the boat's heading, and whose length is proportional to the boat's
|
// * Returns the position of the end of the boat's wake, which is 180 degrees
|
||||||
* speed.
|
// * from the boat's heading, and whose length is proportional to the boat's
|
||||||
*
|
// * speed.
|
||||||
* @return GPSCoordinate of wake endpoint.
|
// *
|
||||||
*/
|
// * @return GPSCoordinate of wake endpoint.
|
||||||
public GPSCoordinate getWake() {
|
// */
|
||||||
double reverseHeading = getHeading() - 180;
|
// public GPSCoordinate getWake() {
|
||||||
double distance = WAKE_SCALE * getVelocity();
|
// double reverseHeading = getHeading() - 180;
|
||||||
|
// double distance = WAKE_SCALE * getVelocity();
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
//
|
||||||
calc.setStartingGeographicPoint(
|
// GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude())
|
// calc.setStartingGeographicPoint(
|
||||||
);
|
// new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude())
|
||||||
calc.setDirection(reverseHeading, distance);
|
// );
|
||||||
Point2D endpoint = calc.getDestinationGeographicPoint();
|
// calc.setDirection(reverseHeading, distance);
|
||||||
return new GPSCoordinate(endpoint.getY(), endpoint.getX());
|
// Point2D endpoint = calc.getDestinationGeographicPoint();
|
||||||
}
|
// return new GPSCoordinate(endpoint.getY(), endpoint.getX());
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return Scaled velocity of the boat
|
// /**
|
||||||
*/
|
// * @return Scaled velocity of the boat
|
||||||
public double getScaledVelocity() {
|
// */
|
||||||
return scaledVelocity;
|
// public double getScaledVelocity() {
|
||||||
}
|
// return scaledVelocity;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the boat's scaled velocity
|
// /**
|
||||||
*
|
// * Sets the boat's scaled velocity
|
||||||
* @param velocity of boat
|
// *
|
||||||
*/
|
// * @param velocity of boat
|
||||||
public void setScaledVelocity(double velocity) {
|
// */
|
||||||
this.scaledVelocity = velocity;
|
// public void setScaledVelocity(double velocity) {
|
||||||
}
|
// this.scaledVelocity = velocity;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return Returns the current position of the boat in a GPSCoordinate Class.
|
// /**
|
||||||
* @see GPSCoordinate
|
// * @return Returns the current position of the boat in a GPSCoordinate Class.
|
||||||
*/
|
// * @see GPSCoordinate
|
||||||
public GPSCoordinate getCurrentPosition() {
|
// */
|
||||||
return currentPosition;
|
// public GPSCoordinate getCurrentPosition() {
|
||||||
}
|
// return currentPosition;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the current position on the GPS that the boat.
|
// /**
|
||||||
*
|
// * Sets the current position on the GPS that the boat.
|
||||||
* @param position GPSCoordinate of the position that the boat is currently on.
|
// *
|
||||||
* @see GPSCoordinate
|
// * @param position GPSCoordinate of the position that the boat is currently on.
|
||||||
*/
|
// * @see GPSCoordinate
|
||||||
public void setCurrentPosition(GPSCoordinate position) {
|
// */
|
||||||
this.currentPosition = position;
|
// public void setCurrentPosition(GPSCoordinate position) {
|
||||||
}
|
// this.currentPosition = position;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return Returns the time that the boat finished the race.
|
// /**
|
||||||
*/
|
// * @return Returns the time that the boat finished the race.
|
||||||
public long getTimeFinished() {
|
// */
|
||||||
return timeFinished;
|
// public long getTimeFinished() {
|
||||||
}
|
// return timeFinished;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the time that the boat finished the race.
|
// /**
|
||||||
*
|
// * Sets the time that the boat finished the race.
|
||||||
* @param timeFinished Time the boat finished the race.
|
// *
|
||||||
*/
|
// * @param timeFinished Time the boat finished the race.
|
||||||
public void setTimeFinished(long timeFinished) {
|
// */
|
||||||
this.timeFinished = timeFinished;
|
// public void setTimeFinished(long timeFinished) {
|
||||||
}
|
// this.timeFinished = timeFinished;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return Returns the colour of the boat.
|
// /**
|
||||||
*/
|
// * @return Returns the colour of the boat.
|
||||||
public Color getColour() {
|
// */
|
||||||
return colour;
|
// public Color getColour() {
|
||||||
}
|
// return colour;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas.
|
// /**
|
||||||
*
|
// * Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas.
|
||||||
* @param colour Colour that the boat is to be set to.
|
// *
|
||||||
* @see ResizableRaceCanvas
|
// * @param colour Colour that the boat is to be set to.
|
||||||
*/
|
// * @see ResizableRaceCanvas
|
||||||
private void setColour(Color colour) {
|
// */
|
||||||
this.colour = colour;
|
// private void setColour(Color colour) {
|
||||||
}
|
// this.colour = colour;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Gets the current leg that the boat is on.
|
// /**
|
||||||
*
|
// * Gets the current leg that the boat is on.
|
||||||
* @return returns the leg the boat is on in a Leg class
|
// *
|
||||||
* @see Leg
|
// * @return returns the leg the boat is on in a Leg class
|
||||||
*/
|
// * @see Leg
|
||||||
public Leg getCurrentLeg() {
|
// */
|
||||||
return currentLeg;
|
// public Leg getCurrentLeg() {
|
||||||
}
|
// return currentLeg;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the boat's current leg.
|
// /**
|
||||||
*
|
// * Sets the boat's current leg.
|
||||||
* @param currentLeg Leg class that the boat is currently on.
|
// *
|
||||||
* @see Leg
|
// * @param currentLeg Leg class that the boat is currently on.
|
||||||
*/
|
// * @see Leg
|
||||||
public void setCurrentLeg(Leg currentLeg) {
|
// */
|
||||||
this.currentLeg = currentLeg;
|
// public void setCurrentLeg(Leg currentLeg) {
|
||||||
this.currentLegName.setValue(currentLeg.getName());
|
// this.currentLeg = currentLeg;
|
||||||
}
|
// this.currentLegName.setValue(currentLeg.getName());
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return Name of boat's current leg
|
// /**
|
||||||
*/
|
// * @return Name of boat's current leg
|
||||||
public StringProperty getCurrentLegName() {
|
// */
|
||||||
return currentLegName;
|
// public StringProperty getCurrentLegName() {
|
||||||
}
|
// return currentLegName;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Gets the distance travelled by the boat in the leg.
|
// /**
|
||||||
*
|
// * Gets the distance travelled by the boat in the leg.
|
||||||
* @return Returns the value in nautical miles (1.852km) that the boat has traversed.
|
// *
|
||||||
*/
|
// * @return Returns the value in nautical miles (1.852km) that the boat has traversed.
|
||||||
public double getDistanceTravelledInLeg() {
|
// */
|
||||||
return distanceTravelledInLeg;
|
// public double getDistanceTravelledInLeg() {
|
||||||
}
|
// return distanceTravelledInLeg;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets the distance travelled by the boat in the leg in nautical miles (1.852km)
|
// /**
|
||||||
*
|
// * Sets the distance travelled by the boat in the leg in nautical miles (1.852km)
|
||||||
* @param distanceTravelledInLeg Distance travelled by the boat in nautical miles.
|
// *
|
||||||
*/
|
// * @param distanceTravelledInLeg Distance travelled by the boat in nautical miles.
|
||||||
public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
// */
|
||||||
this.distanceTravelledInLeg = distanceTravelledInLeg;
|
// public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
||||||
}
|
// this.distanceTravelledInLeg = distanceTravelledInLeg;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* @return true if boat has finished, false if not
|
// /**
|
||||||
*/
|
// * @return true if boat has finished, false if not
|
||||||
public boolean isFinished() {
|
// */
|
||||||
return this.finished;
|
// public boolean isFinished() {
|
||||||
}
|
// return this.finished;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Sets whether boat is finished or not
|
// /**
|
||||||
*
|
// * Sets whether boat is finished or not
|
||||||
* @param bool is finished value
|
// *
|
||||||
*/
|
// * @param bool is finished value
|
||||||
public void setFinished(boolean bool) {
|
// */
|
||||||
this.finished = bool;
|
// public void setFinished(boolean bool) {
|
||||||
}
|
// this.finished = bool;
|
||||||
|
// }
|
||||||
public boolean isStarted() {
|
//
|
||||||
return started;
|
// public boolean isStarted() {
|
||||||
}
|
// return started;
|
||||||
|
// }
|
||||||
public void setStarted(boolean started) {
|
//
|
||||||
this.started = started;
|
// public void setStarted(boolean started) {
|
||||||
}
|
// this.started = started;
|
||||||
|
// }
|
||||||
public String getPosition() {
|
//
|
||||||
return position.get();
|
// public String getPosition() {
|
||||||
}
|
// return position.get();
|
||||||
|
// }
|
||||||
public StringProperty positionProperty() {
|
//
|
||||||
return position;
|
// public StringProperty positionProperty() {
|
||||||
}
|
// return position;
|
||||||
|
// }
|
||||||
public void setPosition(String position) {
|
//
|
||||||
this.position.set(position);
|
// public void setPosition(String position) {
|
||||||
}
|
// this.position.set(position);
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Adds a new point to boat's track.
|
// /**
|
||||||
* @param coordinate of point on track
|
// * Adds a new point to boat's track.
|
||||||
* @see seng302.Model.TrackPoint
|
// * @param coordinate of point on track
|
||||||
*/
|
// * @see seng302.Model.TrackPoint
|
||||||
public void addTrackPoint(GPSCoordinate coordinate) {
|
// */
|
||||||
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
// public void addTrackPoint(GPSCoordinate coordinate) {
|
||||||
long currentTime = System.currentTimeMillis();
|
// Boolean added = System.currentTimeMillis() >= nextValidTime;
|
||||||
if (added && this.started) {
|
// long currentTime = System.currentTimeMillis();
|
||||||
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
// if (added && this.started) {
|
||||||
int TRACK_POINT_LIMIT = 10;
|
// nextValidTime = currentTime + (long) trackPointTimeInterval;
|
||||||
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
// int TRACK_POINT_LIMIT = 10;
|
||||||
}
|
// track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Returns the boat's sampled track between start of race and current time.
|
// /**
|
||||||
* @return queue of track points
|
// * Returns the boat's sampled track between start of race and current time.
|
||||||
* @see seng302.Model.TrackPoint
|
// * @return queue of track points
|
||||||
*/
|
// * @see seng302.Model.TrackPoint
|
||||||
public Queue<TrackPoint> getTrack() {
|
// */
|
||||||
return track;
|
// public Queue<TrackPoint> getTrack() {
|
||||||
}
|
// return track;
|
||||||
|
// }
|
||||||
/**
|
//
|
||||||
* Get base track point time interval
|
// /**
|
||||||
* @return base track point time interval
|
// * Get base track point time interval
|
||||||
*/
|
// * @return base track point time interval
|
||||||
public static float getBaseTrackPointTimeInterval() {
|
// */
|
||||||
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
|
// * Set track point time interval
|
||||||
*/
|
// * @param value track point time interval value
|
||||||
public static void setTrackPointTimeInterval(float value) {
|
// */
|
||||||
trackPointTimeInterval = value;
|
// public static void setTrackPointTimeInterval(float value) {
|
||||||
}
|
// trackPointTimeInterval = value;
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import org.geotools.referencing.GeodeticCalculator;
|
|||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cbt24 on 6/03/17.
|
* This class represents a leg, which is a portion of a race between two
|
||||||
|
* {@link seng302.Model.Marker Marker}s. A leg is used to identify a
|
||||||
|
* {@link seng302.Model.Boat Boat}'s progress through a race.
|
||||||
*/
|
*/
|
||||||
public class Leg {
|
public class Leg {
|
||||||
private final String name; //nautical miles
|
private final String name; //nautical miles
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import seng302.GPSCoordinate;
|
|||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by esa46 on 29/03/17.
|
* A marker on a race course that a boat can pass, to be displayed on the
|
||||||
|
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}. This is
|
||||||
|
* displayed via the {@link seng302.Controllers.RaceController RaceController}.
|
||||||
|
* <br>Markers are also used to calculate a {@link seng302.Model.Leg Leg}
|
||||||
|
* distance.
|
||||||
*/
|
*/
|
||||||
public class Marker {
|
public class Marker {
|
||||||
private final GPSCoordinate averageGPSCoordinate;
|
private final GPSCoordinate averageGPSCoordinate;
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ import java.time.temporal.ChronoUnit;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gondr on 19/04/2017.
|
* This class is used to implement a clock which keeps track of and
|
||||||
|
* displays times relevant to a race. This is displayed on the
|
||||||
|
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas} via the
|
||||||
|
* {@link seng302.Controllers.RaceController RaceController} and the
|
||||||
|
* {@link seng302.Controllers.StartController StartController}.
|
||||||
*/
|
*/
|
||||||
public class RaceClock implements Runnable {
|
public class RaceClock implements Runnable {
|
||||||
private long lastTime;
|
private long lastTime;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import javafx.scene.canvas.Canvas;
|
|||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 4/05/17.
|
* The abstract class for the resizable race canvases.
|
||||||
*/
|
*/
|
||||||
public abstract class ResizableCanvas extends Canvas {
|
public abstract class ResizableCanvas extends Canvas {
|
||||||
protected final GraphicsContext gc;
|
protected final GraphicsContext gc;
|
||||||
|
|||||||
@@ -16,9 +16,16 @@ import java.time.ZonedDateTime;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates a JavaFX Canvas that is fills it's parent.
|
* This JavaFX Canvas is used to update and display details for a
|
||||||
* Cannot be downsized.
|
* {@link seng302.RaceMap RaceMap} via the
|
||||||
* Created by fwy13 on 17/03/17.
|
* {@link seng302.Controllers.RaceController RaceController}.<br>
|
||||||
|
* It fills it's parent and cannot be downsized. <br>
|
||||||
|
* Details displayed include:
|
||||||
|
* {@link seng302.Model.Boat Boats} (and their
|
||||||
|
* {@link seng302.Model.TrackPoint TrackPoint}s),
|
||||||
|
* {@link seng302.Model.Marker Markers}, a
|
||||||
|
* {@link seng302.Model.RaceClock RaceClock}, a wind direction arrow and
|
||||||
|
* various user selected {@link seng302.Model.Annotations Annotations}.
|
||||||
*/
|
*/
|
||||||
public class ResizableRaceCanvas extends ResizableCanvas {
|
public class ResizableRaceCanvas extends ResizableCanvas {
|
||||||
private RaceMap map;
|
private RaceMap map;
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import seng302.RaceMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 4/05/17.
|
* This JavaFX Canvas is used to generate the size of a
|
||||||
|
* {@link seng302.RaceMap RaceMap} using co-ordinates from a
|
||||||
|
* {@link seng302.RaceDataSource RaceDataSource}. This is done via the
|
||||||
|
* {@link seng302.Controllers.RaceController RaceController}.
|
||||||
*/
|
*/
|
||||||
public class ResizableRaceMap extends ResizableCanvas {
|
public class ResizableRaceMap extends ResizableCanvas {
|
||||||
private RaceMap map;
|
private RaceMap map;
|
||||||
@@ -34,8 +37,8 @@ public class ResizableRaceMap extends ResizableCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the map race that it is auppost to be viewing.
|
* Sets the map race that it is supposed to be viewing.
|
||||||
* @param map
|
* @param map the map to be set
|
||||||
*/
|
*/
|
||||||
private void setMap(RaceMap map) {
|
private void setMap(RaceMap map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|||||||
@@ -12,7 +12,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to process and modify a sparkline display
|
* Class to process and modify a sparkline display. This display keeps visual
|
||||||
|
* track of {@link seng302.Model.Boat Boats}s in a race and their current
|
||||||
|
* placing position as they complete each {@link seng302.Model.Leg Leg} by
|
||||||
|
* passing a course {@link seng302.Model.Marker Marker}. <br>
|
||||||
|
* This sparkline is displayed using the
|
||||||
|
* {@link seng302.Controllers.RaceController RaceController}.
|
||||||
*/
|
*/
|
||||||
public class Sparkline {
|
public class Sparkline {
|
||||||
private ArrayList<String> colours;
|
private ArrayList<String> colours;
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ package seng302.Model;
|
|||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cbt24 on 7/04/17.
|
* A TrackPoint is a point plotted to display the track a
|
||||||
|
* {@link seng302.Model.Boat Boat} has travelled in a race. <br>
|
||||||
|
* TrackPoints are displayed on a
|
||||||
|
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}, via the
|
||||||
|
* {@link seng302.Controllers.RaceController RaceController}. <br>
|
||||||
|
* Track points can be made visible or hidden via the RaceController's
|
||||||
|
* {@link seng302.Model.Annotations Annotations}.
|
||||||
*/
|
*/
|
||||||
public class TrackPoint {
|
public class TrackPoint {
|
||||||
private final GPSCoordinate coordinate;
|
private final GPSCoordinate coordinate;
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import java.time.ZonedDateTime;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by connortaylorbrown on 19/04/17.
|
* An object that holds relevant data for a race. <br>
|
||||||
|
* Information includes: {@link seng302.Model.Boat Boat}s,
|
||||||
|
* {@link seng302.Model.Leg Leg}s, {@link seng302.Model.Marker Marker}s and
|
||||||
|
* the {@link seng302.GPSCoordinate GPSCoordinate}s to create a
|
||||||
|
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap}.
|
||||||
*/
|
*/
|
||||||
public interface RaceDataSource {
|
public interface RaceDataSource {
|
||||||
List<Boat> getBoats();
|
List<Boat> getBoats();
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by cbt24 on 15/03/17.
|
* The base size of the map to be used for the
|
||||||
|
* {@link seng302.Model.ResizableRaceMap ResizableRaceMap} and
|
||||||
|
* {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}. It is used
|
||||||
|
* to convert {@link seng302.GPSCoordinate GPSCoordinate}s to relative
|
||||||
|
* {@link seng302.GraphCoordinate GraphCoordinate}s.
|
||||||
*/
|
*/
|
||||||
public class RaceMap {
|
public class RaceMap {
|
||||||
private final double x1;
|
private final double x1;
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import java.util.Map;
|
|||||||
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
import static seng302.Networking.Utils.ByteConverter.bytesToShort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TCP client which receives packets/messages from a race data source (e.g., mock source, official source), and exposes them to any observers.
|
* TCP client which receives packets/messages from a race data source
|
||||||
|
* (e.g., mock source, official source), and exposes them to any observers.
|
||||||
|
* @see seng302.Mock.StreamedCourse
|
||||||
*/
|
*/
|
||||||
public class VisualiserInput implements Runnable {
|
public class VisualiserInput implements Runnable {
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by fwy13 on 26/03/2017.
|
* The abstract class for reading in XML race data.
|
||||||
*/
|
*/
|
||||||
public abstract class XMLReader {
|
public abstract class XMLReader {
|
||||||
|
|
||||||
|
|||||||
@@ -1,154 +1,149 @@
|
|||||||
package seng302.Model;
|
package seng302.Model;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
import org.junit.Test;
|
|
||||||
import seng302.GPSCoordinate;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by esa46 on 22/03/17.
|
* Tests various aspects of a boat in race perform correctly.
|
||||||
*/
|
*/
|
||||||
public class BoatInRaceTest {
|
public class BoatInRaceTest {
|
||||||
|
// TODO change this test to use Boat and not BoatInRace ??
|
||||||
|
// TODO delete BoatInRace class
|
||||||
|
|
||||||
|
// private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||||
private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
// private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueNorthAzimuthReturns0() {
|
||||||
public void calculateDueNorthAzimuthReturns0() {
|
//
|
||||||
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueSouthAzimuthReturns180() {
|
||||||
public void calculateDueSouthAzimuthReturns180() {
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueEastAzimuthReturns90() {
|
||||||
public void calculateDueEastAzimuthReturns90() {
|
//
|
||||||
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueWestAzimuthReturnsNegative90() {
|
||||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
//
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueNorthHeadingReturns0() {
|
||||||
public void calculateDueNorthHeadingReturns0() {
|
//
|
||||||
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueEastHeadingReturns90() {
|
||||||
public void calculateDueEastHeadingReturns90() {
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueSouthHeadingReturns180() {
|
||||||
public void calculateDueSouthHeadingReturns180() {
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void calculateDueWestHeadingReturns270() {
|
||||||
public void calculateDueWestHeadingReturns270() {
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
// Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
// TEST_BOAT.setCurrentLeg(start);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
// assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void createNewBoatCratesInstanceOfSuperClass() {
|
||||||
public void createNewBoatCratesInstanceOfSuperClass() {
|
//
|
||||||
|
// BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt");
|
||||||
BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt");
|
// testBoat.setName("Name can change");
|
||||||
testBoat.setName("Name can change");
|
// assertTrue(testBoat instanceof Boat);
|
||||||
assertTrue(testBoat instanceof Boat);
|
// assertTrue(testBoat.getCurrentLeg() == null);
|
||||||
assertTrue(testBoat.getCurrentLeg() == null);
|
// assertTrue(testBoat.getCurrentPosition() == null);
|
||||||
assertTrue(testBoat.getCurrentPosition() == null);
|
// assertTrue(testBoat.toString().contains("Name can change"));
|
||||||
assertTrue(testBoat.toString().contains("Name can change"));
|
// assertEquals(testBoat.getVelocity(), 20.0);
|
||||||
assertEquals(testBoat.getVelocity(), 20.0);
|
// assertTrue(testBoat.getVelocityProp().toString().contains("20"));
|
||||||
assertTrue(testBoat.getVelocityProp().toString().contains("20"));
|
// assertTrue(testBoat.getAbbrev().equals("tt"));
|
||||||
assertTrue(testBoat.getAbbrev().equals("tt"));
|
// assertTrue(testBoat.getColour().equals(Color.ALICEBLUE));
|
||||||
assertTrue(testBoat.getColour().equals(Color.ALICEBLUE));
|
// assertFalse(testBoat.isFinished());
|
||||||
assertFalse(testBoat.isFinished());
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void getWakeAtProperHeading() throws Exception {
|
||||||
public void getWakeAtProperHeading() throws Exception {
|
// BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
//
|
||||||
|
// // Construct leg of 0 degrees
|
||||||
// Construct leg of 0 degrees
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
// boat.setCurrentLeg(leg0deg);
|
||||||
boat.setCurrentLeg(leg0deg);
|
// boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
//
|
||||||
|
// assertEquals(0, boat.calculateHeading(), 1e-8);
|
||||||
assertEquals(0, boat.calculateHeading(), 1e-8);
|
//
|
||||||
|
// // Construct leg from wake - heading should be 180 degrees
|
||||||
// Construct leg from wake - heading should be 180 degrees
|
// Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0);
|
||||||
Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0);
|
// boat.setCurrentLeg(leg180deg);
|
||||||
boat.setCurrentLeg(leg180deg);
|
//
|
||||||
|
// assertEquals(180, boat.calculateHeading(), 1e-8);
|
||||||
assertEquals(180, boat.calculateHeading(), 1e-8);
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
@Test
|
// public void getWakeProportionalToVelocity() throws Exception {
|
||||||
public void getWakeProportionalToVelocity() throws Exception {
|
// BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
||||||
BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
//
|
||||||
|
// // Construct leg of 0 degrees at 0 N
|
||||||
// Construct leg of 0 degrees at 0 N
|
// Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
// Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
||||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
// boat.setCurrentLeg(leg0deg);
|
||||||
boat.setCurrentLeg(leg0deg);
|
// boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
//
|
||||||
|
// // Get latitude of endpoint of wake at 10 kn (longitude is 0)
|
||||||
// Get latitude of endpoint of wake at 10 kn (longitude is 0)
|
// double endpointAt10Kn = boat.getWake().getLatitude();
|
||||||
double endpointAt10Kn = boat.getWake().getLatitude();
|
//
|
||||||
|
// // Latitude of endpoint at 20 kn should be twice endpoint at 10 kn
|
||||||
// Latitude of endpoint at 20 kn should be twice endpoint at 10 kn
|
// boat.setVelocity(20);
|
||||||
boat.setVelocity(20);
|
// assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
|
||||||
assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8);
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,8 @@ import static junit.framework.TestCase.assertEquals;
|
|||||||
import static seng302.Model.Leg.NM_TO_METERS;
|
import static seng302.Model.Leg.NM_TO_METERS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by esa46 on 22/03/17.
|
* Tests that using a start and end mark initialises the correct leg between
|
||||||
|
* the markers.
|
||||||
*/
|
*/
|
||||||
public class LegTest {
|
public class LegTest {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user