mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Removed unused methods in RaceViewController.java
#story[923]
This commit is contained in:
@@ -51,8 +51,6 @@ public class RaceViewController extends Thread{
|
|||||||
private ArrayList<Yacht> startingBoats = new ArrayList<>();
|
private ArrayList<Yacht> startingBoats = new ArrayList<>();
|
||||||
private boolean displayFps;
|
private boolean displayFps;
|
||||||
private Timeline timerTimeline;
|
private Timeline timerTimeline;
|
||||||
private Map<Yacht, TimelineInfo> timelineInfos = new HashMap<>();
|
|
||||||
private ArrayList<Yacht> boatOrder = new ArrayList<>();
|
|
||||||
private Race race;
|
private Race race;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Integer annotationLevel;
|
private Integer annotationLevel;
|
||||||
@@ -66,12 +64,6 @@ public class RaceViewController extends Thread{
|
|||||||
for (Yacht boat : race.getBoats()) {
|
for (Yacht boat : race.getBoats()) {
|
||||||
startingBoats.add(boat);
|
startingBoats.add(boat);
|
||||||
}
|
}
|
||||||
// try{
|
|
||||||
// initializeTimelines();
|
|
||||||
// }
|
|
||||||
// catch (Exception e){
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
|
|
||||||
includedCanvasController.setup(this);
|
includedCanvasController.setup(this);
|
||||||
includedCanvasController.initializeCanvas();
|
includedCanvasController.initializeCanvas();
|
||||||
@@ -79,10 +71,6 @@ public class RaceViewController extends Thread{
|
|||||||
initializeSettings();
|
initializeSettings();
|
||||||
initialiseWindDirection();
|
initialiseWindDirection();
|
||||||
initialisePositionVBox();
|
initialisePositionVBox();
|
||||||
//set wind direction!!!!!!! can't find another place to put my code --haoming
|
|
||||||
// double windDirection = new ConfigParser("/config/config.xml").getWindDirection();
|
|
||||||
// windDirectionText.setText(String.format("%.1f°", windDirection));
|
|
||||||
// windArrowText.setRotate(windDirection);
|
|
||||||
includedCanvasController.timer.start();
|
includedCanvasController.timer.start();
|
||||||
|
|
||||||
selectAnnotationBtn.setOnAction(event -> {
|
selectAnnotationBtn.setOnAction(event -> {
|
||||||
@@ -225,97 +213,6 @@ public class RaceViewController extends Thread{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates time line for each boat, and stores time time into timelineInfos hash map
|
|
||||||
*/
|
|
||||||
private void initializeTimelines() {
|
|
||||||
HashMap<Yacht, List> boat_events = race.getEvents();
|
|
||||||
for (Yacht boat : boat_events.keySet()) {
|
|
||||||
startingBoats.add(boat);
|
|
||||||
// // x, y are the real time coordinates
|
|
||||||
// DoubleProperty x = new SimpleDoubleProperty();
|
|
||||||
// DoubleProperty y = new SimpleDoubleProperty();
|
|
||||||
//
|
|
||||||
// List<KeyFrame> keyFrames = new ArrayList<>();
|
|
||||||
// List<Event> events = boat_events.get(boat);
|
|
||||||
//
|
|
||||||
// // iterates all events and convert each event to keyFrame, then add them into a list
|
|
||||||
// for (Event event : events) {
|
|
||||||
// if (event.getIsFinishingEvent()) {
|
|
||||||
// keyFrames.add(
|
|
||||||
// new KeyFrame(Duration.seconds(event.getTime()),
|
|
||||||
// onFinished -> {race.setBoatFinished(boat); handleEvent(event);},
|
|
||||||
// new KeyValue(x, event.getThisMark().getLatitude()),
|
|
||||||
// new KeyValue(y, event.getThisMark().getLongitude())
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// keyFrames.add(
|
|
||||||
// new KeyFrame(Duration.seconds(event.getTime()),
|
|
||||||
// onFinished ->{
|
|
||||||
// handleEvent(event);
|
|
||||||
// boat.setHeading(event.getBoatHeading());
|
|
||||||
// },
|
|
||||||
// new KeyValue(x, event.getThisMark().getLatitude()),
|
|
||||||
// new KeyValue(y, event.getThisMark().getLongitude())
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// timelineInfos.put(boat, new TimelineInfo(new Timeline(keyFrames.toArray(new KeyFrame[keyFrames.size()])), x, y));
|
|
||||||
}
|
|
||||||
setRaceDuration();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setRaceDuration(){
|
|
||||||
Double maxDuration = 0.0;
|
|
||||||
Timeline maxTimeline = null;
|
|
||||||
|
|
||||||
for (TimelineInfo timelineInfo : timelineInfos.values()) {
|
|
||||||
|
|
||||||
Timeline timeline = timelineInfo.getTimeline();
|
|
||||||
if (timeline.getTotalDuration().toMillis() >= maxDuration) {
|
|
||||||
maxDuration = timeline.getTotalDuration().toMillis();
|
|
||||||
maxTimeline = timeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timelines are paused by default
|
|
||||||
timeline.play();
|
|
||||||
timeline.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
maxTimeline.setOnFinished(event -> {
|
|
||||||
race.setRaceFinished();
|
|
||||||
loadRaceResultView();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Play each boats timerTimeline
|
|
||||||
*/
|
|
||||||
public void playTimelines(){
|
|
||||||
for (TimelineInfo timelineInfo : timelineInfos.values()){
|
|
||||||
Timeline timeline = timelineInfo.getTimeline();
|
|
||||||
|
|
||||||
if (timeline.getStatus() == Animation.Status.PAUSED){
|
|
||||||
timeline.play();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pause each boats timerTimeline
|
|
||||||
*/
|
|
||||||
public void pauseTimelines(){
|
|
||||||
for (TimelineInfo timelineInfo : timelineInfos.values()){
|
|
||||||
Timeline timeline = timelineInfo.getTimeline();
|
|
||||||
|
|
||||||
if (timeline.getStatus() == Animation.Status.RUNNING){
|
|
||||||
timeline.pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the list of boats in the order they finished the race
|
* Display the list of boats in the order they finished the race
|
||||||
*/
|
*/
|
||||||
@@ -335,29 +232,11 @@ public class RaceViewController extends Thread{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleEvent(Event event) {
|
|
||||||
Yacht boat = event.getBoat();
|
|
||||||
boatOrder.remove(boat);
|
|
||||||
boat.setMarkLastPast(event.getMarkPosInRace());
|
|
||||||
boatOrder.add(boat);
|
|
||||||
boatOrder.sort(new Comparator<Yacht>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Yacht b1, Yacht b2) {
|
|
||||||
return b2.getMarkLastPast() - b1.getMarkLastPast();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
showOrder();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showOrder() {
|
private void showOrder() {
|
||||||
positionVbox.getChildren().clear();
|
positionVbox.getChildren().clear();
|
||||||
positionVbox.getChildren().removeAll();
|
positionVbox.getChildren().removeAll();
|
||||||
positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||||
|
|
||||||
// for (Boat boat : boatOrder) {
|
|
||||||
// positionVbox.getChildren().add(new Text(boat.getShortName() + " " + boat.getSpeedInKnots() + " Knots"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
for (Yacht boat : StreamParser.getBoatsPos().values()) {
|
for (Yacht boat : StreamParser.getBoatsPos().values()) {
|
||||||
if (boat.getBoatStatus() == 3) { // 3 is finish status
|
if (boat.getBoatStatus() == 3) { // 3 is finish status
|
||||||
Text textToAdd = new Text(boat.getPosition() + ". " +
|
Text textToAdd = new Text(boat.getPosition() + ". " +
|
||||||
@@ -424,15 +303,10 @@ public class RaceViewController extends Thread{
|
|||||||
return race;
|
return race;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Yacht, TimelineInfo> getTimelineInfos() {
|
|
||||||
return timelineInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Yacht> getStartingBoats(){
|
public ArrayList<Yacht> getStartingBoats(){
|
||||||
return startingBoats;
|
return startingBoats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setAnnotations(Integer annotationLevel) {
|
private void setAnnotations(Integer annotationLevel) {
|
||||||
switch (annotationLevel) {
|
switch (annotationLevel) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user