diff --git a/mock/src/main/java/seng302/DataInput/PolarParser.java b/mock/src/main/java/seng302/DataInput/PolarParser.java index 59878edd..222cdbbf 100644 --- a/mock/src/main/java/seng302/DataInput/PolarParser.java +++ b/mock/src/main/java/seng302/DataInput/PolarParser.java @@ -1,9 +1,5 @@ package seng302.DataInput; -/** - * Created by hba56 on 10/05/17. - */ - import seng302.Exceptions.InvalidPolarFileException; import seng302.Model.Bearing; import seng302.Model.Polars; diff --git a/mock/src/main/java/seng302/Exceptions/InvalidBoatDataException.java b/mock/src/main/java/seng302/Exceptions/InvalidBoatDataException.java index 98250e2a..693103b7 100644 --- a/mock/src/main/java/seng302/Exceptions/InvalidBoatDataException.java +++ b/mock/src/main/java/seng302/Exceptions/InvalidBoatDataException.java @@ -1,9 +1,5 @@ package seng302.Exceptions; -/** - * Created by f123 on 25-Apr-17. - */ - /** * An exception thrown when we cannot generate Boats.xml and send an XML message. */ diff --git a/mock/src/main/java/seng302/Exceptions/InvalidPolarFileException.java b/mock/src/main/java/seng302/Exceptions/InvalidPolarFileException.java index cc997c67..d2e302e7 100644 --- a/mock/src/main/java/seng302/Exceptions/InvalidPolarFileException.java +++ b/mock/src/main/java/seng302/Exceptions/InvalidPolarFileException.java @@ -1,9 +1,5 @@ package seng302.Exceptions; -/** - * Created by f123 on 10-May-17. - */ - /** * An exception thrown when we cannot parse a polar data file. */ diff --git a/mock/src/main/java/seng302/Exceptions/InvalidRaceDataException.java b/mock/src/main/java/seng302/Exceptions/InvalidRaceDataException.java index 11e4fcfc..2b99a549 100644 --- a/mock/src/main/java/seng302/Exceptions/InvalidRaceDataException.java +++ b/mock/src/main/java/seng302/Exceptions/InvalidRaceDataException.java @@ -1,9 +1,5 @@ package seng302.Exceptions; -/** - * Created by f123 on 25-Apr-17. - */ - /** * Exception thrown when we cannot generate Race.xml data, and send an XML message. */ diff --git a/mock/src/main/java/seng302/Model/GPSCoordinate.java b/mock/src/main/java/seng302/Model/GPSCoordinate.java index 14f9dc34..2b80eb65 100644 --- a/mock/src/main/java/seng302/Model/GPSCoordinate.java +++ b/mock/src/main/java/seng302/Model/GPSCoordinate.java @@ -92,7 +92,7 @@ public class GPSCoordinate { /** * Calculates min and max values and passed it to calculate if coordinate is in the boundary * @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 */ public static boolean isInsideBoundary(GPSCoordinate coordinate, List boundary) { @@ -139,7 +139,7 @@ public class GPSCoordinate { /** * Helper function to find if a point is in a 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. * @return true if a line from the point intersects the two boundary points */ @@ -307,7 +307,7 @@ public class GPSCoordinate { List> 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); 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. Repeat for all edges. 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); //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. - GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing)); - GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing)); + GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing)); + GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing)); //Add edge to list. shrunkEdges.add(new Pair<>(firstPointTranslated, secondPointTranslated)); @@ -357,11 +357,11 @@ public class GPSCoordinate { Bearing bearing = GPSCoordinate.calculateBearing(firstPoint, secondPoint); //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. - GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing)); - GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpindicularBearing)); + GPSCoordinate firstPointTranslated = GPSCoordinate.calculateNewPosition(firstPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing)); + GPSCoordinate secondPointTranslated = GPSCoordinate.calculateNewPosition(secondPoint, shrinkDistance, Azimuth.fromBearing(perpendicularBearing)); //Add edge to list. 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. - * @param boundary The list of coodinates. + * @param boundary The list of coordinates. * @return True if clockwise, false if anti-clockwise. */ public static boolean isClockwisePolygon(List boundary) { - /** 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) + /* 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) point[0] = (5,0) edge[0]: (6-5)(4+0) = 4 point[1] = (6,4) edge[1]: (4-6)(5+4) = -18 point[2] = (4,5) edge[2]: (1-4)(5+5) = -30 diff --git a/mock/src/main/java/seng302/Model/Polars.java b/mock/src/main/java/seng302/Model/Polars.java index cf7d448d..dc770e8d 100644 --- a/mock/src/main/java/seng302/Model/Polars.java +++ b/mock/src/main/java/seng302/Model/Polars.java @@ -4,10 +4,6 @@ import javafx.util.Pair; import java.util.*; -/** - * Created by hba56 on 10/05/17. - */ - /** * Encapsulates an entire polar table. Has a function to calculate VMG. */ diff --git a/mock/src/main/java/seng302/Model/VMG.java b/mock/src/main/java/seng302/Model/VMG.java index 67bc5297..b431ae06 100644 --- a/mock/src/main/java/seng302/Model/VMG.java +++ b/mock/src/main/java/seng302/Model/VMG.java @@ -1,9 +1,5 @@ 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. */ diff --git a/mock/src/test/java/seng302/DataInput/PolarParserTest.java b/mock/src/test/java/seng302/DataInput/PolarParserTest.java index 85d44435..b10adece 100644 --- a/mock/src/test/java/seng302/DataInput/PolarParserTest.java +++ b/mock/src/test/java/seng302/DataInput/PolarParserTest.java @@ -13,8 +13,8 @@ import static org.testng.Assert.*; public class PolarParserTest { @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 { diff --git a/network/src/main/java/seng302/Networking/BinaryMessageDecoder.java b/network/src/main/java/seng302/Networking/BinaryMessageDecoder.java index 0e7eb8f6..1564bcd0 100644 --- a/network/src/main/java/seng302/Networking/BinaryMessageDecoder.java +++ b/network/src/main/java/seng302/Networking/BinaryMessageDecoder.java @@ -10,10 +10,6 @@ import java.nio.ByteBuffer; import java.util.Arrays; 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. */ @@ -187,7 +183,7 @@ public class BinaryMessageDecoder { return mrDecoder.getMarkRounding(); case COURSEWIND: - //System.out.println("Couse Wind Message!"); + //System.out.println("Course Wind Message!"); CourseWindDecoder cwDecoder = new CourseWindDecoder(messageBody); return new CourseWinds(cwDecoder.getMessageVersionNumber(), cwDecoder.getByteWindID(), cwDecoder.getLoopMessages()); diff --git a/network/src/main/java/seng302/Networking/BinaryMessageEncoder.java b/network/src/main/java/seng302/Networking/BinaryMessageEncoder.java index 8a8d3db6..e0de7184 100644 --- a/network/src/main/java/seng302/Networking/BinaryMessageEncoder.java +++ b/network/src/main/java/seng302/Networking/BinaryMessageEncoder.java @@ -10,10 +10,6 @@ import static seng302.Networking.Utils.ByteConverter.intToBytes; import static seng302.Networking.Utils.ByteConverter.longToBytes; 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. */ diff --git a/network/src/main/java/seng302/Networking/Exceptions/InvalidMessageException.java b/network/src/main/java/seng302/Networking/Exceptions/InvalidMessageException.java index 3296067e..0eb9e8f9 100644 --- a/network/src/main/java/seng302/Networking/Exceptions/InvalidMessageException.java +++ b/network/src/main/java/seng302/Networking/Exceptions/InvalidMessageException.java @@ -1,9 +1,5 @@ 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...). */ diff --git a/network/src/main/java/seng302/Networking/Messages/AC35Data.java b/network/src/main/java/seng302/Networking/Messages/AC35Data.java index 0291064d..a42a92be 100644 --- a/network/src/main/java/seng302/Networking/Messages/AC35Data.java +++ b/network/src/main/java/seng302/Networking/Messages/AC35Data.java @@ -1,10 +1,6 @@ package seng302.Networking.Messages; -/** - * Created by fwy13 on 25/04/17. - */ - import seng302.Networking.Messages.Enums.MessageType; /** diff --git a/network/src/main/java/seng302/Networking/Messages/BoatLocation.java b/network/src/main/java/seng302/Networking/Messages/BoatLocation.java index 2763e658..85f9891e 100644 --- a/network/src/main/java/seng302/Networking/Messages/BoatLocation.java +++ b/network/src/main/java/seng302/Networking/Messages/BoatLocation.java @@ -1,9 +1,5 @@ package seng302.Networking.Messages; -/** - * Created by f123 on 21-Apr-17. - */ - import seng302.Networking.Messages.Enums.MessageType; import seng302.Networking.Utils.AC35UnitConverter; diff --git a/network/src/main/java/seng302/Networking/Messages/Enums/BoatStatusEnum.java b/network/src/main/java/seng302/Networking/Messages/Enums/BoatStatusEnum.java index 06b13fc4..8e8f06b2 100644 --- a/network/src/main/java/seng302/Networking/Messages/Enums/BoatStatusEnum.java +++ b/network/src/main/java/seng302/Networking/Messages/Enums/BoatStatusEnum.java @@ -3,10 +3,6 @@ package seng302.Networking.Messages.Enums; import java.util.HashMap; import java.util.Map; -/** - * Created by esa46 on 28/04/17. - */ - /** * Enumeration that encapsulates the various statuses a boat can have. */ @@ -46,8 +42,8 @@ public enum BoatStatusEnum { private static final Map byteToStatusMap = new HashMap<>(); - /** - * Static initialization block. Initializes the byteToStatusMap. + /* + Static initialization block. Initializes the byteToStatusMap. */ static { for (BoatStatusEnum type : BoatStatusEnum.values()) { diff --git a/network/src/main/java/seng302/Networking/Messages/Enums/MessageType.java b/network/src/main/java/seng302/Networking/Messages/Enums/MessageType.java index 22c38d4a..84ab6a0a 100644 --- a/network/src/main/java/seng302/Networking/Messages/Enums/MessageType.java +++ b/network/src/main/java/seng302/Networking/Messages/Enums/MessageType.java @@ -1,9 +1,5 @@ package seng302.Networking.Messages.Enums; -/** - * Created by hba56 on 21/04/17. - */ - import java.util.HashMap; import java.util.Map; @@ -49,8 +45,8 @@ public enum MessageType { private static final Map byteToTypeMap = new HashMap<>(); - /** - * Static initialization block. Initializes the byteToTypeMap. + /* + Static initialization block. Initializes the byteToTypeMap. */ static { for (MessageType type : MessageType.values()) { diff --git a/network/src/main/java/seng302/Networking/Messages/Enums/RaceStatusEnum.java b/network/src/main/java/seng302/Networking/Messages/Enums/RaceStatusEnum.java index 2563545d..3904eb58 100644 --- a/network/src/main/java/seng302/Networking/Messages/Enums/RaceStatusEnum.java +++ b/network/src/main/java/seng302/Networking/Messages/Enums/RaceStatusEnum.java @@ -76,8 +76,8 @@ public enum RaceStatusEnum { private static final Map byteToStatusMap = new HashMap<>(); - /** - * Static initialization block. Initializes the byteToStatusMap. + /* + Static initialization block. Initializes the byteToStatusMap. */ static { for (RaceStatusEnum type : RaceStatusEnum.values()) { diff --git a/network/src/main/java/seng302/Networking/Messages/Enums/RaceTypeEnum.java b/network/src/main/java/seng302/Networking/Messages/Enums/RaceTypeEnum.java index 01c1539e..57bfa0cf 100644 --- a/network/src/main/java/seng302/Networking/Messages/Enums/RaceTypeEnum.java +++ b/network/src/main/java/seng302/Networking/Messages/Enums/RaceTypeEnum.java @@ -54,8 +54,8 @@ public enum RaceTypeEnum { private static final Map byteToStatusMap = new HashMap<>(); - /** - * Static initialization block. Initializes the byteToStatusMap. + /* + Static initialization block. Initializes the byteToStatusMap. */ static { for (RaceTypeEnum type : RaceTypeEnum.values()) { diff --git a/network/src/main/java/seng302/Networking/Messages/Heartbeat.java b/network/src/main/java/seng302/Networking/Messages/Heartbeat.java index c54f2f08..3a8c960c 100644 --- a/network/src/main/java/seng302/Networking/Messages/Heartbeat.java +++ b/network/src/main/java/seng302/Networking/Messages/Heartbeat.java @@ -2,10 +2,6 @@ package seng302.Networking.Messages; import seng302.Networking.Messages.Enums.MessageType; -/** - * Created by fwy13 on 25/04/17. - */ - /** * Represents a Heartbeat message. */ diff --git a/visualiser/src/main/java/seng302/GPSCoordinate.java b/visualiser/src/main/java/seng302/GPSCoordinate.java index 0da61471..96519dbe 100644 --- a/visualiser/src/main/java/seng302/GPSCoordinate.java +++ b/visualiser/src/main/java/seng302/GPSCoordinate.java @@ -2,7 +2,9 @@ package seng302; /** * 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 { diff --git a/visualiser/src/main/java/seng302/GraphCoordinate.java b/visualiser/src/main/java/seng302/GraphCoordinate.java index 458052dc..2b4523cc 100644 --- a/visualiser/src/main/java/seng302/GraphCoordinate.java +++ b/visualiser/src/main/java/seng302/GraphCoordinate.java @@ -1,8 +1,10 @@ package seng302; /** - * Graph Coordinate that is to be displayed on the Canvas - * Created by cbt24 on 15/03/17. + * It is a coordinate representing a location on the + * {@link seng302.Model.ResizableRaceMap ResizableRaceMap}. + * It has been converted from a {@link seng302.GPSCoordinate GPSCoordinate} + * to display objects in their relative positions. */ public class GraphCoordinate { private final int x; diff --git a/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java b/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java index b7778c8e..f48b1b4d 100644 --- a/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java +++ b/visualiser/src/main/java/seng302/Mock/BoatXMLReader.java @@ -15,7 +15,9 @@ import java.util.List; 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 { private final Map streamedBoatMap = new HashMap<>(); @@ -123,7 +125,8 @@ public class BoatXMLReader extends XMLReader { for (int i = 0; i < boat.getChildNodes().getLength(); 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 - * 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 GPSPosition The relative GPS position of the boat. */ private void readBoatPositionInformation(int sourceID, Node GPSPosition) { - // TODO Get relative point before implementing. (GPSposition is based off a relative point). + // TODO Get relative point before implementing. (GPSPosition is based + // off a relative point). } /** diff --git a/visualiser/src/main/java/seng302/Mock/StreamedRace.java b/visualiser/src/main/java/seng302/Mock/StreamedRace.java index 7cd29c6e..9098e0bd 100644 --- a/visualiser/src/main/java/seng302/Mock/StreamedRace.java +++ b/visualiser/src/main/java/seng302/Mock/StreamedRace.java @@ -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 */ private int convertEstTime(long estTimeMillis, long currentTime) { diff --git a/visualiser/src/main/java/seng302/Model/Annotations.java b/visualiser/src/main/java/seng302/Model/Annotations.java index de4be5c2..b4f58260 100644 --- a/visualiser/src/main/java/seng302/Model/Annotations.java +++ b/visualiser/src/main/java/seng302/Model/Annotations.java @@ -13,7 +13,14 @@ import java.util.Map; /** * 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}.
+ * Annotation options for a {@link seng302.Model.Boat Boat} include: its name, + * abbreviation, speed, the time since it passed the last + * {@link seng302.Model.Marker Marker}, estimated time to the next marker, + * and a path it has travelled made up of + * {@link seng302.Model.TrackPoint TrackPoint}s. */ public class Annotations { private ResizableRaceCanvas raceMap; diff --git a/visualiser/src/main/java/seng302/Model/Boat.java b/visualiser/src/main/java/seng302/Model/Boat.java index c9765107..3d0613ca 100644 --- a/visualiser/src/main/java/seng302/Model/Boat.java +++ b/visualiser/src/main/java/seng302/Model/Boat.java @@ -11,7 +11,10 @@ import java.util.Queue; 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 { diff --git a/visualiser/src/main/java/seng302/Model/BoatInRace.java b/visualiser/src/main/java/seng302/Model/BoatInRace.java index 39087177..b949900e 100644 --- a/visualiser/src/main/java/seng302/Model/BoatInRace.java +++ b/visualiser/src/main/java/seng302/Model/BoatInRace.java @@ -1,310 +1,311 @@ -package seng302.Model; - -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.scene.paint.Color; -import org.geotools.referencing.GeodeticCalculator; -import seng302.GPSCoordinate; - -import java.awt.geom.Point2D; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * Boat in the Race extends Boat. - * Created by esa46 on 15/03/17. - */ -public class BoatInRace extends Boat { - - private Leg currentLeg; - private double scaledVelocity; - private double distanceTravelledInLeg; - private GPSCoordinate currentPosition; - private long timeFinished; - private Color colour; - private boolean finished = false; - private final StringProperty currentLegName; - private boolean started = false; - private final StringProperty position; - private double heading; - private static final double WAKE_SCALE = 10; - - private final Queue track = new ConcurrentLinkedQueue<>(); - private long nextValidTime = 0; - - private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000; - private static float trackPointTimeInterval = 5000; // every 1 seconds - - /** - * Constructor method. - * - * @param name Name of the boat. - * @param velocity Speed that the boat travels. - * @param colour Colour the boat will be displayed as on the map - * @param abbrev of boat - */ - public BoatInRace(String name, double velocity, Color colour, String abbrev) { - super(name, velocity, abbrev); - setColour(colour); - currentLegName = new SimpleStringProperty(""); - position = new SimpleStringProperty("-"); - } - - /** - * Calculates the azimuth of the travel via map coordinates of the raceMarkers - * - * @return the direction that the boat is heading towards in degrees (-180 to 180). - */ - public double calculateAzimuth() { - - GeodeticCalculator calc = new GeodeticCalculator(); - GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate(); - GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate(); - - calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude()); - calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude()); - - return calc.getAzimuth(); - } - - /** - * Converts an azimuth to a bearing - * - * @param azimuth azimuth value to be converted - * @return the bearings in degrees (0 to 360). - */ - private static double calculateHeading(double azimuth) { - if (azimuth >= 0) { - return azimuth; - } else { - return azimuth + 360; - } - } - - public double getHeading() { - return heading; - } - - public void setHeading(double heading) { - this.heading = heading; - } - - /** - * Calculates the bearing of the travel via map coordinates of the raceMarkers - * - * @return the direction that the boat is heading towards in degrees (0 to 360). - */ - public double calculateHeading() { - double azimuth = calculateAzimuth(); - return calculateHeading(azimuth); - } - - /** - * Returns the position of the end of the boat's wake, which is 180 degrees - * from the boat's heading, and whose length is proportional to the boat's - * speed. - * - * @return GPSCoordinate of wake endpoint. - */ - public GPSCoordinate getWake() { - double reverseHeading = getHeading() - 180; - double distance = WAKE_SCALE * getVelocity(); - - GeodeticCalculator calc = new GeodeticCalculator(); - calc.setStartingGeographicPoint( - new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude()) - ); - calc.setDirection(reverseHeading, distance); - Point2D endpoint = calc.getDestinationGeographicPoint(); - return new GPSCoordinate(endpoint.getY(), endpoint.getX()); - } - - /** - * @return Scaled velocity of the boat - */ - public double getScaledVelocity() { - return scaledVelocity; - } - - /** - * Sets the boat's scaled velocity - * - * @param velocity of boat - */ - public void setScaledVelocity(double velocity) { - this.scaledVelocity = velocity; - } - - /** - * @return Returns the current position of the boat in a GPSCoordinate Class. - * @see GPSCoordinate - */ - public GPSCoordinate getCurrentPosition() { - return currentPosition; - } - - /** - * Sets the current position on the GPS that the boat. - * - * @param position GPSCoordinate of the position that the boat is currently on. - * @see GPSCoordinate - */ - public void setCurrentPosition(GPSCoordinate position) { - this.currentPosition = position; - } - - /** - * @return Returns the time that the boat finished the race. - */ - public long getTimeFinished() { - return timeFinished; - } - - /** - * Sets the time that the boat finished the race. - * - * @param timeFinished Time the boat finished the race. - */ - public void setTimeFinished(long timeFinished) { - this.timeFinished = timeFinished; - } - - /** - * @return Returns the colour of the boat. - */ - public Color getColour() { - return colour; - } - - /** - * Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas. - * - * @param colour Colour that the boat is to be set to. - * @see ResizableRaceCanvas - */ - private void setColour(Color colour) { - this.colour = colour; - } - - /** - * Gets the current leg that the boat is on. - * - * @return returns the leg the boat is on in a Leg class - * @see Leg - */ - public Leg getCurrentLeg() { - return currentLeg; - } - - /** - * Sets the boat's current leg. - * - * @param currentLeg Leg class that the boat is currently on. - * @see Leg - */ - public void setCurrentLeg(Leg currentLeg) { - this.currentLeg = currentLeg; - this.currentLegName.setValue(currentLeg.getName()); - } - - /** - * @return Name of boat's current leg - */ - public StringProperty getCurrentLegName() { - return currentLegName; - } - - /** - * Gets the distance travelled by the boat in the leg. - * - * @return Returns the value in nautical miles (1.852km) that the boat has traversed. - */ - public double getDistanceTravelledInLeg() { - return distanceTravelledInLeg; - } - - /** - * Sets the distance travelled by the boat in the leg in nautical miles (1.852km) - * - * @param distanceTravelledInLeg Distance travelled by the boat in nautical miles. - */ - public void setDistanceTravelledInLeg(double distanceTravelledInLeg) { - this.distanceTravelledInLeg = distanceTravelledInLeg; - } - - /** - * @return true if boat has finished, false if not - */ - public boolean isFinished() { - return this.finished; - } - - /** - * Sets whether boat is finished or not - * - * @param bool is finished value - */ - public void setFinished(boolean bool) { - this.finished = bool; - } - - public boolean isStarted() { - return started; - } - - public void setStarted(boolean started) { - this.started = started; - } - - public String getPosition() { - return position.get(); - } - - public StringProperty positionProperty() { - return position; - } - - public void setPosition(String position) { - this.position.set(position); - } - - /** - * Adds a new point to boat's track. - * @param coordinate of point on track - * @see seng302.Model.TrackPoint - */ - public void addTrackPoint(GPSCoordinate coordinate) { - Boolean added = System.currentTimeMillis() >= nextValidTime; - long currentTime = System.currentTimeMillis(); - if (added && this.started) { - nextValidTime = currentTime + (long) trackPointTimeInterval; - int TRACK_POINT_LIMIT = 10; - track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval)); - } - } - - /** - * Returns the boat's sampled track between start of race and current time. - * @return queue of track points - * @see seng302.Model.TrackPoint - */ - public Queue getTrack() { - return track; - } - - /** - * Get base track point time interval - * @return base track point time interval - */ - public static float getBaseTrackPointTimeInterval() { - return BASE_TRACK_POINT_TIME_INTERVAL; - } - - /** - * Set track point time interval - * @param value track point time interval value - */ - public static void setTrackPointTimeInterval(float value) { - trackPointTimeInterval = value; - } -} +//package seng302.Model; +// +//import javafx.beans.property.SimpleStringProperty; +//import javafx.beans.property.StringProperty; +//import javafx.scene.paint.Color; +//import org.geotools.referencing.GeodeticCalculator; +//import seng302.GPSCoordinate; +// +//import java.awt.geom.Point2D; +//import java.util.Queue; +//import java.util.concurrent.ConcurrentLinkedQueue; +// +///** +// * Boat in the Race extends {@link seng302.Model.Boat Boat}. +// * The extended properties are related to the boats current race position. +// * @See seng302.Model.Boat +// */ +//public class BoatInRace extends Boat { +// +// private Leg currentLeg; +// private double scaledVelocity; +// private double distanceTravelledInLeg; +// private GPSCoordinate currentPosition; +// private long timeFinished; +// private Color colour; +// private boolean finished = false; +// private final StringProperty currentLegName; +// private boolean started = false; +// private final StringProperty position; +// private double heading; +// private static final double WAKE_SCALE = 10; +// +// private final Queue track = new ConcurrentLinkedQueue<>(); +// private long nextValidTime = 0; +// +// private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000; +// private static float trackPointTimeInterval = 5000; // every 1 seconds +// +// /** +// * Constructor method. +// * +// * @param name Name of the boat. +// * @param velocity Speed that the boat travels. +// * @param colour Colour the boat will be displayed as on the map +// * @param abbrev of boat +// */ +// public BoatInRace(String name, double velocity, Color colour, String abbrev) { +// super(name, velocity, abbrev); +// setColour(colour); +// currentLegName = new SimpleStringProperty(""); +// position = new SimpleStringProperty("-"); +// } +// +// /** +// * Calculates the azimuth of the travel via map coordinates of the raceMarkers +// * +// * @return the direction that the boat is heading towards in degrees (-180 to 180). +// */ +// public double calculateAzimuth() { +// +// GeodeticCalculator calc = new GeodeticCalculator(); +// GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate(); +// GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate(); +// +// calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude()); +// calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude()); +// +// return calc.getAzimuth(); +// } +// +// /** +// * Converts an azimuth to a bearing +// * +// * @param azimuth azimuth value to be converted +// * @return the bearings in degrees (0 to 360). +// */ +// private static double calculateHeading(double azimuth) { +// if (azimuth >= 0) { +// return azimuth; +// } else { +// return azimuth + 360; +// } +// } +// +// public double getHeading() { +// return heading; +// } +// +// public void setHeading(double heading) { +// this.heading = heading; +// } +// +// /** +// * Calculates the bearing of the travel via map coordinates of the raceMarkers +// * +// * @return the direction that the boat is heading towards in degrees (0 to 360). +// */ +// public double calculateHeading() { +// double azimuth = calculateAzimuth(); +// return calculateHeading(azimuth); +// } +// +// /** +// * Returns the position of the end of the boat's wake, which is 180 degrees +// * from the boat's heading, and whose length is proportional to the boat's +// * speed. +// * +// * @return GPSCoordinate of wake endpoint. +// */ +// public GPSCoordinate getWake() { +// double reverseHeading = getHeading() - 180; +// double distance = WAKE_SCALE * getVelocity(); +// +// GeodeticCalculator calc = new GeodeticCalculator(); +// calc.setStartingGeographicPoint( +// new Point2D.Double(getCurrentPosition().getLongitude(), getCurrentPosition().getLatitude()) +// ); +// calc.setDirection(reverseHeading, distance); +// Point2D endpoint = calc.getDestinationGeographicPoint(); +// return new GPSCoordinate(endpoint.getY(), endpoint.getX()); +// } +// +// /** +// * @return Scaled velocity of the boat +// */ +// public double getScaledVelocity() { +// return scaledVelocity; +// } +// +// /** +// * Sets the boat's scaled velocity +// * +// * @param velocity of boat +// */ +// public void setScaledVelocity(double velocity) { +// this.scaledVelocity = velocity; +// } +// +// /** +// * @return Returns the current position of the boat in a GPSCoordinate Class. +// * @see GPSCoordinate +// */ +// public GPSCoordinate getCurrentPosition() { +// return currentPosition; +// } +// +// /** +// * Sets the current position on the GPS that the boat. +// * +// * @param position GPSCoordinate of the position that the boat is currently on. +// * @see GPSCoordinate +// */ +// public void setCurrentPosition(GPSCoordinate position) { +// this.currentPosition = position; +// } +// +// /** +// * @return Returns the time that the boat finished the race. +// */ +// public long getTimeFinished() { +// return timeFinished; +// } +// +// /** +// * Sets the time that the boat finished the race. +// * +// * @param timeFinished Time the boat finished the race. +// */ +// public void setTimeFinished(long timeFinished) { +// this.timeFinished = timeFinished; +// } +// +// /** +// * @return Returns the colour of the boat. +// */ +// public Color getColour() { +// return colour; +// } +// +// /** +// * Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas. +// * +// * @param colour Colour that the boat is to be set to. +// * @see ResizableRaceCanvas +// */ +// private void setColour(Color colour) { +// this.colour = colour; +// } +// +// /** +// * Gets the current leg that the boat is on. +// * +// * @return returns the leg the boat is on in a Leg class +// * @see Leg +// */ +// public Leg getCurrentLeg() { +// return currentLeg; +// } +// +// /** +// * Sets the boat's current leg. +// * +// * @param currentLeg Leg class that the boat is currently on. +// * @see Leg +// */ +// public void setCurrentLeg(Leg currentLeg) { +// this.currentLeg = currentLeg; +// this.currentLegName.setValue(currentLeg.getName()); +// } +// +// /** +// * @return Name of boat's current leg +// */ +// public StringProperty getCurrentLegName() { +// return currentLegName; +// } +// +// /** +// * Gets the distance travelled by the boat in the leg. +// * +// * @return Returns the value in nautical miles (1.852km) that the boat has traversed. +// */ +// public double getDistanceTravelledInLeg() { +// return distanceTravelledInLeg; +// } +// +// /** +// * Sets the distance travelled by the boat in the leg in nautical miles (1.852km) +// * +// * @param distanceTravelledInLeg Distance travelled by the boat in nautical miles. +// */ +// public void setDistanceTravelledInLeg(double distanceTravelledInLeg) { +// this.distanceTravelledInLeg = distanceTravelledInLeg; +// } +// +// /** +// * @return true if boat has finished, false if not +// */ +// public boolean isFinished() { +// return this.finished; +// } +// +// /** +// * Sets whether boat is finished or not +// * +// * @param bool is finished value +// */ +// public void setFinished(boolean bool) { +// this.finished = bool; +// } +// +// public boolean isStarted() { +// return started; +// } +// +// public void setStarted(boolean started) { +// this.started = started; +// } +// +// public String getPosition() { +// return position.get(); +// } +// +// public StringProperty positionProperty() { +// return position; +// } +// +// public void setPosition(String position) { +// this.position.set(position); +// } +// +// /** +// * Adds a new point to boat's track. +// * @param coordinate of point on track +// * @see seng302.Model.TrackPoint +// */ +// public void addTrackPoint(GPSCoordinate coordinate) { +// Boolean added = System.currentTimeMillis() >= nextValidTime; +// long currentTime = System.currentTimeMillis(); +// if (added && this.started) { +// nextValidTime = currentTime + (long) trackPointTimeInterval; +// int TRACK_POINT_LIMIT = 10; +// track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval)); +// } +// } +// +// /** +// * Returns the boat's sampled track between start of race and current time. +// * @return queue of track points +// * @see seng302.Model.TrackPoint +// */ +// public Queue getTrack() { +// return track; +// } +// +// /** +// * Get base track point time interval +// * @return base track point time interval +// */ +// public static float getBaseTrackPointTimeInterval() { +// return BASE_TRACK_POINT_TIME_INTERVAL; +// } +// +// /** +// * Set track point time interval +// * @param value track point time interval value +// */ +// public static void setTrackPointTimeInterval(float value) { +// trackPointTimeInterval = value; +// } +//} diff --git a/visualiser/src/main/java/seng302/Model/Leg.java b/visualiser/src/main/java/seng302/Model/Leg.java index 61a4d63b..92b6117a 100644 --- a/visualiser/src/main/java/seng302/Model/Leg.java +++ b/visualiser/src/main/java/seng302/Model/Leg.java @@ -4,7 +4,9 @@ import org.geotools.referencing.GeodeticCalculator; 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 { private final String name; //nautical miles diff --git a/visualiser/src/main/java/seng302/Model/Marker.java b/visualiser/src/main/java/seng302/Model/Marker.java index 567af254..7c0b7296 100644 --- a/visualiser/src/main/java/seng302/Model/Marker.java +++ b/visualiser/src/main/java/seng302/Model/Marker.java @@ -6,7 +6,11 @@ import seng302.GPSCoordinate; 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}. + *
Markers are also used to calculate a {@link seng302.Model.Leg Leg} + * distance. */ public class Marker { private final GPSCoordinate averageGPSCoordinate; diff --git a/visualiser/src/main/java/seng302/Model/RaceClock.java b/visualiser/src/main/java/seng302/Model/RaceClock.java index 1e36224d..1800a239 100644 --- a/visualiser/src/main/java/seng302/Model/RaceClock.java +++ b/visualiser/src/main/java/seng302/Model/RaceClock.java @@ -16,7 +16,11 @@ import java.time.temporal.ChronoUnit; 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 { private long lastTime; diff --git a/visualiser/src/main/java/seng302/Model/ResizableCanvas.java b/visualiser/src/main/java/seng302/Model/ResizableCanvas.java index 1dab2aa6..95ee7a32 100644 --- a/visualiser/src/main/java/seng302/Model/ResizableCanvas.java +++ b/visualiser/src/main/java/seng302/Model/ResizableCanvas.java @@ -4,7 +4,7 @@ import javafx.scene.canvas.Canvas; 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 { protected final GraphicsContext gc; diff --git a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java index bccd3395..cb5107b0 100644 --- a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -16,9 +16,16 @@ import java.time.ZonedDateTime; import java.util.*; /** - * This creates a JavaFX Canvas that is fills it's parent. - * Cannot be downsized. - * Created by fwy13 on 17/03/17. + * This JavaFX Canvas is used to update and display details for a + * {@link seng302.RaceMap RaceMap} via the + * {@link seng302.Controllers.RaceController RaceController}.
+ * It fills it's parent and cannot be downsized.
+ * Details displayed include: + * {@link seng302.Model.Boat Boats} (and their + * {@link seng302.Model.TrackPoint TrackPoint}s), + * {@link seng302.Model.Marker Markers}, a + * {@link seng302.Model.RaceClock RaceClock}, a wind direction arrow and + * various user selected {@link seng302.Model.Annotations Annotations}. */ public class ResizableRaceCanvas extends ResizableCanvas { private RaceMap map; diff --git a/visualiser/src/main/java/seng302/Model/ResizableRaceMap.java b/visualiser/src/main/java/seng302/Model/ResizableRaceMap.java index 4a2bed6f..01b97af9 100644 --- a/visualiser/src/main/java/seng302/Model/ResizableRaceMap.java +++ b/visualiser/src/main/java/seng302/Model/ResizableRaceMap.java @@ -9,7 +9,10 @@ import seng302.RaceMap; 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 { private RaceMap map; @@ -34,8 +37,8 @@ public class ResizableRaceMap extends ResizableCanvas { } /** - * Sets the map race that it is auppost to be viewing. - * @param map + * Sets the map race that it is supposed to be viewing. + * @param map the map to be set */ private void setMap(RaceMap map) { this.map = map; diff --git a/visualiser/src/main/java/seng302/Model/Sparkline.java b/visualiser/src/main/java/seng302/Model/Sparkline.java index a58815fc..0c4e503d 100644 --- a/visualiser/src/main/java/seng302/Model/Sparkline.java +++ b/visualiser/src/main/java/seng302/Model/Sparkline.java @@ -12,7 +12,12 @@ import java.util.HashMap; 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}.
+ * This sparkline is displayed using the + * {@link seng302.Controllers.RaceController RaceController}. */ public class Sparkline { private ArrayList colours; diff --git a/visualiser/src/main/java/seng302/Model/TrackPoint.java b/visualiser/src/main/java/seng302/Model/TrackPoint.java index 1a2007cf..12eab755 100644 --- a/visualiser/src/main/java/seng302/Model/TrackPoint.java +++ b/visualiser/src/main/java/seng302/Model/TrackPoint.java @@ -3,7 +3,13 @@ package seng302.Model; 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.
+ * TrackPoints are displayed on a + * {@link seng302.Model.ResizableRaceCanvas ResizableRaceCanvas}, via the + * {@link seng302.Controllers.RaceController RaceController}.
+ * Track points can be made visible or hidden via the RaceController's + * {@link seng302.Model.Annotations Annotations}. */ public class TrackPoint { private final GPSCoordinate coordinate; diff --git a/visualiser/src/main/java/seng302/RaceDataSource.java b/visualiser/src/main/java/seng302/RaceDataSource.java index 5f2e52ad..e3bb7634 100644 --- a/visualiser/src/main/java/seng302/RaceDataSource.java +++ b/visualiser/src/main/java/seng302/RaceDataSource.java @@ -8,7 +8,11 @@ import java.time.ZonedDateTime; import java.util.List; /** - * Created by connortaylorbrown on 19/04/17. + * An object that holds relevant data for a race.
+ * Information includes: {@link seng302.Model.Boat Boat}s, + * {@link seng302.Model.Leg Leg}s, {@link seng302.Model.Marker Marker}s and + * the {@link seng302.GPSCoordinate GPSCoordinate}s to create a + * {@link seng302.Model.ResizableRaceMap ResizableRaceMap}. */ public interface RaceDataSource { List getBoats(); diff --git a/visualiser/src/main/java/seng302/RaceMap.java b/visualiser/src/main/java/seng302/RaceMap.java index cbd9f2a4..6d55b0a9 100644 --- a/visualiser/src/main/java/seng302/RaceMap.java +++ b/visualiser/src/main/java/seng302/RaceMap.java @@ -1,7 +1,11 @@ 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 { private final double x1; diff --git a/visualiser/src/main/java/seng302/VisualiserInput.java b/visualiser/src/main/java/seng302/VisualiserInput.java index a7461ceb..f5a3f561 100644 --- a/visualiser/src/main/java/seng302/VisualiserInput.java +++ b/visualiser/src/main/java/seng302/VisualiserInput.java @@ -18,7 +18,9 @@ import java.util.Map; import static seng302.Networking.Utils.ByteConverter.bytesToShort; /** - * TCP client which receives packets/messages from a race data source (e.g., mock source, official source), and exposes them to any observers. + * 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 { diff --git a/visualiser/src/main/java/seng302/XMLReader.java b/visualiser/src/main/java/seng302/XMLReader.java index 67253791..f250e268 100644 --- a/visualiser/src/main/java/seng302/XMLReader.java +++ b/visualiser/src/main/java/seng302/XMLReader.java @@ -12,7 +12,7 @@ import java.io.IOException; import java.io.InputStream; /** - * Created by fwy13 on 26/03/2017. + * The abstract class for reading in XML race data. */ public abstract class XMLReader { diff --git a/visualiser/src/test/java/seng302/Model/BoatInRaceTest.java b/visualiser/src/test/java/seng302/Model/BoatInRaceTest.java index 029a0f43..22c2caaf 100644 --- a/visualiser/src/test/java/seng302/Model/BoatInRaceTest.java +++ b/visualiser/src/test/java/seng302/Model/BoatInRaceTest.java @@ -1,154 +1,149 @@ 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 { - - - private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0); - private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); - - - @Test - public void calculateDueNorthAzimuthReturns0() { - - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(50, 0)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8); - } - - @Test - public void calculateDueSouthAzimuthReturns180() { - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(-50, 0)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8); - } - - - @Test - public void calculateDueEastAzimuthReturns90() { - - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(0, 50)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8); - } - - - @Test - public void calculateDueWestAzimuthReturnsNegative90() { - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(0, -50)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8); - - } - - @Test - public void calculateDueNorthHeadingReturns0() { - - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(50, 0)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8); - } - - - @Test - public void calculateDueEastHeadingReturns90() { - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(0, 50)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8); - } - - @Test - public void calculateDueSouthHeadingReturns180() { - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(-50, 0)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8); - } - - @Test - public void calculateDueWestHeadingReturns270() { - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(0, -50)); - Leg start = new Leg("Start", startMarker, endMarker, 0); - TEST_BOAT.setCurrentLeg(start); - assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8); - } - - @Test - public void createNewBoatCratesInstanceOfSuperClass() { - - BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt"); - testBoat.setName("Name can change"); - assertTrue(testBoat instanceof Boat); - assertTrue(testBoat.getCurrentLeg() == null); - assertTrue(testBoat.getCurrentPosition() == null); - assertTrue(testBoat.toString().contains("Name can change")); - assertEquals(testBoat.getVelocity(), 20.0); - assertTrue(testBoat.getVelocityProp().toString().contains("20")); - assertTrue(testBoat.getAbbrev().equals("tt")); - assertTrue(testBoat.getColour().equals(Color.ALICEBLUE)); - assertFalse(testBoat.isFinished()); - } - - - @Test - public void getWakeAtProperHeading() throws Exception { - BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); - - // Construct leg of 0 degrees - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(50, 0)); - Leg leg0deg = new Leg("Start", startMarker, endMarker, 0); - boat.setCurrentLeg(leg0deg); - boat.setCurrentPosition(new GPSCoordinate(0, 0)); - - assertEquals(0, boat.calculateHeading(), 1e-8); - - // Construct leg from wake - heading should be 180 degrees - Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0); - boat.setCurrentLeg(leg180deg); - - assertEquals(180, boat.calculateHeading(), 1e-8); - } - - - @Test - public void getWakeProportionalToVelocity() throws Exception { - BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt"); - - // Construct leg of 0 degrees at 0 N - Marker startMarker = new Marker(ORIGIN_COORDS); - Marker endMarker = new Marker(new GPSCoordinate(50, 0)); - Leg leg0deg = new Leg("Start", startMarker, endMarker, 0); - boat.setCurrentLeg(leg0deg); - boat.setCurrentPosition(new GPSCoordinate(0, 0)); - - // Get latitude of endpoint of wake at 10 kn (longitude is 0) - double endpointAt10Kn = boat.getWake().getLatitude(); - - // Latitude of endpoint at 20 kn should be twice endpoint at 10 kn - boat.setVelocity(20); - assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8); - } + // TODO change this test to use Boat and not BoatInRace ?? + // TODO delete BoatInRace class + +// private final GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0); +// private final BoatInRace TEST_BOAT = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); +// +// +// @Test +// public void calculateDueNorthAzimuthReturns0() { +// +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(50, 0)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8); +// } +// +// @Test +// public void calculateDueSouthAzimuthReturns180() { +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(-50, 0)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8); +// } +// +// +// @Test +// public void calculateDueEastAzimuthReturns90() { +// +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(0, 50)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8); +// } +// +// +// @Test +// public void calculateDueWestAzimuthReturnsNegative90() { +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(0, -50)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8); +// +// } +// +// @Test +// public void calculateDueNorthHeadingReturns0() { +// +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(50, 0)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8); +// } +// +// +// @Test +// public void calculateDueEastHeadingReturns90() { +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(0, 50)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8); +// } +// +// @Test +// public void calculateDueSouthHeadingReturns180() { +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(-50, 0)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8); +// } +// +// @Test +// public void calculateDueWestHeadingReturns270() { +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(0, -50)); +// Leg start = new Leg("Start", startMarker, endMarker, 0); +// TEST_BOAT.setCurrentLeg(start); +// assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8); +// } +// +// @Test +// public void createNewBoatCratesInstanceOfSuperClass() { +// +// BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt"); +// testBoat.setName("Name can change"); +// assertTrue(testBoat instanceof Boat); +// assertTrue(testBoat.getCurrentLeg() == null); +// assertTrue(testBoat.getCurrentPosition() == null); +// assertTrue(testBoat.toString().contains("Name can change")); +// assertEquals(testBoat.getVelocity(), 20.0); +// assertTrue(testBoat.getVelocityProp().toString().contains("20")); +// assertTrue(testBoat.getAbbrev().equals("tt")); +// assertTrue(testBoat.getColour().equals(Color.ALICEBLUE)); +// assertFalse(testBoat.isFinished()); +// } +// +// +// @Test +// public void getWakeAtProperHeading() throws Exception { +// BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); +// +// // Construct leg of 0 degrees +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(50, 0)); +// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0); +// boat.setCurrentLeg(leg0deg); +// boat.setCurrentPosition(new GPSCoordinate(0, 0)); +// +// assertEquals(0, boat.calculateHeading(), 1e-8); +// +// // Construct leg from wake - heading should be 180 degrees +// Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0); +// boat.setCurrentLeg(leg180deg); +// +// assertEquals(180, boat.calculateHeading(), 1e-8); +// } +// +// +// @Test +// public void getWakeProportionalToVelocity() throws Exception { +// BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt"); +// +// // Construct leg of 0 degrees at 0 N +// Marker startMarker = new Marker(ORIGIN_COORDS); +// Marker endMarker = new Marker(new GPSCoordinate(50, 0)); +// Leg leg0deg = new Leg("Start", startMarker, endMarker, 0); +// boat.setCurrentLeg(leg0deg); +// boat.setCurrentPosition(new GPSCoordinate(0, 0)); +// +// // Get latitude of endpoint of wake at 10 kn (longitude is 0) +// double endpointAt10Kn = boat.getWake().getLatitude(); +// +// // Latitude of endpoint at 20 kn should be twice endpoint at 10 kn +// boat.setVelocity(20); +// assertEquals(2 * endpointAt10Kn, boat.getWake().getLatitude(), 1e-8); +// } } \ No newline at end of file diff --git a/visualiser/src/test/java/seng302/Model/LegTest.java b/visualiser/src/test/java/seng302/Model/LegTest.java index c58f2eb1..56176a61 100644 --- a/visualiser/src/test/java/seng302/Model/LegTest.java +++ b/visualiser/src/test/java/seng302/Model/LegTest.java @@ -10,7 +10,8 @@ import static junit.framework.TestCase.assertEquals; 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 {