Merged with develop

This commit is contained in:
Calum
2017-05-25 01:21:40 +12:00
parent 5e26ad7c36
commit 3085125f3e
7 changed files with 27 additions and 113 deletions
+2 -2
View File
@@ -64,9 +64,9 @@ public class App extends Application {
} }
//Change the StreamReceiver in this else block to change the default data source. //Change the StreamReceiver in this else block to change the default data source.
else{ else{
// sr = new StreamReceiver("localhost", 4949, "RaceStream"); sr = new StreamReceiver("localhost", 4949, "RaceStream");
// sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941, "RaceStream"); // sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941, "RaceStream");
sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream"); // sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
} }
sr.start(); sr.start();
@@ -22,7 +22,6 @@ import seng302.models.mark.MarkType;
import seng302.models.mark.SingleMark; import seng302.models.mark.SingleMark;
import seng302.models.map.Boundary; import seng302.models.map.Boundary;
import seng302.models.map.CanvasMap; import seng302.models.map.CanvasMap;
import seng302.models.mark.*;
import seng302.models.stream.StreamParser; import seng302.models.stream.StreamParser;
import seng302.models.stream.XMLParser; import seng302.models.stream.XMLParser;
import seng302.models.stream.XMLParser.RaceXMLObject.Limit; import seng302.models.stream.XMLParser.RaceXMLObject.Limit;
@@ -132,62 +131,37 @@ public class CanvasController {
initializeBoats(); initializeBoats();
initializeMarks(); initializeMarks();
timer = new AnimationTimer() { timer = new AnimationTimer() {
private int UPDATE_FPM_PERIOD = 50; // update FPM label every 50 frames
private int updateFPMCounter = 100;
private long lastTime = 0; private long lastTime = 0;
@Override @Override
public void handle(long now) { public void handle(long now) {
//fps stuff
long oldFrameTime = frameTimes[frameTimeIndex] ;
frameTimes[frameTimeIndex] = now ;
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length ;
if (frameTimeIndex == 0) {
arrayFilled = true ;
}
long elapsedNanos;
if (arrayFilled) {
elapsedNanos = now - oldFrameTime ;
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ;
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
if (updateFPMCounter++ > UPDATE_FPM_PERIOD) {
updateFPMCounter = 0;
drawFps(frameRate.intValue());
}
raceViewController.updateSparkLine();
}
// TODO: 1/05/17 cir27 - Make the RaceObjects update on the actual delay.
elapsedNanos = 1000 / 60;
updateGroups();
if (StreamParser.isRaceFinished()) {
this.stop();
if (lastTime == 0) { if (lastTime == 0) {
lastTime = now; lastTime = now;
} else { } else {
if (now - lastTime >= (1e8 / 60)) { //Fix for framerate going above 60 when minimized if (now - lastTime >= (1e8 / 60)) { //Fix for framerate going above 60 when minimized
long oldFrameTime = frameTimes[frameTimeIndex] ; long oldFrameTime = frameTimes[frameTimeIndex];
frameTimes[frameTimeIndex] = now ; frameTimes[frameTimeIndex] = now;
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length ; frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length;
if (frameTimeIndex == 0) { if (frameTimeIndex == 0) {
arrayFilled = true ; arrayFilled = true;
} }
long elapsedNanos; long elapsedNanos;
if (arrayFilled) { if (arrayFilled) {
elapsedNanos = now - oldFrameTime ; elapsedNanos = now - oldFrameTime;
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ; long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ; frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
drawFps(frameRate.intValue()); drawFps(frameRate.intValue());
} }
updateGroups(frameRate); updateGroups();
if (StreamParser.isRaceFinished()) { if (StreamParser.isRaceFinished()) {
this.stop(); this.stop();
} }
lastTime = now; lastTime = now;
} }
} }
if (StreamParser.isRaceFinished()) {
this.stop();
}
} }
}; };
} }
@@ -239,7 +213,7 @@ public class CanvasController {
raceBorder.getPoints().setAll(boundaryPoints); raceBorder.getPoints().setAll(boundaryPoints);
} }
private void updateGroups(double frameRate){ private void updateGroups(){
for (BoatGroup boatGroup : boatGroups) { for (BoatGroup boatGroup : boatGroups) {
// some raceObjects will have multiple ID's (for instance gate marks) // some raceObjects will have multiple ID's (for instance gate marks)
//checking if the current "ID" has any updates associated with it //checking if the current "ID" has any updates associated with it
@@ -262,8 +236,6 @@ public class CanvasController {
private void checkForCourseChanges() { private void checkForCourseChanges() {
if (StreamParser.isNewRaceXmlReceived()){ if (StreamParser.isNewRaceXmlReceived()){
gc.clearRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
drawGoogleMap();
addRaceBorder(); addRaceBorder();
} }
} }
@@ -6,7 +6,6 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Side;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.chart.LineChart; import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis; import javafx.scene.chart.NumberAxis;
@@ -442,49 +441,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
return displayFps; return displayFps;
} }
/**
* Display the important annotations for a specific BoatGroup
*
* @param bg The boat group to set the annotations for
*/
private void setBoatGroupImportantAnnotations(BoatGroup bg) {
if (importantAnnotations.getAnnotationState(Annotation.NAME)) {
bg.setTeamNameObjectVisible(true);
} else {
bg.setTeamNameObjectVisible(false);
}
if (importantAnnotations.getAnnotationState(Annotation.SPEED)) {
bg.setVelocityObjectVisible(true);
} else {
bg.setVelocityObjectVisible(false);
}
if (importantAnnotations.getAnnotationState(Annotation.TRACK)) {
bg.setLineGroupVisible(true);
} else {
bg.setLineGroupVisible(false);
}
if (importantAnnotations.getAnnotationState(Annotation.WAKE)) {
bg.setWakeVisible(true);
} else {
bg.setWakeVisible(false);
}
//TODO fix boat annotations with new boatgroup
if (importantAnnotations.getAnnotationState(Annotation.ESTTIMETONEXTMARK)) {
bg.setEstTimeToNextMarkObjectVisible(true);
} else {
bg.setEstTimeToNextMarkObjectVisible(false);
}
if (importantAnnotations.getAnnotationState(Annotation.LEGTIME)) {
bg.setLegTimeObjectVisible(true);
} else {
bg.setLegTimeObjectVisible(false);
}
}
private void setAnnotations(Integer annotationLevel) { private void setAnnotations(Integer annotationLevel) {
switch (annotationLevel) { switch (annotationLevel) {
// No Annotations // No Annotations
@@ -6,12 +6,8 @@ import javafx.scene.control.Button;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage; import javafx.stage.Stage;
import seng302.controllers.RaceViewController;
import seng302.controllers.annotations.Annotation;
import java.net.URL; import java.net.URL;;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class ImportantAnnotationController implements Initializable { public class ImportantAnnotationController implements Initializable {
@@ -5,7 +5,6 @@ import javafx.scene.Group;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import seng302.controllers.annotations.Annotation;
import seng302.models.Yacht; import seng302.models.Yacht;
import seng302.models.stream.StreamParser; import seng302.models.stream.StreamParser;
-9
View File
@@ -1,19 +1,10 @@
package seng302.models; package seng302.models;
import javafx.beans.InvalidationListener;
import javafx.beans.property.*;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.Initializable;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import seng302.controllers.RaceViewController; import seng302.controllers.RaceViewController;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Year;
import java.util.ArrayList;
import java.util.List;
/** /**
* Yacht class for the racing boat. * Yacht class for the racing boat.