mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Changed package heirachy. Merged Controller and StartScreenController.
#refactor
This commit is contained in:
@@ -6,9 +6,9 @@ import javafx.scene.Parent;
|
|||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import seng302.models.PolarTable;
|
import seng302.model.PolarTable;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.StreamReceiver;
|
import seng302.model.stream.StreamReceiver;
|
||||||
|
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
|
|
||||||
@@ -16,11 +16,11 @@ public class App extends Application {
|
|||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
PolarTable.parsePolarFile(getClass().getResourceAsStream("/config/acc_polars.csv"));
|
PolarTable.parsePolarFile(getClass().getResourceAsStream("/config/acc_polars.csv"));
|
||||||
|
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("/views/MainView.fxml"));
|
Parent root = FXMLLoader.load(getClass().getResource("/views/StartScreenView.fxml"));
|
||||||
primaryStage.setTitle("RaceVision");
|
primaryStage.setTitle("RaceVision");
|
||||||
primaryStage.setScene(new Scene(root, 1530, 960));
|
primaryStage.setScene(new Scene(root, 1530, 960));
|
||||||
primaryStage.setMaxWidth(1530);
|
// primaryStage.setMaxWidth(1530);
|
||||||
primaryStage.setMaxHeight(960);
|
// primaryStage.setMaxHeight(960);
|
||||||
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/PP.png")));
|
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/PP.png")));
|
||||||
// primaryStage.setMaximized(true);
|
// primaryStage.setMaximized(true);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package seng302.client;
|
|
||||||
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by cir27 on 20/07/17.
|
|
||||||
*/
|
|
||||||
public class GameView extends AnchorPane {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package seng302.controllers;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
|
||||||
import seng302.models.stream.StreamParser;
|
|
||||||
import seng302.client.ClientToServerThread;
|
|
||||||
import seng302.server.messages.BoatActionMessage;
|
|
||||||
import seng302.server.messages.BoatActionType;
|
|
||||||
|
|
||||||
public class Controller implements Initializable {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private AnchorPane contentPane;
|
|
||||||
private ClientToServerThread clientToServerThread;
|
|
||||||
|
|
||||||
private Object setContentPane(String jfxUrl) {
|
|
||||||
try {
|
|
||||||
contentPane.getChildren().removeAll();
|
|
||||||
contentPane.getChildren().clear();
|
|
||||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader((getClass().getResource(jfxUrl)));
|
|
||||||
Parent view = fxmlLoader.load();
|
|
||||||
contentPane.getChildren().addAll(view);
|
|
||||||
return fxmlLoader.getController();
|
|
||||||
} catch (javafx.fxml.LoadException e) {
|
|
||||||
System.err.println(e.getCause());
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
|
||||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
|
||||||
StartScreenController startScreenController = (StartScreenController) setContentPane("/views/StartScreenView.fxml");
|
|
||||||
startScreenController.setController(this);
|
|
||||||
StreamParser.boatLocations.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Handle the key-pressed event from the text field. */
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
BoatActionMessage boatActionMessage;
|
|
||||||
switch (e.getCode()){
|
|
||||||
case SPACE: // align with vmg
|
|
||||||
boatActionMessage = new BoatActionMessage(BoatActionType.VMG);
|
|
||||||
clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
|
||||||
break;
|
|
||||||
case PAGE_UP: // upwind
|
|
||||||
boatActionMessage = new BoatActionMessage(BoatActionType.UPWIND);
|
|
||||||
clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
|
||||||
break;
|
|
||||||
case PAGE_DOWN: // downwind
|
|
||||||
boatActionMessage = new BoatActionMessage(BoatActionType.DOWNWIND);
|
|
||||||
clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
|
||||||
break;
|
|
||||||
case ENTER: // tack/gybe
|
|
||||||
boatActionMessage = new BoatActionMessage(BoatActionType.TACK_GYBE);
|
|
||||||
clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
|
||||||
break;
|
|
||||||
//TODO Allow a zoom in and zoom out methods
|
|
||||||
case Z: // zoom in
|
|
||||||
System.out.println("Zoom in");
|
|
||||||
break;
|
|
||||||
case X: // zoom out
|
|
||||||
System.out.println("Zoom out");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
switch (e.getCode()) {
|
|
||||||
//TODO 12/07/17 Determine the sail state and send the appropriate packet (eg. if sails are in, send a sail out packet)
|
|
||||||
case SHIFT: // sails in/sails out
|
|
||||||
BoatActionMessage boatActionMessage = new BoatActionMessage(BoatActionType.SAILS_IN);
|
|
||||||
clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClientToServerThread(ClientToServerThread ctt) {
|
|
||||||
clientToServerThread = ctt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.models.Player;
|
import seng302.model.Player;
|
||||||
|
|
||||||
public interface ClientConnectionDelegate {
|
public interface ClientConnectionDelegate {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.models.Player;
|
import seng302.model.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.models.Player;
|
import seng302.model.Player;
|
||||||
import seng302.server.messages.Heartbeat;
|
import seng302.server.messages.Heartbeat;
|
||||||
import seng302.server.messages.Message;
|
import seng302.server.messages.Message;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.models.Player;
|
import seng302.model.Player;
|
||||||
import seng302.models.stream.PacketBufferDelegate;
|
import seng302.model.stream.PacketBufferDelegate;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.models.Player;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.channels.ServerSocketChannel;
|
|
||||||
import java.nio.channels.SocketChannel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for a thread to listen to connections
|
* A class for a thread to listen to connections
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import seng302.gameServer.GameState;
|
import seng302.model.Player;
|
||||||
import seng302.models.Player;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.PacketBufferDelegate;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
import seng302.models.stream.StreamParser;
|
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
|
||||||
import seng302.server.messages.Message;
|
import seng302.server.messages.Message;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models;
|
package seng302.model;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
package seng302.models;
|
package seng302.model;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.channels.SocketChannel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Class defining a player and their respective details in the game as held by the model
|
* A Class defining a player and their respective details in the game as held by the model
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models;
|
package seng302.model;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package seng302.models;
|
package seng302.model;
|
||||||
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.controllers.RaceViewController;
|
import seng302.visualiser.controllers.RaceViewController;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.map;
|
package seng302.model.map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Boundary class represents a rectangle territorial boundary on a map. It
|
* The Boundary class represents a rectangle territorial boundary on a map. It
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.map;
|
package seng302.model.map;
|
||||||
|
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.map;
|
package seng302.model.map;
|
||||||
|
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import seng302.utilities.GeoPoint;
|
import seng302.utilities.GeoPoint;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.map;
|
package seng302.model.map;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.mark;
|
package seng302.model.mark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To represent a gate mark which contains two single marks.
|
* To represent a gate mark which contains two single marks.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.mark;
|
package seng302.model.mark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract class to represent general marks
|
* An abstract class to represent general marks
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.mark;
|
package seng302.model.mark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To represent two types of mark
|
* To represent two types of mark
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.mark;
|
package seng302.model.mark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the marker as a single mark
|
* Represents the marker as a single mark
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package seng302.models.stream;
|
package seng302.model.stream;
|
||||||
|
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
|
|
||||||
public interface PacketBufferDelegate {
|
public interface PacketBufferDelegate {
|
||||||
boolean addToBuffer(StreamPacket streamPacket);
|
boolean addToBuffer(StreamPacket streamPacket);
|
||||||
+9
-14
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.stream;
|
package seng302.model.stream;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -20,10 +21,10 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.models.Yacht;
|
import seng302.model.Yacht;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.stream.packets.BoatPositionPacket;
|
import seng302.model.stream.packets.BoatPositionPacket;
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The purpose of this class is to take in the stream of divided packets so they can be read
|
* The purpose of this class is to take in the stream of divided packets so they can be read
|
||||||
@@ -35,8 +36,6 @@ public class StreamParser{
|
|||||||
|
|
||||||
public static ConcurrentHashMap<Long, PriorityBlockingQueue<BoatPositionPacket>> markLocations = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<Long, PriorityBlockingQueue<BoatPositionPacket>> markLocations = new ConcurrentHashMap<>();
|
||||||
public static ConcurrentHashMap<Long, PriorityBlockingQueue<BoatPositionPacket>> boatLocations = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<Long, PriorityBlockingQueue<BoatPositionPacket>> boatLocations = new ConcurrentHashMap<>();
|
||||||
private String threadName;
|
|
||||||
private Thread t;
|
|
||||||
private static boolean newRaceXmlReceived = false;
|
private static boolean newRaceXmlReceived = false;
|
||||||
private static boolean raceStarted = false;
|
private static boolean raceStarted = false;
|
||||||
private static XMLParser xmlObject;
|
private static XMLParser xmlObject;
|
||||||
@@ -49,7 +48,6 @@ public class StreamParser{
|
|||||||
private static Double windSpeed = 0d;
|
private static Double windSpeed = 0d;
|
||||||
private static Long currentTimeLong;
|
private static Long currentTimeLong;
|
||||||
private static String currentTimeString;
|
private static String currentTimeString;
|
||||||
private static boolean appRunning;
|
|
||||||
|
|
||||||
|
|
||||||
//CONVERSION CONSTANTS
|
//CONVERSION CONSTANTS
|
||||||
@@ -436,6 +434,8 @@ public class StreamParser{
|
|||||||
boats.get((int)subjectId).setLastMarkRounded(mark);
|
boats.get((int)subjectId).setLastMarkRounded(mark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Long[] array = new Long[]{subjectId, timeStamp, (long) markId};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -448,7 +448,7 @@ public class StreamParser{
|
|||||||
int messageVersionNo = payload[0];
|
int messageVersionNo = payload[0];
|
||||||
int selectedWindId = payload[1];
|
int selectedWindId = payload[1];
|
||||||
int loopCount = payload[2];
|
int loopCount = payload[2];
|
||||||
ArrayList<String> windInfo = new ArrayList<>();
|
List<String> windInfo = new ArrayList<>();
|
||||||
for (int i = 0; i < loopCount; i++) {
|
for (int i = 0; i < loopCount; i++) {
|
||||||
String wind = "WindId: " + payload[3 + (20 * i)];
|
String wind = "WindId: " + payload[3 + (20 * i)];
|
||||||
wind +=
|
wind +=
|
||||||
@@ -507,7 +507,6 @@ public class StreamParser{
|
|||||||
} else if (actionType == 6) {
|
} else if (actionType == 6) {
|
||||||
System.out.println("DOWNWIND");
|
System.out.println("DOWNWIND");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -630,10 +629,6 @@ public class StreamParser{
|
|||||||
return currentTimeLong;
|
return currentTimeLong;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void appClose() {
|
|
||||||
appRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check if a new un-processed xml has been found, if so will return true before
|
* Used to check if a new un-processed xml has been found, if so will return true before
|
||||||
* toggling off so that the next check will return false.
|
* toggling off so that the next check will return false.
|
||||||
+2
-10
@@ -1,19 +1,11 @@
|
|||||||
package seng302.models.stream;
|
package seng302.model.stream;
|
||||||
|
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
import seng302.server.messages.BoatActionMessage;
|
|
||||||
import seng302.server.messages.BoatActionType;
|
|
||||||
import seng302.server.messages.Heartbeat;
|
|
||||||
import seng302.server.messages.Message;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.channels.SocketChannel;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import java.util.zip.CRC32;
|
|
||||||
import java.util.zip.Checksum;
|
|
||||||
|
|
||||||
|
|
||||||
public class StreamReceiver extends Thread {
|
public class StreamReceiver extends Thread {
|
||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.stream;
|
package seng302.model.stream;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -8,11 +8,11 @@ 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.models.Yacht;
|
import seng302.model.Yacht;
|
||||||
import seng302.models.mark.GateMark;
|
import seng302.model.mark.GateMark;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.mark.MarkType;
|
import seng302.model.mark.MarkType;
|
||||||
import seng302.models.mark.SingleMark;
|
import seng302.model.mark.SingleMark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to create an XML object from the XML Packet Messages.
|
* Class to create an XML object from the XML Packet Messages.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.stream.packets;
|
package seng302.model.stream.packets;
|
||||||
|
|
||||||
public class BoatPositionPacket {
|
public class BoatPositionPacket {
|
||||||
private long boatId;
|
private long boatId;
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
package seng302.models.stream.packets;
|
package seng302.model.stream.packets;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Kusal on 4/24/2017.
|
* Created by Kusal on 4/24/2017.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.stream.packets;
|
package seng302.model.stream.packets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kre39 on 23/04/17.
|
* Created by kre39 on 23/04/17.
|
||||||
+28
-18
@@ -1,23 +1,36 @@
|
|||||||
package seng302.client;
|
package seng302.visualiser;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
import java.util.zip.Checksum;
|
import java.util.zip.Checksum;
|
||||||
|
|
||||||
import seng302.models.stream.StreamParser;
|
import javafx.beans.value.ChangeListener;
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import seng302.model.stream.StreamParser;
|
||||||
|
import seng302.model.stream.XMLParser;
|
||||||
|
import seng302.model.stream.packets.BoatPositionPacket;
|
||||||
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
import seng302.server.messages.BoatActionMessage;
|
import seng302.server.messages.BoatActionMessage;
|
||||||
import seng302.server.messages.BoatActionType;
|
|
||||||
import seng302.server.messages.Message;
|
import seng302.server.messages.Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kre39 on 13/07/17.
|
* Created by kre39 on 13/07/17.
|
||||||
*/
|
*/
|
||||||
public class ClientToServerThread extends Thread {
|
public class ClientToServerThread extends Thread {
|
||||||
|
private Queue<StreamPacket> streamPackets = new ConcurrentLinkedQueue<>();
|
||||||
|
private List<ListChangeListener<Queue<StreamPacket>>> boatPacketListeners = new ArrayList<>();
|
||||||
|
|
||||||
private Socket socket;
|
private Socket socket;
|
||||||
private InputStream is;
|
private InputStream is;
|
||||||
private OutputStream os;
|
private OutputStream os;
|
||||||
@@ -49,17 +62,6 @@ public class ClientToServerThread extends Thread {
|
|||||||
// TODO: 14/07/17 wmu16 - Work out how to fix this while loop
|
// TODO: 14/07/17 wmu16 - Work out how to fix this while loop
|
||||||
while(true) {
|
while(true) {
|
||||||
try {
|
try {
|
||||||
//Perform a write if it is time to as delegated by the MainServerThread
|
|
||||||
if (updateClient) {
|
|
||||||
// TODO: 13/07/17 wmu16 - Write out game state - some function that would write all appropriate messages to this output stream
|
|
||||||
// try {
|
|
||||||
// GameState.outputState(os);
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// System.out.println("IO error in server thread upon writing to output stream");
|
|
||||||
// }
|
|
||||||
updateClient = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
crcBuffer = new ByteArrayOutputStream();
|
crcBuffer = new ByteArrayOutputStream();
|
||||||
sync1 = readByte();
|
sync1 = readByte();
|
||||||
sync2 = readByte();
|
sync2 = readByte();
|
||||||
@@ -76,9 +78,10 @@ public class ClientToServerThread extends Thread {
|
|||||||
long computedCrc = checksum.getValue();
|
long computedCrc = checksum.getValue();
|
||||||
long packetCrc = Message.bytesToLong(getBytes(4));
|
long packetCrc = Message.bytesToLong(getBytes(4));
|
||||||
if (computedCrc == packetCrc) {
|
if (computedCrc == packetCrc) {
|
||||||
StreamParser.parsePacket(new StreamPacket(type, payloadLength, timeStamp, payload));
|
streamPackets.add(new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||||
// TODO: 17/07/17 wmu16 - Fix this or maybe we dont need to go through the main server at all!?!?
|
for (ListChangeListener cl : boatPacketListeners) {
|
||||||
// packetBufferDelegate.addToBuffer(new StreamPacket(type, payloadLength, timeStamp, payload));
|
cl.onChanged();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Packet has been dropped");
|
System.err.println("Packet has been dropped");
|
||||||
}
|
}
|
||||||
@@ -111,6 +114,13 @@ public class ClientToServerThread extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addStreamObserver (ListChangeListener<Queue<StreamPacket>> listChangeListener) {
|
||||||
|
boatPacketListeners.add(listChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeStreamObserver (ListChangeListener<Queue<StreamPacket>> listChangeListener) {
|
||||||
|
boatPacketListeners.remove(listChangeListener);
|
||||||
|
}
|
||||||
|
|
||||||
private int readByte() throws Exception {
|
private int readByte() throws Exception {
|
||||||
int currentByte = -1;
|
int currentByte = -1;
|
||||||
+61
-76
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers;
|
package seng302.visualiser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -8,46 +8,40 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
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 javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import seng302.fxObjects.BoatGroup;
|
import seng302.visualiser.controllers.RaceViewController;
|
||||||
import seng302.models.Colors;
|
import seng302.visualiser.fxObjects.BoatGroup;
|
||||||
import seng302.models.Yacht;
|
import seng302.visualiser.fxObjects.MarkGroup;
|
||||||
import seng302.models.mark.GateMark;
|
import seng302.model.Colors;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.Yacht;
|
||||||
import seng302.fxObjects.MarkGroup;
|
import seng302.model.map.Boundary;
|
||||||
import seng302.models.mark.MarkType;
|
import seng302.model.map.CanvasMap;
|
||||||
import seng302.models.mark.SingleMark;
|
import seng302.model.mark.GateMark;
|
||||||
import seng302.models.map.Boundary;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.map.CanvasMap;
|
import seng302.model.mark.MarkType;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.mark.SingleMark;
|
||||||
import seng302.models.stream.XMLParser;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.XMLParser.RaceXMLObject.Limit;
|
import seng302.model.stream.XMLParser;
|
||||||
import seng302.models.stream.XMLParser.RaceXMLObject.Participant;
|
import seng302.model.stream.XMLParser.RaceXMLObject.Limit;
|
||||||
import seng302.models.stream.packets.BoatPositionPacket;
|
import seng302.model.stream.XMLParser.RaceXMLObject.Participant;
|
||||||
|
import seng302.model.stream.packets.BoatPositionPacket;
|
||||||
import seng302.utilities.GeoPoint;
|
import seng302.utilities.GeoPoint;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ptg19 on 15/03/17.
|
* Created by cir27 on 20/07/17.
|
||||||
* Modified by Haoming Yin (hyi25) on 20/3/2017.
|
|
||||||
*/
|
*/
|
||||||
public class GameViewController {
|
public class GameView extends Pane {
|
||||||
|
|
||||||
@FXML
|
|
||||||
private AnchorPane mainPane;
|
|
||||||
|
|
||||||
private RaceViewController raceViewController;
|
private RaceViewController raceViewController;
|
||||||
private ObservableList<Node> gameObjects;
|
private ObservableList<Node> gameObjects;
|
||||||
private ImageView mapImage;
|
private ImageView mapImage;
|
||||||
@@ -94,12 +88,12 @@ public class GameViewController {
|
|||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
raceViewController = new RaceViewController();
|
raceViewController = new RaceViewController();
|
||||||
gameObjects = mainPane.getChildren();
|
gameObjects = this.getChildren();
|
||||||
// create image view for map, bind panel size to image
|
// create image view for map, bind panel size to image
|
||||||
mapImage = new ImageView();
|
mapImage = new ImageView();
|
||||||
mainPane.getChildren().add(mapImage);
|
gameObjects.add(mapImage);
|
||||||
mapImage.fitWidthProperty().bind(mainPane.widthProperty());
|
mapImage.fitWidthProperty().bind(this.widthProperty());
|
||||||
mapImage.fitHeightProperty().bind(mainPane.heightProperty());
|
mapImage.fitHeightProperty().bind(this.heightProperty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeCanvas() {
|
void initializeCanvas() {
|
||||||
@@ -113,9 +107,9 @@ public class GameViewController {
|
|||||||
gameObjects.add(raceBorder);
|
gameObjects.add(raceBorder);
|
||||||
initializeMarks();
|
initializeMarks();
|
||||||
initializeBoats();
|
initializeBoats();
|
||||||
mainPane.widthProperty().addListener(resize -> {
|
this.widthProperty().addListener(resize -> {
|
||||||
canvasWidth = mainPane.getWidth();
|
canvasWidth = this.getWidth();
|
||||||
canvasHeight = mainPane.getHeight();
|
canvasHeight = this.getHeight();
|
||||||
fitMarksToCanvas();
|
fitMarksToCanvas();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -125,34 +119,33 @@ public class GameViewController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
if (lastTime == 0) {
|
if (lastTime == 0) {
|
||||||
lastTime = now;
|
lastTime = now;
|
||||||
} else {
|
} else {
|
||||||
if (now - lastTime >= (1e8 / 60)) { //Fix for framerate going above 60 when minimized
|
if (now - lastTime >= (1e8 / 60)) { //Fix for framerate going above 60 when minimized
|
||||||
long oldFrameTime = frameTimes[frameTimeIndex];
|
long oldFrameTime = frameTimes[frameTimeIndex];
|
||||||
frameTimes[frameTimeIndex] = now;
|
frameTimes[frameTimeIndex] = now;
|
||||||
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length;
|
frameTimeIndex = (frameTimeIndex + 1) % frameTimes.length;
|
||||||
if (frameTimeIndex == 0) {
|
if (frameTimeIndex == 0) {
|
||||||
arrayFilled = true;
|
arrayFilled = true;
|
||||||
}
|
|
||||||
long elapsedNanos;
|
|
||||||
if (arrayFilled) {
|
|
||||||
elapsedNanos = now - oldFrameTime;
|
|
||||||
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
|
|
||||||
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
|
|
||||||
if (FPSCount-- == 0) {
|
|
||||||
FPSCount = 30;
|
|
||||||
drawFps(frameRate.intValue());
|
|
||||||
}
|
|
||||||
raceViewController.updateSparkLine();
|
|
||||||
}
|
|
||||||
updateGroups();
|
|
||||||
if (StreamParser.isRaceFinished()) {
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
lastTime = now;
|
|
||||||
}
|
}
|
||||||
|
long elapsedNanos;
|
||||||
|
if (arrayFilled) {
|
||||||
|
elapsedNanos = now - oldFrameTime;
|
||||||
|
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length;
|
||||||
|
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame;
|
||||||
|
if (FPSCount-- == 0) {
|
||||||
|
FPSCount = 30;
|
||||||
|
// drawFps(frameRate.intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateGroups();
|
||||||
|
if (StreamParser.isRaceFinished()) {
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
lastTime = now;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (StreamParser.isRaceFinished()) {
|
if (StreamParser.isRaceFinished()) {
|
||||||
this.stop();
|
this.stop();
|
||||||
switchToFinishScreen();
|
switchToFinishScreen();
|
||||||
@@ -164,7 +157,7 @@ public class GameViewController {
|
|||||||
private void switchToFinishScreen() {
|
private void switchToFinishScreen() {
|
||||||
try {
|
try {
|
||||||
// canvas view -> anchor pane -> grid pane -> main view
|
// canvas view -> anchor pane -> grid pane -> main view
|
||||||
GridPane gridPane = (GridPane) mainPane.getParent().getParent();
|
GridPane gridPane = (GridPane) this.getParent().getParent();
|
||||||
AnchorPane contentPane = (AnchorPane) gridPane.getParent();
|
AnchorPane contentPane = (AnchorPane) gridPane.getParent();
|
||||||
contentPane.getChildren().removeAll();
|
contentPane.getChildren().removeAll();
|
||||||
contentPane.getChildren().clear();
|
contentPane.getChildren().clear();
|
||||||
@@ -343,14 +336,14 @@ public class GameViewController {
|
|||||||
gameObjects.addAll(markGroups);
|
gameObjects.addAll(markGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawFps(int fps){
|
// private void drawFps(int fps){
|
||||||
if (raceViewController.isDisplayFps()){
|
// if (raceViewController.isDisplayFps()){
|
||||||
FPSdisplay.setVisible(true);
|
// FPSdisplay.setVisible(true);
|
||||||
FPSdisplay.setText(String.format("%d FPS", fps));
|
// FPSdisplay.setText(String.format("%d FPS", fps));
|
||||||
} else {
|
// } else {
|
||||||
FPSdisplay.setVisible(false);
|
// FPSdisplay.setVisible(false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates x and y location for every marker that fits it to the canvas the race will be
|
* Calculates x and y location for every marker that fits it to the canvas the race will be
|
||||||
@@ -519,12 +512,4 @@ public class GameViewController {
|
|||||||
metersPerPixelY = dVertical / dy;
|
metersPerPixelY = dVertical / dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BoatGroup> getBoatGroups() {
|
}
|
||||||
return boatGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MarkGroup> getMarkGroups() {
|
|
||||||
return markGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers;
|
package seng302.visualiser.controllers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -15,9 +15,9 @@ 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.models.Yacht;
|
import seng302.model.Yacht;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.XMLParser.RaceXMLObject.Participant;
|
import seng302.model.stream.XMLParser.RaceXMLObject.Participant;
|
||||||
|
|
||||||
public class FinishScreenViewController implements Initializable {
|
public class FinishScreenViewController implements Initializable {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers;
|
package seng302.visualiser.controllers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
+14
-17
@@ -1,10 +1,9 @@
|
|||||||
package seng302.controllers;
|
package seng302.visualiser.controllers;
|
||||||
|
|
||||||
import javafx.animation.KeyFrame;
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.Timeline;
|
import javafx.animation.Timeline;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Point2D;
|
import javafx.geometry.Point2D;
|
||||||
@@ -17,7 +16,6 @@ import javafx.scene.control.Button;
|
|||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
import javafx.scene.control.Slider;
|
import javafx.scene.control.Slider;
|
||||||
import javafx.scene.input.KeyEvent;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
@@ -29,24 +27,23 @@ import javafx.stage.Stage;
|
|||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import seng302.client.ClientToServerThread;
|
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.controllers.annotations.Annotation;
|
import seng302.visualiser.controllers.annotations.Annotation;
|
||||||
import seng302.controllers.annotations.ImportantAnnotationController;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationController;
|
||||||
import seng302.controllers.annotations.ImportantAnnotationDelegate;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationDelegate;
|
||||||
import seng302.controllers.annotations.ImportantAnnotationsState;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
|
||||||
import seng302.fxObjects.BoatGroup;
|
import seng302.visualiser.fxObjects.BoatGroup;
|
||||||
import seng302.fxObjects.MarkGroup;
|
import seng302.visualiser.fxObjects.MarkGroup;
|
||||||
import seng302.models.*;
|
import seng302.model.*;
|
||||||
import seng302.models.mark.GateMark;
|
import seng302.model.mark.GateMark;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.mark.SingleMark;
|
import seng302.model.mark.SingleMark;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
import seng302.models.stream.XMLParser;
|
import seng302.model.stream.XMLParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import seng302.models.stream.XMLParser.RaceXMLObject.Participant;
|
import seng302.model.stream.XMLParser.RaceXMLObject.Participant;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+2
-12
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers;
|
package seng302.visualiser.controllers;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
@@ -6,7 +6,7 @@ import javafx.scene.control.TextField;
|
|||||||
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.client.ClientToServerThread;
|
import seng302.visualiser.ClientToServerThread;
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
import seng302.gameServer.MainServerThread;
|
import seng302.gameServer.MainServerThread;
|
||||||
|
|
||||||
@@ -25,8 +25,6 @@ public class StartScreenController {
|
|||||||
@FXML
|
@FXML
|
||||||
private GridPane startScreen2;
|
private GridPane startScreen2;
|
||||||
|
|
||||||
private Controller controller;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the fxml content into the parent pane
|
* Loads the fxml content into the parent pane
|
||||||
* @param jfxUrl
|
* @param jfxUrl
|
||||||
@@ -40,10 +38,7 @@ public class StartScreenController {
|
|||||||
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
contentPane.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(jfxUrl));
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(jfxUrl));
|
||||||
contentPane.getChildren().addAll((Pane) fxmlLoader.load());
|
contentPane.getChildren().addAll((Pane) fxmlLoader.load());
|
||||||
|
|
||||||
return fxmlLoader.getController();
|
return fxmlLoader.getController();
|
||||||
} catch (javafx.fxml.LoadException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -80,15 +75,10 @@ public class StartScreenController {
|
|||||||
String ipAddress = ipTextField.getText().trim().toLowerCase();
|
String ipAddress = ipTextField.getText().trim().toLowerCase();
|
||||||
try {
|
try {
|
||||||
ClientToServerThread clientToServerThread = new ClientToServerThread(ipAddress, 4950);
|
ClientToServerThread clientToServerThread = new ClientToServerThread(ipAddress, 4950);
|
||||||
controller.setClientToServerThread(clientToServerThread);
|
|
||||||
clientToServerThread.start();
|
clientToServerThread.start();
|
||||||
setContentPane("/views/LobbyView.fxml");
|
setContentPane("/views/LobbyView.fxml");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setController(Controller controller) {
|
|
||||||
this.controller = controller;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers.annotations;
|
package seng302.visualiser.controllers.annotations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotations the user can select as important
|
* Annotations the user can select as important
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers.annotations;
|
package seng302.visualiser.controllers.annotations;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers.annotations;
|
package seng302.visualiser.controllers.annotations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ImportantAnnotationDelegate handles updating the important annotations
|
* An ImportantAnnotationDelegate handles updating the important annotations
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.controllers.annotations;
|
package seng302.visualiser.controllers.annotations;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package seng302.visualiser.controllers.client;
|
||||||
|
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.input.KeyEvent;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import seng302.model.stream.XMLParser;
|
||||||
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
|
import seng302.server.messages.BoatActionMessage;
|
||||||
|
import seng302.server.messages.BoatActionType;
|
||||||
|
import seng302.visualiser.ClientToServerThread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cir27 on 20/07/17.
|
||||||
|
*/
|
||||||
|
public class ClientController {
|
||||||
|
|
||||||
|
Pane holderPane;
|
||||||
|
ClientToServerThread socketThread;
|
||||||
|
|
||||||
|
public ClientController (String ipAddress, Pane holder) {
|
||||||
|
this.holderPane = holder;
|
||||||
|
socketThread = new ClientToServerThread(ipAddress, 4950);
|
||||||
|
socketThread.start();
|
||||||
|
socketThread.waitForXML(event -> storeXMLData());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parsePacket(StreamPacket packet) {
|
||||||
|
try {
|
||||||
|
switch (packet.getType()) {
|
||||||
|
case HEARTBEAT:
|
||||||
|
extractHeartBeat(packet);
|
||||||
|
break;
|
||||||
|
case RACE_STATUS:
|
||||||
|
extractRaceStatus(packet);
|
||||||
|
break;
|
||||||
|
case DISPLAY_TEXT_MESSAGE:
|
||||||
|
extractDisplayMessage(packet);
|
||||||
|
break;
|
||||||
|
case XML_MESSAGE:
|
||||||
|
newRaceXmlReceived = true;
|
||||||
|
extractXmlMessage(packet);
|
||||||
|
break;
|
||||||
|
case RACE_START_STATUS:
|
||||||
|
extractRaceStartStatus(packet);
|
||||||
|
break;
|
||||||
|
case YACHT_EVENT_CODE:
|
||||||
|
extractYachtEventCode(packet);
|
||||||
|
break;
|
||||||
|
case YACHT_ACTION_CODE:
|
||||||
|
extractYachtActionCode(packet);
|
||||||
|
break;
|
||||||
|
case CHATTER_TEXT:
|
||||||
|
extractChatterText(packet);
|
||||||
|
break;
|
||||||
|
case BOAT_LOCATION:
|
||||||
|
extractBoatLocation(packet);
|
||||||
|
break;
|
||||||
|
case MARK_ROUNDING:
|
||||||
|
extractMarkRounding(packet);
|
||||||
|
break;
|
||||||
|
case COURSE_WIND:
|
||||||
|
extractCourseWind(packet);
|
||||||
|
break;
|
||||||
|
case AVG_WIND:
|
||||||
|
extractAvgWind(packet);
|
||||||
|
break;
|
||||||
|
case BOAT_ACTION:
|
||||||
|
extractBoatAction(packet);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.out.println("Error parsing packet");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /** Handle the key-pressed event from the text field. */
|
||||||
|
// public void keyPressed(KeyEvent e) {
|
||||||
|
// BoatActionMessage boatActionMessage;
|
||||||
|
// switch (e.getCode()){
|
||||||
|
// case SPACE: // align with vmg
|
||||||
|
// boatActionMessage = new BoatActionMessage(BoatActionType.VMG);
|
||||||
|
// clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
||||||
|
// break;
|
||||||
|
// case PAGE_UP: // upwind
|
||||||
|
// boatActionMessage = new BoatActionMessage(BoatActionType.UPWIND);
|
||||||
|
// clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
||||||
|
// break;
|
||||||
|
// case PAGE_DOWN: // downwind
|
||||||
|
// boatActionMessage = new BoatActionMessage(BoatActionType.DOWNWIND);
|
||||||
|
// clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
||||||
|
// break;
|
||||||
|
// case ENTER: // tack/gybe
|
||||||
|
// boatActionMessage = new BoatActionMessage(BoatActionType.TACK_GYBE);
|
||||||
|
// clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
||||||
|
// break;
|
||||||
|
// //TODO Allow a zoom in and zoom out methods
|
||||||
|
// case Z: // zoom in
|
||||||
|
// System.out.println("Zoom in");
|
||||||
|
// break;
|
||||||
|
// case X: // zoom out
|
||||||
|
// System.out.println("Zoom out");
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void keyReleased(KeyEvent e) {
|
||||||
|
// switch (e.getCode()) {
|
||||||
|
// //TODO 12/07/17 Determine the sail state and send the appropriate packet (eg. if sails are in, send a sail out packet)
|
||||||
|
// case SHIFT: // sails in/sails out
|
||||||
|
// BoatActionMessage boatActionMessage = new BoatActionMessage(BoatActionType.SAILS_IN);
|
||||||
|
// clientToServerThread.sendBoatActionMessage(boatActionMessage);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// onKeyPressed="#keyPressed" onKeyReleased="#keyReleased"
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package seng302.visualiser.controllers.host;
|
||||||
|
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cir27 on 20/07/17.
|
||||||
|
*/
|
||||||
|
public class HostController {
|
||||||
|
Pane mainHolder;
|
||||||
|
public HostController (Pane holder) {
|
||||||
|
this.mainHolder = holder;
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -1,12 +1,12 @@
|
|||||||
package seng302.fxObjects;
|
package seng302.visualiser.fxObjects;
|
||||||
|
|
||||||
import javafx.scene.CacheHint;
|
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.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import seng302.models.Yacht;
|
import seng302.model.Yacht;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
+7
-7
@@ -1,4 +1,4 @@
|
|||||||
package seng302.fxObjects;
|
package seng302.visualiser.fxObjects;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -9,13 +9,13 @@ import javafx.scene.paint.Color;
|
|||||||
import javafx.scene.shape.Line;
|
import javafx.scene.shape.Line;
|
||||||
import javafx.scene.shape.Polygon;
|
import javafx.scene.shape.Polygon;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
import seng302.controllers.GameViewController;
|
import seng302.visualiser.controllers.GameViewController;
|
||||||
import seng302.models.Yacht;
|
import seng302.model.Yacht;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.models.mark.GateMark;
|
import seng302.model.mark.GateMark;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.mark.SingleMark;
|
import seng302.model.mark.SingleMark;
|
||||||
import seng302.models.stream.StreamParser;
|
import seng302.model.stream.StreamParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
* BoatGroup is a javafx group that by default contains a graphical objects for representing a 2
|
||||||
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
package seng302.fxObjects;
|
package seng302.visualiser.fxObjects;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -8,10 +8,10 @@ import javafx.scene.Node;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Circle;
|
import javafx.scene.shape.Circle;
|
||||||
import javafx.scene.shape.Line;
|
import javafx.scene.shape.Line;
|
||||||
import seng302.models.mark.GateMark;
|
import seng302.model.mark.GateMark;
|
||||||
import seng302.models.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.models.mark.MarkType;
|
import seng302.model.mark.MarkType;
|
||||||
import seng302.models.mark.SingleMark;
|
import seng302.model.mark.SingleMark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grouping of javaFX objects needed to represent a Mark on screen.
|
* Grouping of javaFX objects needed to represent a Mark on screen.
|
||||||
+1
-2
@@ -1,4 +1,4 @@
|
|||||||
package seng302.fxObjects;
|
package seng302.visualiser.fxObjects;
|
||||||
|
|
||||||
import javafx.scene.CacheHint;
|
import javafx.scene.CacheHint;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
@@ -7,7 +7,6 @@ import javafx.scene.shape.Arc;
|
|||||||
import javafx.scene.shape.ArcType;
|
import javafx.scene.shape.ArcType;
|
||||||
import javafx.scene.shape.StrokeLineCap;
|
import javafx.scene.shape.StrokeLineCap;
|
||||||
import javafx.scene.transform.Rotate;
|
import javafx.scene.transform.Rotate;
|
||||||
import javafx.scene.transform.Scale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A group containing objects used to represent wakes onscreen. Contains functionality for their animation.
|
* A group containing objects used to represent wakes onscreen. Contains functionality for their animation.
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane fx:id="finishScreenGridPane" maxHeight="837.0" maxWidth="837.0" minHeight="837.0" minWidth="837.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="837.0" prefWidth="837.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.FinishScreenViewController">
|
<GridPane fx:id="finishScreenGridPane" maxHeight="837.0" maxWidth="837.0" minHeight="837.0" minWidth="837.0" nodeOrientation="LEFT_TO_RIGHT" prefHeight="837.0" prefWidth="837.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.FinishScreenViewController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane fx:id="mainPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.GameViewController" />
|
<AnchorPane fx:id="mainPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.GameViewController" />
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.text.*?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
|
<GridPane fx:id="lobbyScreen" nodeOrientation="LEFT_TO_RIGHT" prefHeight="533.0" prefWidth="802.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.LobbyController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="171.0" minHeight="0.0" prefHeight="31.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="399.0" minHeight="10.0" prefHeight="394.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="63.0" minHeight="10.0" prefHeight="26.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Text fx:id="lobbyIpText" fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="Lobby: IP" GridPane.columnSpan="2147483647" GridPane.halignment="CENTER">
|
||||||
|
<font>
|
||||||
|
<Font size="29.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<GridPane GridPane.rowIndex="2">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Button focusTraversable="false" mnemonicParsing="false" onAction="#readyButtonPressed" prefWidth="101.0" text="Ready" GridPane.halignment="CENTER" />
|
||||||
|
<Button focusTraversable="false" mnemonicParsing="false" onAction="#leaveLobbyButtonPressed" text="Leave Lobby" GridPane.columnIndex="1" GridPane.halignment="CENTER" />
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
<AnchorPane focusTraversable="true" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
||||||
|
<children>
|
||||||
|
<GridPane layoutX="335.0" layoutY="146.0" prefHeight="399.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="261.0" minWidth="0.0" prefWidth="2.0" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="261.0" minWidth="0.0" prefWidth="2.0" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints maxHeight="125.0" minHeight="0.0" prefHeight="0.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints maxHeight="266.0" minHeight="10.0" prefHeight="266.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
|
<children>
|
||||||
|
<ListView fx:id="competitorsListView" layoutX="154.0" layoutY="59.0" prefHeight="266.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</children></AnchorPane>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<GridPane fx:id="lobbyScreen" nodeOrientation="LEFT_TO_RIGHT" prefHeight="533.0" prefWidth="802.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.LobbyController">
|
<GridPane fx:id="lobbyScreen" nodeOrientation="LEFT_TO_RIGHT" prefHeight="533.0" prefWidth="802.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.LobbyController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane fx:id="contentPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onKeyPressed="#keyPressed" onKeyReleased="#keyReleased" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.Controller" />
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<?import javafx.scene.shape.*?>
|
<?import javafx.scene.shape.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<GridPane prefHeight="960.0" prefWidth="1530.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.RaceViewController">
|
<GridPane prefHeight="960.0" prefWidth="1530.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.RaceViewController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
<ColumnConstraints maxWidth="246.0" minWidth="246.0" prefWidth="246.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="1034.0" />
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<GridPane fx:id="startScreen2" nodeOrientation="LEFT_TO_RIGHT" prefWidth="800.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.controllers.StartScreenController">
|
<GridPane fx:id="startScreen2" nodeOrientation="LEFT_TO_RIGHT" prefWidth="800.0" style="-fx-background-color: #2C2c36;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.visualiser.controllers.StartScreenController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<?import javafx.scene.canvas.*?>
|
<?import javafx.scene.canvas.*?>
|
||||||
|
|
||||||
|
|
||||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="960.0" prefWidth="1280.0" style="-fx-background-color: #ddd;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.models.map.TestMapController">
|
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="960.0" prefWidth="1280.0" style="-fx-background-color: #ddd;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng302.model.map.TestMapController">
|
||||||
<children>
|
<children>
|
||||||
<Canvas fx:id="mapCanvas" height="960.0" width="1280.0" />
|
<Canvas fx:id="mapCanvas" height="960.0" width="1280.0" />
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//package seng302;
|
//package seng302;
|
||||||
//
|
//
|
||||||
//import org.junit.Test;
|
//import org.junit.Test;
|
||||||
//import seng302.models.Boat;
|
//import seng302.model.Boat;
|
||||||
//
|
//
|
||||||
//import static org.junit.Assert.assertEquals;
|
//import static org.junit.Assert.assertEquals;
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package seng302;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.models.Colors;
|
import seng302.model.Colors;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.controllers.RaceViewController;
|
import seng302.visualiser.controllers.RaceViewController;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -1,10 +1,8 @@
|
|||||||
package seng302.models.map;
|
package seng302.model.map;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.utilities.GeoPoint;
|
import seng302.utilities.GeoPoint;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.mark;
|
package seng302.model.mark;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package seng302.models.stream;
|
package seng302.model.stream;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -8,7 +8,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.PriorityBlockingQueue;
|
import java.util.concurrent.PriorityBlockingQueue;
|
||||||
import seng302.models.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
// TODO: 4/05/17 cir27 - Currently the CI cannot build these tests. Unsure of exact issue but believe it may be a driver issue. Find a way to make tests work.
|
|
||||||
|
|
||||||
//package seng302.models;
|
|
||||||
//
|
|
||||||
//public class BoatGroupTest {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
package seng302.models;
|
|
||||||
/*
|
|
||||||
* Created by cir27 on 4/05/17.
|
|
||||||
|
|
||||||
public class BoatGroupTest {
|
|
||||||
BoatGroup boatGroup;
|
|
||||||
@Before
|
|
||||||
public void setUp () {
|
|
||||||
Yacht b = new Yacht("TEST", 0.0, "T" ,0);
|
|
||||||
boatGroup = new BoatGroup(b, Color.BLACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setDestinationFirstUseForcesLocationUpdate () {
|
|
||||||
boatGroup.setDestination(10, 10, 90, 0);
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
Assert.assertTrue(10 == bp.getLayoutX());
|
|
||||||
Assert.assertTrue(10 == bp.getLayoutY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setDestinationFutureUseDoesntForce () {
|
|
||||||
for (int i = 0; i < 60; i++) {
|
|
||||||
boatGroup.setDestination(200, 200, 90, 0);
|
|
||||||
}
|
|
||||||
boatGroup.setDestination(210, 210, 90, 0);
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
Assert.assertTrue(200 == bp.getLayoutX());
|
|
||||||
Assert.assertTrue(200 == bp.getLayoutY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setDestinationUnrealisticMovementForceUpdate () {
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
double xLocation = bp.getLayoutX();
|
|
||||||
double yLocation = bp.getLayoutY();
|
|
||||||
boatGroup.setDestination(xLocation + 500, yLocation + 500, 90, 0);
|
|
||||||
Assert.assertTrue(xLocation + 500 == bp.getLayoutX());
|
|
||||||
Assert.assertTrue(yLocation + 500 == bp.getLayoutY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void setDestinationUnrealisticNegativeForceUpdate () {
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
double xLocation = bp.getLayoutX();
|
|
||||||
double yLocation = bp.getLayoutY();
|
|
||||||
boatGroup.setDestination(xLocation - 500, yLocation - 500, 90, 0);
|
|
||||||
Assert.assertTrue(xLocation - 500 == bp.getLayoutX());
|
|
||||||
Assert.assertTrue(yLocation - 500 == bp.getLayoutY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void updatePositionGeneratesExpectedMovement () {
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
double xLocation = bp.getLayoutX();
|
|
||||||
double yLocation = bp.getLayoutY();
|
|
||||||
int movement = 10;
|
|
||||||
double delay = RaceObject.getExpectedUpdateInterval();
|
|
||||||
double defaultTimePeriod = 1000 / 60;
|
|
||||||
double expectedMovement = movement / delay * defaultTimePeriod;
|
|
||||||
for (int i = 0; i < 60; i++) {
|
|
||||||
boatGroup.setDestination(xLocation, yLocation, 90, 0);
|
|
||||||
}
|
|
||||||
boatGroup.setDestination(xLocation + 10, yLocation + 10, 90, 0);
|
|
||||||
boatGroup.updatePosition(1000/60);
|
|
||||||
Assert.assertEquals(expectedMovement, bp.getLayoutX() - xLocation, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void correctRaceID () {
|
|
||||||
Assert.assertTrue(boatGroup.hasRaceId(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void incorrectRaceID () {
|
|
||||||
Assert.assertTrue(!boatGroup.hasRaceId(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void nothingOnWrongId () {
|
|
||||||
Polygon bp = (Polygon) boatGroup.getChildren().get(2);
|
|
||||||
double originalX = bp.getLayoutX();
|
|
||||||
double originalY = bp.getLayoutY();
|
|
||||||
boatGroup.setDestination(10, 10, 90, 12);
|
|
||||||
Assert.assertTrue(originalX == bp.getLayoutX());
|
|
||||||
Assert.assertTrue(originalY == bp.getLayoutY());
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
// TODO: 4/05/17 cir27 - Currently the CI cannot build these tests. Unsure of exact issue but believe it may be a driver issue. Find a way to make tests work.
|
|
||||||
//
|
|
||||||
//package seng302.models;
|
|
||||||
//
|
|
||||||
//public class MarkGroupTest {
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
package seng302.models;
|
|
||||||
/*
|
|
||||||
import javafx.scene.shape.Circle;
|
|
||||||
import seng302.*;
|
|
||||||
import javafx.geometry.Point2D;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import seng302.models.mark.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by cir27 on 4/05/17.
|
|
||||||
*/
|
|
||||||
//public class MarkGroupTest {
|
|
||||||
// private MarkGroup gateMG;
|
|
||||||
// private MarkGroup singleMG;
|
|
||||||
//
|
|
||||||
// @Before
|
|
||||||
// public void setUp () {
|
|
||||||
// Mark single = new SingleMark("SM", 0, 0 , 0);
|
|
||||||
// Mark gate = new GateMark(
|
|
||||||
// "GM",
|
|
||||||
// MarkType.OPEN_GATE,
|
|
||||||
// new SingleMark("GM1", 0, 0, 1),
|
|
||||||
// new SingleMark("GM2", 0, 0, 2),
|
|
||||||
// 0,
|
|
||||||
// 0);
|
|
||||||
// gateMG = new MarkGroup(gate, new Point2D(10, 10), new Point2D(20, 20));
|
|
||||||
// singleMG = new MarkGroup(single, new Point2D(0, 0));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void hasIDSingle () {
|
|
||||||
// Assert.assertTrue(singleMG.hasRaceId(0));
|
|
||||||
// Assert.assertTrue(!singleMG.hasRaceId(100,12));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void hasIdGate () {
|
|
||||||
// Assert.assertTrue(gateMG.hasRaceId(1));
|
|
||||||
// Assert.assertTrue(gateMG.hasRaceId(2));
|
|
||||||
// Assert.assertTrue(!gateMG.hasRaceId(100,12));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void nothingOnWrongId () {
|
|
||||||
// double originalX = singleMG.getChildren().get(0).getLayoutX();
|
|
||||||
// double originalY = singleMG.getChildren().get(0).getLayoutY();
|
|
||||||
// singleMG.setDestination(10, 10, 0, 4);
|
|
||||||
// singleMG.updatePosition(400);
|
|
||||||
// Assert.assertTrue(originalX == singleMG.getChildren().get(0).getLayoutX());
|
|
||||||
// Assert.assertTrue(originalY == singleMG.getChildren().get(0).getLayoutY());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void correctMovementCorrectIdSingle () {
|
|
||||||
// double originalX = singleMG.getChildren().get(0).getLayoutX();
|
|
||||||
// double originalY = singleMG.getChildren().get(0).getLayoutY();
|
|
||||||
// long timeinterval = 1000/60;
|
|
||||||
// double expectedChange = 10 / 200 * timeinterval;
|
|
||||||
// singleMG.setDestination(originalX + 10, originalY + 10, 0, 0);
|
|
||||||
// singleMG.updatePosition(timeinterval);
|
|
||||||
// Assert.assertTrue(originalX + expectedChange == singleMG.getChildren().get(0).getLayoutX());
|
|
||||||
// Assert.assertTrue(originalY + expectedChange == singleMG.getChildren().get(0).getLayoutY());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void correctMovementCorrectIDGate () {
|
|
||||||
// double originalX1 = gateMG.getChildren().get(0).getLayoutX();
|
|
||||||
// double originalY1 = gateMG.getChildren().get(0).getLayoutY();
|
|
||||||
// double originalX2 = gateMG.getChildren().get(1).getLayoutX();
|
|
||||||
// double originalY2 = gateMG.getChildren().get(1).getLayoutY();
|
|
||||||
// long timeinterval = 1000/60;
|
|
||||||
// double expectedChange = 10 / 200 * timeinterval;
|
|
||||||
// gateMG.setDestination(originalX1 + 10, originalY1 + 10, 0, 1);
|
|
||||||
// gateMG.setDestination(originalX2 + 10, originalY2 + 10, 0, 2);
|
|
||||||
// gateMG.updatePosition(timeinterval);
|
|
||||||
// Assert.assertTrue(originalX1 + expectedChange == gateMG.getChildren().get(0).getLayoutX());
|
|
||||||
// Assert.assertTrue(originalY1 + expectedChange == gateMG.getChildren().get(0).getLayoutY());
|
|
||||||
// Assert.assertTrue(originalX2 + expectedChange == gateMG.getChildren().get(1).getLayoutX());
|
|
||||||
// Assert.assertTrue(originalY2 + expectedChange == gateMG.getChildren().get(1).getLayoutY());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
//package seng302.models.parsers;
|
|
||||||
//
|
|
||||||
//import org.junit.Before;
|
|
||||||
//import org.junit.Test;
|
|
||||||
//import seng302.models.Boat;
|
|
||||||
//import seng302.models.Yacht;
|
|
||||||
//
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//
|
|
||||||
//import static org.junit.Assert.*;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * Created by Haoming on 18/03/17.
|
|
||||||
// */
|
|
||||||
//public class TeamsParserTest {
|
|
||||||
//
|
|
||||||
// private TeamsParser tp;
|
|
||||||
// @Before
|
|
||||||
// public void readFile() {
|
|
||||||
// tp = new TeamsParser("/config/teams.xml");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void getBoats() throws Exception {
|
|
||||||
// ArrayList<Yacht> boats = tp.getBoats();
|
|
||||||
//
|
|
||||||
// assertEquals(6, boats.size(), 1e-10);
|
|
||||||
//
|
|
||||||
// assertEquals("Oracle Team USA", boats.get(0).getBoatName());
|
|
||||||
// //assertEquals(30.9, boats.get(0).getVelocity(), 1e-10);
|
|
||||||
//
|
|
||||||
// assertEquals("Groupama Team France", boats.get(5).getBoatName());
|
|
||||||
// //assertEquals(45.6, boats.get(5).getVelocity(), 1e-10);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@@ -3,8 +3,8 @@ package seng302.visualizer.annotations;
|
|||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.controllers.annotations.Annotation;
|
import seng302.visualiser.controllers.annotations.Annotation;
|
||||||
import seng302.controllers.annotations.ImportantAnnotationsState;
|
import seng302.visualiser.controllers.annotations.ImportantAnnotationsState;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user