mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +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.FXMLLoader;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
import javafx.util.StringConverter;
|
||||
import seng302.models.*;
|
||||
import seng302.models.parsers.ConfigParser;
|
||||
|
||||
@@ -27,7 +29,7 @@ public class RaceViewController extends Thread{
|
||||
@FXML
|
||||
private VBox positionVbox;
|
||||
@FXML
|
||||
private CheckBox toggleAnnotation, toggleFps;
|
||||
private CheckBox toggleFps;
|
||||
@FXML
|
||||
private Text timerLabel;
|
||||
@FXML
|
||||
@@ -35,10 +37,11 @@ public class RaceViewController extends Thread{
|
||||
@FXML
|
||||
private Text windArrowText, windDirectionText;
|
||||
@FXML
|
||||
private Slider annotationSlider;
|
||||
@FXML
|
||||
private CanvasController includedCanvasController;
|
||||
|
||||
private ArrayList<Boat> startingBoats = new ArrayList<>();
|
||||
private boolean displayAnnotations;
|
||||
private boolean displayFps;
|
||||
private Timeline timerTimeline;
|
||||
private Map<Boat, TimelineInfo> timelineInfos = new HashMap<>();
|
||||
@@ -74,22 +77,50 @@ public class RaceViewController extends Thread{
|
||||
|
||||
|
||||
|
||||
private void initializeSettings(){
|
||||
displayAnnotations = true;
|
||||
private void initializeSettings() {
|
||||
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>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||
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(){
|
||||
@@ -270,10 +301,6 @@ public class RaceViewController extends Thread{
|
||||
return displayFps;
|
||||
}
|
||||
|
||||
public boolean isDisplayAnnotations() {
|
||||
return displayAnnotations;
|
||||
}
|
||||
|
||||
public Race getRace() {
|
||||
return race;
|
||||
}
|
||||
@@ -286,10 +313,54 @@ public class RaceViewController extends Thread{
|
||||
return startingBoats;
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void toggleAnnotations () {
|
||||
for (RaceObject ro : includedCanvasController.getRaceObjects()) {
|
||||
ro.toggleAnnotations();
|
||||
|
||||
private void setAnnotations(Integer annotationLevel) {
|
||||
switch (annotationLevel) {
|
||||
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);
|
||||
}
|
||||
|
||||
public void toggleAnnotations () {
|
||||
teamNameObject.setVisible(!teamNameObject.isVisible());
|
||||
velocityObject.setVisible(!velocityObject.isVisible());
|
||||
lineGroup.setVisible(!lineGroup.isVisible());
|
||||
wake.setVisible(!wake.isVisible());
|
||||
public void setTeamNameObjectVisible(Boolean visible) {
|
||||
teamNameObject.setVisible(visible);
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
@@ -76,6 +76,4 @@ public abstract class RaceObject extends Group {
|
||||
public abstract boolean hasRaceId (int... raceIds);
|
||||
|
||||
public abstract int[] getRaceIds ();
|
||||
|
||||
public abstract void toggleAnnotations ();
|
||||
}
|
||||
|
||||
@@ -223,9 +223,6 @@ public class MarkGroup extends RaceObject {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public void toggleAnnotations () {
|
||||
|
||||
}
|
||||
|
||||
public static int getMarkRadius() {
|
||||
return MARK_RADIUS;
|
||||
|
||||
Reference in New Issue
Block a user