Fixed and merged heading-visualisation

- Fixed the boats not appearing at the starting line.
- Merged with master
#story[24]
main
Fan-Wu Yang 9 years ago
parent edd9c2a48d
commit 6ffe3d02a3

@ -54,7 +54,7 @@ public class Boat {
*/ */
public void setVelocity(double velocity) { public void setVelocity(double velocity) {
this.velocity = 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 Color colour;
private boolean finished = false; private boolean finished = false;
private StringProperty currentLegName; private StringProperty currentLegName;
private boolean started = false;
/** /**
* Constructor method. * Constructor method.
@ -221,4 +222,11 @@ public class BoatInRace extends Boat {
this.finished = bool; 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++) { for (int i = 0; i < startingBoats.size(); i++) {
if (startingBoats.get(i) != null) { if (startingBoats.get(i) != null) {
System.out.println(i + 1 + ". " + startingBoats.get(i).toString() + ", Speed: " 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)); startingBoats.get(i).setCurrentLeg(legs.get(0));
} }
} }
@ -165,16 +165,6 @@ public abstract class Race implements Runnable {
*/ */
protected void updateTime(String time){ protected void updateTime(String time){
Platform.runLater(() -> {controller.setTimer(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"); System.setProperty("javafx.animation.fullspeed", "true");
for (BoatInRace boat: startingBoats){
boat.setStarted(true);
}
new AnimationTimer() { new AnimationTimer() {
long timeRaceStarted = System.currentTimeMillis(); //start time of loop long timeRaceStarted = System.currentTimeMillis(); //start time of loop

@ -210,17 +210,7 @@ public class ResizableRaceCanvas extends Canvas {
displayLine(startline1, startline2, Color.GREEN); displayLine(startline1, startline2, Color.GREEN);
updateBoats();
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()));}
}
}
}
//display wind direction arrow - specify origin point and angle - angle now set to random angle //display wind direction arrow - specify origin point and angle - angle now set to random angle
displayArrow(new GraphCoordinate((int)getWidth()-40, 40), 150); displayArrow(new GraphCoordinate((int)getWidth()-40, 40), 150);
@ -244,13 +234,15 @@ public class ResizableRaceCanvas extends Canvas {
if (boats != null) { if (boats != null) {
for (BoatInRace boat : boats) { for (BoatInRace boat : boats) {
boolean finished = boat.getCurrentLeg().getName().equals("Finish") || boat.getCurrentLeg().getName().equals("DNF"); 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()); displayBoat(boat, boat.calculateHeading());
GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition()); GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition());
GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake()); GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake());
displayLine(wakeFrom, wakeTo, boat.getColour()); displayLine(wakeFrom, wakeTo, boat.getColour());
} } else if (!isStart){
else { displayBoat(boat, boat.calculateHeading());
} else {
displayBoat(boat, 0); displayBoat(boat, 0);
} }

@ -35,8 +35,8 @@ public class RaceXMLReader extends XMLReader{
private void read(){ private void read(){
readCourse(); readCourse();
readBoats();
readLegs(); readLegs();
readBoats();
} }
public void readBoats(){ public void readBoats(){
@ -50,6 +50,9 @@ public class RaceXMLReader extends XMLReader{
//System.out.println(String.format("%s, %s, %s",name, abbrev, velo)); //System.out.println(String.format("%s, %s, %s",name, abbrev, velo));
BoatInRace boat = new BoatInRace(name, velo, colors[i], abbrev); BoatInRace boat = new BoatInRace(name, velo, colors[i], abbrev);
boat.setCurrentPosition(startPt1); boat.setCurrentPosition(startPt1);
if (legs.size() > 0){
boat.setCurrentLeg(legs.get(0));
}
boats.add(boat); boats.add(boat);
} }
} }

@ -2,37 +2,37 @@
<boats> <boats>
<boat> <boat>
<name>ORACLE TEAM USA</name> <name>ORACLE TEAM USA</name>
<speed>300</speed> <speed>30</speed>
<abbr>USA</abbr> <abbr>USA</abbr>
<colour>BLUEVIOLET</colour> <colour>BLUEVIOLET</colour>
</boat> </boat>
<boat> <boat>
<name>Land Rover BAR</name> <name>Land Rover BAR</name>
<speed>500</speed> <speed>50</speed>
<abbr>GBR</abbr> <abbr>GBR</abbr>
<colour>BLACK</colour> <colour>BLACK</colour>
</boat> </boat>
<boat> <boat>
<name>SoftBank Team Japan</name> <name>SoftBank Team Japan</name>
<speed>400</speed> <speed>40</speed>
<abbr>JPN</abbr> <abbr>JPN</abbr>
<colour>RED</colour> <colour>RED</colour>
</boat> </boat>
<boat> <boat>
<name>Groupama Team France</name> <name>Groupama Team France</name>
<speed>350</speed> <speed>35</speed>
<abbr>FRA</abbr> <abbr>FRA</abbr>
<colour>ORANGE</colour> <colour>ORANGE</colour>
</boat> </boat>
<boat> <boat>
<name>Artemis Racing</name> <name>Artemis Racing</name>
<speed>440</speed> <speed>44</speed>
<abbr>SWE</abbr> <abbr>SWE</abbr>
<colour>DARKOLIVEGREEN</colour> <colour>DARKOLIVEGREEN</colour>
</boat> </boat>
<boat> <boat>
<name>Emirates Team New Zealand</name> <name>Emirates Team New Zealand</name>
<speed>620</speed> <speed>62</speed>
<abbr>NZL</abbr> <abbr>NZL</abbr>
<colour>LIMEGREEN</colour> <colour>LIMEGREEN</colour>
</boat> </boat>

@ -98,5 +98,4 @@
</items> </items>
</SplitPane> </SplitPane>
</children> </children>
>>>>>>> Temporary merge branch 2
</AnchorPane> </AnchorPane>

Loading…
Cancel
Save