diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 00000000..1c24f9a8
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mock/pom.xml b/mock/pom.xml
index a81f8ac5..3d29db73 100644
--- a/mock/pom.xml
+++ b/mock/pom.xml
@@ -161,4 +161,4 @@
-
+
\ No newline at end of file
diff --git a/mock/src/main/java/seng302/Model/Race.java b/mock/src/main/java/seng302/Model/Race.java
index fa9223fe..a5de88c9 100644
--- a/mock/src/main/java/seng302/Model/Race.java
+++ b/mock/src/main/java/seng302/Model/Race.java
@@ -95,16 +95,19 @@ public class Race implements Runnable {
/**
- * Wind direction bearing.
- */
+ * Wind direction bearing.
+ */
private Bearing windDirection;
-
+
/**
- * Wind speed (knots).
- * Convert this to millimeters per second before passing to RaceStatus.
- */
+ * Wind speed (knots).
+ * Convert this to millimeters per second before passing to RaceStatus.
+ */
private double windSpeed;
+ private int windDir;
+ private int changeWind = 4;
+
/**
@@ -141,6 +144,7 @@ public class Race implements Runnable {
*/
public void run() {
initialiseBoats();
+ initialiseWindDir();
countdownTimer.start();
}
@@ -303,6 +307,9 @@ public class Race implements Runnable {
//Parse the marks.
parseMarks();
+ // Change wind direction
+ changeWindDir();
+
//Parse the race status.
parseRaceStatus();
@@ -314,7 +321,6 @@ public class Race implements Runnable {
this.stop();
}
-
//Update the animations timer's time.
currentTime = System.currentTimeMillis();
}
@@ -373,6 +379,9 @@ public class Race implements Runnable {
this.stop();
}
+ // Change wind direction
+ changeWindDir();
+
//Parse the boat locations.
parseBoatLocations();
@@ -828,4 +837,42 @@ public class Race implements Runnable {
public ObservableList getBoats() {
return boats;
}
-}
+
+ protected void initialiseWindDir(){
+ windDir = new Random().nextInt(65535+1);
+ this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
+ }
+
+ protected void changeWindDir(){
+ int r = new Random().nextInt(changeWind)+1;
+ if(r==1){
+ windDir+=100;
+ } else if (r==2){
+ windDir-=100;
+ }
+ if (windDir > 65535){
+ windDir -= 65535;
+ }
+ if (windDir < 0){
+ windDir += 65535;
+ }
+ this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
+ }
+
+ protected void setWindDir(int wind){
+ if (wind>=0 && wind<=65535){
+ windDir = wind;
+ this.windDirection = new Bearing(BoatLocation.convertHeadingIntToDouble(windDir));
+ }
+ }
+
+ protected void setChangeWind(int changeVal){
+ if (changeVal>=0){
+ changeWind = changeVal;
+ }
+ }
+
+ protected int getWind(){
+ return windDir;
+ }
+}
\ No newline at end of file
diff --git a/mock/src/test/java/seng302/Model/RaceTest.java b/mock/src/test/java/seng302/Model/RaceTest.java
index abfa5a8a..7365e320 100644
--- a/mock/src/test/java/seng302/Model/RaceTest.java
+++ b/mock/src/test/java/seng302/Model/RaceTest.java
@@ -222,7 +222,6 @@ public class RaceTest{
BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml", new Polars());
RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
Race testRace = new Race(raceDataSource, mockOutput);
-
testRace.setDnfChance(0);
assertFalse(testRace.doNotFinish());
@@ -289,12 +288,29 @@ public class RaceTest{
testBoat.setCurrentPosition(ORIGIN.getAverageGPSCoordinate());
testRace.updatePosition(testBoat, 100, 100);
assertFalse(testBoat.getCurrentPosition() == ORIGIN.getAverageGPSCoordinate());
-
} catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
e.printStackTrace();
fail();
}
}
+ @Ignore
+ @Test
+ public void windDirectionCorrectValues(){
+// try {
+// MockOutput mockOutput = Mockito.mock(MockOutput.class);
+// BoatDataSource boatDataSource = new BoatXMLReader("mockXML/boatTest.xml");
+// RaceDataSource raceDataSource = new RaceXMLReader("mockXML/raceTest.xml", boatDataSource);
+// Race testRace = new Race(raceDataSource, mockOutput);
+// testRace.setChangeWind(1);
+// testRace.setWindDir(65535);
+// testRace.changeWindDir();
+// assertEquals(100, testRace.getWind());
+// } catch (ParserConfigurationException | IOException | SAXException | ParseException | StreamedCourseXMLException e) {
+// e.printStackTrace();
+// fail();
+// }
+ }
+
}
diff --git a/visualiser/.idea/workspace.xml b/visualiser/.idea/workspace.xml
index 58b5f16d..8e698fa3 100644
--- a/visualiser/.idea/workspace.xml
+++ b/visualiser/.idea/workspace.xml
@@ -17,12 +17,12 @@
-
+
-
+
@@ -31,8 +31,8 @@
-
-
+
+
@@ -48,14 +48,18 @@
-
+
-
-
+
+
+
+
+
+
@@ -65,19 +69,18 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -86,7 +89,7 @@
-
+
@@ -96,7 +99,7 @@
-
+
@@ -106,7 +109,7 @@
-
+
@@ -116,8 +119,8 @@
-
-
+
+
@@ -128,7 +131,7 @@
-
+
@@ -138,8 +141,8 @@
-
-
+
+
@@ -148,7 +151,7 @@
-
+
@@ -158,7 +161,7 @@
-
+
@@ -211,8 +214,10 @@
DEFINITION_ORDER
-
-
+
+
+
+
@@ -538,6 +543,18 @@
+
+
+
@@ -676,136 +693,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -822,14 +709,6 @@
-
-
-
-
-
-
-
-
@@ -872,15 +751,6 @@
-
-
-
-
-
-
-
-
-
@@ -914,12 +784,6 @@
-
-
-
-
-
-
@@ -948,22 +812,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1025,13 +873,12 @@
-
+
-
@@ -1043,9 +890,7 @@
-
-
-
+
@@ -1053,10 +898,13 @@
-
+
+
+
+
@@ -1074,19 +922,110 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -1094,7 +1033,6 @@
-
@@ -1102,7 +1040,6 @@
-
@@ -1110,23 +1047,14 @@
-
-
-
-
-
-
-
-
-
+
-
@@ -1134,7 +1062,6 @@
-
@@ -1142,7 +1069,6 @@
-
@@ -1150,15 +1076,6 @@
-
-
-
-
-
-
-
-
-
@@ -1166,7 +1083,6 @@
-
@@ -1174,7 +1090,6 @@
-
@@ -1182,7 +1097,6 @@
-
@@ -1190,10 +1104,6 @@
-
-
-
-
@@ -1201,7 +1111,6 @@
-
@@ -1209,7 +1118,6 @@
-
@@ -1217,25 +1125,26 @@
-
-
-
-
-
+
+
+
+
+
+
-
+
@@ -1245,14 +1154,13 @@
-
-
-
+
+
@@ -1263,14 +1171,13 @@
-
-
-
+
+
@@ -1279,13 +1186,12 @@
-
-
+
@@ -1293,7 +1199,7 @@
-
+
@@ -1301,31 +1207,22 @@
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -1333,28 +1230,43 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/visualiser/pom.xml b/visualiser/pom.xml
index fb7b17a8..156c8e60 100644
--- a/visualiser/pom.xml
+++ b/visualiser/pom.xml
@@ -163,4 +163,4 @@
-
+
\ No newline at end of file
diff --git a/visualiser/src/main/java/seng302/Controllers/ArrowController.java b/visualiser/src/main/java/seng302/Controllers/ArrowController.java
new file mode 100644
index 00000000..af2113b3
--- /dev/null
+++ b/visualiser/src/main/java/seng302/Controllers/ArrowController.java
@@ -0,0 +1,17 @@
+package seng302.Controllers;
+
+import javafx.fxml.FXML;
+import javafx.scene.layout.Pane;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+/**
+ * Created by Joseph on 22/05/2017.
+ */
+public class ArrowController extends Controller {
+
+ @Override
+ public void initialize(URL location, ResourceBundle resources) {
+ }
+}
diff --git a/visualiser/src/main/java/seng302/Controllers/RaceController.java b/visualiser/src/main/java/seng302/Controllers/RaceController.java
index ddd0e12c..f52e5054 100644
--- a/visualiser/src/main/java/seng302/Controllers/RaceController.java
+++ b/visualiser/src/main/java/seng302/Controllers/RaceController.java
@@ -7,15 +7,23 @@ import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
+import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+import javafx.scene.paint.Paint;
import seng302.Mock.StreamedRace;
import seng302.Model.*;
import seng302.VisualiserInput;
import java.net.URL;
import java.util.*;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
* Created by fwy13 on 15/03/2017.
@@ -32,7 +40,9 @@ public class RaceController extends Controller {
private ArrayList colours;
private Map boatColours = new HashMap<>();
private int legNum;
+ @FXML Pane arrow;
@FXML SplitPane race;
+ @FXML StackPane arrowPane;
@FXML CheckBox showFPS;
@FXML CheckBox showBoatPath;
@FXML CheckBox showAnnotations;
@@ -166,6 +176,9 @@ public class RaceController extends Controller {
StreamedRace newRace = new StreamedRace(visualiserInput, this);
//newRace.initialiseBoats();
legNum = visualiserInput.getCourse().getLegs().size()-1;
+
+ makeArrow();
+
raceMap = new ResizableRaceCanvas(visualiserInput.getCourse());
raceMap.setMouseTransparent(true);
raceMap.widthProperty().bind(canvasBase.widthProperty());
@@ -173,6 +186,7 @@ public class RaceController extends Controller {
//raceMap.setBoats(newRace.getStartingBoats());
raceMap.draw();
raceMap.setVisible(true);
+ raceMap.setArrow(arrow.getChildren().get(0));
canvasBase.getChildren().add(0, raceMap);
@@ -182,6 +196,7 @@ public class RaceController extends Controller {
raceBoundaries.heightProperty().bind(canvasBase.heightProperty());
raceBoundaries.draw();
raceBoundaries.setVisible(true);
+
canvasBase.getChildren().add(0, raceBoundaries);
race.setVisible(true);
@@ -368,4 +383,8 @@ public class RaceController extends Controller {
(int)( color.getGreen() * 255 ),
(int)( color.getBlue() * 255 ) );
}
+
+ private void makeArrow() {
+ arrowPane.getChildren().add(arrow);
+ }
}
diff --git a/visualiser/src/main/java/seng302/Model/Boat.java b/visualiser/src/main/java/seng302/Model/Boat.java
index 5715927b..6e553318 100644
--- a/visualiser/src/main/java/seng302/Model/Boat.java
+++ b/visualiser/src/main/java/seng302/Model/Boat.java
@@ -66,7 +66,7 @@ public class Boat {
*/
public GPSCoordinate getWake() {
double reverseHeading = getHeading() - 180;
- double wakeScale = 3;
+ double wakeScale = 5;
double distance = wakeScale * getVelocity();
GeodeticCalculator calc = new GeodeticCalculator();
diff --git a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java
index 6c25391a..7a47b06c 100644
--- a/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java
+++ b/visualiser/src/main/java/seng302/Model/ResizableRaceCanvas.java
@@ -1,6 +1,8 @@
package seng302.Model;
+import javafx.scene.Node;
+import javafx.scene.layout.Pane;
import javafx.collections.ObservableList;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
@@ -30,6 +32,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
private final List markers;
private final RaceDataSource raceData;
private Map boatColours = new HashMap<>();
+ private Node arrow;
public ResizableRaceCanvas(RaceDataSource raceData) {
super();
@@ -140,6 +143,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
gc.restore();
}
+ private void displayFancyArrow(GraphCoordinate coordinate, double angle) {
+ angle = angle % 360;
+ if (arrow != null && arrow.getRotate() != angle) {
+ arrow.setRotate(angle);
+ }
+ }
+
/**
* Rotates things on the canvas Note: this must be called in between gc.save() and gc.restore() else they will rotate everything
*
@@ -234,9 +244,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) {
- displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), ((StreamedCourse) raceData).getWindDirection());
+ displayFancyArrow(new GraphCoordinate((int) getWidth() - 40, 40), ((StreamedCourse) raceData).getWindDirection());
} else {
- displayArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
+ displayFancyArrow(new GraphCoordinate((int) getWidth() - 40, 40), 150);
}
}
@@ -331,6 +341,10 @@ public class ResizableRaceCanvas extends ResizableCanvas {
));
}
+ public void setArrow(Node arrow) {
+ this.arrow = arrow;
+ }
+
private void mapBoatColours() {
int currentColour = 0;
for (Boat boat : boats) {
diff --git a/visualiser/src/main/java/seng302/VisualiserInput.java b/visualiser/src/main/java/seng302/VisualiserInput.java
index 4c11ca02..4c3df9d9 100644
--- a/visualiser/src/main/java/seng302/VisualiserInput.java
+++ b/visualiser/src/main/java/seng302/VisualiserInput.java
@@ -288,7 +288,7 @@ public class VisualiserInput implements Runnable {
for (BoatStatus boatStatus: this.raceStatus.getBoatStatuses()) {
this.boatStatusMap.put(boatStatus.getSourceID(), boatStatus);
}
- setCourseWindDirection(raceStatus.getScaledWindDirection() + 180);
+ setCourseWindDirection(raceStatus.getScaledWindDirection());
}
//DisplayTextMessage.
/*else if (message instanceof DisplayTextMessage) {
diff --git a/visualiser/src/main/resources/images/arrow.png b/visualiser/src/main/resources/images/arrow.png
new file mode 100644
index 00000000..fab6e21d
Binary files /dev/null and b/visualiser/src/main/resources/images/arrow.png differ
diff --git a/visualiser/src/main/resources/scenes/arrow.fxml b/visualiser/src/main/resources/scenes/arrow.fxml
new file mode 100644
index 00000000..6e8a88b5
--- /dev/null
+++ b/visualiser/src/main/resources/scenes/arrow.fxml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/visualiser/src/main/resources/scenes/race.fxml b/visualiser/src/main/resources/scenes/race.fxml
index 39828525..70f46745 100644
--- a/visualiser/src/main/resources/scenes/race.fxml
+++ b/visualiser/src/main/resources/scenes/race.fxml
@@ -19,6 +19,7 @@
+
@@ -69,6 +70,7 @@
+
@@ -85,10 +87,10 @@
-
+
-
+