Cleaned up line to be in a shippable shape

#story[1101]
main
hba56 8 years ago
parent 22722286ef
commit bb75806781

@ -3,8 +3,7 @@ package visualiser.model;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.paint.Color; import javafx.scene.paint.*;
import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate; import javafx.scene.transform.Rotate;
import network.Messages.Enums.BoatStatusEnum; import network.Messages.Enums.BoatStatusEnum;
import shared.dataInput.RaceDataSource; import shared.dataInput.RaceDataSource;
@ -502,15 +501,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Race boundary. //Race boundary.
drawBoundary(); drawBoundary();
//Guiding Line
drawRaceLine();
//Boats. //Boats.
drawBoats(); drawBoats();
//Marks. //Marks.
drawMarks(); drawMarks();
//Guiding Line
drawRaceLine();
//Wind arrow. This rotates the wind arrow node. //Wind arrow. This rotates the wind arrow node.
displayWindArrow(this.visualiserRace.getWindDirection().degrees()); displayWindArrow(this.visualiserRace.getWindDirection().degrees());
@ -558,36 +557,49 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//use the direction line to find a point parallel to it by the mark //use the direction line to find a point parallel to it by the mark
GPSCoordinate pointToStartCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint, GPSCoordinate pointToStartCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
150, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()+90)); 100, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()+90));
//use the direction line to find a point to curve too //use the direction line to find a point to curve too
GPSCoordinate pointToEndCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint, GPSCoordinate pointToEndCurve = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
150, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees()+90)); 100, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees()+90));
//use the curve points to find the two control points for the bezier curve //use the curve points to find the two control points for the bezier curve
GPSCoordinate controlPoint;
GPSCoordinate controlPoint2;
Bearing bearingOfCurveLine = GPSCoordinate.calculateBearing(pointToStartCurve, pointToEndCurve); Bearing bearingOfCurveLine = GPSCoordinate.calculateBearing(pointToStartCurve, pointToEndCurve);
GPSCoordinate controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve, if ((bearingOfDirectionLine.degrees() - bearingOfNextDirectionLine.degrees() +360)%360< 145){
75, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+ 50)); //small turn
controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve,
50, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+45));
controlPoint2 = controlPoint;
}else{
//large turn
controlPoint = GPSCoordinate.calculateNewPosition(pointToStartCurve,
150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+90));
controlPoint2 = GPSCoordinate.calculateNewPosition(pointToEndCurve,
150, Azimuth.fromDegrees(bearingOfCurveLine.degrees()+90));
}
//change all gps into graph coordinate //change all gps into graph coordinate
GraphCoordinate startPath = this.map.convertGPS(startDirectionLinePoint); GraphCoordinate startPath = this.map.convertGPS(startDirectionLinePoint);
GraphCoordinate curvePoint = this.map.convertGPS(pointToStartCurve); GraphCoordinate curvePoint = this.map.convertGPS(pointToStartCurve);
GraphCoordinate curvePointEnd = this.map.convertGPS(pointToEndCurve); GraphCoordinate curvePointEnd = this.map.convertGPS(pointToEndCurve);
GraphCoordinate c1 = this.map.convertGPS(controlPoint); GraphCoordinate c1 = this.map.convertGPS(controlPoint);
GraphCoordinate c2 = this.map.convertGPS(controlPoint2);
gc.setStroke(Color.RED); gc.setLineWidth(2);
gc.setLineWidth(1); gc.setStroke(Color.MEDIUMAQUAMARINE);
gc.beginPath(); gc.beginPath();
gc.moveTo(startPath.getX(), startPath.getY()); gc.moveTo(startPath.getX(), startPath.getY());
gc.lineTo(curvePoint.getX(), curvePoint.getY()); gc.lineTo(curvePoint.getX(), curvePoint.getY());
gc.bezierCurveTo(c1.getX(), c1.getY(), c1.getX(), c1.getY(), curvePointEnd.getX(), curvePointEnd.getY()); drawArrowHead(startDirectionLinePoint, pointToStartCurve);
gc.bezierCurveTo(c1.getX(), c1.getY(), c2.getX(), c2.getY(), curvePointEnd.getX(), curvePointEnd.getY());
gc.stroke(); gc.stroke();
gc.closePath(); gc.closePath();
gc.save(); gc.save();
drawArrowHead(controlPoint, pointToEndCurve);
return pointToEndCurve; return pointToEndCurve;
}else{//last leg so no curve }else{//last leg so no curve
GraphCoordinate startPath = this.map.convertGPS(legStartPoint); GraphCoordinate startPath = this.map.convertGPS(legStartPoint);

Loading…
Cancel
Save