Fixed and merged heading-visualisation
- Fixed the boats not appearing at the starting line. - Merged with master #story[24]
This commit is contained in:
@@ -54,7 +54,7 @@ public class Boat {
|
||||
*/
|
||||
public void setVelocity(double velocity) {
|
||||
this.velocity = velocity;
|
||||
this.velocityProp.setValue(velocity);
|
||||
this.velocityProp.setValue(String.valueOf(Math.round(velocity)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ public class BoatInRace extends Boat {
|
||||
private Color colour;
|
||||
private boolean finished = false;
|
||||
private StringProperty currentLegName;
|
||||
private boolean started = false;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
@@ -221,4 +222,11 @@ public class BoatInRace extends Boat {
|
||||
this.finished = bool;
|
||||
}
|
||||
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
}
|
||||
|
||||
public void setStarted(boolean started) {
|
||||
this.started = started;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class Race implements Runnable {
|
||||
for (int i = 0; i < startingBoats.size(); i++) {
|
||||
if (startingBoats.get(i) != null) {
|
||||
System.out.println(i + 1 + ". " + startingBoats.get(i).toString() + ", Speed: "
|
||||
+ Math.round(startingBoats.get(i).getVelocity() * 1.94384) + "kn");
|
||||
+ Math.round(startingBoats.get(i).getVelocity()) + "kn");
|
||||
startingBoats.get(i).setCurrentLeg(legs.get(0));
|
||||
}
|
||||
}
|
||||
@@ -165,16 +165,6 @@ public abstract class Race implements Runnable {
|
||||
*/
|
||||
protected void updateTime(String time){
|
||||
Platform.runLater(() -> {controller.setTimer(time);});
|
||||
=======
|
||||
* Updates the GUI race clock
|
||||
* @param time
|
||||
*/
|
||||
protected void updateTime(String time) {
|
||||
|
||||
Platform.runLater(() -> {
|
||||
controller.setTimer(time);
|
||||
});
|
||||
>>>>>>> Temporary merge branch 2
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,6 +188,10 @@ public abstract class Race implements Runnable {
|
||||
|
||||
System.setProperty("javafx.animation.fullspeed", "true");
|
||||
|
||||
for (BoatInRace boat: startingBoats){
|
||||
boat.setStarted(true);
|
||||
}
|
||||
|
||||
new AnimationTimer() {
|
||||
|
||||
long timeRaceStarted = System.currentTimeMillis(); //start time of loop
|
||||
|
||||
@@ -210,17 +210,7 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
|
||||
displayLine(startline1, startline2, Color.GREEN);
|
||||
|
||||
|
||||
if (boats != null) {
|
||||
for (BoatInRace boat : boats) {
|
||||
if (boat != null) {
|
||||
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
|
||||
displayPoint(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
|
||||
if (raceAnno){
|
||||
displayText(boat.getAbbrev(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateBoats();
|
||||
|
||||
//display wind direction arrow - specify origin point and angle - angle now set to random angle
|
||||
displayArrow(new GraphCoordinate((int)getWidth()-40, 40), 150);
|
||||
@@ -244,13 +234,15 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
if (boats != null) {
|
||||
for (BoatInRace boat : boats) {
|
||||
boolean finished = boat.getCurrentLeg().getName().equals("Finish") || boat.getCurrentLeg().getName().equals("DNF");
|
||||
if (!finished) {
|
||||
boolean isStart = boat.isStarted();
|
||||
if (!finished && isStart) {
|
||||
displayBoat(boat, boat.calculateHeading());
|
||||
GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition());
|
||||
GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake());
|
||||
displayLine(wakeFrom, wakeTo, boat.getColour());
|
||||
}
|
||||
else {
|
||||
} else if (!isStart){
|
||||
displayBoat(boat, boat.calculateHeading());
|
||||
} else {
|
||||
displayBoat(boat, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ public class RaceXMLReader extends XMLReader{
|
||||
|
||||
private void read(){
|
||||
readCourse();
|
||||
readBoats();
|
||||
readLegs();
|
||||
readBoats();
|
||||
}
|
||||
|
||||
public void readBoats(){
|
||||
@@ -50,6 +50,9 @@ public class RaceXMLReader extends XMLReader{
|
||||
//System.out.println(String.format("%s, %s, %s",name, abbrev, velo));
|
||||
BoatInRace boat = new BoatInRace(name, velo, colors[i], abbrev);
|
||||
boat.setCurrentPosition(startPt1);
|
||||
if (legs.size() > 0){
|
||||
boat.setCurrentLeg(legs.get(0));
|
||||
}
|
||||
boats.add(boat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
<boats>
|
||||
<boat>
|
||||
<name>ORACLE TEAM USA</name>
|
||||
<speed>300</speed>
|
||||
<speed>30</speed>
|
||||
<abbr>USA</abbr>
|
||||
<colour>BLUEVIOLET</colour>
|
||||
</boat>
|
||||
<boat>
|
||||
<name>Land Rover BAR</name>
|
||||
<speed>500</speed>
|
||||
<speed>50</speed>
|
||||
<abbr>GBR</abbr>
|
||||
<colour>BLACK</colour>
|
||||
</boat>
|
||||
<boat>
|
||||
<name>SoftBank Team Japan</name>
|
||||
<speed>400</speed>
|
||||
<speed>40</speed>
|
||||
<abbr>JPN</abbr>
|
||||
<colour>RED</colour>
|
||||
</boat>
|
||||
<boat>
|
||||
<name>Groupama Team France</name>
|
||||
<speed>350</speed>
|
||||
<speed>35</speed>
|
||||
<abbr>FRA</abbr>
|
||||
<colour>ORANGE</colour>
|
||||
</boat>
|
||||
<boat>
|
||||
<name>Artemis Racing</name>
|
||||
<speed>440</speed>
|
||||
<speed>44</speed>
|
||||
<abbr>SWE</abbr>
|
||||
<colour>DARKOLIVEGREEN</colour>
|
||||
</boat>
|
||||
<boat>
|
||||
<name>Emirates Team New Zealand</name>
|
||||
<speed>620</speed>
|
||||
<speed>62</speed>
|
||||
<abbr>NZL</abbr>
|
||||
<colour>LIMEGREEN</colour>
|
||||
</boat>
|
||||
|
||||
@@ -98,5 +98,4 @@
|
||||
</items>
|
||||
</SplitPane>
|
||||
</children>
|
||||
>>>>>>> Temporary merge branch 2
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user