Merge remote-tracking branch 'origin/master' into story_61
This commit is contained in:
@@ -12,7 +12,6 @@ import shared.model.GPSCoordinate;
|
||||
import shared.model.Mark;
|
||||
import shared.model.RaceClock;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,12 +38,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
*/
|
||||
private VisualiserRace visualiserRace;
|
||||
|
||||
/**
|
||||
* The background of the race.
|
||||
* We render the background whenever the race boundary changes, or the screen size changes.
|
||||
*/
|
||||
private Image background;
|
||||
|
||||
|
||||
private boolean annoName = true;
|
||||
private boolean annoAbbrev = true;
|
||||
@@ -54,22 +47,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
private boolean annoTimeSinceLastMark = true;
|
||||
|
||||
|
||||
/**
|
||||
* The wind arrow node.
|
||||
*/
|
||||
private Node arrow;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a {@link ResizableRaceCanvas} using a given {@link VisualiserRace}.
|
||||
* @param visualiserRace The race that data is read from in order to be drawn.
|
||||
* @param arrow The wind arrow's node.
|
||||
*/
|
||||
public ResizableRaceCanvas(VisualiserRace visualiserRace, Node arrow) {
|
||||
public ResizableRaceCanvas(VisualiserRace visualiserRace) {
|
||||
super();
|
||||
|
||||
this.visualiserRace = visualiserRace;
|
||||
this.arrow = arrow;
|
||||
|
||||
RaceDataSource raceData = visualiserRace.getRaceDataSource();
|
||||
|
||||
@@ -375,32 +361,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Displays an arrow representing wind direction on the Canvas.
|
||||
* This function accepts a wind-to bearing, but displays a wind-from bearing.
|
||||
*
|
||||
* @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
|
||||
* @see GraphCoordinate
|
||||
*/
|
||||
private void displayWindArrow(double angle) {
|
||||
|
||||
//We need to display wind-from, so add 180 degrees.
|
||||
angle += 180d;
|
||||
|
||||
//Get it within [0, 360).
|
||||
while (angle >= 360d) {
|
||||
angle -= 360d;
|
||||
}
|
||||
|
||||
//Rotate the wind arrow.
|
||||
if (arrow != null && arrow.getRotate() != angle) {
|
||||
arrow.setRotate(angle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws all of the {@link Mark}s on the canvas.
|
||||
*/
|
||||
@@ -440,13 +400,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
this.map.setWidth((int) getWidth());
|
||||
this.map.setHeight((int) getHeight());
|
||||
|
||||
//Redraw the boundary.
|
||||
redrawBoundaryImage();
|
||||
|
||||
//Draw the race.
|
||||
drawRace();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -459,15 +415,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
|
||||
/**
|
||||
* Draws the race boundary, and saves the image to {@link #background}.
|
||||
* You should call {@link #clear()} before calling this.
|
||||
* Draws the race boundary.
|
||||
*/
|
||||
private void redrawBoundaryImage() {
|
||||
private void drawBoundary() {
|
||||
|
||||
//Prepare to draw.
|
||||
gc.setLineWidth(1);
|
||||
gc.setFill(Color.AQUA);
|
||||
gc.drawImage(new Image(getClass().getClassLoader().getResourceAsStream("images/WaterBackground.png")), 0, 0);
|
||||
|
||||
|
||||
//Calculate the screen coordinates of the boundary.
|
||||
@@ -487,9 +441,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
//Draw the boundary.
|
||||
gc.fillPolygon(xpoints, ypoints, xpoints.length);
|
||||
|
||||
//Render boundary to image.
|
||||
this.background = snapshot(null, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,18 +462,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
//Marks.
|
||||
drawMarks();
|
||||
|
||||
//Wind arrow. This rotates the wind arrow node.
|
||||
displayWindArrow(this.visualiserRace.getWindDirection().degrees());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the race boundary image onto the canvas.
|
||||
* See {@link #background}.
|
||||
*/
|
||||
private void drawBoundary() {
|
||||
gc.drawImage(this.background, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user