|
|
|
|
@ -39,9 +39,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
private Image sailsLuff = new Image("/images/sailsLuff.gif", 25, 10, false, false);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The race we read data from and draw.
|
|
|
|
|
* The race state we read data from and draw.
|
|
|
|
|
*/
|
|
|
|
|
private VisualiserRaceEvent visualiserRace;
|
|
|
|
|
private VisualiserRaceState raceState;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean annoName = true;
|
|
|
|
|
@ -56,14 +56,14 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructs a {@link ResizableRaceCanvas} using a given {@link VisualiserRaceEvent}.
|
|
|
|
|
* @param visualiserRace The race that data is read from in order to be drawn.
|
|
|
|
|
* @param raceState The race state to be drawn.
|
|
|
|
|
*/
|
|
|
|
|
public ResizableRaceCanvas(VisualiserRaceEvent visualiserRace) {
|
|
|
|
|
public ResizableRaceCanvas(VisualiserRaceState raceState) {
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
this.visualiserRace = visualiserRace;
|
|
|
|
|
this.raceState = raceState;
|
|
|
|
|
|
|
|
|
|
RaceDataSource raceData = visualiserRace.getVisualiserRaceState().getRaceDataSource();
|
|
|
|
|
RaceDataSource raceData = raceState.getRaceDataSource();
|
|
|
|
|
|
|
|
|
|
double lat1 = raceData.getMapTopLeft().getLatitude();
|
|
|
|
|
double long1 = raceData.getMapTopLeft().getLongitude();
|
|
|
|
|
@ -276,8 +276,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
boat.getCountry(),
|
|
|
|
|
boat.getCurrentSpeed(),
|
|
|
|
|
this.map.convertGPS(boat.getPosition()),
|
|
|
|
|
boat.getTimeToNextMarkFormatted(this.visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()),
|
|
|
|
|
boat.getTimeSinceLastMarkFormatted(this.visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()),
|
|
|
|
|
boat.getTimeToNextMarkFormatted(raceState.getRaceClock().getCurrentTime()),
|
|
|
|
|
boat.getTimeSinceLastMarkFormatted(raceState.getRaceClock().getCurrentTime()),
|
|
|
|
|
Color.BLACK,
|
|
|
|
|
20 );
|
|
|
|
|
|
|
|
|
|
@ -291,7 +291,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
*/
|
|
|
|
|
private void drawBoats() {
|
|
|
|
|
|
|
|
|
|
List<VisualiserBoat> boats = new ArrayList<>(visualiserRace.getVisualiserRaceState().getBoats());
|
|
|
|
|
List<VisualiserBoat> boats = new ArrayList<>(raceState.getBoats());
|
|
|
|
|
//Sort to ensure we draw boats in consistent order.
|
|
|
|
|
boats.sort(Comparator.comparingInt(Boat::getSourceID));
|
|
|
|
|
|
|
|
|
|
@ -510,7 +510,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
*/
|
|
|
|
|
private void drawMarks() {
|
|
|
|
|
|
|
|
|
|
for (Mark mark : new ArrayList<>(visualiserRace.getVisualiserRaceState().getMarks())) {
|
|
|
|
|
for (Mark mark : new ArrayList<>(raceState.getMarks())) {
|
|
|
|
|
drawMark(mark);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -574,7 +574,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Calculate the screen coordinates of the boundary.
|
|
|
|
|
List<GPSCoordinate> boundary = new ArrayList<>(visualiserRace.getVisualiserRaceState().getBoundary());
|
|
|
|
|
List<GPSCoordinate> boundary = new ArrayList<>(raceState.getBoundary());
|
|
|
|
|
double[] xpoints = new double[boundary.size()];
|
|
|
|
|
double[] ypoints = new double[boundary.size()];
|
|
|
|
|
|
|
|
|
|
@ -601,8 +601,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
public void drawRace() {
|
|
|
|
|
|
|
|
|
|
//Update RaceMap with new GPS values of race.
|
|
|
|
|
this.map.setGPSTopLeft(visualiserRace.getVisualiserRaceState().getRaceDataSource().getMapTopLeft());
|
|
|
|
|
this.map.setGPSBotRight(visualiserRace.getVisualiserRaceState().getRaceDataSource().getMapBottomRight());
|
|
|
|
|
this.map.setGPSTopLeft(raceState.getRaceDataSource().getMapTopLeft());
|
|
|
|
|
this.map.setGPSBotRight(raceState.getRaceDataSource().getMapBottomRight());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clear();
|
|
|
|
|
@ -627,7 +627,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|
|
|
|
* draws a transparent line around the course that shows the paths boats must travel
|
|
|
|
|
*/
|
|
|
|
|
public void drawRaceLine(){
|
|
|
|
|
List<Leg> legs = this.visualiserRace.getVisualiserRaceState().getLegs();
|
|
|
|
|
List<Leg> legs = raceState.getLegs();
|
|
|
|
|
GPSCoordinate legStartPoint = legs.get(0).getStartCompoundMark().getAverageGPSCoordinate();
|
|
|
|
|
GPSCoordinate nextStartPoint;
|
|
|
|
|
for (int i = 0; i < legs.size() -1; i++) {
|
|
|
|
|
|