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:
@@ -14,6 +14,7 @@ public class StreamedCourse extends Observable implements RaceDataSource {
|
||||
StreamedCourseXMLReader streamedCourseXMLReader = null;
|
||||
BoatXMLReader boatXMLReader = null;
|
||||
RegattaXMLReader regattaXMLReader = null;
|
||||
private double windDirection = 0;
|
||||
|
||||
public StreamedCourse() {}
|
||||
|
||||
@@ -54,6 +55,14 @@ public class StreamedCourse extends Observable implements RaceDataSource {
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
public void setWindDirection(double windDirection) {
|
||||
this.windDirection = windDirection;
|
||||
}
|
||||
|
||||
public double getWindDirection() {
|
||||
return windDirection;
|
||||
}
|
||||
|
||||
public boolean hasReadRegatta() { return regattaXMLReader != null; }
|
||||
|
||||
public boolean hasReadBoats() { return boatXMLReader != null; }
|
||||
|
||||
@@ -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 {
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -157,6 +157,13 @@ public class VisualiserInput implements Runnable {
|
||||
return markRoundingMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wind direction for the current course.
|
||||
*/
|
||||
private void setCourseWindDirection(double direction) {
|
||||
this.course.setWindDirection(direction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns the next message as an array of bytes from the socket. Use getNextMessage() to get the actual message object instead.
|
||||
* @return Encoded binary message bytes.
|
||||
@@ -286,6 +293,7 @@ public class VisualiserInput implements Runnable {
|
||||
for (BoatStatus boatStatus: this.raceStatus.getBoatStatuses()) {
|
||||
this.boatStatusMap.put(boatStatus.getSourceID(), boatStatus);
|
||||
}
|
||||
setCourseWindDirection(raceStatus.getScaledWindDirection() + 180);
|
||||
}
|
||||
//DisplayTextMessage.
|
||||
/*else if (message instanceof DisplayTextMessage) {
|
||||
|
||||
Reference in New Issue
Block a user