Fixed Annotations and bound windarrow
- Wind arrow for the bermuda race is bound between 215 and 235 degrees - annotations will not correctly highlight what they are showing #story[877] #story[882]
This commit is contained in:
@@ -39,6 +39,7 @@ public class RaceController extends Controller {
|
||||
private static String speedCheckAnno = "speed";
|
||||
private static String pathCheckAnno = "path";
|
||||
private static String timeCheckAnno = "time";
|
||||
private static String estTimeCheckAnno = "est time";
|
||||
|
||||
private static int noBtn = 0;
|
||||
private static int hideBtn = 1;
|
||||
@@ -67,6 +68,7 @@ public class RaceController extends Controller {
|
||||
@FXML CheckBox showAbbrev;
|
||||
@FXML CheckBox showSpeed;
|
||||
@FXML CheckBox showTime;
|
||||
@FXML CheckBox showEstTime;
|
||||
@FXML Label timer;
|
||||
@FXML Label FPS;
|
||||
@FXML Label timeZone;
|
||||
@@ -356,7 +358,6 @@ public class RaceController extends Controller {
|
||||
if (buttonChecked != hideBtn) {
|
||||
//if we are checking the box straight out of hide instead of using the radio buttons
|
||||
annoShownBeforeHide.put(dictionaryAnnotationKey, selected);
|
||||
System.out.println();
|
||||
if (prevBtnChecked == hideBtn && buttonChecked == noBtn){
|
||||
storeCurrentAnnotationDictionary();
|
||||
}
|
||||
@@ -373,6 +374,7 @@ public class RaceController extends Controller {
|
||||
annoShownBeforeHide.put(pathCheckAnno, showBoatPath.isSelected());
|
||||
annoShownBeforeHide.put(speedCheckAnno, showSpeed.isSelected());
|
||||
annoShownBeforeHide.put(timeCheckAnno, showTime.isSelected());
|
||||
annoShownBeforeHide.put(estTimeCheckAnno, showEstTime.isSelected());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,7 +388,8 @@ public class RaceController extends Controller {
|
||||
importantAnno.put(abbrevCheckAnno, false);
|
||||
importantAnno.put(pathCheckAnno, false);
|
||||
importantAnno.put(speedCheckAnno, false);
|
||||
importantAnno.put(timeCheckAnno, true);
|
||||
importantAnno.put(timeCheckAnno, false);
|
||||
importantAnno.put(estTimeCheckAnno, false);
|
||||
|
||||
annoShownBeforeHide = new HashMap<>();
|
||||
annoShownBeforeHide.put(nameCheckAnno, true);
|
||||
@@ -394,6 +397,7 @@ public class RaceController extends Controller {
|
||||
annoShownBeforeHide.put(pathCheckAnno, true);
|
||||
annoShownBeforeHide.put(speedCheckAnno, true);
|
||||
annoShownBeforeHide.put(timeCheckAnno, true);
|
||||
annoShownBeforeHide.put(estTimeCheckAnno, true);
|
||||
//listener for show name in annotation
|
||||
showName.selectedProperty().addListener((ov, old_val, new_val) -> {
|
||||
if (old_val != new_val) {
|
||||
@@ -439,6 +443,14 @@ public class RaceController extends Controller {
|
||||
raceMap.update();
|
||||
}
|
||||
});
|
||||
showEstTime.selectedProperty().addListener((ov, old_val, new_val) -> {
|
||||
if (old_val != new_val) {
|
||||
raceMap.toggleAnnoEstTime();
|
||||
radioBtnChecked = false;
|
||||
storeCurrentAnnotationState(estTimeCheckAnno, new_val);
|
||||
raceMap.update();
|
||||
}
|
||||
});
|
||||
//listener to save currently selected annotation
|
||||
saveAnno.setOnAction(event -> {
|
||||
presetAnno.clear();
|
||||
@@ -447,9 +459,10 @@ public class RaceController extends Controller {
|
||||
presetAnno.add(showSpeed.isSelected());
|
||||
presetAnno.add(showBoatPath.isSelected());
|
||||
presetAnno.add(showTime.isSelected());
|
||||
presetAnno.add(showEstTime.isSelected());
|
||||
});
|
||||
//listener for hiding
|
||||
hideAnnoRBTN.setOnAction((e)->{
|
||||
System.out.println("called hide");
|
||||
buttonChecked = hideBtn;
|
||||
selectShow = false;
|
||||
showName.setSelected(false);
|
||||
@@ -457,55 +470,30 @@ public class RaceController extends Controller {
|
||||
showBoatPath.setSelected(false);
|
||||
showSpeed.setSelected(false);
|
||||
showTime.setSelected(false);
|
||||
showEstTime.setSelected(false);
|
||||
raceMap.update();
|
||||
buttonChecked = noBtn;
|
||||
prevBtnChecked = hideBtn;
|
||||
selectShow = true;
|
||||
});
|
||||
//listener for hiding
|
||||
/*hideAnnoRBTN.selectedProperty().addListener((ov, old_val, new_val) ->{
|
||||
buttonChecked = hideBtn;
|
||||
showName.setSelected(false);
|
||||
showAbbrev.setSelected(false);
|
||||
showBoatPath.setSelected(false);
|
||||
showSpeed.setSelected(false);
|
||||
showTime.setSelected(false);
|
||||
raceMap.update();
|
||||
buttonChecked = noBtn;
|
||||
prevBtnChecked = hideBtn;
|
||||
});*/
|
||||
//listener for showing all annotations
|
||||
showAnnoRBTN.setOnAction((e)->{
|
||||
if (selectShow) {
|
||||
System.out.println("called show");
|
||||
buttonChecked = showBtn;
|
||||
showName.setSelected(annoShownBeforeHide.get(nameCheckAnno));
|
||||
showAbbrev.setSelected(annoShownBeforeHide.get(abbrevCheckAnno));
|
||||
showBoatPath.setSelected(annoShownBeforeHide.get(pathCheckAnno));
|
||||
showSpeed.setSelected(annoShownBeforeHide.get(speedCheckAnno));
|
||||
showTime.setSelected(annoShownBeforeHide.get(timeCheckAnno));
|
||||
showEstTime.setSelected(annoShownBeforeHide.get(estTimeCheckAnno));
|
||||
raceMap.update();
|
||||
buttonChecked = noBtn;
|
||||
prevBtnChecked = showBtn;
|
||||
}
|
||||
selectShow = true;
|
||||
});/*.addListener((ov, old_val, new_val) ->{
|
||||
if (selectShow) {
|
||||
buttonChecked = showBtn;
|
||||
showName.setSelected(annoShownBeforeHide.get(nameCheckAnno));
|
||||
showAbbrev.setSelected(annoShownBeforeHide.get(abbrevCheckAnno));
|
||||
showBoatPath.setSelected(annoShownBeforeHide.get(pathCheckAnno));
|
||||
showSpeed.setSelected(annoShownBeforeHide.get(speedCheckAnno));
|
||||
showTime.setSelected(annoShownBeforeHide.get(timeCheckAnno));
|
||||
raceMap.update();
|
||||
buttonChecked = noBtn;
|
||||
prevBtnChecked = showBtn;
|
||||
}
|
||||
selectShow = true;
|
||||
});*/
|
||||
});
|
||||
//listener for showing all important
|
||||
partialAnnoRBTN.setOnAction((e)->{
|
||||
System.out.println("called Partial");
|
||||
selectShow = false;
|
||||
buttonChecked = partialBtn;
|
||||
showName.setSelected(false);
|
||||
@@ -513,6 +501,7 @@ public class RaceController extends Controller {
|
||||
showSpeed.setSelected(true);
|
||||
showBoatPath.setSelected(false);
|
||||
showTime.setSelected(false);
|
||||
showEstTime.setSelected(false);
|
||||
|
||||
raceMap.update();
|
||||
buttonChecked = noBtn;
|
||||
@@ -521,7 +510,6 @@ public class RaceController extends Controller {
|
||||
});
|
||||
//listener for showing all important
|
||||
importantAnnoRBTN.setOnAction((e) ->{
|
||||
System.out.println("called Important");
|
||||
selectShow = false;
|
||||
buttonChecked = importantBtn;
|
||||
if (presetAnno.size() > 0) {
|
||||
@@ -530,6 +518,7 @@ public class RaceController extends Controller {
|
||||
showSpeed.setSelected(presetAnno.get(2));
|
||||
showBoatPath.setSelected(presetAnno.get(3));
|
||||
showTime.setSelected(presetAnno.get(4));
|
||||
showEstTime.setSelected(presetAnno.get(5));
|
||||
storeCurrentAnnotationDictionary();
|
||||
raceMap.update();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ public class StartController extends Controller implements Observer {
|
||||
raceStat = visualiserInput.getRaceStatus().getRaceStatus();
|
||||
raceStatusLabel.setText("Race Status: " + visualiserInput.getRaceStatus().getRaceStatus());
|
||||
if (raceStat==2 || raceStat == 3) {
|
||||
System.out.println("countdown finished!");//TEMP DEBUG REMOVE
|
||||
stop();
|
||||
|
||||
startWrapper.setVisible(false);
|
||||
|
||||
@@ -114,16 +114,17 @@ public class StreamedRace implements Runnable {
|
||||
* Updates the boat's gps coordinates
|
||||
*
|
||||
* @param boat to be updated
|
||||
* @param millisecondsElapsed time since last update
|
||||
*/
|
||||
private void updatePosition(Boat boat, int millisecondsElapsed) {
|
||||
private void updatePosition(Boat boat) {
|
||||
int sourceID = boat.getSourceID();
|
||||
BoatLocation boatLocation = visualiserInput.getBoatLocationMessage(sourceID);
|
||||
BoatStatus boatStatus = visualiserInput.getBoatStatusMessage(sourceID);
|
||||
if(boatLocation != null) {
|
||||
double lat = boatLocation.getLatitudeDouble();
|
||||
double lon = boatLocation.getLongitudeDouble();
|
||||
boat.setCurrentPosition(new GPSCoordinate(lat, lon));
|
||||
boat.setHeading(boatLocation.getHeadingDegrees());
|
||||
boat.setEstTime(convertEstTime(boatStatus.getEstTimeAtNextMark(), boatLocation.getTime()));
|
||||
double MMPS_TO_KN = 0.001944;
|
||||
boat.setVelocity(boatLocation.getBoatSOG() * MMPS_TO_KN);
|
||||
}
|
||||
@@ -198,19 +199,20 @@ public class StreamedRace implements Runnable {
|
||||
public void handle(long arg0) {
|
||||
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
|
||||
|
||||
for (Boat boat : startingBoats) {
|
||||
if (boat != null && !boat.isFinished()) {
|
||||
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
|
||||
checkPosition(boat, totalTimeElapsed);
|
||||
for (Boat boat : startingBoats) {
|
||||
if (boat != null && !boat.isFinished()) {
|
||||
updatePosition(boat);
|
||||
checkPosition(boat, totalTimeElapsed);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (Marker mark: boatMarkers){
|
||||
if (mark != null){
|
||||
updateMarker(mark);
|
||||
for (Marker mark: boatMarkers){
|
||||
if (mark != null){
|
||||
updateMarker(mark);
|
||||
}
|
||||
}
|
||||
}
|
||||
//System.out.println(boatsFinished + ":" + startingBoats.size());
|
||||
if (visualiserInput.getRaceStatus().isFinished()){
|
||||
|
||||
if (visualiserInput.getRaceStatus().isFinished()) {
|
||||
controller.finishRace(startingBoats);
|
||||
stop();
|
||||
}
|
||||
@@ -258,4 +260,18 @@ public class StreamedRace implements Runnable {
|
||||
return startingBoats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes an estimated time an event will occur, and converts it to the number of seconds before the event will occur.
|
||||
*
|
||||
* @param estTimeMillis
|
||||
* @return int difference between time the race started and the estimated time
|
||||
*/
|
||||
private int convertEstTime(long estTimeMillis, long currentTime) {
|
||||
|
||||
long estElapsedMillis = estTimeMillis - currentTime;
|
||||
int estElapsedSecs = Math.round(estElapsedMillis/1000);
|
||||
return estElapsedSecs;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Boat {
|
||||
private boolean started = false;
|
||||
private boolean dnf = false;
|
||||
private int sourceID;
|
||||
private int estTime;
|
||||
private final Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
||||
private long nextValidTime = 0;
|
||||
|
||||
@@ -248,4 +249,21 @@ public class Boat {
|
||||
public void setTimeSinceLastMark(ZonedDateTime timeSinceLastMark) {
|
||||
this.timeSinceLastMark = timeSinceLastMark;
|
||||
}
|
||||
|
||||
public void setEstTime(int estTime) { this.estTime = estTime; }
|
||||
|
||||
public String getFormattedEstTime() {
|
||||
if (estTime < 0) {
|
||||
return " -";
|
||||
}
|
||||
if (estTime <= 60) {
|
||||
return " " + estTime + "s";
|
||||
} else {
|
||||
int seconds = estTime % 60;
|
||||
int minutes = (estTime - seconds) / 60;
|
||||
return String.format(" %dm %ds", minutes, seconds);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
private boolean annoAbbrev = true;
|
||||
private boolean annoSpeed = true;
|
||||
private boolean annoPath = true;
|
||||
private boolean annoEstTime = true;
|
||||
private boolean annoTimeSinceLastMark = true;
|
||||
private List<Color> colours;
|
||||
private final List<Marker> markers;
|
||||
@@ -177,7 +178,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
* @param coordinate coordinate the text appears
|
||||
* @param timeSinceLastMark time since the last mark was passed
|
||||
*/
|
||||
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, ZonedDateTime timeSinceLastMark) {
|
||||
private void displayText(String name, String abbrev, double speed, GraphCoordinate coordinate, String estTime, ZonedDateTime timeSinceLastMark) {
|
||||
String text = "";
|
||||
//Check name toggle value
|
||||
if (annoName){
|
||||
@@ -191,10 +192,13 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
if (annoSpeed){
|
||||
text += String.format("%.2fkn ", speed);
|
||||
}
|
||||
if (annoEstTime) {
|
||||
text += estTime;
|
||||
}
|
||||
//Check time since last mark toggle value
|
||||
if(annoTimeSinceLastMark){
|
||||
Duration timeSince = Duration.between(timeSinceLastMark, raceClock.getTime());
|
||||
text += String.format("%d", timeSince.getSeconds());
|
||||
text += String.format(" %ds ", timeSince.getSeconds());
|
||||
}
|
||||
//String text = String.format("%s, %2$.2fkn", name, speed);
|
||||
long xCoord = coordinate.getX() + 20;
|
||||
@@ -277,6 +281,10 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
annoPath = !annoPath;
|
||||
}
|
||||
|
||||
public void toggleAnnoEstTime() {
|
||||
annoEstTime = !annoEstTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle boat time display in annotation
|
||||
*/
|
||||
@@ -320,7 +328,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
if (Duration.between(boat.getTimeSinceLastMark(), raceClock.getTime()).getSeconds() < 0) {
|
||||
boat.setTimeSinceLastMark(raceClock.getTime());
|
||||
}
|
||||
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getTimeSinceLastMark());
|
||||
displayText(boat.toString(), boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()), boat.getFormattedEstTime(), boat.getTimeSinceLastMark());
|
||||
//TODO this needs to be fixed.
|
||||
drawTrack(boat, boatColours.get(sourceID));
|
||||
}
|
||||
|
||||
@@ -88,6 +88,10 @@ public class VisualiserInput implements Runnable {
|
||||
return boatLocationMap.get(sourceID);
|
||||
}
|
||||
|
||||
public BoatStatus getBoatStatusMessage(int sourceID) {
|
||||
return boatStatusMap.get(sourceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the time since last heartbeat, in milliseconds.
|
||||
* @return Time since last heartbeat, in milliseconds..
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.chart.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.chart.LineChart?>
|
||||
<?import javafx.scene.chart.NumberAxis?>
|
||||
<?import javafx.scene.control.Accordion?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.RadioButton?>
|
||||
<?import javafx.scene.control.Separator?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TitledPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<SplitPane fx:id="race" dividerPositions="0.7" prefHeight="431.0" prefWidth="610.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.Controllers.RaceController">
|
||||
@@ -24,7 +36,7 @@
|
||||
<children>
|
||||
<Accordion>
|
||||
<panes>
|
||||
<TitledPane animated="false" text="Annotation Control">
|
||||
<TitledPane animated="false" prefHeight="395.0" prefWidth="222.0" text="Annotation Control">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0">
|
||||
<children>
|
||||
@@ -33,13 +45,14 @@
|
||||
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="50.0" />
|
||||
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="75.0" />
|
||||
<CheckBox fx:id="showTime" mnemonicParsing="false" selected="true" text="Show Boat Leg Time" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="100.0" />
|
||||
<Separator prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" />
|
||||
<Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="130.0" />
|
||||
<RadioButton fx:id="hideAnnoRBTN" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="155.0" />
|
||||
<RadioButton fx:id="showAnnoRBTN" mnemonicParsing="false" text="Visible" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="180.0" />
|
||||
<RadioButton fx:id="partialAnnoRBTN" mnemonicParsing="false" text="Partial" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="205.0" />
|
||||
<RadioButton fx:id="importantAnnoRBTN" mnemonicParsing="false" text="Important" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="230.0" />
|
||||
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="255.0" />
|
||||
<CheckBox fx:id="showEstTime" mnemonicParsing="false" selected="true" text="Show Est. Time to Next Mark" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="125.0" />
|
||||
<Separator layoutX="19.6" layoutY="175.6" prefHeight="0.0" prefWidth="200.0" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="150.0" />
|
||||
<Label text="Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="150.0" />
|
||||
<RadioButton fx:id="hideAnnoRBTN" mnemonicParsing="false" text="Hidden" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="175.0" />
|
||||
<RadioButton fx:id="showAnnoRBTN" mnemonicParsing="false" text="Visible" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="200.0" />
|
||||
<RadioButton fx:id="partialAnnoRBTN" mnemonicParsing="false" text="Partial" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="225.0" />
|
||||
<RadioButton fx:id="importantAnnoRBTN" mnemonicParsing="false" text="Important" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="250.0" />
|
||||
<Button fx:id="saveAnno" layoutX="11.0" layoutY="126.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Important Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="275.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
||||
Reference in New Issue
Block a user