diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 57e4c6ca..8e141d98 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -22,7 +22,6 @@
-
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 1b5f6446..334458a7 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -21,13 +21,6 @@
-
-
-
diff --git a/src/main/java/seng302/Constants.java b/src/main/java/seng302/Constants.java
index b2fba662..125e5444 100644
--- a/src/main/java/seng302/Constants.java
+++ b/src/main/java/seng302/Constants.java
@@ -3,6 +3,7 @@ package seng302;
import seng302.Model.Leg;
/**
+ * Constants that are used throughout the program
* Created by Erika on 19-Mar-17.
*/
public class Constants {
diff --git a/src/main/java/seng302/Controllers/Controller.java b/src/main/java/seng302/Controllers/Controller.java
index 86081bee..e771e8d0 100644
--- a/src/main/java/seng302/Controllers/Controller.java
+++ b/src/main/java/seng302/Controllers/Controller.java
@@ -7,19 +7,34 @@ import java.net.URL;
import java.util.ResourceBundle;
/**
- * Created by Gondr on 15/03/2017.
+ * Controller parent for app controllers.
+ * Created by fwy13 on 15/03/2017.
*/
public abstract class Controller implements Initializable{
protected App parent;
+ /**
+ * Sets the parent of the application
+ * @param parent
+ */
public void setParent(App parent){
this.parent = parent;
}
+ /**
+ * Sets the loads a pane into the parent.
+ * @param fxmlName
+ * @throws Exception
+ */
public void loadPane(String fxmlName) throws Exception {
this.parent.loadPane(fxmlName);
}
+ /**
+ * Initialisation class that is run on start up.
+ * @param location
+ * @param resources
+ */
@Override
public abstract void initialize(URL location, ResourceBundle resources);
}
diff --git a/src/main/java/seng302/Controllers/MainController.java b/src/main/java/seng302/Controllers/MainController.java
index d6edf653..5ebb99cc 100644
--- a/src/main/java/seng302/Controllers/MainController.java
+++ b/src/main/java/seng302/Controllers/MainController.java
@@ -6,10 +6,15 @@ import java.net.URL;
import java.util.ResourceBundle;
/**
- * Created by Gondr on 15/03/2017.
+ * Created by fwy13 on 15/03/2017.
*/
public class MainController extends Controller {
+ /**
+ * Main Controller for the applications will house the menu and the displayed pane.
+ * @param location
+ * @param resources
+ */
@Override
public void initialize(URL location, ResourceBundle resources) {
diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java
index 3716e052..0b8402f0 100644
--- a/src/main/java/seng302/Controllers/RaceController.java
+++ b/src/main/java/seng302/Controllers/RaceController.java
@@ -26,14 +26,13 @@ import java.util.ArrayList;
import java.util.ResourceBundle;
/**
- * Created by Gondr on 15/03/2017.
+ * Created by fwy13 on 15/03/2017.
*/
public class RaceController extends Controller{
@FXML
AnchorPane canvasBase;
- @FXML
- ResizableRaceCanvas raceMap;
+ ResizableRaceCanvas raceMap;
@FXML
TableView boatInfoTable;
@@ -44,10 +43,11 @@ public class RaceController extends Controller{
@FXML
TableColumn boatMarkColumn;
- private GraphicsContext gc;
- private RaceMap map;
-
-
+ /**
+ * updates the ResizableRaceCanvas (raceMap) with most recent data
+ * @param boats boats that are to be displayed in the race
+ * @see ResizableRaceCanvas
+ */
public void updateMap(ObservableList boats) {
BoatInRace[] boatInRaces = new BoatInRace[boats.size()];
raceMap.setBoats(boats.toArray(boatInRaces));
@@ -55,6 +55,10 @@ public class RaceController extends Controller{
}
+ /**
+ * Updates the array listened by the TableView (boatInfoTable) that displays the boat information.
+ * @param race Race to listen to.
+ */
public void updateInfoTable(Race race) {
boatInfoTable.getItems().clear();
boatInfoTable.setItems(race.getStartingBoats());
@@ -88,6 +92,10 @@ public class RaceController extends Controller{
(new Thread(race)).start();
}
+ /**
+ * Function for the Bermuda Race.
+ * @return legs in the Bermuda Race.
+ */
private ArrayList generateBermudaCourseLegs() {
ArrayList legs = new ArrayList<>();
diff --git a/src/main/java/seng302/GPSCoordinate.java b/src/main/java/seng302/GPSCoordinate.java
index 3e02853a..4f55a037 100644
--- a/src/main/java/seng302/GPSCoordinate.java
+++ b/src/main/java/seng302/GPSCoordinate.java
@@ -1,6 +1,7 @@
package seng302;
/**
+ * GPS Coordinate for the world map.
* Created by esa46 on 15/03/17.
*/
public class GPSCoordinate {
@@ -8,18 +9,35 @@ public class GPSCoordinate {
private double latitude;
private double longitude;
+ /**
+ * Constructor Method
+ * @param latitude latitude the coordinate is located at.
+ * @param longitude Longitude that the coordinate is located at.
+ */
public GPSCoordinate(double latitude, double longitude) { this.latitude = latitude; this.longitude = longitude; }
+ /**
+ * Gets the Latitude that the Coordinate is at.
+ * @return Returns the latitude of the Coordinate.
+ */
public double getLatitude() {
return latitude;
}
+ /**
+ * Gets the Longitude that the Coordinate is at.
+ * @return Returns the longitude of the Coordinate.
+ */
public double getLongitude() {
return longitude;
}
+ /**
+ * To String method of the Coordinate in the form Latitude: $f, Longitude: $f.
+ * @return A String representation of the GPSCoordinate Class.
+ */
public String toString() {
- return String.format("Latitude: %f Longitude: %f", latitude, longitude);
+ return String.format("Latitude: %f, Longitude: %f", latitude, longitude);
}
}
diff --git a/src/main/java/seng302/GraphCoordinate.java b/src/main/java/seng302/GraphCoordinate.java
index 7a6a927f..0ac557ab 100644
--- a/src/main/java/seng302/GraphCoordinate.java
+++ b/src/main/java/seng302/GraphCoordinate.java
@@ -1,18 +1,32 @@
package seng302;
/**
+ * Graph Coordinate that is to be displayed on the Canvas
* Created by cbt24 on 15/03/17.
*/
public class GraphCoordinate {
private int x;
private int y;
+ /**
+ * Constructor method.
+ * @param x X coordinate.
+ * @param y Y coordinate.
+ */
public GraphCoordinate(int x, int y) { this.x = x; this.y = y; }
+ /**
+ * Returns the X coordinate.
+ * @return x axis Coordinate.
+ */
public int getX() {
return x;
}
+ /**
+ * Returns the Y coordinate.
+ * @return y axis Coordinate.
+ */
public int getY() {
return y;
}
diff --git a/src/main/java/seng302/Model/BoatInRace.java b/src/main/java/seng302/Model/BoatInRace.java
index 5dfc96e3..a224b5e2 100644
--- a/src/main/java/seng302/Model/BoatInRace.java
+++ b/src/main/java/seng302/Model/BoatInRace.java
@@ -7,6 +7,7 @@ import seng302.GPSCoordinate;
/**
+ * Boat in the Race extends Boat.
* Created by esa46 on 15/03/17.
*/
public class BoatInRace extends Boat {
@@ -17,47 +18,96 @@ public class BoatInRace extends Boat {
private long timeFinished;
private Color colour;
+ /**
+ *
+ * @return Returns the current position of the boat in a GPSCoordinate Class.
+ * @see GPSCoordinate
+ */
public GPSCoordinate getCurrentPosition() {
return currentPosition;
}
+ /**
+ *
+ * @return Returns the time that the boat finished the race.
+ */
public long getTimeFinished() {
return 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
+ */
public void setColour(Color colour) {
this.colour = colour;
}
+ /**
+ * 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;
}
-
+ /**
+ * Constructor method.
+ * @param name Name of the boat.
+ * @param velocity Speed that the boat travels.
+ */
public BoatInRace(String name, double velocity) {
super(name, velocity);
}
+ /**
+ * 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 current Leg of that the boat is on.
+ * @param currentLeg Leg class that the boat is currently on.
+ * @see Leg
+ */
public void setCurrentLeg(Leg currentLeg) {
this.currentLeg = currentLeg;
}
+ /**
+ * 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 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;
}
+ /**
+ * 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;
}
@@ -65,7 +115,7 @@ public class BoatInRace extends Boat {
/**
* Calculates the bearing of the travel via map coordinates of the raceMarkers
- * @return
+ * @return the heading that the boat is heading towards in degrees.
*/
public double calculateHeading(){
//to be changed to coordinates when used to match reality.
diff --git a/src/main/java/seng302/Model/Leg.java b/src/main/java/seng302/Model/Leg.java
index fdab9343..84810448 100644
--- a/src/main/java/seng302/Model/Leg.java
+++ b/src/main/java/seng302/Model/Leg.java
@@ -30,21 +30,25 @@ public class Leg {
this.distance = calculateDistance();
}
+ /**
+ * Construction Method
+ * @param name Name of the Leg
+ */
public Leg(String name) {
this.name = name;
}
/**
- *
- * @return the name of the Leg
+ * Returns the name of the Leg
+ * @return Returns the name of the Leg
*/
public String getName() {
return name;
}
/**
- *
- * @return the total distance of the leg.
+ * Get the distance in nautical miles
+ * @return Returns the total distance of the leg.
*/
public double getDistance() {
return distance;
@@ -53,32 +57,43 @@ public class Leg {
/**
*
- * @return the name of the Leg
+ * @return Returns the name of the Leg
*/
public String toString() {
return name;
}
/**
- *
- * @return the coordinate of the start of the leg )
+ * Returns the coordinates in GPSCoordinate class of the boats starting coordinate.
+ * @return Returns the coordinate of the start of the leg.
+ * @see GPSCoordinate
*/
public GPSCoordinate getStartGraphCoordinate() {
return startGPSCoordinate;
}
/**
- *
- * @return the coordinate of the end of the leg
+ * Returns the coordinates in a GPSCoordinate class that the boat ends on.
+ * @return Returns the coordinate of the end of the leg.
+ * @see GPSCoordinate
*/
public GPSCoordinate getEndGraphCoordinate() {
return endGPSCoordinate;
}
+ /**
+ * Returns the leg number that the leg exists in the Race
+ * @return Returns the Leg
+ * @see Race
+ */
public int getLegNumber() {
return legNumber;
}
+ /**
+ * Calculates the distance that the legs are in nautical miles (1.852 km).
+ * @return Returns the leg distance.
+ */
private double calculateDistance() {
GeodeticCalculator calc = new GeodeticCalculator();
diff --git a/src/main/java/seng302/Model/Race.java b/src/main/java/seng302/Model/Race.java
index 11e50ca1..a0225d13 100644
--- a/src/main/java/seng302/Model/Race.java
+++ b/src/main/java/seng302/Model/Race.java
@@ -35,16 +35,27 @@ public abstract class Race implements Runnable {
this.controller = controller;
}
+ /**
+ * Constructor for Race class
+ * @param boats boats participating in the race.
+ * @param marks legs that there are in the race.
+ */
public Race(BoatInRace[] boats, ArrayList marks) {
this(boats, marks, null);
}
+ /**
+ * Runnable for the thread.
+ */
public void run() {
updateController();
preRace();
simulateRace();
}
+ /**
+ * Set up the state in waiting for the race starts.
+ */
private void preRace() {
//show the boats participating.
System.out.println("Boats Participating:");
@@ -100,9 +111,15 @@ public abstract class Race implements Runnable {
}
}
-
+ /**
+ * Checks the position of the boat, this updates the boats current position.
+ * @param boat Boat that the postion is to be updated for.
+ * @param timeElapsed Time that has elapse since the start of the the race.
+ * @see BoatInRace
+ */
protected void checkPosition(BoatInRace boat, long timeElapsed) {
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()){
+ //updateController(); removed as we do not update the table every time anymore.
//boat has passed onto new leg
if (boat.getCurrentLeg().getName().equals("Finish")) {
//boat has finished
@@ -117,11 +134,19 @@ public abstract class Race implements Runnable {
}
}
+ /**
+ * Update call for the controller.
+ */
protected void updateController() {
if(controller != null) controller.updateInfoTable(this);
}
-
+ /**
+ * Returns the boats that have started the race.
+ * @return ObservableList of BoatInRace class that participated in the race.
+ * @see ObservableList
+ * @see BoatInRace
+ */
public ObservableList getStartingBoats() {
return startingBoats;
}
diff --git a/src/main/java/seng302/Model/ResizableRaceCanvas.java b/src/main/java/seng302/Model/ResizableRaceCanvas.java
index 26f665dc..c5bce448 100644
--- a/src/main/java/seng302/Model/ResizableRaceCanvas.java
+++ b/src/main/java/seng302/Model/ResizableRaceCanvas.java
@@ -15,13 +15,19 @@ import java.util.ArrayList;
import java.util.Random;
/**
+ * This creates a JavaFX Canvas that is fills it's parent.
+ * Cannot be downsized.
* Created by fwy13 on 17/03/17.
*/
public class ResizableRaceCanvas extends Canvas {
- GraphicsContext gc;
- RaceMap map;
+ private GraphicsContext gc;
+ private RaceMap map;
private BoatInRace[] boats;
+ /**
+ * Sets the boats that are to be displayed in this race.
+ * @param boats
+ */
public void setBoats(BoatInRace[] boats) {
this.boats = boats;
}
@@ -34,19 +40,43 @@ public class ResizableRaceCanvas extends Canvas {
heightProperty().addListener(evt -> drawRaceMap());
}
+ /**
+ * Constructor
+ */
public ResizableRaceCanvas(){
this(null);
}
+ /**
+ * Sets the RaceMap that the RaceCanvas is to be displaying for.
+ * @param map
+ */
public void setMap (RaceMap map) {
this.map = map;
}
+ /**
+ * Displays the mark of a race as a circle.
+ * @param graphCoordinate Latitude and Logintude in GraphCoordinate that it is to be displayed as.
+ * @param paint Colour the mark is to be coloured.
+ * @see GraphCoordinate
+ * @see Color
+ * @see Paint
+ */
public void displayMark(GraphCoordinate graphCoordinate, Paint paint){
gc.setFill(paint);
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 15, 15);
}
+ /**
+ * Displays a line on the map with rectangles on the starting and ending point of the line.
+ * @param graphCoordinateA Starting Point of the line in GraphCoordinate.
+ * @param graphCoordinateB End Point of the line in GraphCoordinate.
+ * @param paint Colour the line is to coloured.
+ * @see GraphCoordinate
+ * @see Color
+ * @see Paint
+ */
public void displayLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint){
gc.setStroke(paint);
gc.setFill(paint);
@@ -55,11 +85,25 @@ public class ResizableRaceCanvas extends Canvas {
gc.strokeLine(graphCoordinateA.getX(), graphCoordinateA.getY(), graphCoordinateB.getX(), graphCoordinateB.getY());
}
+ /**
+ * Display a point on the Canvas
+ * @param graphCoordinate Coordinate that the point is to be displayed at.
+ * @param paint Colour that the boat is to be coloured.
+ * @see GraphCoordinate
+ * @see Paint
+ * @see Color
+ */
public void displayPoint(GraphCoordinate graphCoordinate, Paint paint){
gc.setFill(paint);
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10);
}
+ /**
+ * Displays an arrow on the Canvas
+ * @param coordinate Coordinate that the arrow is to be displayed at.
+ * @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
+ * @see GraphCoordinate
+ */
public void displayArrow(GraphCoordinate coordinate, int angle){
gc.save();
rotate(angle, coordinate.getX(),coordinate.getY());
@@ -69,13 +113,20 @@ public class ResizableRaceCanvas extends Canvas {
gc.restore();
}
-
+ /**
+ * Rotates things on the canvas Note: this must be called in between gc.save() and gc.restore() else they will rotate everything
+ * @param angle Bearing angle to rotate at in degrees
+ * @param px Pivot point x of rotation.
+ * @param py Pivot point y of rotation.
+ */
private void rotate(double angle, double px, double py) {
Rotate r = new Rotate(angle, px, py);
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
}
-
+ /**
+ * Draws the Race Map
+ */
public void drawRaceMap() {
double width = getWidth();
@@ -123,24 +174,45 @@ public class ResizableRaceCanvas extends Canvas {
displayArrow(new GraphCoordinate(500, 20), 100);
}
+ /**
+ * Draws a boat at a certain GPSCoordinate
+ * @param colour Colour to colour boat.
+ * @param gpsCoordinates GPScoordinate that the boat is to be drawn at.
+ * @see GPSCoordinate
+ * @see Color
+ */
public void drawBoat(Color colour, GPSCoordinate gpsCoordinates) {
GraphCoordinate graphCoordinate = this.map.convertGPS(gpsCoordinates);
System.out.println("DrawingBoat" + gpsCoordinates.getLongitude());
displayPoint(graphCoordinate, colour);
}
+ /**
+ * Set the Canvas to resizable.
+ * @return That the Canvas is resizable.
+ */
@Override
public boolean isResizable() {
return true;
}
+ /**
+ * Returns the preferred width of the Canvas
+ * @param width
+ * @return Returns the width of the Canvas
+ */
@Override
- public double prefWidth(double height) {
+ public double prefWidth(double width) {
return getWidth();
}
+ /**
+ * Returns the preferred height of the Canvas
+ * @param height
+ * @return Returns the height of the Canvas
+ */
@Override
- public double prefHeight(double width) {
+ public double prefHeight(double height) {
return getHeight();
}
}
diff --git a/src/main/java/seng302/RaceMap.java b/src/main/java/seng302/RaceMap.java
index f96fbd38..1ad374ab 100644
--- a/src/main/java/seng302/RaceMap.java
+++ b/src/main/java/seng302/RaceMap.java
@@ -7,6 +7,15 @@ public class RaceMap {
private double x1, x2, y1, y2;
private int width, height;
+ /**
+ * Contructor Method.
+ * @param x1 Latitude of the top left point.
+ * @param y1 Longitude of the top left point.
+ * @param x2 Latitude of the top right point.
+ * @param y2 Longitude of the top right point.
+ * @param width width that the Canvas the race is to be drawn on is.
+ * @param height height that the Canvas the race is to be drawn on is.
+ */
public RaceMap(double x1, double y1, double x2, double y2, int width, int height) {
this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; this.width = width; this.height = height;
}
@@ -22,6 +31,13 @@ public class RaceMap {
return new GraphCoordinate((int) ((height * (lon - y1) / (y2 - y1))),(int) (width * (lat - x1) / (x2 - x1)));
}
+ /**
+ * Converts the GPS Coordinate to GraphCoordinates
+ * @param coordinate GPSCoordinate representation of Latitude and Longitude.
+ * @return GraphCoordinate that the GPS is coordinates are to be displayed on the map.
+ * @see GraphCoordinate
+ * @see GPSCoordinate
+ */
public GraphCoordinate convertGPS(GPSCoordinate coordinate) {
return convertGPS(coordinate.getLatitude(), coordinate.getLongitude());
}