Now reads course wind direction from the live stream, so the wind arrow now changes when the wind changes. #story[882]

This commit is contained in:
Joseph Gardner
2017-05-08 17:23:55 +12:00
parent a32775eab6
commit e1ba2ae5b6
4 changed files with 32 additions and 3 deletions
@@ -8,6 +8,7 @@ import javafx.scene.paint.Paint;
import javafx.scene.transform.Rotate;
import seng302.*;
import seng302.Controllers.RaceController;
import seng302.Mock.StreamedCourse;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,6 +30,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
private List<Color> colours;
private List<Marker> markers;
double[] xpoints = {}, ypoints = {};
RaceDataSource raceData;
public ResizableRaceCanvas(RaceDataSource raceData) {
super();
@@ -42,6 +44,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
this.markers = raceData.getMarkers();
makeColours();
this.raceData = raceData;
}
/**
@@ -133,7 +136,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
* @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
* @see GraphCoordinate
*/
private void displayArrow(GraphCoordinate coordinate, int angle) {
private void displayArrow(GraphCoordinate coordinate, double angle) {
gc.save();
rotate(angle, coordinate.getX(), coordinate.getY());
gc.setFill(Color.BLACK);
@@ -236,7 +239,11 @@ public class ResizableRaceCanvas extends ResizableCanvas {
drawMarkers();
//display wind direction arrow - specify origin point and angle - angle now set to random angle
displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
if (raceData instanceof StreamedCourse) {
displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), ((StreamedCourse) raceData).getWindDirection());
} else {
displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
}
}
/**
@@ -363,4 +370,4 @@ public class ResizableRaceCanvas extends ResizableCanvas {
));
}
}
}