From e8cd9b2ee80f0d05ccac72d44feadc51d2697724 Mon Sep 17 00:00:00 2001 From: Connor Taylor-Brown Date: Sat, 25 Mar 2017 20:41:16 +1300 Subject: [PATCH 1/4] Implemented wake visualisation for each boat - Added and tested wake calculation for BoatInRace - Draws boat in canvas between start and entering Finish leg - Allow boat velocity to be set after initialisation for testing #story [21] --- .../seng302/Controllers/RaceController.java | 1 + src/main/java/seng302/Model/Boat.java | 4 ++ src/main/java/seng302/Model/BoatInRace.java | 16 +++++++- .../seng302/Model/ResizableRaceCanvas.java | 25 ++++++------ .../java/seng302/Model/BoatInRaceTest.java | 40 +++++++++++++++++++ 5 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java index f9e5c63a..da82c3dc 100644 --- a/src/main/java/seng302/Controllers/RaceController.java +++ b/src/main/java/seng302/Controllers/RaceController.java @@ -66,6 +66,7 @@ public class RaceController extends Controller{ BoatInRace[] boatInRaces = new BoatInRace[boats.size()]; raceMap.setBoats(boats.toArray(boatInRaces)); raceMap.drawRaceMap(); + raceMap.updateBoats(); } /** diff --git a/src/main/java/seng302/Model/Boat.java b/src/main/java/seng302/Model/Boat.java index f93b1d18..a0625638 100644 --- a/src/main/java/seng302/Model/Boat.java +++ b/src/main/java/seng302/Model/Boat.java @@ -48,6 +48,10 @@ public class Boat { return velocity; } + public void setVelocity(double velocity) { + this.velocity = velocity; + } + /** * * @return The Name of the boat. diff --git a/src/main/java/seng302/Model/BoatInRace.java b/src/main/java/seng302/Model/BoatInRace.java index a3de0ecb..5291244f 100644 --- a/src/main/java/seng302/Model/BoatInRace.java +++ b/src/main/java/seng302/Model/BoatInRace.java @@ -6,6 +6,7 @@ import javafx.scene.paint.Color; import org.geotools.referencing.GeodeticCalculator; import seng302.GPSCoordinate; +import java.awt.geom.Point2D; /** @@ -147,7 +148,7 @@ public class BoatInRace extends Boat { /** * Converts an azimuth to a bearing - * @param azimuth azimuth valuye to be converted + * @param azimuth azimuth value to be converted * @return the bearings in degrees (0 to 360). */ public static double calculateHeading(double azimuth) { @@ -167,4 +168,17 @@ public class BoatInRace extends Boat { double azimuth = this.calculateAzimuth(); return calculateHeading(azimuth); } + + public GPSCoordinate getWake() { + double reverseHeading = calculateHeading() - 180; + double distance = 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()); + } } diff --git a/src/main/java/seng302/Model/ResizableRaceCanvas.java b/src/main/java/seng302/Model/ResizableRaceCanvas.java index 7fe6c741..36d16531 100644 --- a/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -66,8 +66,9 @@ public class ResizableRaceCanvas extends Canvas { * @see Paint */ public void displayMark(GraphCoordinate graphCoordinate, Paint paint){ + double d = 15; gc.setFill(paint); - gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 15, 15); + gc.fillOval(graphCoordinate.getX() - (d/2), graphCoordinate.getY() - (d/2), d, d); } /** @@ -187,7 +188,6 @@ public class ResizableRaceCanvas extends Canvas { if (boats != null) { for (BoatInRace boat : boats) { if (boat != null) { -// System.out.print("Drawing Boat At: " + boat.getCurrentPosition()); displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour()); displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); } @@ -198,17 +198,16 @@ 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); + public void updateBoats() { + if (boats != null) { + for (BoatInRace boat : boats) { + if (boat != null && !boat.getCurrentLeg().getName().equals("Finish")) { + GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition()); + GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake()); + displayLine(wakeFrom, wakeTo, boat.getColour()); + } + } + } } /** diff --git a/src/test/java/seng302/Model/BoatInRaceTest.java b/src/test/java/seng302/Model/BoatInRaceTest.java index 1e430be1..ba3dd033 100644 --- a/src/test/java/seng302/Model/BoatInRaceTest.java +++ b/src/test/java/seng302/Model/BoatInRaceTest.java @@ -1,6 +1,7 @@ package seng302.Model; import javafx.scene.paint.Color; +import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import seng302.GPSCoordinate; @@ -111,4 +112,43 @@ public class BoatInRaceTest { assertEquals(testBoat.getVelocity(), 20.0); } + + @Test + public void getWakeAtProperHeading() throws Exception { + BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); + + // Construct leg of 0 degrees + GPSCoordinate startPoint = new GPSCoordinate(0, 0); + GPSCoordinate endPoint = new GPSCoordinate(50, 0); + Leg leg0deg = new Leg("Start", startPoint, endPoint, 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", startPoint, 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 + GPSCoordinate startPoint = new GPSCoordinate(0, 0); + GPSCoordinate endPoint = new GPSCoordinate(50, 0); + Leg leg0deg = new Leg("Start", startPoint, endPoint, 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 From 3aaee1291def928b20e4578741b860285bd3ae5c Mon Sep 17 00:00:00 2001 From: Connor Taylor-Brown Date: Mon, 27 Mar 2017 20:51:20 +1300 Subject: [PATCH 2/4] Implemented heading visualisation - Boats are represented as isosceles triangles - Boats are rotated toward heading while in race - As heading is only available in race, RaceController draws boats on start line and in race separately #story [24] --- .../seng302/Controllers/RaceController.java | 1 + .../seng302/Model/ResizableRaceCanvas.java | 84 +++++++------------ 2 files changed, 29 insertions(+), 56 deletions(-) diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java index 6cb86211..f44d0e7e 100644 --- a/src/main/java/seng302/Controllers/RaceController.java +++ b/src/main/java/seng302/Controllers/RaceController.java @@ -129,6 +129,7 @@ public class RaceController extends Controller { raceMap.widthProperty().bind(canvasBase.widthProperty()); raceMap.heightProperty().bind(canvasBase.heightProperty()); raceMap.setBoats(boats); + raceMap.drawBoats(); raceMap.drawRaceMap(); raceMap.setVisible(true); diff --git a/src/main/java/seng302/Model/ResizableRaceCanvas.java b/src/main/java/seng302/Model/ResizableRaceCanvas.java index c6891e72..cc55458a 100644 --- a/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -7,15 +7,9 @@ import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.transform.Rotate; import seng302.Constants; -import seng302.GPSCoordinate; import seng302.GraphCoordinate; import seng302.RaceMap; -import java.awt.*; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.Random; - /** * This creates a JavaFX Canvas that is fills it's parent. * Cannot be downsized. @@ -50,15 +44,6 @@ public class ResizableRaceCanvas extends Canvas { 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. * @@ -74,6 +59,20 @@ public class ResizableRaceCanvas extends Canvas { gc.fillOval(graphCoordinate.getX() - (d/2), graphCoordinate.getY() - (d/2), d, d); } + public void displayBoat(BoatInRace boat, double angle) { + GraphCoordinate pos = this.map.convertGPS(boat.getCurrentPosition()); + Paint paint = boat.getColour(); + + double[] x = {pos.getX() - 6, pos.getX(), pos.getX() + 6}; + double[] y = {pos.getY() + 12, pos.getY() - 12, pos.getY() + 12}; + gc.setFill(paint); + + gc.save(); + rotate(angle, pos.getX(), pos.getY()); + gc.fillPolygon(x, y, 3); + gc.restore(); + } + /** * Displays a line on the map with rectangles on the starting and ending point of the line. * @@ -92,20 +91,6 @@ 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 * @@ -168,10 +153,6 @@ public class ResizableRaceCanvas extends Canvas { //System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height); this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int) width, (int) height); - if (map == null) { - return; - } - //finish line gc.setLineWidth(2); GraphCoordinate finishLineCoord1 = this.map.convertGPS(Constants.finishLineMarker1); @@ -192,16 +173,6 @@ public class ResizableRaceCanvas extends Canvas { displayLine(startline1, startline2, Color.GREEN); - - if (boats != null) { - for (BoatInRace boat : boats) { - if (boat != null) { - displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour()); - displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); - } - } - } - //display wind direction arrow - specify origin point and angle displayArrow(new GraphCoordinate(500, 20), 100); } @@ -210,26 +181,16 @@ public class ResizableRaceCanvas extends Canvas { if (boats != null) { for (BoatInRace boat : boats) { if (boat != null && !boat.getCurrentLeg().getName().equals("Finish")) { + displayBoat(boat, boat.calculateHeading()); GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition()); GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake()); displayLine(wakeFrom, wakeTo, boat.getColour()); } + else displayBoat(boat, 0); + displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); } } } - /** - * 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. @@ -262,4 +223,15 @@ public class ResizableRaceCanvas extends Canvas { public double prefHeight(double height) { return getHeight(); } + + public void drawBoats() { + if (boats != null) { + for (BoatInRace boat : boats) { + if (boat != null) { + displayBoat(boat, 0); + displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); + } + } + } + } } From cfbb27513d3f3c14e5beda37ff836c6c54566e37 Mon Sep 17 00:00:00 2001 From: Connor Taylor-Brown Date: Mon, 27 Mar 2017 20:59:51 +1300 Subject: [PATCH 3/4] Fixed wake scale for realistic speeds. #story[21] --- src/main/java/seng302/Constants.java | 2 ++ src/main/java/seng302/Model/BoatInRace.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/seng302/Constants.java b/src/main/java/seng302/Constants.java index fc198910..1c3e43a3 100644 --- a/src/main/java/seng302/Constants.java +++ b/src/main/java/seng302/Constants.java @@ -21,6 +21,8 @@ public class Constants { public static final GPSCoordinate finishLineMarker1 = new GPSCoordinate(32.317379, -64.839291); public static final GPSCoordinate finishLineMarker2 = new GPSCoordinate(32.317257, -64.836260); + public static final double wakeScale = 10; + public static final BoatInRace[] OFFICIAL_AC35_COMPETITORS = new BoatInRace[] {new BoatInRace("Oracle Team USA", 30.0, Color.BLUEVIOLET, "USA"), new BoatInRace("Land Rover BAR", 23.0, Color.BLACK, "BAR"), diff --git a/src/main/java/seng302/Model/BoatInRace.java b/src/main/java/seng302/Model/BoatInRace.java index d2776845..01b410ae 100644 --- a/src/main/java/seng302/Model/BoatInRace.java +++ b/src/main/java/seng302/Model/BoatInRace.java @@ -4,6 +4,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.scene.paint.Color; import org.geotools.referencing.GeodeticCalculator; +import seng302.Constants; import seng302.GPSCoordinate; import java.awt.geom.Point2D; @@ -76,7 +77,7 @@ public class BoatInRace extends Boat { public GPSCoordinate getWake() { double reverseHeading = calculateHeading() - 180; - double distance = getVelocity(); + double distance = Constants.wakeScale * getVelocity(); GeodeticCalculator calc = new GeodeticCalculator(); calc.setStartingGeographicPoint( From 1524ed5a0e0831e519e64b77a4bb39c4a7770fd1 Mon Sep 17 00:00:00 2001 From: cbt24 Date: Wed, 29 Mar 2017 13:27:41 +1300 Subject: [PATCH 4/4] Merged annotation toggle and DNF features with heading visualisation. --- .../seng302/Controllers/RaceController.java | 37 ++++++++++++++---- src/main/java/seng302/Model/Boat.java | 6 ++- src/main/java/seng302/Model/BoatInRace.java | 6 +++ src/main/java/seng302/Model/Race.java | 19 ++++++++++ .../seng302/Model/ResizableRaceCanvas.java | 38 +++++++++++++++++-- src/main/resources/scenes/racepane.fxml | 15 ++++++-- 6 files changed, 105 insertions(+), 16 deletions(-) diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java index f44d0e7e..e83146a8 100644 --- a/src/main/java/seng302/Controllers/RaceController.java +++ b/src/main/java/seng302/Controllers/RaceController.java @@ -2,15 +2,12 @@ package seng302.Controllers; import javafx.beans.property.ReadOnlyObjectWrapper; +import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.event.EventHandler; import javafx.fxml.FXML; -import javafx.scene.control.Label; -import javafx.scene.control.SplitPane; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TitledPane; +import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.input.MouseEvent; import javafx.scene.layout.AnchorPane; @@ -39,6 +36,11 @@ public class RaceController extends Controller { @FXML SplitPane ongoingRacePane; + @FXML + CheckBox showFPS; + + @FXML + CheckBox showAnno; @FXML Label timer; @@ -67,8 +69,7 @@ public class RaceController extends Controller { public void updateMap(ObservableList boats) { BoatInRace[] boatInRaces = new BoatInRace[boats.size()]; raceMap.setBoats(boats.toArray(boatInRaces)); - raceMap.drawRaceMap(); - raceMap.updateBoats(); + raceMap.update(); } /** @@ -114,7 +115,17 @@ public class RaceController extends Controller { @Override public void initialize(URL location, ResourceBundle resources) { - + //listener for fps + showFPS.selectedProperty().addListener(new ChangeListener() { + public void changed(ObservableValue ov, + Boolean old_val, Boolean new_val) { + if (showFPS.isSelected()){ + FPS.setVisible(true); + } else { + FPS.setVisible(false); + } + } + }); } /** @@ -126,6 +137,7 @@ public class RaceController extends Controller { private void startRace(int scaleFactor) { BoatInRace[] boats = generateAC35Competitors(); raceMap = new ResizableRaceCanvas(); + raceMap.setMouseTransparent(true); raceMap.widthProperty().bind(canvasBase.widthProperty()); raceMap.heightProperty().bind(canvasBase.heightProperty()); raceMap.setBoats(boats); @@ -142,6 +154,15 @@ public class RaceController extends Controller { new Thread((race)).start(); + + //listener for annotation + showAnno.selectedProperty().addListener(new ChangeListener() { + public void changed(ObservableValue ov, + Boolean old_val, Boolean new_val) { + raceMap.toggleAnno(); + raceMap.update(); + } + }); } diff --git a/src/main/java/seng302/Model/Boat.java b/src/main/java/seng302/Model/Boat.java index 1b1801fc..222e1a68 100644 --- a/src/main/java/seng302/Model/Boat.java +++ b/src/main/java/seng302/Model/Boat.java @@ -21,7 +21,7 @@ public class Boat { */ public Boat(String name, double velocity, String abbrev) { this.velocity = velocity; - this.velocityProp = new SimpleStringProperty(String.valueOf(velocity* 1.94384)); + this.velocityProp = new SimpleStringProperty(String.valueOf(Math.round(velocity))); this.abbrev = abbrev; this.name = new SimpleStringProperty(name); } @@ -48,6 +48,10 @@ public class Boat { return velocity; } + /** + * Sets the speed of the boat in knots. + * @param velocity speed in knots + */ public void setVelocity(double velocity) { this.velocity = velocity; } diff --git a/src/main/java/seng302/Model/BoatInRace.java b/src/main/java/seng302/Model/BoatInRace.java index 01b410ae..72906939 100644 --- a/src/main/java/seng302/Model/BoatInRace.java +++ b/src/main/java/seng302/Model/BoatInRace.java @@ -75,6 +75,12 @@ public class BoatInRace extends Boat { 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 = calculateHeading() - 180; double distance = Constants.wakeScale * getVelocity(); diff --git a/src/main/java/seng302/Model/Race.java b/src/main/java/seng302/Model/Race.java index 340b7e35..5ab877d7 100644 --- a/src/main/java/seng302/Model/Race.java +++ b/src/main/java/seng302/Model/Race.java @@ -8,6 +8,7 @@ import javafx.collections.ObservableList; import seng302.Controllers.RaceController; import java.util.ArrayList; +import java.util.Random; /** * Parent class for races @@ -164,10 +165,19 @@ public abstract class Race implements Runnable { Platform.runLater(() -> {controller.setTimer(time);}); } + /** + * Update the calculated fps to the fps label + * @param fps The new calculated fps value + */ private void updateFPS(int fps) { Platform.runLater(() -> {controller.setFrames("FPS: " + fps);}); } + private boolean doNotFinish() { + Random rand = new Random(); + return rand.nextInt(100) < 1; + } + /** * Starts the Race Simulation, playing the race start to finish with the timescale. * This prints the boats participating, the order that the events occur in time order, and the respective information of the events. @@ -203,6 +213,11 @@ public abstract class Race implements Runnable { if (controller != null) controller.updateMap(startingBoats); if (timerEnabled) updateTime(calcTimer()); + } else { + //Exit animation timer + updateTime(calcTimer()); + updateFPS(0); //race ended so fps = 0 + stop(); //exit animation timer } fps++; if ((System.currentTimeMillis()-timeCurrent) > 1000){ @@ -240,6 +255,10 @@ public abstract class Race implements Runnable { boatsFinished++; boat.setFinished(true); boat.setTimeFinished(timeElapsed); + } else if(doNotFinish()) { + boatsFinished++; + boat.setFinished(true); + boat.setCurrentLeg(new Leg("DNF",-1)); } else { //Calculate how much the boat overshot the marker by boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance()); diff --git a/src/main/java/seng302/Model/ResizableRaceCanvas.java b/src/main/java/seng302/Model/ResizableRaceCanvas.java index cc55458a..4764dee7 100644 --- a/src/main/java/seng302/Model/ResizableRaceCanvas.java +++ b/src/main/java/seng302/Model/ResizableRaceCanvas.java @@ -19,6 +19,7 @@ public class ResizableRaceCanvas extends Canvas { private GraphicsContext gc; private RaceMap map; private BoatInRace[] boats; + private boolean raceAnno = true; /** * Sets the boats that are to be displayed in this race. @@ -141,6 +142,14 @@ public class ResizableRaceCanvas extends Canvas { gc.fillText(text, xCoord, yCoord); } + /** + * Draws race map with up to date data. + */ + public void update() { + this.drawRaceMap(); + this.updateBoats(); + } + /** * Draws the Race Map */ @@ -177,21 +186,39 @@ public class ResizableRaceCanvas extends Canvas { displayArrow(new GraphCoordinate(500, 20), 100); } + /** + * Draws boats while race in progress, when leg heading is set. + */ public void updateBoats() { if (boats != null) { for (BoatInRace boat : boats) { - if (boat != null && !boat.getCurrentLeg().getName().equals("Finish")) { + boolean finished = boat.getCurrentLeg().getName().equals("Finish") || boat.getCurrentLeg().getName().equals("DNF"); + if (!finished) { displayBoat(boat, boat.calculateHeading()); GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition()); GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake()); displayLine(wakeFrom, wakeTo, boat.getColour()); } - else displayBoat(boat, 0); - displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); + else { + displayBoat(boat, 0); + } + + if (raceAnno) displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); } } } + /** + * Toggle the raceAnno value + */ + public void toggleAnno(){ + if (raceAnno){ + raceAnno = false; + } else { + raceAnno = true; + } + } + /** * Set the Canvas to resizable. * @@ -224,12 +251,15 @@ public class ResizableRaceCanvas extends Canvas { return getHeight(); } + /** + * Draws boats during race setup, when leg heading is not set. + */ public void drawBoats() { if (boats != null) { for (BoatInRace boat : boats) { if (boat != null) { displayBoat(boat, 0); - displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); + if (raceAnno) displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition())); } } } diff --git a/src/main/resources/scenes/racepane.fxml b/src/main/resources/scenes/racepane.fxml index 2840e5a1..620b0e81 100644 --- a/src/main/resources/scenes/racepane.fxml +++ b/src/main/resources/scenes/racepane.fxml @@ -69,9 +69,18 @@ -