mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Created annotation slider to display different levels of annotations
Removed toggleAnnotations method as abstract from race object and made only for boat group as it didnt make sense for markgroup, at least not currently as they have no annotations to show #story[558]
This commit is contained in:
@@ -9,11 +9,13 @@ import javafx.event.ActionEvent;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.Slider;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
import seng302.models.*;
|
import seng302.models.*;
|
||||||
import seng302.models.parsers.ConfigParser;
|
import seng302.models.parsers.ConfigParser;
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ public class RaceViewController extends Thread{
|
|||||||
@FXML
|
@FXML
|
||||||
private VBox positionVbox;
|
private VBox positionVbox;
|
||||||
@FXML
|
@FXML
|
||||||
private CheckBox toggleAnnotation, toggleFps;
|
private CheckBox toggleFps;
|
||||||
@FXML
|
@FXML
|
||||||
private Text timerLabel;
|
private Text timerLabel;
|
||||||
@FXML
|
@FXML
|
||||||
@@ -35,10 +37,11 @@ public class RaceViewController extends Thread{
|
|||||||
@FXML
|
@FXML
|
||||||
private Text windArrowText, windDirectionText;
|
private Text windArrowText, windDirectionText;
|
||||||
@FXML
|
@FXML
|
||||||
|
private Slider annotationSlider;
|
||||||
|
@FXML
|
||||||
private CanvasController includedCanvasController;
|
private CanvasController includedCanvasController;
|
||||||
|
|
||||||
private ArrayList<Boat> startingBoats = new ArrayList<>();
|
private ArrayList<Boat> startingBoats = new ArrayList<>();
|
||||||
private boolean displayAnnotations;
|
|
||||||
private boolean displayFps;
|
private boolean displayFps;
|
||||||
private Timeline timerTimeline;
|
private Timeline timerTimeline;
|
||||||
private Map<Boat, TimelineInfo> timelineInfos = new HashMap<>();
|
private Map<Boat, TimelineInfo> timelineInfos = new HashMap<>();
|
||||||
@@ -74,22 +77,50 @@ public class RaceViewController extends Thread{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initializeSettings(){
|
private void initializeSettings() {
|
||||||
displayAnnotations = true;
|
|
||||||
displayFps = true;
|
displayFps = true;
|
||||||
|
|
||||||
toggleAnnotation.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
|
||||||
displayAnnotations = !displayAnnotations;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
toggleFps.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
toggleFps.selectedProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||||
displayFps = !displayFps;
|
displayFps = !displayFps;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//SLIFER STUFF BELOW
|
||||||
|
annotationSlider.setLabelFormatter(new StringConverter<Double>() {
|
||||||
|
@Override
|
||||||
|
public String toString(Double n) {
|
||||||
|
if (n == 0) return "None";
|
||||||
|
if (n == 1) return "Low";
|
||||||
|
if (n == 2) return "Medium";
|
||||||
|
if (n == 3) return "All";
|
||||||
|
|
||||||
|
return "All";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Double fromString(String s) {
|
||||||
|
switch (s) {
|
||||||
|
case "None":
|
||||||
|
return 0d;
|
||||||
|
case "Low":
|
||||||
|
return 1d;
|
||||||
|
case "Medium":
|
||||||
|
return 2d;
|
||||||
|
case "All":
|
||||||
|
return 3d;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 3d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
annotationSlider.valueProperty().addListener((obs, oldval, newVal) ->
|
||||||
|
setAnnotations((int)annotationSlider.getValue()));
|
||||||
|
|
||||||
|
annotationSlider.setValue(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTimer(){
|
private void initializeTimer(){
|
||||||
@@ -270,10 +301,6 @@ public class RaceViewController extends Thread{
|
|||||||
return displayFps;
|
return displayFps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisplayAnnotations() {
|
|
||||||
return displayAnnotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Race getRace() {
|
public Race getRace() {
|
||||||
return race;
|
return race;
|
||||||
}
|
}
|
||||||
@@ -286,10 +313,54 @@ public class RaceViewController extends Thread{
|
|||||||
return startingBoats;
|
return startingBoats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
private void toggleAnnotations () {
|
private void setAnnotations(Integer annotationLevel) {
|
||||||
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
switch (annotationLevel) {
|
||||||
ro.toggleAnnotations();
|
case 0:
|
||||||
|
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
||||||
|
if(ro instanceof BoatGroup) {
|
||||||
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
|
bg.setTeamNameObjectVisible(false);
|
||||||
|
bg.setVelocityObjectVisible(false);
|
||||||
|
bg.setLineGroupVisible(false);
|
||||||
|
bg.setWakeVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
||||||
|
if(ro instanceof BoatGroup) {
|
||||||
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
|
bg.setTeamNameObjectVisible(true);
|
||||||
|
bg.setVelocityObjectVisible(false);
|
||||||
|
bg.setLineGroupVisible(false);
|
||||||
|
bg.setWakeVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
||||||
|
if(ro instanceof BoatGroup) {
|
||||||
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
|
bg.setTeamNameObjectVisible(true);
|
||||||
|
bg.setVelocityObjectVisible(false);
|
||||||
|
bg.setLineGroupVisible(true);
|
||||||
|
bg.setWakeVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
||||||
|
if(ro instanceof BoatGroup) {
|
||||||
|
BoatGroup bg = (BoatGroup) ro;
|
||||||
|
bg.setTeamNameObjectVisible(true);
|
||||||
|
bg.setVelocityObjectVisible(true);
|
||||||
|
bg.setLineGroupVisible(true);
|
||||||
|
bg.setWakeVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -229,11 +229,20 @@ public class BoatGroup extends RaceObject{
|
|||||||
wake.rotate(rotationalGoal);
|
wake.rotate(rotationalGoal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleAnnotations () {
|
public void setTeamNameObjectVisible(Boolean visible) {
|
||||||
teamNameObject.setVisible(!teamNameObject.isVisible());
|
teamNameObject.setVisible(visible);
|
||||||
velocityObject.setVisible(!velocityObject.isVisible());
|
}
|
||||||
lineGroup.setVisible(!lineGroup.isVisible());
|
|
||||||
wake.setVisible(!wake.isVisible());
|
public void setVelocityObjectVisible(Boolean visible) {
|
||||||
|
velocityObject.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLineGroupVisible(Boolean visible) {
|
||||||
|
lineGroup.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWakeVisible(Boolean visible) {
|
||||||
|
wake.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boat getBoat() {
|
public Boat getBoat() {
|
||||||
|
|||||||
@@ -76,6 +76,4 @@ public abstract class RaceObject extends Group {
|
|||||||
public abstract boolean hasRaceId (int... raceIds);
|
public abstract boolean hasRaceId (int... raceIds);
|
||||||
|
|
||||||
public abstract int[] getRaceIds ();
|
public abstract int[] getRaceIds ();
|
||||||
|
|
||||||
public abstract void toggleAnnotations ();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,9 +223,6 @@ public class MarkGroup extends RaceObject {
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public void toggleAnnotations () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMarkRadius() {
|
public static int getMarkRadius() {
|
||||||
return MARK_RADIUS;
|
return MARK_RADIUS;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.shape.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.control.CheckBox?>
|
<?import javafx.scene.control.CheckBox?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
@@ -12,7 +17,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
<GridPane prefHeight="1080.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.RaceViewController">
|
<GridPane prefHeight="1080.0" prefWidth="1920.0" 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.RaceViewController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
||||||
@@ -40,8 +45,7 @@
|
|||||||
<Font name="System Bold" size="13.0" />
|
<Font name="System Bold" size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<CheckBox fx:id="toggleAnnotation" layoutX="27.0" layoutY="462.0" mnemonicParsing="false" onAction="#toggleAnnotations" selected="true" text="Show annotations" />
|
<CheckBox fx:id="toggleFps" layoutX="21.0" layoutY="453.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" text="Show FPS" />
|
||||||
<CheckBox fx:id="toggleFps" layoutX="27.0" layoutY="488.0" mnemonicParsing="false" prefHeight="18.0" prefWidth="143.0" selected="true" text="Show FPS" />
|
|
||||||
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0" />
|
<VBox fx:id="positionVbox" layoutX="12.0" layoutY="280.0" prefHeight="140.0" prefWidth="200.0" />
|
||||||
<Pane layoutX="11.0" layoutY="30.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
<Pane layoutX="11.0" layoutY="30.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="51.0" prefWidth="193.0">
|
||||||
<children>
|
<children>
|
||||||
@@ -52,6 +56,8 @@
|
|||||||
</Text>
|
</Text>
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
|
<Slider fx:id="annotationSlider" blockIncrement="1.0" layoutX="38.0" layoutY="527.0" majorTickUnit="1.0" max="3.0" minorTickCount="0" prefHeight="51.0" prefWidth="170.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" />
|
||||||
|
<Label layoutX="10.0" layoutY="499.0" text="Annotations" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane fx:id="contentAnchorPane" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowSpan="2147483647" GridPane.valignment="TOP">
|
<AnchorPane fx:id="contentAnchorPane" prefHeight="960.0" prefWidth="1280.0" GridPane.columnIndex="1" GridPane.halignment="LEFT" GridPane.rowSpan="2147483647" GridPane.valignment="TOP">
|
||||||
|
|||||||
Reference in New Issue
Block a user