Added annotation to toggle all boat paths on and off #Pair[jjg64, zwu18] #Story[759]

main
Joseph Gardner 9 years ago
parent eb9fce1f22
commit fc15c3d151

@ -33,6 +33,9 @@ public class RaceController extends Controller {
@FXML SplitPane race;
@FXML
CheckBox showFPS;
@FXML
CheckBox showBoatPath;
@FXML
CheckBox showAnnotations;
@FXML
@ -226,6 +229,15 @@ public class RaceController extends Controller {
raceMap.update();
}
});
//listener for show abbreviation for annotation
showBoatPath.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov,
Boolean old_val, Boolean new_val) {
raceMap.toggleBoatPath();
raceMap.update();
}
});
//listener to show speed for annotation
showSpeed.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov,
@ -242,6 +254,7 @@ public class RaceController extends Controller {
presetAnno.add(showName.isSelected());
presetAnno.add(showAbbrev.isSelected());
presetAnno.add(showSpeed.isSelected());
presetAnno.add(showBoatPath.isSelected());
}
});
//listener to show saved annotation
@ -252,6 +265,7 @@ public class RaceController extends Controller {
showName.setSelected(presetAnno.get(0));
showAbbrev.setSelected(presetAnno.get(1));
showSpeed.setSelected(presetAnno.get(2));
showBoatPath.setSelected(presetAnno.get(3));
raceMap.update();
}
}

@ -32,7 +32,7 @@ public abstract class Race implements Runnable {
protected int scaleFactor;
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
protected int PRERACE_TIME = 0; //120000; //time in milliseconds to pause during pre-race
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
private boolean timerEnabled = true; //boolean to determine if timer is ran
/**

@ -29,6 +29,7 @@ public class ResizableRaceCanvas extends Canvas {
private boolean annoName = true;
private boolean annoAbbrev = true;
private boolean annoSpeed = true;
private boolean annoPath = true;
private ArrayList<GPSCoordinate> raceBoundaries;
double[] xpoints = {}, ypoints = {};
@ -298,6 +299,14 @@ public class ResizableRaceCanvas extends Canvas {
}
}
public void toggleBoatPath() {
if (annoPath) {
annoPath = false;
} else {
annoPath = true;
}
}
/**
* Toggle abbreviation display in annotation
*/
@ -353,11 +362,13 @@ public class ResizableRaceCanvas extends Canvas {
* @see seng302.Model.TrackPoint
*/
private void drawTrack(BoatInRace boat) {
for (TrackPoint point : boat.getTrack()) {
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
Color boatColour = boat.getColour();
gc.setFill(new Color(boatColour.getRed(), boatColour.getGreen(), boatColour.getBlue(), point.getAlpha()));
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), 5, 5);
if (annoPath) {
for (TrackPoint point : boat.getTrack()) {
GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate());
Color boatColour = boat.getColour();
gc.setFill(new Color(boatColour.getRed(), boatColour.getGreen(), boatColour.getBlue(), point.getAlpha()));
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), 5, 5);
}
}
}

@ -7,7 +7,6 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<SplitPane fx:id="race" dividerPositions="0.7" 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">
<items>
<GridPane fx:id="canvasBase">
@ -24,14 +23,15 @@
<panes>
<TitledPane animated="false" text="Annotation Control">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="240.0" prefWidth="200.0">
<children>
<CheckBox fx:id="showBoatPath" mnemonicParsing="false" selected="true" text="Show Boat Paths" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="104.0" />
<CheckBox fx:id="showAnnotations" layoutX="-2.0" layoutY="14.0" mnemonicParsing="false" selected="true" text="Show Annotations" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<CheckBox fx:id="showName" layoutY="39.0" mnemonicParsing="false" selected="true" text="Show Boat Name" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="26.0" />
<CheckBox fx:id="showAbbrev" layoutY="61.0" mnemonicParsing="false" selected="true" text="Show Boat Abbreviation" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="52.0" />
<CheckBox fx:id="showSpeed" layoutY="90.0" mnemonicParsing="false" selected="true" text="Show Boat Speed" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="78.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Annotation" AnchorPane.topAnchor="104.0" />
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0" mnemonicParsing="false" text="Show Set Annotation" AnchorPane.topAnchor="139.0" />
<Button fx:id="saveAnno" layoutX="11.0" layoutY="106.0" maxWidth="154.0" mnemonicParsing="false" prefWidth="154.0" text="Save Annotation" AnchorPane.topAnchor="130.0" />
<Button fx:id="showSetAnno" layoutX="11.0" layoutY="139.0" mnemonicParsing="false" text="Show Set Annotation" AnchorPane.topAnchor="160.0" />
</children>
</AnchorPane>
</content>
@ -74,4 +74,4 @@
</children>
</AnchorPane>
</items>
</SplitPane>
</SplitPane>

Loading…
Cancel
Save