This commit is contained in:
Michael Rausch
2017-05-22 13:30:48 +12:00
3 changed files with 26 additions and 16 deletions
@@ -50,6 +50,7 @@ public class CanvasController {
private final int RHS_BUFFER = BUFFER_SIZE + MARK_SIZE / 2;
private final int TOP_BUFFER = BUFFER_SIZE;
private final int BOT_BUFFER = TOP_BUFFER + MARK_SIZE / 2;
private boolean horizontalInversion = false;
private double distanceScaleFactor;
private ScaleDirection scaleDirection;
@@ -128,7 +129,6 @@ public class CanvasController {
}
// TODO: 1/05/17 cir27 - Make the RaceObjects update on the actual delay.
elapsedNanos = 1000 / 60;
updateRaceObjects();
if (StreamParser.isRaceFinished()) {
this.stop();
@@ -386,16 +386,11 @@ public class CanvasController {
//If the course is on a point on the earth where longitudes wrap around.
Limit minLonMark = sortedPoints.get(0);
Limit maxLonMark = sortedPoints.get(sortedPoints.size()-1);
SingleMark thisMinLon = new SingleMark(minLonMark.toString(), minLonMark.getLat(), minLonMark.getLng(), minLonMark.getSeqID());
SingleMark thisMaxLon = new SingleMark(maxLonMark.toString(), maxLonMark.getLat(), maxLonMark.getLng(), maxLonMark.getSeqID());
// TODO: 30/03/17 cir27 - Correctly account for longitude wrapping around.
if (thisMaxLon.getLongitude() - thisMinLon.getLongitude() > 180) {
SingleMark temp = thisMinLon;
thisMinLon = thisMaxLon;
thisMaxLon = temp;
minLonPoint = new SingleMark(minLonMark.toString(), minLonMark.getLat(), minLonMark.getLng(), minLonMark.getSeqID());
minLatPoint = new SingleMark(maxLonMark.toString(), maxLonMark.getLat(), maxLonMark.getLng(), maxLonMark.getSeqID());
if (maxLonPoint.getLongitude() - minLonPoint.getLongitude() > 180) {
horizontalInversion = true;
}
minLonPoint = thisMinLon;
maxLonPoint = thisMaxLon;
}
/**
@@ -426,6 +421,9 @@ public class CanvasController {
referencePointX += distanceScaleFactor * Math.sin(referenceAngle) * Mark.calculateDistance(referencePoint, minLonPoint);
referencePointX += ((CANVAS_WIDTH - (LHS_BUFFER + RHS_BUFFER)) - (minLonToMaxLon * distanceScaleFactor)) / 2;
}
if(horizontalInversion) {
referencePointX = CANVAS_WIDTH - RHS_BUFFER - (referencePointX - LHS_BUFFER);
}
}
/**
@@ -509,6 +507,9 @@ public class CanvasController {
xAxisLocation -= (int) Math.round(distanceScaleFactor * Math.cos(angleFromReference) * distanceFromReference);
yAxisLocation += (int) Math.round(distanceScaleFactor * Math.sin(angleFromReference) * distanceFromReference);
}
if(horizontalInversion) {
xAxisLocation = CANVAS_WIDTH - RHS_BUFFER - (xAxisLocation - LHS_BUFFER);
}
return new Point2D(xAxisLocation, yAxisLocation);
}
+10 -1
View File
@@ -109,9 +109,13 @@ public class BoatGroup extends RaceObject {
teamNameObject.setCacheHint(CacheHint.SPEED);
velocityObject = new Text(String.valueOf(boat.getVelocity()));
DateFormat format = new SimpleDateFormat("mm:ss");
// TODO: 21/05/17 make a nice way of checking for this to be null
estTimeToNextMarkObject = new Text("Next mark: null");
if (boat.getEstimateTimeAtNextMark() != null) {
String timeToNextMark = format
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
estTimeToNextMarkObject = new Text("Next mark: " + timeToNextMark);
}
if (boat.getMarkRoundingTime() != null) {
String elapsedTime = format
.format(StreamParser.getCurrentTimeLong() - boat.getMarkRoundingTime());
@@ -280,9 +284,14 @@ public class BoatGroup extends RaceObject {
velocityObject.setText(String.format("%.2f m/s", boat.getVelocity()));
DateFormat format = new SimpleDateFormat("mm:ss");
// estimate time to next mark
// TODO: 21/05/17 make a nice way of checking for this to be null
estTimeToNextMarkObject.setText("Next mark: null");
if (boat.getEstimateTimeAtNextMark() != null) {
String timeToNextMark = format
.format(boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
.format(
boat.getEstimateTimeAtNextMark() - StreamParser.getCurrentTimeLong());
estTimeToNextMarkObject.setText("Next mark: " + timeToNextMark);
}
// elapsed time
if (boat.getMarkRoundingTime() != null) {
String elapsedTime = format
+1 -1
View File
@@ -152,7 +152,7 @@ public class Race {
/**
* Set a boat as finished
* @param boat The boat that has finished the race/home/cosc/student/wmu16
* @param boat The boat that has finished the race
*/
public void setBoatFinished(Yacht boat){
this.finishingOrder.add(boat);