mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Boats now move on screen as intended.
TODO - Make the client connect to the server.
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import seng302.model.Player;
|
import seng302.model.Player;
|
||||||
@@ -77,7 +78,7 @@ public class GameState implements Runnable {
|
|||||||
public static void addPlayer(Player player) {
|
public static void addPlayer(Player player) {
|
||||||
players.add(player);
|
players.add(player);
|
||||||
String playerText = player.getYacht().getSourceId() + " " + player.getYacht().getBoatName() + " " + player.getYacht().getCountry();
|
String playerText = player.getYacht().getSourceId() + " " + player.getYacht().getBoatName() + " " + player.getYacht().getCountry();
|
||||||
observablePlayers.add(playerText);
|
Platform.runLater(() -> observablePlayers.add(playerText)); //Had to add this to handle javaFX window using array
|
||||||
playerStringMap.put(player, playerText);
|
playerStringMap.put(player, playerText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class ClientToServerThread implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
streamPackets.add(new StreamPacket(type, payloadLength, timeStamp, payload));
|
streamPackets.add(new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||||
for (ClientSocketListener csl : listeners)
|
for (ClientSocketListener csl : listeners)
|
||||||
csl.newPacket();
|
Platform.runLater(csl::newPacket);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clientLog("Packet has been dropped", 1);
|
clientLog("Packet has been dropped", 1);
|
||||||
@@ -147,7 +147,6 @@ public class ClientToServerThread implements Runnable {
|
|||||||
clientLog(e.getMessage(), 1);
|
clientLog(e.getMessage(), 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("streamPackets.size() = " + streamPackets.size());
|
|
||||||
}
|
}
|
||||||
closeSocket();
|
closeSocket();
|
||||||
clientLog("Closed connection to Server", 0);
|
clientLog("Closed connection to Server", 0);
|
||||||
@@ -247,4 +246,8 @@ public class ClientToServerThread implements Runnable {
|
|||||||
public Thread getThread() {
|
public Thread getThread() {
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getClientId () {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,16 @@
|
|||||||
package seng302.visualiser;
|
package seng302.visualiser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.input.KeyEvent;
|
import javafx.scene.input.KeyEvent;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javax.xml.transform.OutputKeys;
|
|
||||||
import javax.xml.transform.Transformer;
|
|
||||||
import javax.xml.transform.TransformerFactory;
|
|
||||||
import javax.xml.transform.dom.DOMSource;
|
|
||||||
import javax.xml.transform.stream.StreamResult;
|
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
import seng302.gameServer.MainServerThread;
|
import seng302.gameServer.MainServerThread;
|
||||||
import seng302.model.RaceState;
|
import seng302.model.RaceState;
|
||||||
@@ -53,7 +46,7 @@ public class GameClient {
|
|||||||
private RaceXMLData courseData;
|
private RaceXMLData courseData;
|
||||||
private RaceState raceState = new RaceState();
|
private RaceState raceState = new RaceState();
|
||||||
|
|
||||||
private ObservableList<String> lobbyList = FXCollections.observableArrayList();
|
private ObservableList<String> clientLobbyList = FXCollections.observableArrayList();
|
||||||
|
|
||||||
private long lastSendingTime;
|
private long lastSendingTime;
|
||||||
private int KEY_STROKE_SENDING_FREQUENCY = 50;
|
private int KEY_STROKE_SENDING_FREQUENCY = 50;
|
||||||
@@ -70,7 +63,7 @@ public class GameClient {
|
|||||||
System.out.println("Unable to connect to host...");
|
System.out.println("Unable to connect to host...");
|
||||||
}
|
}
|
||||||
LobbyController lobbyController = loadLobby("/views/LobbyView.fxml");
|
LobbyController lobbyController = loadLobby("/views/LobbyView.fxml");
|
||||||
lobbyController.setPlayerListSource(lobbyList);
|
lobbyController.setPlayerListSource(clientLobbyList);
|
||||||
lobbyController.disableReadyButton();
|
lobbyController.disableReadyButton();
|
||||||
lobbyController.setTitle("Connected to host - IP : " + ipAddress + " Port : " + portNumber);
|
lobbyController.setTitle("Connected to host - IP : " + ipAddress + " Port : " + portNumber);
|
||||||
lobbyController.addCloseListener((exitCause) -> this.loadStartScreen());
|
lobbyController.addCloseListener((exitCause) -> this.loadStartScreen());
|
||||||
@@ -134,26 +127,20 @@ public class GameClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadRaceView() {
|
private void loadRaceView() {
|
||||||
// allBoatsMap.forEach((id, boat) -> {
|
|
||||||
// if (courseData.getParticipants().contains(id))
|
|
||||||
// racingBoats.put(id, boat);
|
|
||||||
// });
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||||
RaceViewController.class.getResource("/views/RaceView.fxml"));
|
RaceViewController.class.getResource("/views/RaceView.fxml"));
|
||||||
// raceView = fxmlLoader.getController();
|
|
||||||
try {
|
try {
|
||||||
Node node = fxmlLoader.load();
|
Node node = fxmlLoader.load();
|
||||||
Platform.runLater(() -> {
|
holderPane.getChildren().clear();
|
||||||
holderPane.getChildren().clear();
|
holderPane.getChildren().add(node);
|
||||||
holderPane.getChildren().add(node);
|
|
||||||
});
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
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();
|
||||||
raceView.loadRace(allBoatsMap, courseData, raceState);
|
Yacht player = allBoatsMap.get(socketThread.getClientId());
|
||||||
|
raceView.loadRace(allBoatsMap, courseData, raceState, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parsePackets() {
|
private void parsePackets() {
|
||||||
@@ -166,7 +153,6 @@ public class GameClient {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case REGATTA_XML:
|
case REGATTA_XML:
|
||||||
System.out.println("REGATTA XML");
|
|
||||||
regattaData = XMLParser.parseRegatta(
|
regattaData = XMLParser.parseRegatta(
|
||||||
StreamParser.extractXmlMessage(packet)
|
StreamParser.extractXmlMessage(packet)
|
||||||
);
|
);
|
||||||
@@ -175,40 +161,27 @@ public class GameClient {
|
|||||||
ZoneId.ofOffset("UTC", ZoneOffset.ofHours(regattaData.getUtcOffset()))
|
ZoneId.ofOffset("UTC", ZoneOffset.ofHours(regattaData.getUtcOffset()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// startRaceIfAllDataReceived();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RACE_XML:
|
case RACE_XML:
|
||||||
try {
|
|
||||||
TransformerFactory tf = TransformerFactory.newInstance();
|
|
||||||
Transformer transformer = tf.newTransformer();
|
|
||||||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
transformer.transform(new DOMSource(StreamParser.extractXmlMessage(packet)),
|
|
||||||
new StreamResult(writer));
|
|
||||||
// String output = writer.getBuffer().toString().replaceAll("\n|\r", "");
|
|
||||||
System.out.println(writer.getBuffer().toString());
|
|
||||||
}catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
courseData = XMLParser.parseRace(
|
courseData = XMLParser.parseRace(
|
||||||
StreamParser.extractXmlMessage(packet)
|
StreamParser.extractXmlMessage(packet)
|
||||||
);
|
);
|
||||||
if (raceView != null) {
|
if (raceView != null) {
|
||||||
raceView.updateRaceData(courseData);
|
raceView.updateRaceData(courseData);
|
||||||
}
|
}
|
||||||
// startRaceIfAllDataReceived();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BOAT_XML:
|
case BOAT_XML:
|
||||||
System.out.println("BOAT XML");
|
|
||||||
allBoatsMap = XMLParser.parseBoats(
|
allBoatsMap = XMLParser.parseBoats(
|
||||||
StreamParser.extractXmlMessage(packet)
|
StreamParser.extractXmlMessage(packet)
|
||||||
);
|
);
|
||||||
lobbyList.clear();
|
clientLobbyList.clear();
|
||||||
allBoatsMap
|
allBoatsMap.forEach((id, boat) -> {
|
||||||
.forEach((id, boat) -> lobbyList.add(id.toString() + boat.getBoatName()));
|
clientLobbyList.add(id + " " + boat.getBoatName());
|
||||||
allBoatsMap.forEach((i, b) -> System.out.println(b.getBoatName()));
|
System.out.println(id + " " + boat.getBoatName());
|
||||||
|
|
||||||
|
});
|
||||||
// startRaceIfAllDataReceived();
|
// startRaceIfAllDataReceived();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package seng302.visualiser;
|
package seng302.visualiser;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty;
|
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
@@ -98,15 +95,6 @@ public class GameView extends Pane {
|
|||||||
gameObjects.add(raceBorder);
|
gameObjects.add(raceBorder);
|
||||||
gameObjects.add(markers);
|
gameObjects.add(markers);
|
||||||
initializeTimer();
|
initializeTimer();
|
||||||
// this.widthProperty().addListener(resize -> {
|
|
||||||
// canvasWidth = this.getWidth();
|
|
||||||
// canvasHeight = this.getHeight();
|
|
||||||
// if (borderPoints != null) {
|
|
||||||
// updateBorder(borderPoints);
|
|
||||||
// } else if (course != null) {
|
|
||||||
// updateCourse(course, markSequence);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTimer () {
|
private void initializeTimer () {
|
||||||
@@ -201,6 +189,7 @@ public class GameView extends Pane {
|
|||||||
//Create mark dots
|
//Create mark dots
|
||||||
for (Mark mark : cMark.getMarks()) {
|
for (Mark mark : cMark.getMarks()) {
|
||||||
makeAndBindMarker(mark, colour);
|
makeAndBindMarker(mark, colour);
|
||||||
|
System.out.println("hi" + mark.getName());
|
||||||
}
|
}
|
||||||
//Create gate line
|
//Create gate line
|
||||||
if (cMark.isGate()) {
|
if (cMark.isGate()) {
|
||||||
@@ -309,13 +298,22 @@ public class GameView extends Pane {
|
|||||||
public void setBoats(List<Yacht> yachts) {
|
public void setBoats(List<Yacht> yachts) {
|
||||||
BoatObject newBoat;
|
BoatObject newBoat;
|
||||||
for (Yacht yacht : yachts) {
|
for (Yacht yacht : yachts) {
|
||||||
|
Paint colour = Colors.getColor();
|
||||||
newBoat = new BoatObject();
|
newBoat = new BoatObject();
|
||||||
newBoat.setFill(Colors.getColor());
|
newBoat.setFill(colour);
|
||||||
boatObjects.put(yacht, newBoat);
|
boatObjects.put(yacht, newBoat);
|
||||||
|
createAndBindAnnotationBox(yacht, colour);
|
||||||
|
wakesGroup.getChildren().add(newBoat.getWake());
|
||||||
|
boatObjectGroup.getChildren().add(newBoat);
|
||||||
|
trails.getChildren().add(newBoat.getTrail());
|
||||||
|
// TODO: 1/08/17 Make this less vile to look at.
|
||||||
yacht.addLocationListener((boat, lat, lon, heading, velocity) ->{
|
yacht.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);
|
bo.moveTo(p2d.getX(), p2d.getY(), heading);
|
||||||
|
// annotations.get(boat).setLayoutX(p2d.getX());
|
||||||
|
// annotations.get(boat).setLayoutY(p2d.getY());
|
||||||
|
// annotations.get(boat).setLocation(100d, 100d);
|
||||||
annotations.get(boat).setLocation(p2d.getX(), p2d.getY());
|
annotations.get(boat).setLocation(p2d.getX(), p2d.getY());
|
||||||
bo.setTrajectory(
|
bo.setTrajectory(
|
||||||
heading,
|
heading,
|
||||||
@@ -323,13 +321,10 @@ public class GameView extends Pane {
|
|||||||
metersPerPixelX,
|
metersPerPixelX,
|
||||||
metersPerPixelY);
|
metersPerPixelY);
|
||||||
});
|
});
|
||||||
createAndBindAnnotationBox(yacht);
|
|
||||||
wakesGroup.getChildren().add(newBoat.getWake());
|
|
||||||
boatObjectGroup.getChildren().add(newBoat);
|
|
||||||
trails.getChildren().add(newBoat.getTrail());
|
|
||||||
}
|
}
|
||||||
annotationsGroup.getChildren().addAll(annotations.values());
|
annotationsGroup.getChildren().addAll(annotations.values());
|
||||||
gameObjects.addAll(trails);
|
gameObjects.addAll(trails);
|
||||||
|
gameObjects.add(wakesGroup);
|
||||||
gameObjects.addAll(annotationsGroup);
|
gameObjects.addAll(annotationsGroup);
|
||||||
gameObjects.addAll(boatObjectGroup);
|
gameObjects.addAll(boatObjectGroup);
|
||||||
}
|
}
|
||||||
@@ -346,32 +341,33 @@ public class GameView extends Pane {
|
|||||||
// metersPerPixelY);
|
// metersPerPixelY);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void createAndBindAnnotationBox (Yacht yacht) {
|
private void createAndBindAnnotationBox (Yacht yacht, Paint colour) {
|
||||||
AnnotationBox newAnnotation;
|
AnnotationBox newAnnotation = new AnnotationBox();
|
||||||
newAnnotation = new AnnotationBox();
|
newAnnotation.setFill(colour);
|
||||||
newAnnotation.addAnnotation("name", yacht.getShortName());
|
|
||||||
// newAnnotation.addAnnotation("country", boat.getCountry());
|
|
||||||
newAnnotation.addAnnotation(
|
newAnnotation.addAnnotation(
|
||||||
"velocity",
|
"name", "Player: " + yacht.getShortName()
|
||||||
yacht.getVelocityProperty(),
|
|
||||||
(velocity) -> String.format("Speed: %.2f ms", velocity.doubleValue())
|
|
||||||
);
|
|
||||||
newAnnotation.addAnnotation(
|
|
||||||
"nextMark",
|
|
||||||
yacht.timeTillNextProperty(),
|
|
||||||
(time) -> {
|
|
||||||
DateFormat format = new SimpleDateFormat("mm:ss");
|
|
||||||
return format.format(time);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
newAnnotation.addAnnotation(
|
|
||||||
"lastMark",
|
|
||||||
yacht.timeTillNextProperty(),
|
|
||||||
(time) -> {
|
|
||||||
DateFormat format = new SimpleDateFormat("mm:ss");
|
|
||||||
return format.format(time);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
// newAnnotation.addAnnotation(
|
||||||
|
// "velocity",
|
||||||
|
// yacht.getVelocityProperty(),
|
||||||
|
// (velocity) -> String.format("Speed: %.2f ms", velocity.doubleValue())
|
||||||
|
// );
|
||||||
|
// newAnnotation.addAnnotation(
|
||||||
|
// "nextMark",
|
||||||
|
// yacht.timeTillNextProperty(),
|
||||||
|
// (time) -> {
|
||||||
|
// DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
|
// return format.format(time);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// newAnnotation.addAnnotation(
|
||||||
|
// "lastMark",
|
||||||
|
// yacht.timeTillNextProperty(),
|
||||||
|
// (time) -> {
|
||||||
|
// DateFormat format = new SimpleDateFormat("mm:ss");
|
||||||
|
// return format.format(time);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
annotations.put(yacht, newAnnotation);
|
annotations.put(yacht, newAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,10 +551,6 @@ public class GameView extends Pane {
|
|||||||
fpsDisplay.setVisible(visibility);
|
fpsDisplay.setVisible(visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyBooleanProperty getFPSVisibilityProperty () {
|
|
||||||
return fpsDisplay.visibleProperty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectBoat (Yacht selectedYacht) {
|
public void selectBoat (Yacht selectedYacht) {
|
||||||
boatObjects.forEach((boat, group) ->
|
boatObjects.forEach((boat, group) ->
|
||||||
group.setIsSelected(boat == selectedYacht)
|
group.setIsSelected(boat == selectedYacht)
|
||||||
@@ -575,6 +567,10 @@ public class GameView extends Pane {
|
|||||||
|
|
||||||
public void setBoatAsPlayer (Yacht playerYacht) {
|
public void setBoatAsPlayer (Yacht playerYacht) {
|
||||||
boatObjects.get(playerYacht).setAsPlayer();
|
boatObjects.get(playerYacht).setAsPlayer();
|
||||||
// annotations.get(playerYacht).setAsPlayer();
|
annotations.get(playerYacht).addAnnotation(
|
||||||
|
"velocity",
|
||||||
|
playerYacht.getVelocityProperty(),
|
||||||
|
(velocity) -> String.format("Speed: %.2f ms", velocity.doubleValue())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package seng302.visualiser.controllers;
|
package seng302.visualiser.controllers;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import seng302.gameServer.GameStages;
|
import seng302.gameServer.GameStages;
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
@@ -24,7 +20,7 @@ import seng302.gameServer.GameState;
|
|||||||
* A class describing the actions of the lobby screen
|
* A class describing the actions of the lobby screen
|
||||||
* Created by wmu16 on 10/07/17.
|
* Created by wmu16 on 10/07/17.
|
||||||
*/
|
*/
|
||||||
public class LobbyController implements Initializable {
|
public class LobbyController {
|
||||||
|
|
||||||
public enum CloseStatus {
|
public enum CloseStatus {
|
||||||
LEAVE,
|
LEAVE,
|
||||||
@@ -75,182 +71,67 @@ public class LobbyController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private ImageView eighthImageView;
|
private ImageView eighthImageView;
|
||||||
|
|
||||||
private static List<ObservableList<String>> competitors = new ArrayList<>();
|
private List<ObservableList<String>> competitors = new ArrayList<>();
|
||||||
private static ObservableList<String> firstCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> firstCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> secondCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> secondCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> thirdCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> thirdCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> fourthCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> fourthCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> fifthCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> fifthCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> sixthCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> sixthCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> seventhCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> seventhCompetitor = FXCollections.observableArrayList();
|
||||||
private static ObservableList<String> eighthCompetitor = FXCollections.observableArrayList();
|
private ObservableList<String> eighthCompetitor = FXCollections.observableArrayList();
|
||||||
// private ClientStateQueryingRunnable clientStateQueryingRunnable;
|
|
||||||
private static List<ImageView> imageViews;
|
private List<ImageView> imageViews = new ArrayList<>();
|
||||||
private static List<ListView> listViews;
|
private List<ListView> listViews;
|
||||||
|
|
||||||
private int MAX_NUM_PLAYERS = 8;
|
private int MAX_NUM_PLAYERS = 8;
|
||||||
|
|
||||||
private Boolean switchedPane = false;
|
|
||||||
|
|
||||||
private List<LobbyCloseListener> lobbyListeners = new ArrayList<>();
|
private List<LobbyCloseListener> lobbyListeners = new ArrayList<>();
|
||||||
|
private ObservableList<String> players = FXCollections.observableArrayList();
|
||||||
|
|
||||||
private void setContentPane(String jfxUrl) {
|
public void initialize() {
|
||||||
try {
|
imageViews = new ArrayList<>();
|
||||||
AnchorPane contentPane = (AnchorPane) lobbyScreen.getParent();
|
Collections
|
||||||
contentPane.getChildren().removeAll();
|
.addAll(imageViews, firstImageView, secondImageView, thirdImageView, fourthImageView,
|
||||||
contentPane.getChildren().clear();
|
fifthImageView, sixthImageView, seventhImageView, eighthImageView);
|
||||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
listViews = new ArrayList<>();
|
||||||
contentPane.getChildren()
|
Collections.addAll(listViews, firstListView, secondListView, thirdListView, fourthListView, fifthListView,
|
||||||
.addAll((Pane) FXMLLoader.load(getClass().getResource(jfxUrl)));
|
sixthListView, seventhListView, eighthListView);
|
||||||
} catch (javafx.fxml.LoadException e) {
|
competitors = new ArrayList<>();
|
||||||
e.printStackTrace();
|
Collections.addAll(competitors, firstCompetitor, secondCompetitor, thirdCompetitor,
|
||||||
} catch (IOException e) {
|
fourthCompetitor, fifthCompetitor, sixthCompetitor, seventhCompetitor, eighthCompetitor);
|
||||||
e.printStackTrace();
|
|
||||||
|
initialiseImageView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialiseListView() {
|
||||||
|
listViews.forEach(listView -> listView.getItems().clear());
|
||||||
|
imageViews.forEach(gif -> gif.setVisible(false));
|
||||||
|
competitors.forEach(ol -> ol.removeAll());
|
||||||
|
for (int i = 0; i < players.size(); i++) {
|
||||||
|
competitors.get(i).add(players.get(i));
|
||||||
|
listViews.get(i).setItems(competitors.get(i));
|
||||||
|
imageViews.get(i).setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
// if (ClientState.isHost()) {
|
|
||||||
// lobbyIpText.setText("Lobby Host IP: " + ClientState.getHostIp());
|
|
||||||
// readyButton.setDisable(false);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// lobbyIpText.setText("Connected to IP: ");
|
|
||||||
// readyButton.setDisable(true);
|
|
||||||
// readyButton.setVisible(false);
|
|
||||||
// }
|
|
||||||
// initialiseListView();
|
|
||||||
// initialiseLobbyControllerThread();
|
|
||||||
// initialiseImageView(); // parrot gif init
|
|
||||||
// if (ClientState.isHost()) {
|
|
||||||
// lobbyIpText.setText("Lobby Host IP: " + ClientState.getHostIp());
|
|
||||||
// readyButton.setDisable(false);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// lobbyIpText.setText("Connected to IP: ");
|
|
||||||
// readyButton.setDisable(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// imageViews = new ArrayList<>();
|
|
||||||
// Collections.addAll(imageViews, firstImageView, secondImageView, thirdImageView, fourthImageView,
|
|
||||||
// fifthImageView, sixthImageView, seventhImageView, eighthImageView);
|
|
||||||
// listViews = new ArrayList<>();
|
|
||||||
// Collections.addAll(listViews, firstListView, secondListView, thirdListView, fourthListView, fifthListView,
|
|
||||||
// sixthListView, seventhListView, eighthListView);
|
|
||||||
// competitors = new ArrayList<>();
|
|
||||||
// Collections.addAll(competitors, firstCompetitor, secondCompetitor, thirdCompetitor,
|
|
||||||
// fourthCompetitor, fifthCompetitor, sixthCompetitor, seventhCompetitor, eighthCompetitor);
|
|
||||||
//
|
|
||||||
// initialiseListView();
|
|
||||||
// initialiseImageView(); // parrot gif init
|
|
||||||
|
|
||||||
// set up client state query thread, so that when it receives the race-started packet
|
|
||||||
// it can switch to the race view
|
|
||||||
// ClientStateQueryingRunnable clientStateQueryingRunnable = new ClientStateQueryingRunnable();
|
|
||||||
// clientStateQueryingRunnable.addObserver(this);
|
|
||||||
// Thread clientStateQueryingThread = new Thread(clientStateQueryingRunnable, "Client State querying thread");
|
|
||||||
// clientStateQueryingThread.setDaemon(true);
|
|
||||||
// clientStateQueryingThread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void update(Observable o, Object arg) {
|
|
||||||
// Platform.runLater(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// if (arg.equals("game started") && !switchedPane) {
|
|
||||||
// switchToRaceView();
|
|
||||||
// }
|
|
||||||
// if (arg.equals(("update players"))) {
|
|
||||||
// initialiseListView();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initialiseListView() {
|
|
||||||
// firstListView.getItems().clear();
|
|
||||||
// secondListView.getItems().clear();
|
|
||||||
// thirdListView.getItems().clear();
|
|
||||||
// fourthListView.getItems().clear();
|
|
||||||
// fifthListView.getItems().clear();
|
|
||||||
// sixthListView.getItems().clear();
|
|
||||||
// seventhListView.getItems().clear();
|
|
||||||
// eighthListView.getItems().clear();
|
|
||||||
|
|
||||||
// listViews.forEach(listView -> listView.getItems().clear());
|
|
||||||
// imageViews.forEach(gif -> gif.setVisible(false));
|
|
||||||
// competitors.forEach(ol -> ol.removeAll());
|
|
||||||
//
|
|
||||||
// List<Integer> ids = new ArrayList<>(ClientState.getBoats().keySet());
|
|
||||||
// for (int i = 0; i < ids.size(); i++) {
|
|
||||||
// competitors.get(i).add(String.format("Player ID: %d", ids.get(i)));
|
|
||||||
// listViews.get(i).setItems(competitors.get(i));
|
|
||||||
// imageViews.get(i).setVisible(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// firstCompetitor.add(ClientState.getClientSourceId());
|
|
||||||
|
|
||||||
// int competitorIndex = 1;
|
|
||||||
// for (Integer yachtId : ClientState.getBoats().keySet()) {
|
|
||||||
// // break if there are more than 7 competitors
|
|
||||||
// if (competitorIndex >= 8) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if (!yachtId.equals(Integer.parseInt(ClientState.getClientSourceId()))) {
|
|
||||||
// competitors.get(competitorIndex).add(String.valueOf(yachtId));
|
|
||||||
// competitorIndex++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// firstListView.setItems(firstCompetitor);
|
|
||||||
// secondListView.setItems(secondCompetitor);
|
|
||||||
// thirdListView.setItems(thirdCompetitor);
|
|
||||||
// fourthListView.setItems(fourthCompetitor);
|
|
||||||
// fifthListView.setItems(fifthCompetitor);
|
|
||||||
// sixthListView.setItems(sixthCompetitor);
|
|
||||||
// seventhListView.setItems(seventhCompetitor);
|
|
||||||
// eighthListView.setItems(eighthCompetitor);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private void initialiseLobbyControllerThread() {
|
|
||||||
// Thread thread = new Thread(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// Platform.runLater(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// thread.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialiseImageView() {
|
private void initialiseImageView() {
|
||||||
// for (int i = 0; i < MAX_NUM_PLAYERS; i++) {
|
imageViews.add(firstImageView);
|
||||||
// imageViews.get(i).setImage(new Image(getClass().getResourceAsStream("/pics/sail.png")));
|
imageViews.add(secondImageView);
|
||||||
// }
|
imageViews.add(thirdImageView);
|
||||||
// Image image1 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
imageViews.add(fourthImageView);
|
||||||
// firstImageView.setImage(image1);
|
imageViews.add(fifthImageView);
|
||||||
// Image image2 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
imageViews.add(sixthImageView);
|
||||||
// secondImageView.setImage(image2);
|
imageViews.add(seventhImageView);
|
||||||
// Image image3 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
imageViews.add(eighthImageView);
|
||||||
// thirdImageView.setImage(image3);
|
for (int i = 0; i < MAX_NUM_PLAYERS; i++) {
|
||||||
// Image image4 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
imageViews.get(i).setImage(
|
||||||
// fourthImageView.setImage(image4);
|
new Image(
|
||||||
// Image image5 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
RaceViewController.class.getResourceAsStream(
|
||||||
// fifthImageView.setImage(image5);
|
"/pics/sail.png")
|
||||||
// Image image6 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
)
|
||||||
// sixthImageView.setImage(image6);
|
);
|
||||||
// Image image7 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
}
|
||||||
// seventhImageView.setImage(image7);
|
|
||||||
// Image image8 = new Image(getClass().getResourceAsStream("/pics/sail.png"));
|
|
||||||
// eighthImageView.setImage(image8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -267,8 +148,6 @@ public class LobbyController implements Initializable {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void readyButtonPressed() {
|
public void readyButtonPressed() {
|
||||||
// setContentPane("/views/RaceView.fxml");
|
|
||||||
// playTheme();
|
|
||||||
GameState.setCurrentStage(GameStages.RACING);
|
GameState.setCurrentStage(GameStages.RACING);
|
||||||
for (LobbyCloseListener readyListener : lobbyListeners)
|
for (LobbyCloseListener readyListener : lobbyListeners)
|
||||||
readyListener.notify(CloseStatus.READY);
|
readyListener.notify(CloseStatus.READY);
|
||||||
@@ -308,13 +187,13 @@ public class LobbyController implements Initializable {
|
|||||||
lobbyListeners.add(listener);
|
lobbyListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: 1/08/17 could definitely do this in a cleaner way.
|
||||||
public void setPlayerListSource (ObservableList<String> players) {
|
public void setPlayerListSource (ObservableList<String> players) {
|
||||||
// if (competitorsListView != null)
|
this.players = players;
|
||||||
// competitorsListView.setItems(players);
|
players.addListener((ListChangeListener<? super String>) (lcl) ->
|
||||||
// if (firstListView != null) {
|
initialiseListView()
|
||||||
firstListView.setItems(players);
|
);
|
||||||
firstImageView.setVisible(false);
|
initialiseListView();
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableReadyButton () {
|
public void disableReadyButton () {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javafx.animation.KeyFrame;
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -101,7 +100,9 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
selectAnnotationBtn.setOnAction(event -> loadSelectAnnotationView());
|
selectAnnotationBtn.setOnAction(event -> loadSelectAnnotationView());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRace (Map<Integer, Yacht> participants, RaceXMLData raceData, RaceState raceState) {
|
public void loadRace (
|
||||||
|
Map<Integer, Yacht> participants, RaceXMLData raceData, RaceState raceState, Yacht player
|
||||||
|
) {
|
||||||
this.participants = participants;
|
this.participants = participants;
|
||||||
this.courseData = raceData;
|
this.courseData = raceData;
|
||||||
this.markers = raceData.getCompoundMarks();
|
this.markers = raceData.getCompoundMarks();
|
||||||
@@ -113,19 +114,14 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
initialiseBoatSelectionComboBox();
|
initialiseBoatSelectionComboBox();
|
||||||
|
|
||||||
gameView = new GameView();
|
gameView = new GameView();
|
||||||
System.out.println("haha");
|
contentAnchorPane.getChildren().add(gameView);
|
||||||
Platform.runLater(() -> {
|
gameView.setBoats(new ArrayList<>(participants.values()));
|
||||||
contentAnchorPane.getChildren().add(gameView);
|
gameView.updateBorder(raceData.getCourseLimit());
|
||||||
|
gameView.updateCourse(
|
||||||
// contentAnchorPane.getChildren().add(gameView);
|
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
||||||
System.out.println("hehe");
|
);
|
||||||
gameView.setBoats(new ArrayList<>(participants.values()));
|
gameView.setBoatAsPlayer(player);
|
||||||
gameView.updateBorder(raceData.getCourseLimit());
|
gameView.startRace();
|
||||||
gameView.updateCourse(
|
|
||||||
new ArrayList<>(raceData.getCompoundMarks().values()), raceData.getMarkSequence()
|
|
||||||
);
|
|
||||||
gameView.startRace();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,5 +606,4 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
|||||||
this.courseData = raceData;
|
this.courseData = raceData;
|
||||||
gameView.updateBorder(raceData.getCourseLimit());
|
gameView.updateBorder(raceData.getCourseLimit());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ package seng302.visualiser.fxObjects;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.scene.CacheHint;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.paint.Paint;
|
import javafx.scene.paint.Paint;
|
||||||
@@ -60,8 +61,8 @@ public class AnnotationBox extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Text offset constants
|
//Text offset constants
|
||||||
private static final double X_OFFSET_TEXT = 18d;
|
private static final double X_OFFSET_TEXT = 20d;
|
||||||
private static final double Y_OFFSET_TEXT_INIT = -29d;
|
private static final double Y_OFFSET_TEXT_INIT = -35d;
|
||||||
private static final double Y_OFFSET_PER_TEXT = 12d;
|
private static final double Y_OFFSET_PER_TEXT = 12d;
|
||||||
//Background constants
|
//Background constants
|
||||||
private static final double TEXT_BUFFER = 3;
|
private static final double TEXT_BUFFER = 3;
|
||||||
@@ -71,7 +72,7 @@ public class AnnotationBox extends Group{
|
|||||||
private static final double BACKGROUND_ARC_SIZE = 10;
|
private static final double BACKGROUND_ARC_SIZE = 10;
|
||||||
|
|
||||||
private int visibleAnnotations = 0;
|
private int visibleAnnotations = 0;
|
||||||
private double backgroundWidth = 125d;
|
private double backgroundWidth = 145d;
|
||||||
|
|
||||||
private Rectangle background = new Rectangle();
|
private Rectangle background = new Rectangle();
|
||||||
private Paint theme = Color.BLACK;
|
private Paint theme = Color.BLACK;
|
||||||
@@ -79,7 +80,7 @@ public class AnnotationBox extends Group{
|
|||||||
private Map<String, Annotation> annotationsByName = new HashMap<>();
|
private Map<String, Annotation> annotationsByName = new HashMap<>();
|
||||||
|
|
||||||
public AnnotationBox() {
|
public AnnotationBox() {
|
||||||
// this.setCache(true);
|
this.setCache(true);
|
||||||
background.setX(BACKGROUND_X);
|
background.setX(BACKGROUND_X);
|
||||||
background.setY(BACKGROUND_Y);
|
background.setY(BACKGROUND_Y);
|
||||||
background.setWidth(backgroundWidth);
|
background.setWidth(backgroundWidth);
|
||||||
@@ -89,8 +90,8 @@ public class AnnotationBox extends Group{
|
|||||||
background.setFill(new Color(1, 1, 1, 0.75));
|
background.setFill(new Color(1, 1, 1, 0.75));
|
||||||
background.setStroke(theme);
|
background.setStroke(theme);
|
||||||
background.setStrokeWidth(2);
|
background.setStrokeWidth(2);
|
||||||
// background.setCache(true);
|
background.setCache(true);
|
||||||
// background.setCacheHint(CacheHint.SPEED);
|
background.setCacheHint(CacheHint.SPEED);
|
||||||
this.getChildren().add(background);
|
this.getChildren().add(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,17 +124,18 @@ public class AnnotationBox extends Group{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAnnotationVisibility (String annotationName, boolean visibility) {
|
public void setAnnotationVisibility (String annotationName, boolean visibility) {
|
||||||
Text textField = annotationsByName.get(annotationName).text;
|
if (annotationsByName.containsKey(annotationName)) {
|
||||||
boolean currentState = textField.visibleProperty().get();
|
Text textField = annotationsByName.get(annotationName).text;
|
||||||
|
boolean currentState = textField.visibleProperty().get();
|
||||||
if (visibility != currentState) {
|
if (visibility != currentState) {
|
||||||
if (visibility)
|
if (visibility)
|
||||||
visibleAnnotations++;
|
visibleAnnotations++;
|
||||||
else
|
else
|
||||||
visibleAnnotations--;
|
visibleAnnotations--;
|
||||||
|
}
|
||||||
|
textField.setVisible(visibility);
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
textField.setVisible(visibility);
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAnnotation (String annotationName) {
|
public void removeAnnotation (String annotationName) {
|
||||||
@@ -143,13 +145,32 @@ public class AnnotationBox extends Group{
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindLocation () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation (double x, double y) {
|
public void setLocation (double x, double y) {
|
||||||
this.setTranslateX(x);
|
// double dx = x - this.getLayoutX();
|
||||||
this.setTranslateY(y);
|
// double dy = y - this.getLayoutY();
|
||||||
|
// this.relocate(x, y);
|
||||||
|
//// this.relocate(x, y);
|
||||||
|
// for (Node n : this.getChildren()) {
|
||||||
|
// n.relocate(
|
||||||
|
// n.getLayoutX() + dx,
|
||||||
|
// n.getLayoutY() + dy
|
||||||
|
// );
|
||||||
|
//// n.setLayoutX(n.getLayoutX() + dx);
|
||||||
|
//// n.setLayoutY(n.getLayoutY() + dy);
|
||||||
|
// }
|
||||||
|
// update();
|
||||||
|
this.relocate(x + BACKGROUND_X, y + BACKGROUND_Y);
|
||||||
|
// for (int i = 1; i <= visibleAnnotations; i++) {
|
||||||
|
// Text text = (Text) this.getChildren().get(i);
|
||||||
|
// if (text.visibleProperty().get()) {
|
||||||
|
// text.setLayoutX(x + X_OFFSET_TEXT);
|
||||||
|
// text.setLayoutY(y + Y_OFFSET_TEXT_INIT * Y_OFFSET_PER_TEXT * (i + 1));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// moveTexts(x, y);
|
||||||
|
// for (Node n : this.getChildren()) {
|
||||||
|
// n.relocate(x, y);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidth (double width) {
|
public void setWidth (double width) {
|
||||||
@@ -160,10 +181,19 @@ public class AnnotationBox extends Group{
|
|||||||
private void update () {
|
private void update () {
|
||||||
background.setVisible(visibleAnnotations != 0);
|
background.setVisible(visibleAnnotations != 0);
|
||||||
background.setHeight(Math.abs(BACKGROUND_X) + TEXT_BUFFER + BACKGROUND_H_PER_TEXT * visibleAnnotations);
|
background.setHeight(Math.abs(BACKGROUND_X) + TEXT_BUFFER + BACKGROUND_H_PER_TEXT * visibleAnnotations);
|
||||||
|
// System.out.println("visibleAnnotations = " + visibleAnnotations);
|
||||||
for (int i = 1; i <= visibleAnnotations; i++) {
|
for (int i = 1; i <= visibleAnnotations; i++) {
|
||||||
Text text = (Text) this.getChildren().get(i);
|
Text text = (Text) this.getChildren().get(i);
|
||||||
if (text.visibleProperty().get())
|
if (text.visibleProperty().get()) {
|
||||||
text.relocate(X_OFFSET_TEXT, Y_OFFSET_TEXT_INIT * Y_OFFSET_PER_TEXT * (i + 1));
|
// System.out.println("AYY LMAO");
|
||||||
|
// System.out.println("text.getText() = " + text.getText());
|
||||||
|
//// System.out
|
||||||
|
//// .println("text.visibleProperty().get() = " + text.visibleProperty().get());
|
||||||
|
// System.out.println(text.getLayoutX());
|
||||||
|
// System.out.println(background.getLayoutX());
|
||||||
|
text.setX(X_OFFSET_TEXT);
|
||||||
|
text.setY(Y_OFFSET_TEXT_INIT + Y_OFFSET_PER_TEXT * i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,8 +206,8 @@ public class AnnotationBox extends Group{
|
|||||||
Text text = new Text();
|
Text text = new Text();
|
||||||
text.setFill(theme);
|
text.setFill(theme);
|
||||||
text.setStrokeWidth(2);
|
text.setStrokeWidth(2);
|
||||||
// text.setCacheHint(CacheHint.SPEED);
|
text.setCacheHint(CacheHint.SPEED);
|
||||||
// text.setCache(true);
|
text.setCache(true);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ public class BoatObject extends Group {
|
|||||||
boatPoly.setStroke(Color.BLACK);
|
boatPoly.setStroke(Color.BLACK);
|
||||||
});
|
});
|
||||||
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
||||||
// boatPoly.setCache(true);
|
boatPoly.setCache(true);
|
||||||
// boatPoly.setCacheHint(CacheHint.SPEED);
|
boatPoly.setCacheHint(CacheHint.SPEED);
|
||||||
|
|
||||||
// annotationBox = new AnnotationBox();
|
// annotationBox = new AnnotationBox();
|
||||||
// annotationBox.setFill(colour);
|
// annotationBox.setFill(colour);
|
||||||
@@ -260,8 +260,6 @@ public class BoatObject extends Group {
|
|||||||
);
|
);
|
||||||
boatPoly.setStroke(Color.BLACK);
|
boatPoly.setStroke(Color.BLACK);
|
||||||
boatPoly.setStrokeWidth(3);
|
boatPoly.setStrokeWidth(3);
|
||||||
// boatAnnotations.setAsPlayer();
|
|
||||||
// isPlayer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrajectory(double heading, double velocity) {
|
public void setTrajectory(double heading, double velocity) {
|
||||||
|
|||||||
@@ -27,31 +27,7 @@
|
|||||||
<Mark SeqID="1" Name="Wind Gate 1" TargetLat="57.665316" TargetLng="11.827184" SourceID="126" />
|
<Mark SeqID="1" Name="Wind Gate 1" TargetLat="57.665316" TargetLng="11.827184" SourceID="126" />
|
||||||
<Mark SeqID="2" Name="Wind Gate 2" TargetLat="57.664190" TargetLng="11.829576" SourceID="127" />
|
<Mark SeqID="2" Name="Wind Gate 2" TargetLat="57.664190" TargetLng="11.829576" SourceID="127" />
|
||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
<CompoundMark CompoundMarkID="5" Name="Mark2">
|
<CompoundMark CompoundMarkID="5" Name="Mark4">
|
||||||
<Mark SeqID="1" Name="Lee Gate 1" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="124" />
|
|
||||||
<Mark SeqID="2" Name="Lee Gate 2" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="125" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="6" Name="Mark3">
|
|
||||||
<Mark SeqID="1" Name="Wind Gate 1" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="126" />
|
|
||||||
<Mark SeqID="2" Name="Wind Gate 2" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="127" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="7" Name="Mark2">
|
|
||||||
<Mark SeqID="1" Name="Lee Gate 1" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="124" />
|
|
||||||
<Mark SeqID="2" Name="Lee Gate 2" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="125" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="8" Name="Mark3">
|
|
||||||
<Mark SeqID="1" Name="Wind Gate 1" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="126" />
|
|
||||||
<Mark SeqID="2" Name="Wind Gate 2" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="127" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="9" Name="Mark2">
|
|
||||||
<Mark SeqID="1" Name="Lee Gate 1" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="124" />
|
|
||||||
<Mark SeqID="2" Name="Lee Gate 2" TargetLat="57.6708220" TargetLng="11.8433900" SourceID="125" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="10" Name="Mark3">
|
|
||||||
<Mark SeqID="1" Name="Wind Gate 1" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="126" />
|
|
||||||
<Mark SeqID="2" Name="Wind Gate 2" TargetLat="57.6650170" TargetLng="11.8279170" SourceID="127" />
|
|
||||||
</CompoundMark>
|
|
||||||
<CompoundMark CompoundMarkID="11" Name="Mark4">
|
|
||||||
<Mark SeqID="1" Name="Finish Line 1" TargetLat="57.672350" TargetLng="11.842535" SourceID="128" />
|
<Mark SeqID="1" Name="Finish Line 1" TargetLat="57.672350" TargetLng="11.842535" SourceID="128" />
|
||||||
<Mark SeqID="2" Name="Finish Line 2" TargetLat="57.6715240" TargetLng="11.8444950" SourceID="129" />
|
<Mark SeqID="2" Name="Finish Line 2" TargetLat="57.6715240" TargetLng="11.8444950" SourceID="129" />
|
||||||
</CompoundMark>
|
</CompoundMark>
|
||||||
@@ -61,13 +37,13 @@
|
|||||||
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
|
<Corner SeqID="2" CompoundMarkID="2" Rounding="Port" ZoneSize="3" />
|
||||||
<Corner SeqID="3" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="3" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
|
||||||
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
|
<Corner SeqID="4" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
|
||||||
<Corner SeqID="5" CompoundMarkID="5" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="5" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
|
||||||
<Corner SeqID="6" CompoundMarkID="6" Rounding="PS" ZoneSize="3" />
|
<Corner SeqID="6" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
|
||||||
<Corner SeqID="7" CompoundMarkID="7" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="7" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
|
||||||
<Corner SeqID="8" CompoundMarkID="8" Rounding="PS" ZoneSize="3" />
|
<Corner SeqID="8" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
|
||||||
<Corner SeqID="9" CompoundMarkID="9" Rounding="SP" ZoneSize="3" />
|
<Corner SeqID="9" CompoundMarkID="3" Rounding="SP" ZoneSize="3" />
|
||||||
<Corner SeqID="10" CompoundMarkID="10" Rounding="PS" ZoneSize="3" />
|
<Corner SeqID="10" CompoundMarkID="4" Rounding="PS" ZoneSize="3" />
|
||||||
<Corner SeqID="11" CompoundMarkID="11" Rounding="PS" ZoneSize="3" />
|
<Corner SeqID="11" CompoundMarkID="5" Rounding="PS" ZoneSize="3" />
|
||||||
</CompoundMarkSequence>
|
</CompoundMarkSequence>
|
||||||
<CourseLimit>
|
<CourseLimit>
|
||||||
<Limit SeqID="1" Lat="57.6739450" Lon="11.8417100" />
|
<Limit SeqID="1" Lat="57.6739450" Lon="11.8417100" />
|
||||||
|
|||||||
Reference in New Issue
Block a user