Fixed sparkline not updating.
#story[1095]
This commit is contained in:
@@ -2,6 +2,8 @@ package shared.model;
|
||||
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import shared.dataInput.BoatDataSource;
|
||||
@@ -37,6 +39,12 @@ public abstract class RaceState {
|
||||
*/
|
||||
private RegattaDataSource regattaDataSource;
|
||||
|
||||
/**
|
||||
* Legs in the race.
|
||||
* We have this in a separate list so that it can be observed.
|
||||
*/
|
||||
private ObservableList<Leg> legs;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -65,6 +73,9 @@ public abstract class RaceState {
|
||||
*/
|
||||
public RaceState() {
|
||||
|
||||
//Legs.
|
||||
this.legs = FXCollections.observableArrayList();
|
||||
|
||||
//Race clock.
|
||||
this.raceClock = new RaceClock(ZonedDateTime.now());
|
||||
|
||||
@@ -90,8 +101,9 @@ public abstract class RaceState {
|
||||
* @param legs The new list of legs to use.
|
||||
*/
|
||||
protected void useLegsList(List<Leg> legs) {
|
||||
this.legs.setAll(legs);
|
||||
//We add a "dummy" leg at the end of the race.
|
||||
if (legs.size() > 0) {
|
||||
if (getLegs().size() > 0) {
|
||||
getLegs().add(new Leg("Finish", getLegs().size()));
|
||||
}
|
||||
}
|
||||
@@ -126,6 +138,7 @@ public abstract class RaceState {
|
||||
public void setRaceDataSource(RaceDataSource raceDataSource) {
|
||||
this.raceDataSource = raceDataSource;
|
||||
this.getRaceClock().setStartingTime(raceDataSource.getStartDateTime());
|
||||
useLegsList(raceDataSource.getLegs());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,8 +322,8 @@ public abstract class RaceState {
|
||||
* Returns the legs of the race.
|
||||
* @return Legs of the race.
|
||||
*/
|
||||
public List<Leg> getLegs() {
|
||||
return raceDataSource.getLegs();
|
||||
public ObservableList<Leg> getLegs() {
|
||||
return legs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user