Merge branch 'master' into story68
-updated port and starboard boat checks -added gps method to check if on correct side of a line -updated pos check method to make boats round marks with the new tech # Conflicts: # racevisionGame/src/main/java/mock/app/ConnectionAcceptor.java # racevisionGame/src/main/java/mock/app/Event.java # racevisionGame/src/main/java/mock/model/commandFactory/TackGybeCommand.java # racevisionGame/src/main/java/mock/model/commandFactory/VMGCommand.java
This commit is contained in:
@@ -36,12 +36,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
*/
|
||||
private VisualiserRace visualiserRace;
|
||||
|
||||
/**
|
||||
* The background of the race.
|
||||
* We render the background whenever the race boundary changes, or the screen size changes.
|
||||
*/
|
||||
private Image background;
|
||||
|
||||
|
||||
private boolean annoName = true;
|
||||
private boolean annoAbbrev = true;
|
||||
@@ -412,13 +406,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
this.map.setWidth((int) getWidth());
|
||||
this.map.setHeight((int) getHeight());
|
||||
|
||||
//Redraw the boundary.
|
||||
redrawBoundaryImage();
|
||||
|
||||
//Draw the race.
|
||||
drawRace();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -431,15 +421,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
|
||||
/**
|
||||
* Draws the race boundary, and saves the image to {@link #background}.
|
||||
* You should call {@link #clear()} before calling this.
|
||||
* Draws the race boundary.
|
||||
*/
|
||||
private void redrawBoundaryImage() {
|
||||
private void drawBoundary() {
|
||||
|
||||
//Prepare to draw.
|
||||
gc.setLineWidth(1);
|
||||
gc.setFill(Color.AQUA);
|
||||
gc.drawImage(new Image(getClass().getClassLoader().getResourceAsStream("images/WaterBackground.png")), 0, 0);
|
||||
|
||||
|
||||
//Calculate the screen coordinates of the boundary.
|
||||
@@ -459,9 +447,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
//Draw the boundary.
|
||||
gc.fillPolygon(xpoints, ypoints, xpoints.length);
|
||||
|
||||
//Render boundary to image.
|
||||
this.background = snapshot(null, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -624,15 +609,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.strokeLine(lineEnd.getX(), lineEnd.getY(), x2, y2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the race boundary image onto the canvas.
|
||||
* See {@link #background}.
|
||||
*/
|
||||
private void drawBoundary() {
|
||||
gc.drawImage(this.background, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import shared.dataInput.RegattaDataSource;
|
||||
import shared.model.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -198,24 +197,24 @@ public class VisualiserRace extends Race implements Runnable {
|
||||
if (boatLocation != null && boatStatus != null) {
|
||||
|
||||
//Get the new position.
|
||||
double latitude = boatLocation.getLatitudeDouble();
|
||||
double longitude = boatLocation.getLongitudeDouble();
|
||||
double latitude = boatLocation.getLatitude();
|
||||
double longitude = boatLocation.getLongitude();
|
||||
GPSCoordinate gpsCoordinate = new GPSCoordinate(latitude, longitude);
|
||||
|
||||
boat.setCurrentPosition(gpsCoordinate);
|
||||
|
||||
//Bearing.
|
||||
boat.setBearing(Bearing.fromDegrees(boatLocation.getHeadingDegrees()));
|
||||
boat.setBearing(boatLocation.getHeading());
|
||||
|
||||
//Time until next mark.
|
||||
boat.setEstimatedTimeAtNextMark(raceClock.getLocalTime(boatStatus.getEstTimeAtNextMark()));
|
||||
|
||||
//Speed.
|
||||
boat.setCurrentSpeed(boatLocation.getBoatSOG() / Constants.KnotsToMMPerSecond);
|
||||
boat.setCurrentSpeed(boatLocation.getBoatSpeedKnots());
|
||||
|
||||
|
||||
//Boat status.
|
||||
BoatStatusEnum newBoatStatusEnum = BoatStatusEnum.fromByte(boatStatus.getBoatStatus());
|
||||
BoatStatusEnum newBoatStatusEnum = boatStatus.getBoatStatus();
|
||||
|
||||
//If we are changing from non-racing to racing, we need to initialise boat with their time at last mark.
|
||||
if ((boat.getStatus() != BoatStatusEnum.RACING) && (newBoatStatusEnum == BoatStatusEnum.RACING)) {
|
||||
@@ -292,8 +291,8 @@ public class VisualiserRace extends Race implements Runnable {
|
||||
if (boatLocation != null) {
|
||||
|
||||
//We only update the boat's position.
|
||||
double latitude = boatLocation.getLatitudeDouble();
|
||||
double longitude = boatLocation.getLongitudeDouble();
|
||||
double latitude = boatLocation.getLatitude();
|
||||
double longitude = boatLocation.getLongitude();
|
||||
GPSCoordinate gpsCoordinate = new GPSCoordinate(latitude, longitude);
|
||||
|
||||
mark.setPosition(gpsCoordinate);
|
||||
@@ -309,12 +308,12 @@ public class VisualiserRace extends Race implements Runnable {
|
||||
private void updateRaceStatus(RaceStatus raceStatus) {
|
||||
|
||||
//Race status enum.
|
||||
this.raceStatusEnum = RaceStatusEnum.fromByte(raceStatus.getRaceStatus());
|
||||
this.raceStatusEnum = raceStatus.getRaceStatus();
|
||||
|
||||
//Wind.
|
||||
this.setWind(
|
||||
Bearing.fromDegrees(raceStatus.getScaledWindDirection()),
|
||||
raceStatus.getWindSpeedKnots() );
|
||||
raceStatus.getWindDirection(),
|
||||
raceStatus.getWindSpeed() );
|
||||
|
||||
//Current race time.
|
||||
this.raceClock.setUTCTime(raceStatus.getCurrentTime());
|
||||
|
||||
Reference in New Issue
Block a user