|
|
|
|
@ -22,13 +22,13 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
private GraphicsContext gc;
|
|
|
|
|
private RaceMap map;
|
|
|
|
|
private List<BoatInRace> boats;
|
|
|
|
|
private RaceDataSource raceData;
|
|
|
|
|
private boolean raceAnno = true;
|
|
|
|
|
private boolean annoName = true;
|
|
|
|
|
private boolean annoAbbrev = true;
|
|
|
|
|
private boolean annoSpeed = true;
|
|
|
|
|
private boolean annoPath = true;
|
|
|
|
|
private ArrayList<GPSCoordinate> raceBoundaries;
|
|
|
|
|
private List<GPSCoordinate> raceBoundaries;
|
|
|
|
|
private List<Marker> markers;
|
|
|
|
|
double[] xpoints = {}, ypoints = {};
|
|
|
|
|
|
|
|
|
|
public ResizableRaceCanvas(RaceDataSource raceData) {
|
|
|
|
|
@ -41,9 +41,11 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
double long1 = raceData.getMapTopLeft().getLongitude();
|
|
|
|
|
double lat2 = raceData.getMapBottomRight().getLatitude();
|
|
|
|
|
double long2 = raceData.getMapBottomRight().getLongitude();
|
|
|
|
|
|
|
|
|
|
setMap(new RaceMap(lat1, long1, lat2, long2, (int) getWidth(), (int) getHeight()));
|
|
|
|
|
|
|
|
|
|
this.raceData = raceData;
|
|
|
|
|
this.raceBoundaries = raceData.getBoundary();
|
|
|
|
|
this.markers = raceData.getMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -209,6 +211,22 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
gc.fillPolygon(xpoints, ypoints, xpoints.length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw race markers
|
|
|
|
|
*/
|
|
|
|
|
public void drawMarkers() {
|
|
|
|
|
for(Marker marker: markers) {
|
|
|
|
|
GraphCoordinate mark1 = this.map.convertGPS(marker.getMark1());
|
|
|
|
|
if(marker.isCompoundMark()) {
|
|
|
|
|
GraphCoordinate mark2 = this.map.convertGPS(marker.getMark2());
|
|
|
|
|
// TODO - improve colour coding of markers
|
|
|
|
|
displayLine(mark1, mark2, Color.GREEN);
|
|
|
|
|
} else {
|
|
|
|
|
displayPoint(mark1, Color.GREEN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draws the Race Map
|
|
|
|
|
*/
|
|
|
|
|
@ -225,67 +243,16 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
this.map.setHeight((int) height);
|
|
|
|
|
this.map.setWidth((int) width);
|
|
|
|
|
|
|
|
|
|
//finish line
|
|
|
|
|
gc.setLineWidth(2);
|
|
|
|
|
drawBoundaries();
|
|
|
|
|
drawPoints();
|
|
|
|
|
drawMarkers();
|
|
|
|
|
|
|
|
|
|
updateBoats();
|
|
|
|
|
|
|
|
|
|
//display wind direction arrow - specify origin point and angle - angle now set to random angle
|
|
|
|
|
displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void drawPoints() {
|
|
|
|
|
// GraphCoordinate finishLineCoord1 = this.map.convertGPS(Constants.finishLineMarker1);
|
|
|
|
|
// GraphCoordinate finishLineCoord2 = this.map.convertGPS(Constants.finishLineMarker2);
|
|
|
|
|
// displayLine(finishLineCoord1, finishLineCoord2, Color.DARKRED);
|
|
|
|
|
// //marks
|
|
|
|
|
// GraphCoordinate markCoord = this.map.convertGPS(Constants.mark1);
|
|
|
|
|
// GraphCoordinate windwardGate1 = this.map.convertGPS(Constants.windwardGate1);
|
|
|
|
|
// GraphCoordinate windwardGate2 = this.map.convertGPS(Constants.windwardGate2);
|
|
|
|
|
// GraphCoordinate leewardGate1 = this.map.convertGPS(Constants.leewardGate1);
|
|
|
|
|
// GraphCoordinate leewardGate2 = this.map.convertGPS(Constants.leewardGate2);
|
|
|
|
|
// displayMark(markCoord, Color.GOLD);
|
|
|
|
|
// displayLine(windwardGate1, windwardGate2, Color.DARKCYAN);
|
|
|
|
|
// displayLine(leewardGate1, leewardGate2, Color.DARKVIOLET);
|
|
|
|
|
// //start line
|
|
|
|
|
// GraphCoordinate startline1 = this.map.convertGPS(Constants.startLineMarker1);
|
|
|
|
|
// GraphCoordinate startline2 = this.map.convertGPS(Constants.startLineMarker2);
|
|
|
|
|
//
|
|
|
|
|
// displayLine(startline1, startline2, Color.GREEN);
|
|
|
|
|
|
|
|
|
|
for (Leg leg : raceData.getLegs()) {
|
|
|
|
|
boolean hasStart = false;
|
|
|
|
|
boolean hasEnd = false;
|
|
|
|
|
GraphCoordinate start1 = null;
|
|
|
|
|
GraphCoordinate start2 = null;
|
|
|
|
|
GraphCoordinate end1 = null;
|
|
|
|
|
GraphCoordinate end2 = null;
|
|
|
|
|
String legName = leg.getName().toLowerCase();
|
|
|
|
|
if (leg.getStartMarker() != null) {
|
|
|
|
|
start1 = this.map.convertGPS(leg.getStartMarker().getMark1());
|
|
|
|
|
start2 = this.map.convertGPS(leg.getStartMarker().getMark2());
|
|
|
|
|
hasStart = true;
|
|
|
|
|
} if (leg.getEndMarker() != null) {
|
|
|
|
|
end1 = this.map.convertGPS(leg.getEndMarker().getMark1());
|
|
|
|
|
end2 = this.map.convertGPS(leg.getEndMarker().getMark2());
|
|
|
|
|
hasEnd = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (legName.contains("line") || legName.contains("gate")) {
|
|
|
|
|
if (hasStart && start1 != null && start2 != null) displayLine(start1, start2, Color.BLACK);
|
|
|
|
|
if (hasEnd && start1 != null && start2 != null) displayLine(end1, end2, Color.BLACK);
|
|
|
|
|
} else if (hasStart && start1 != null && start2 != null) {
|
|
|
|
|
if (legName.contains("start")) displayLine(start1, start2, Color.BLACK);
|
|
|
|
|
else displayMark(start1, Color.BLACK);
|
|
|
|
|
}
|
|
|
|
|
else if (hasEnd && end1 != null && end2 != null) {
|
|
|
|
|
if (legName.contains("finish")) displayLine(end1, end2, Color.BLACK);
|
|
|
|
|
else displayMark(end1, Color.BLACK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draws a boat at a certain GPSCoordinate
|
|
|
|
|
*
|
|
|
|
|
@ -356,7 +323,7 @@ public class ResizableRaceCanvas extends Canvas {
|
|
|
|
|
*/
|
|
|
|
|
public void updateBoats() {
|
|
|
|
|
// TODO Remove null when boats are ready
|
|
|
|
|
//boats = null;
|
|
|
|
|
boats = null;
|
|
|
|
|
if (boats != null) {
|
|
|
|
|
for (BoatInRace boat : boats) {
|
|
|
|
|
boolean finished = boat.getCurrentLeg().getName().equals("Finish") || boat.getCurrentLeg().getName().equals("DNF");
|
|
|
|
|
|