mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Final commit for yacht refactor
tags: #story[1124] #pair[hyi25, wmu16]
This commit is contained in:
+5
-4
@@ -20,15 +20,16 @@ import seng302.model.mark.CompoundMark;
|
|||||||
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
* compared to the XMLParser boat class, also done outside Boat class because some old variables are
|
||||||
* not used anymore.
|
* not used anymore.
|
||||||
*/
|
*/
|
||||||
public class Yacht extends Observable {
|
public class ClientYacht extends Observable {
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface YachtLocationListener {
|
public interface YachtLocationListener {
|
||||||
|
|
||||||
void notifyLocation(Yacht yacht, double lat, double lon, double heading, double velocity);
|
void notifyLocation(ClientYacht clientYacht, double lat, double lon, double heading,
|
||||||
|
double velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(Yacht.class);
|
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||||
|
|
||||||
|
|
||||||
//BOTH AFAIK
|
//BOTH AFAIK
|
||||||
@@ -58,7 +59,7 @@ public class Yacht extends Observable {
|
|||||||
private Integer positionInt = 0;
|
private Integer positionInt = 0;
|
||||||
private Color colour;
|
private Color colour;
|
||||||
|
|
||||||
public Yacht(String boatType, Integer sourceId, String hullID, String shortName,
|
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
||||||
String boatName, String country) {
|
String boatName, String country) {
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
@@ -16,7 +16,7 @@ import seng302.utilities.GeoUtility;
|
|||||||
*/
|
*/
|
||||||
public class ServerYacht extends Observable {
|
public class ServerYacht extends Observable {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(Yacht.class);
|
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||||
|
|
||||||
public static final Double TURN_STEP = 5.0;
|
public static final Double TURN_STEP = 5.0;
|
||||||
|
|
||||||
@@ -264,18 +264,16 @@ public class ServerYacht extends Observable {
|
|||||||
return sourceId;
|
return sourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 15/08/17 EXTREME BUG DO NOT DELETE THIS FUNCTION BREAKS PROGRAM IDK WHY ¯\_(ツ)_/¯
|
// TODO: 15/08/17 This method is implicitly called from the XML generator for boats DO NOT DELETE
|
||||||
public String getHullID() {
|
public String getHullID() {
|
||||||
System.out.println("HullId");
|
|
||||||
if (hullID == null) {
|
if (hullID == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return hullID;
|
return hullID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 15/08/17 EXTREME BUG DO NOT DELETE THIS FUNCTION BREAKS PROGRAM IDK WHY ¯\_(ツ)_/¯
|
// TODO: 15/08/17 This method is implicitly called from the XML generator for boats DO NOT DELETE
|
||||||
public String getShortName() {
|
public String getShortName() {
|
||||||
System.out.println("shortName");
|
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.Yacht;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Corner;
|
import seng302.model.mark.Corner;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
@@ -125,8 +125,8 @@ public class XMLParser {
|
|||||||
* @param doc XML Document Object
|
* @param doc XML Document Object
|
||||||
* @return Mapping of sourceIds to Boats.
|
* @return Mapping of sourceIds to Boats.
|
||||||
*/
|
*/
|
||||||
public static Map<Integer, Yacht> parseBoats(Document doc){
|
public static Map<Integer, ClientYacht> parseBoats(Document doc) {
|
||||||
Map<Integer, Yacht> competingBoats = new HashMap<>();
|
Map<Integer, ClientYacht> competingBoats = new HashMap<>();
|
||||||
|
|
||||||
Element docEle = doc.getDocumentElement();
|
Element docEle = doc.getDocumentElement();
|
||||||
|
|
||||||
@@ -135,7 +135,8 @@ public class XMLParser {
|
|||||||
Node currentBoat = boatsList.item(i);
|
Node currentBoat = boatsList.item(i);
|
||||||
if (currentBoat.getNodeName().equals("Boat")) {
|
if (currentBoat.getNodeName().equals("Boat")) {
|
||||||
// Boat boat = new Boat(currentBoat);
|
// Boat boat = new Boat(currentBoat);
|
||||||
Yacht yacht = new Yacht(XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
ClientYacht yacht = new ClientYacht(
|
||||||
|
XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
||||||
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
||||||
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
||||||
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import javafx.scene.input.KeyEvent;
|
|||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import seng302.gameServer.MainServerThread;
|
import seng302.gameServer.MainServerThread;
|
||||||
import seng302.gameServer.server.messages.BoatAction;
|
import seng302.gameServer.server.messages.BoatAction;
|
||||||
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
import seng302.model.Yacht;
|
|
||||||
import seng302.model.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
import seng302.model.stream.parser.MarkRoundingData;
|
import seng302.model.stream.parser.MarkRoundingData;
|
||||||
import seng302.model.stream.parser.PositionUpdateData;
|
import seng302.model.stream.parser.PositionUpdateData;
|
||||||
@@ -41,7 +41,7 @@ public class GameClient {
|
|||||||
|
|
||||||
private RaceViewController raceView;
|
private RaceViewController raceView;
|
||||||
|
|
||||||
private Map<Integer, Yacht> allBoatsMap;
|
private Map<Integer, ClientYacht> allBoatsMap;
|
||||||
private RegattaXMLData regattaData;
|
private RegattaXMLData regattaData;
|
||||||
private RaceXMLData courseData;
|
private RaceXMLData courseData;
|
||||||
private RaceState raceState = new RaceState();
|
private RaceState raceState = new RaceState();
|
||||||
@@ -151,7 +151,7 @@ public class GameClient {
|
|||||||
holderPane.getScene().setOnKeyPressed(this::keyPressed);
|
holderPane.getScene().setOnKeyPressed(this::keyPressed);
|
||||||
holderPane.getScene().setOnKeyReleased(this::keyReleased);
|
holderPane.getScene().setOnKeyReleased(this::keyReleased);
|
||||||
raceView = fxmlLoader.getController();
|
raceView = fxmlLoader.getController();
|
||||||
Yacht player = allBoatsMap.get(socketThread.getClientId());
|
ClientYacht player = allBoatsMap.get(socketThread.getClientId());
|
||||||
raceView.loadRace(allBoatsMap, courseData, raceState, player);
|
raceView.loadRace(allBoatsMap, courseData, raceState, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,8 +224,8 @@ public class GameClient {
|
|||||||
private void updatePosition(PositionUpdateData positionData) {
|
private void updatePosition(PositionUpdateData positionData) {
|
||||||
if (positionData.getType() == DeviceType.YACHT_TYPE) {
|
if (positionData.getType() == DeviceType.YACHT_TYPE) {
|
||||||
if (allXMLReceived() && allBoatsMap.containsKey(positionData.getDeviceId())) {
|
if (allXMLReceived() && allBoatsMap.containsKey(positionData.getDeviceId())) {
|
||||||
Yacht yacht = allBoatsMap.get(positionData.getDeviceId());
|
ClientYacht clientYacht = allBoatsMap.get(positionData.getDeviceId());
|
||||||
yacht.updateLocation(positionData.getLat(),
|
clientYacht.updateLocation(positionData.getLat(),
|
||||||
positionData.getLon(), positionData.getHeading(),
|
positionData.getLon(), positionData.getHeading(),
|
||||||
positionData.getGroundSpeed());
|
positionData.getGroundSpeed());
|
||||||
}
|
}
|
||||||
@@ -242,11 +242,11 @@ public class GameClient {
|
|||||||
*/
|
*/
|
||||||
private void updateMarkRounding(MarkRoundingData roundingData) {
|
private void updateMarkRounding(MarkRoundingData roundingData) {
|
||||||
if (allXMLReceived()) {
|
if (allXMLReceived()) {
|
||||||
Yacht yacht = allBoatsMap.get(roundingData.getBoatId());
|
ClientYacht clientYacht = allBoatsMap.get(roundingData.getBoatId());
|
||||||
yacht.setMarkRoundingTime(roundingData.getTimeStamp());
|
clientYacht.setMarkRoundingTime(roundingData.getTimeStamp());
|
||||||
yacht.updateTimeSinceLastMarkProperty(
|
clientYacht.updateTimeSinceLastMarkProperty(
|
||||||
raceState.getRaceTime() - roundingData.getTimeStamp());
|
raceState.getRaceTime() - roundingData.getTimeStamp());
|
||||||
yacht.setLastMarkRounded(
|
clientYacht.setLastMarkRounded(
|
||||||
courseData.getCompoundMarks().get(
|
courseData.getCompoundMarks().get(
|
||||||
roundingData.getMarkId()
|
roundingData.getMarkId()
|
||||||
)
|
)
|
||||||
@@ -258,20 +258,20 @@ public class GameClient {
|
|||||||
if (allXMLReceived()) {
|
if (allXMLReceived()) {
|
||||||
raceState.updateState(data);
|
raceState.updateState(data);
|
||||||
for (long[] boatData : data.getBoatData()) {
|
for (long[] boatData : data.getBoatData()) {
|
||||||
Yacht yacht = allBoatsMap.get((int) boatData[0]);
|
ClientYacht clientYacht = allBoatsMap.get((int) boatData[0]);
|
||||||
yacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
clientYacht.setEstimateTimeTillNextMark(raceState.getRaceTime() - boatData[1]);
|
||||||
yacht.setEstimateTimeAtFinish(boatData[2]);
|
clientYacht.setEstimateTimeAtFinish(boatData[2]);
|
||||||
int legNumber = (int) boatData[3];
|
int legNumber = (int) boatData[3];
|
||||||
yacht.setLegNumber(legNumber);
|
clientYacht.setLegNumber(legNumber);
|
||||||
yacht.setBoatStatus((int) boatData[4]);
|
clientYacht.setBoatStatus((int) boatData[4]);
|
||||||
if (legNumber != yacht.getLegNumber()) {
|
if (legNumber != clientYacht.getLegNumber()) {
|
||||||
int placing = 1;
|
int placing = 1;
|
||||||
for (Yacht otherYacht : allBoatsMap.values()) {
|
for (ClientYacht otherClientYacht : allBoatsMap.values()) {
|
||||||
if (otherYacht.getSourceId() != boatData[0] &&
|
if (otherClientYacht.getSourceId() != boatData[0] &&
|
||||||
yacht.getLegNumber() <= otherYacht.getLegNumber())
|
clientYacht.getLegNumber() <= otherClientYacht.getLegNumber())
|
||||||
placing++;
|
placing++;
|
||||||
}
|
}
|
||||||
yacht.setPositionInteger(placing);
|
clientYacht.setPositionInteger(placing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import javafx.scene.paint.Color;
|
|||||||
import javafx.scene.paint.Paint;
|
import javafx.scene.paint.Paint;
|
||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.Colors;
|
import seng302.model.Colors;
|
||||||
import seng302.model.GeoPoint;
|
import seng302.model.GeoPoint;
|
||||||
import seng302.model.Limit;
|
import seng302.model.Limit;
|
||||||
import seng302.model.Yacht;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Corner;
|
import seng302.model.mark.Corner;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
@@ -61,8 +61,8 @@ public class GameView extends Pane {
|
|||||||
private List<Limit> borderPoints;
|
private List<Limit> borderPoints;
|
||||||
private Map<Mark, Marker> markerObjects;
|
private Map<Mark, Marker> markerObjects;
|
||||||
|
|
||||||
private Map<Yacht, BoatObject> boatObjects = new HashMap<>();
|
private Map<ClientYacht, BoatObject> boatObjects = new HashMap<>();
|
||||||
private Map<Yacht, AnnotationBox> annotations = new HashMap<>();
|
private Map<ClientYacht, AnnotationBox> annotations = new HashMap<>();
|
||||||
private ObservableList<Node> gameObjects;
|
private ObservableList<Node> gameObjects;
|
||||||
private Group annotationsGroup = new Group();
|
private Group annotationsGroup = new Group();
|
||||||
private Group wakesGroup = new Group();
|
private Group wakesGroup = new Group();
|
||||||
@@ -318,23 +318,23 @@ public class GameView extends Pane {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws all the boats.
|
* Draws all the boats.
|
||||||
* @param yachts The yachts to set in the race
|
* @param clientYachts The yachts to set in the race
|
||||||
*/
|
*/
|
||||||
public void setBoats(List<Yacht> yachts) {
|
public void setBoats(List<ClientYacht> clientYachts) {
|
||||||
BoatObject newBoat;
|
BoatObject newBoat;
|
||||||
final List<Group> wakes = new ArrayList<>();
|
final List<Group> wakes = new ArrayList<>();
|
||||||
for (Yacht yacht : yachts) {
|
for (ClientYacht clientYacht : clientYachts) {
|
||||||
Paint colour = Colors.getColor();
|
Paint colour = Colors.getColor();
|
||||||
newBoat = new BoatObject();
|
newBoat = new BoatObject();
|
||||||
newBoat.setFill(colour);
|
newBoat.setFill(colour);
|
||||||
boatObjects.put(yacht, newBoat);
|
boatObjects.put(clientYacht, newBoat);
|
||||||
createAndBindAnnotationBox(yacht, colour);
|
createAndBindAnnotationBox(clientYacht, colour);
|
||||||
// wakesGroup.getChildren().add(newBoat.getWake());
|
// wakesGroup.getChildren().add(newBoat.getWake());
|
||||||
wakes.add(newBoat.getWake());
|
wakes.add(newBoat.getWake());
|
||||||
boatObjectGroup.getChildren().add(newBoat);
|
boatObjectGroup.getChildren().add(newBoat);
|
||||||
trails.getChildren().add(newBoat.getTrail());
|
trails.getChildren().add(newBoat.getTrail());
|
||||||
// TODO: 1/08/17 Make this less vile to look at.
|
// TODO: 1/08/17 Make this less vile to look at.
|
||||||
yacht.addLocationListener((boat, lat, lon, heading, velocity) ->{
|
clientYacht.addLocationListener((boat, lat, lon, heading, velocity) -> {
|
||||||
BoatObject bo = boatObjects.get(boat);
|
BoatObject bo = boatObjects.get(boat);
|
||||||
Point2D p2d = findScaledXY(lat, lon);
|
Point2D p2d = findScaledXY(lat, lon);
|
||||||
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity);
|
bo.moveTo(p2d.getX(), p2d.getY(), heading, velocity);
|
||||||
@@ -358,11 +358,11 @@ public class GameView extends Pane {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAndBindAnnotationBox (Yacht yacht, Paint colour) {
|
private void createAndBindAnnotationBox(ClientYacht clientYacht, Paint colour) {
|
||||||
AnnotationBox newAnnotation = new AnnotationBox();
|
AnnotationBox newAnnotation = new AnnotationBox();
|
||||||
newAnnotation.setFill(colour);
|
newAnnotation.setFill(colour);
|
||||||
newAnnotation.addAnnotation(
|
newAnnotation.addAnnotation(
|
||||||
"name", "Player: " + yacht.getShortName()
|
"name", "Player: " + clientYacht.getShortName()
|
||||||
);
|
);
|
||||||
// newAnnotation.addAnnotation(
|
// newAnnotation.addAnnotation(
|
||||||
// "velocity",
|
// "velocity",
|
||||||
@@ -385,7 +385,7 @@ public class GameView extends Pane {
|
|||||||
// return format.format(time);
|
// return format.format(time);
|
||||||
// }
|
// }
|
||||||
// );
|
// );
|
||||||
annotations.put(yacht, newAnnotation);
|
annotations.put(clientYacht, newAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawFps(Double fps){
|
private void drawFps(Double fps){
|
||||||
@@ -562,9 +562,9 @@ public class GameView extends Pane {
|
|||||||
fpsDisplay.setVisible(visibility);
|
fpsDisplay.setVisible(visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectBoat (Yacht selectedYacht) {
|
public void selectBoat(ClientYacht selectedClientYacht) {
|
||||||
boatObjects.forEach((boat, group) ->
|
boatObjects.forEach((boat, group) ->
|
||||||
group.setIsSelected(boat == selectedYacht)
|
group.setIsSelected(boat == selectedClientYacht)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,7 +576,7 @@ public class GameView extends Pane {
|
|||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoatAsPlayer (Yacht playerYacht) {
|
public void setBoatAsPlayer(ClientYacht playerYacht) {
|
||||||
boatObjects.get(playerYacht).setAsPlayer();
|
boatObjects.get(playerYacht).setAsPlayer();
|
||||||
annotations.get(playerYacht).addAnnotation(
|
annotations.get(playerYacht).addAnnotation(
|
||||||
"velocity",
|
"velocity",
|
||||||
|
|||||||
@@ -17,24 +17,24 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import seng302.model.Yacht;
|
import seng302.model.ClientYacht;
|
||||||
|
|
||||||
public class FinishScreenViewController implements Initializable {
|
public class FinishScreenViewController implements Initializable {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private GridPane finishScreenGridPane;
|
private GridPane finishScreenGridPane;
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Yacht> finishOrderTable;
|
private TableView<ClientYacht> finishOrderTable;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Yacht, String> posCol;
|
private TableColumn<ClientYacht, String> posCol;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Yacht, String> boatNameCol;
|
private TableColumn<ClientYacht, String> boatNameCol;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Yacht, String> shortNameCol;
|
private TableColumn<ClientYacht, String> shortNameCol;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Yacht, String> countryCol;
|
private TableColumn<ClientYacht, String> countryCol;
|
||||||
|
|
||||||
ObservableList<Yacht> data = FXCollections.observableArrayList();
|
ObservableList<ClientYacht> data = FXCollections.observableArrayList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
@@ -61,9 +61,9 @@ public class FinishScreenViewController implements Initializable {
|
|||||||
finishOrderTable.refresh();
|
finishOrderTable.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFinishers (List<Yacht> participants) {
|
public void setFinishers(List<ClientYacht> participants) {
|
||||||
List<Yacht> sorted = new ArrayList<>(participants);
|
List<ClientYacht> sorted = new ArrayList<>(participants);
|
||||||
sorted.sort(Comparator.comparingInt(Yacht::getPositionInteger));
|
sorted.sort(Comparator.comparingInt(ClientYacht::getPositionInteger));
|
||||||
finishOrderTable.getItems().setAll(sorted);
|
finishOrderTable.getItems().setAll(sorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import javafx.scene.text.Text;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
|
import seng302.model.ClientYacht;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
import seng302.model.Yacht;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||||
@@ -70,10 +70,10 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
@FXML
|
@FXML
|
||||||
private Button selectAnnotationBtn;
|
private Button selectAnnotationBtn;
|
||||||
@FXML
|
@FXML
|
||||||
private ComboBox<Yacht> yachtSelectionComboBox;
|
private ComboBox<ClientYacht> yachtSelectionComboBox;
|
||||||
|
|
||||||
//Race Data
|
//Race Data
|
||||||
private Map<Integer, Yacht> participants;
|
private Map<Integer, ClientYacht> participants;
|
||||||
private Map<Integer, CompoundMark> markers;
|
private Map<Integer, CompoundMark> markers;
|
||||||
private RaceXMLData courseData;
|
private RaceXMLData courseData;
|
||||||
private GameView gameView;
|
private GameView gameView;
|
||||||
@@ -101,7 +101,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadRace (
|
public void loadRace (
|
||||||
Map<Integer, Yacht> participants, RaceXMLData raceData, RaceState raceState, Yacht player
|
Map<Integer, ClientYacht> participants, RaceXMLData raceData, RaceState raceState,
|
||||||
|
ClientYacht player
|
||||||
) {
|
) {
|
||||||
this.participants = participants;
|
this.participants = participants;
|
||||||
this.courseData = raceData;
|
this.courseData = raceData;
|
||||||
@@ -214,7 +215,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
// TODO: 2/08/17 there is about 0 chance of this working. Once we are keeping track of boat positions it can be fixed.
|
// TODO: 2/08/17 there is about 0 chance of this working. Once we are keeping track of boat positions it can be fixed.
|
||||||
// Collect the racing yachts that aren't already in the chart
|
// Collect the racing yachts that aren't already in the chart
|
||||||
sparkLineData.clear();
|
sparkLineData.clear();
|
||||||
List<Yacht> sparkLineCandidates = new ArrayList<>(participants.values());
|
List<ClientYacht> sparkLineCandidates = new ArrayList<>(participants.values());
|
||||||
// Create a new data series for new yachts
|
// Create a new data series for new yachts
|
||||||
sparkLineCandidates
|
sparkLineCandidates
|
||||||
.stream()
|
.stream()
|
||||||
@@ -260,15 +261,15 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the yachts sparkline of the desired yacht and using the new leg number
|
* Updates the yachts sparkline of the desired yacht and using the new leg number
|
||||||
* @param yacht The yacht to be updated on the sparkline
|
* @param clientYacht The yacht to be updated on the sparkline
|
||||||
* @param legNumber the leg number that the position will be assigned to
|
* @param legNumber the leg number that the position will be assigned to
|
||||||
*/
|
*/
|
||||||
void updateYachtPositionSparkline(Yacht yacht, Integer legNumber){
|
void updateYachtPositionSparkline(ClientYacht clientYacht, Integer legNumber) {
|
||||||
for (XYChart.Series<String, Double> positionData : sparkLineData) {
|
for (XYChart.Series<String, Double> positionData : sparkLineData) {
|
||||||
positionData.getData().add(
|
positionData.getData().add(
|
||||||
new Data<>(
|
new Data<>(
|
||||||
Integer.toString(legNumber),
|
Integer.toString(legNumber),
|
||||||
1.0 + participants.size() - yacht.getPositionInteger()
|
1.0 + participants.size() - clientYacht.getPositionInteger()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -376,21 +377,21 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
// positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
// positionVbox.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||||
|
|
||||||
// list of racing yacht id
|
// list of racing yacht id
|
||||||
List<Yacht> sorted = new ArrayList<>(participants.values());
|
List<ClientYacht> sorted = new ArrayList<>(participants.values());
|
||||||
sorted.sort(Comparator.comparingInt(Yacht::getPositionInteger));
|
sorted.sort(Comparator.comparingInt(ClientYacht::getPositionInteger));
|
||||||
List<Text> vboxEntries = new ArrayList<>();
|
List<Text> vboxEntries = new ArrayList<>();
|
||||||
|
|
||||||
for (Yacht yacht : sorted) {
|
for (ClientYacht clientYacht : sorted) {
|
||||||
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
// System.out.println("yacht == null " + String.valueOf(yacht == null));
|
||||||
if (yacht.getBoatStatus() == 3) { // 3 is finish status
|
if (clientYacht.getBoatStatus() == 3) { // 3 is finish status
|
||||||
Text textToAdd = new Text(yacht.getPositionInteger() + ". " +
|
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||||
yacht.getShortName() + " (Finished)");
|
clientYacht.getShortName() + " (Finished)");
|
||||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||||
vboxEntries.add(textToAdd);
|
vboxEntries.add(textToAdd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Text textToAdd = new Text(yacht.getPositionInteger() + ". " +
|
Text textToAdd = new Text(clientYacht.getPositionInteger() + ". " +
|
||||||
yacht.getShortName() + " ");
|
clientYacht.getShortName() + " ");
|
||||||
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
textToAdd.setFill(Paint.valueOf("#d3d3d3"));
|
||||||
textToAdd.setStyle("");
|
textToAdd.setStyle("");
|
||||||
vboxEntries.add(textToAdd);
|
vboxEntries.add(textToAdd);
|
||||||
@@ -575,9 +576,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
/**
|
/**
|
||||||
* Sets all the annotations of the selected yacht to be visible and all others to be hidden
|
* Sets all the annotations of the selected yacht to be visible and all others to be hidden
|
||||||
*
|
*
|
||||||
* @param yacht The yacht for which we want to view all annotations
|
* @param clientYacht The yacht for which we want to view all annotations
|
||||||
*/
|
*/
|
||||||
private void setSelectedBoat(Yacht yacht) {
|
private void setSelectedBoat(ClientYacht clientYacht) {
|
||||||
// for (BoatObject bg : gameViewController.getBoatGroups()) {
|
// for (BoatObject bg : gameViewController.getBoatGroups()) {
|
||||||
// //We need to iterate over all race groups to get the matching yacht group belonging to this yacht if we
|
// //We need to iterate over all race groups to get the matching yacht group belonging to this yacht if we
|
||||||
// //are to toggle its annotations, there is no other backwards knowledge of a yacht to its yachtgroup.
|
// //are to toggle its annotations, there is no other backwards knowledge of a yacht to its yachtgroup.
|
||||||
|
|||||||
Reference in New Issue
Block a user