Wind Arrow direction fixed
- arrow shows wind direction as from instead of to - removed old unused displayArrow method - renamed displayFancyArrow to displayWindArrow - removed coordinates parameter not used #story[882, 1003]
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package seng302.Model;
|
||||
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.transform.Rotate;
|
||||
@@ -14,8 +13,6 @@ import seng302.RaceMap;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -134,24 +131,18 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
|
||||
/**
|
||||
* Displays an arrow on the Canvas
|
||||
* Displays an arrow representing wind direction on the Canvas
|
||||
*
|
||||
* @param coordinate Coordinate that the arrow is to be displayed at.
|
||||
* @param angle Angle that the arrow is to be facing in degrees 0 degrees = North (Up).
|
||||
* @see GraphCoordinate
|
||||
*/
|
||||
private void displayArrow(GraphCoordinate coordinate, double angle) {
|
||||
gc.save();
|
||||
rotate(angle, coordinate.getX(), coordinate.getY());
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillPolygon(new double[]{coordinate.getX() - 12, coordinate.getX() - 6, coordinate.getX(), coordinate.getX() - 4, coordinate.getX() - 4, coordinate.getX() - 8, coordinate.getX() - 8},
|
||||
new double[]{coordinate.getY() - 5, coordinate.getY() - 20, coordinate.getY() - 5, coordinate.getY() - 5, coordinate.getY() + 20, coordinate.getY() + 20, coordinate.getY() - 5},
|
||||
7);
|
||||
gc.restore();
|
||||
}
|
||||
|
||||
private void displayFancyArrow(GraphCoordinate coordinate, double angle) {
|
||||
private void displayWindArrow(double angle) {
|
||||
angle = angle % 360;
|
||||
|
||||
// show direction wind is coming from
|
||||
if (angle<180){angle = angle + 180;}
|
||||
else {angle = angle - 180;}
|
||||
|
||||
if (arrow != null && arrow.getRotate() != angle) {
|
||||
arrow.setRotate(angle);
|
||||
}
|
||||
@@ -260,9 +251,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
//display wind direction arrow - specify origin point and angle - angle now set to random angle
|
||||
if (raceData instanceof StreamedCourse) {
|
||||
displayFancyArrow(new GraphCoordinate((int) getWidth() - 40, 40), ((StreamedCourse) raceData).getWindDirection());
|
||||
displayWindArrow(((StreamedCourse) raceData).getWindDirection());
|
||||
} else {
|
||||
displayFancyArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
|
||||
displayWindArrow(150);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user