Sails are displayed on first boat in a race. Optimised imports.
- Implemented drawSails method - Sail position is displayed and updated using a boat's heading - Sails conform to 'Points of sail' - Javadoc'd new method and tidied up existing - Sped up track point frequency (visualiserBoat class) - Optimised imports (any other classes changed) - A lot of canvas drawing and sail rotating issues were discovered and eventually overcome along the way. Using a sail image to draw and rotate on the existing canvas rather than a JavaFX shape on a new canvas was the final decision. #story[1098]
This commit is contained in:
@@ -3,18 +3,14 @@ package mock.app;
|
||||
import network.Messages.Enums.XMLMessageType;
|
||||
import network.Messages.LatestMessages;
|
||||
import network.Messages.XMLMessage;
|
||||
import org.mockito.Mock;
|
||||
import visualiser.gameController.ControllerServer;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package mock.app;
|
||||
|
||||
|
||||
|
||||
import network.BinaryMessageEncoder;
|
||||
import network.MessageEncoders.RaceVisionByteEncoder;
|
||||
import network.Messages.*;
|
||||
import network.Messages.Enums.MessageType;
|
||||
import network.Messages.Enums.XMLMessageType;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,18 +4,17 @@ import javafx.animation.AnimationTimer;
|
||||
import network.Messages.BoatLocation;
|
||||
import network.Messages.BoatStatus;
|
||||
import network.Messages.Enums.BoatStatusEnum;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import network.Messages.LatestMessages;
|
||||
import network.Messages.RaceStatus;
|
||||
import network.Utils.AC35UnitConverter;
|
||||
import shared.dataInput.BoatDataSource;
|
||||
import shared.dataInput.RaceDataSource;
|
||||
import network.Messages.Enums.RaceStatusEnum;
|
||||
import shared.dataInput.RegattaDataSource;
|
||||
import shared.model.*;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.Math.cos;
|
||||
|
||||
@@ -5,12 +5,14 @@ import network.Exceptions.InvalidMessageException;
|
||||
import network.MessageDecoders.*;
|
||||
import network.Messages.*;
|
||||
import network.Messages.Enums.MessageType;
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToInt;
|
||||
import static network.Utils.ByteConverter.bytesToLong;
|
||||
|
||||
/**
|
||||
* This class can be used to decode/convert a byte array into a messageBody object, descended from AC35Data.
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package network;
|
||||
|
||||
|
||||
|
||||
import network.Messages.Enums.MessageType;
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
|
||||
/**
|
||||
* This class can be used to encode/convert a byte array message body, plus header data into a byte array containing the entire message, ready to send.
|
||||
|
||||
@@ -2,8 +2,6 @@ package network.MessageDecoders;
|
||||
|
||||
import network.Messages.Enums.BoatActionEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BoatActionDecoder {
|
||||
byte byteBoatAction;
|
||||
BoatActionEnum boatAction;
|
||||
|
||||
@@ -5,9 +5,7 @@ import network.Messages.BoatLocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToInt;
|
||||
import static network.Utils.ByteConverter.bytesToLong;
|
||||
import static network.Utils.ByteConverter.bytesToShort;
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,9 +6,7 @@ import network.Messages.BoatStatus;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToInt;
|
||||
import static network.Utils.ByteConverter.bytesToLong;
|
||||
import static network.Utils.ByteConverter.bytesToShort;
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,9 +2,6 @@ package network.MessageDecoders;
|
||||
|
||||
import network.Messages.Enums.XMLMessageType;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToLong;
|
||||
|
||||
@@ -3,13 +3,14 @@ package network.MessageEncoders;
|
||||
|
||||
import network.Messages.*;
|
||||
|
||||
import static network.Utils.ByteConverter.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static network.Utils.ByteConverter.intToBytes;
|
||||
import static network.Utils.ByteConverter.longToBytes;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package network.Messages;
|
||||
|
||||
import network.Messages.Enums.XMLMessageType;
|
||||
import shared.dataInput.RaceDataSource;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -4,7 +4,6 @@ package network.Messages;
|
||||
import network.Messages.Enums.MessageType;
|
||||
import network.Messages.Enums.XMLMessageType;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import network.Messages.Enums.RaceTypeEnum;
|
||||
import shared.model.Boat;
|
||||
import shared.model.CompoundMark;
|
||||
import shared.model.GPSCoordinate;
|
||||
import shared.model.Leg;
|
||||
|
||||
@@ -8,7 +8,10 @@ import org.w3c.dom.NodeList;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import shared.model.*;
|
||||
import shared.model.CompoundMark;
|
||||
import shared.model.GPSCoordinate;
|
||||
import shared.model.Leg;
|
||||
import shared.model.Mark;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@@ -2,15 +2,11 @@ package shared.dataInput;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
import shared.dataInput.XMLReader;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import shared.model.GPSCoordinate;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,6 @@ package shared.dataInput;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
@@ -4,7 +4,6 @@ package visualiser.Controllers;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.Pane;
|
||||
@@ -12,7 +11,6 @@ import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.shape.Circle;
|
||||
import shared.model.Bearing;
|
||||
import shared.model.Wind;
|
||||
import visualiser.model.VisualiserRace;
|
||||
|
||||
/**
|
||||
* Controller for the arrow.fxml view.
|
||||
|
||||
@@ -12,7 +12,6 @@ import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
import javax.xml.soap.Text;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import mock.app.Event;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import visualiser.model.RaceConnection;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.chart.LineChart;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package visualiser.Controllers;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
import visualiser.app.App;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
package visualiser.app;
|
||||
import javafx.application.Platform;
|
||||
|
||||
import network.BinaryMessageDecoder;
|
||||
import network.Exceptions.InvalidMessageException;
|
||||
import network.Messages.*;
|
||||
import org.xml.sax.SAXException;
|
||||
import shared.dataInput.BoatXMLReader;
|
||||
import shared.dataInput.RaceXMLReader;
|
||||
import shared.dataInput.RegattaXMLReader;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToShort;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import visualiser.gameController.Keys.ControlKey;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,6 @@ package visualiser.gameController;
|
||||
import network.BinaryMessageDecoder;
|
||||
import network.MessageDecoders.BoatActionDecoder;
|
||||
import network.Messages.Enums.BoatActionEnum;
|
||||
import visualiser.gameController.Keys.ControlKey;
|
||||
import visualiser.gameController.Keys.KeyFactory;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -7,8 +7,6 @@ import visualiser.gameController.Keys.KeyFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static javafx.application.Application.launch;
|
||||
|
||||
/**
|
||||
* Class for checking what keys are currently being used
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package visualiser.gameController.Keys;
|
||||
|
||||
import javafx.scene.input.KeyCode;
|
||||
|
||||
/**
|
||||
* Key for the controller, part of the abstract factory KeyFactory
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package visualiser.gameController.Keys;
|
||||
|
||||
import javafx.scene.input.KeyCode;
|
||||
|
||||
/**
|
||||
* Key to trigger auto VMG
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package visualiser.gameController.Keys;
|
||||
|
||||
import javafx.scene.input.KeyCode;
|
||||
|
||||
/**
|
||||
* key to zoom into the game
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package visualiser.model;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
@@ -3,10 +3,6 @@ package visualiser.model;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Connection for Races
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package visualiser.model;
|
||||
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
@@ -12,7 +10,6 @@ import shared.model.GPSCoordinate;
|
||||
import shared.model.Mark;
|
||||
import shared.model.RaceClock;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -29,23 +26,13 @@ import java.util.List;
|
||||
*/
|
||||
public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
/**
|
||||
* The RaceMap used for converting GPSCoordinates to GraphCoordinates.
|
||||
*/
|
||||
private RaceMap map;
|
||||
|
||||
/**
|
||||
* The race we read data from and draw.
|
||||
*/
|
||||
private VisualiserRace visualiserRace;
|
||||
|
||||
/**
|
||||
* The background of the race.
|
||||
* We render the background whenever the race boundary changes, or the screen size changes.
|
||||
*/
|
||||
private RaceMap map; // for converting GPSCoordinates to GraphCoordinates
|
||||
private VisualiserRace visualiserRace; // draw data read from this race
|
||||
private Image background;
|
||||
private Image sailsRight = new Image("/images/sailsRight.png");
|
||||
private Image sailsLeft = new Image("/images/sailsLeft.png");
|
||||
|
||||
|
||||
// annotations
|
||||
private boolean annoName = true;
|
||||
private boolean annoAbbrev = true;
|
||||
private boolean annoSpeed = true;
|
||||
@@ -53,15 +40,12 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
private boolean annoEstTime = true;
|
||||
private boolean annoTimeSinceLastMark = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a {@link ResizableRaceCanvas} using a given {@link VisualiserRace}.
|
||||
* @param visualiserRace The race that data is read from in order to be drawn.
|
||||
*/
|
||||
public ResizableRaceCanvas(VisualiserRace visualiserRace) {
|
||||
super();
|
||||
|
||||
this.visualiserRace = visualiserRace;
|
||||
|
||||
RaceDataSource raceData = visualiserRace.getRaceDataSource();
|
||||
@@ -72,14 +56,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
double long2 = raceData.getMapBottomRight().getLongitude();
|
||||
|
||||
this.map = new RaceMap(
|
||||
lat1, long1, lat2, long2,
|
||||
(int) getWidth(), (int) getHeight() );
|
||||
|
||||
|
||||
lat1, long1, lat2, long2, (int)getWidth(), (int)getHeight());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Toggle name display in annotation
|
||||
*/
|
||||
@@ -119,11 +98,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
annoSpeed = !annoSpeed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Rotates things on the canvas Note: this must be called in between gc.save() and gc.restore() else they will rotate everything
|
||||
* Rotates things displayed on the canvas. Note: this must be called in
|
||||
* between gc.save() and gc.restore() else they will rotate everything
|
||||
*
|
||||
* @param degrees Bearing degrees to rotate.
|
||||
* @param px Pivot point x of rotation.
|
||||
@@ -134,8 +111,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws a circle with a given diameter, centred on a given graph coordinate.
|
||||
* @param center The center coordinate of the circle.
|
||||
@@ -147,8 +122,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.fillOval(
|
||||
center.getX() - (diameter / 2),
|
||||
center.getY() - (diameter / 2),
|
||||
diameter, diameter );
|
||||
|
||||
diameter, diameter
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +138,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.setStroke(paint);
|
||||
gc.setFill(paint);
|
||||
|
||||
|
||||
double endPointDiameter = 6;
|
||||
|
||||
//Draw first end-point.
|
||||
@@ -177,8 +151,8 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
graphCoordinateA.getX(),
|
||||
graphCoordinateA.getY(),
|
||||
graphCoordinateB.getX(),
|
||||
graphCoordinateB.getY() );
|
||||
|
||||
graphCoordinateB.getY()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +172,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
drawCircle(graphCoordinate, pointDiameter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display given name and speed of boat at a graph coordinate
|
||||
*
|
||||
@@ -214,7 +187,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
//The text to draw. Built during the function.
|
||||
String text = "";
|
||||
|
||||
|
||||
//Draw name if annotation is enabled.
|
||||
if (annoName) {
|
||||
text += String.format("%s ", name);
|
||||
@@ -240,7 +212,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
text += timeSinceLastMark;
|
||||
}
|
||||
|
||||
|
||||
//Offset by 20 pixels horizontally.
|
||||
long xCoord = coordinate.getX() + 20;
|
||||
long yCoord = coordinate.getY();
|
||||
@@ -259,41 +230,36 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.fillText(text, xCoord, yCoord);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the label for a given boat. Includes name, abbreviation, speed, time since mark, and time to next mark.
|
||||
* @param boat The boat to draw text for.
|
||||
*/
|
||||
private void drawBoatText(VisualiserBoat boat) {
|
||||
|
||||
drawText(
|
||||
boat.getName(),
|
||||
boat.getCountry(),
|
||||
boat.getCurrentSpeed(),
|
||||
this.map.convertGPS(boat.getCurrentPosition()),
|
||||
boat.getTimeToNextMarkFormatted(this.visualiserRace.getRaceClock().getCurrentTime()),
|
||||
boat.getTimeSinceLastMarkFormatted(this.visualiserRace.getRaceClock().getCurrentTime()) );
|
||||
|
||||
boat.getTimeSinceLastMarkFormatted(this.visualiserRace.getRaceClock().getCurrentTime())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws all of the boats on the canvas.
|
||||
*/
|
||||
private void drawBoats() {
|
||||
|
||||
for (VisualiserBoat boat : visualiserRace.getBoats()) {
|
||||
|
||||
//Draw the boat.
|
||||
drawBoat(boat);
|
||||
//Draw track.
|
||||
drawTrack(boat);
|
||||
|
||||
//Only draw wake if they are currently racing.
|
||||
if (boat.getStatus() == BoatStatusEnum.RACING) {
|
||||
drawWake(boat);
|
||||
}
|
||||
|
||||
//Draw the boat.
|
||||
drawBoat(boat);
|
||||
|
||||
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
|
||||
if ((boat.getStatus() != BoatStatusEnum.RACING) && (boat.getStatus() == BoatStatusEnum.FINISHED)) {
|
||||
@@ -302,16 +268,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
//Draw boat label.
|
||||
drawBoatText(boat);
|
||||
|
||||
//Draw track.
|
||||
drawTrack(boat);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws a given boat on the canvas.
|
||||
* @param boat The boat to draw.
|
||||
@@ -346,28 +305,66 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.fillPolygon(x, y, 3);
|
||||
gc.restore();
|
||||
|
||||
// TODO: update with current players boat
|
||||
if (boat.getSourceID() == 125) {
|
||||
drawSails(boat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws sails for a given boat on the canvas. Sail position is
|
||||
* determined by the boats heading and the current wind direction
|
||||
* according to the "points of sail".
|
||||
* @param boat boat to display sails for
|
||||
*/
|
||||
private void drawSails(VisualiserBoat boat) {
|
||||
GraphCoordinate boatPos =
|
||||
this.map.convertGPS(boat.getCurrentPosition());
|
||||
double xPos = boatPos.getX(); // x pos of sail (on boat)
|
||||
double yPos = boatPos.getY() - 6; // y pos of sail (on boat)
|
||||
double boatBearing = boat.getBearing().degrees();
|
||||
double windDirection = visualiserRace.getWindDirection().degrees();
|
||||
windDirection = 0; // set to 0 for now - will be removed
|
||||
double sailRotateAngle; // required rotation for correct sail display
|
||||
Image sailImage;
|
||||
|
||||
gc.save();
|
||||
// right half of points of sail
|
||||
if (boatBearing<180) {
|
||||
sailImage = sailsRight;
|
||||
sailRotateAngle = boatBearing * 0.5; // math
|
||||
xPos -= 1; // right align to boat edge on canvas
|
||||
// System.out.println("right side -- boat: " + boatBearing +
|
||||
// "|| rotate: " + sailRotateAngle);
|
||||
}
|
||||
// left half of points of sail
|
||||
else {
|
||||
sailImage = sailsLeft;
|
||||
sailRotateAngle = -(360 - boatBearing) * 0.5; // math
|
||||
xPos -= 5; // left align to boat edge on canvas
|
||||
// System.out.println("left side -- boat: " + boatBearing +
|
||||
// "|| rotate: " + sailRotateAngle);
|
||||
}
|
||||
|
||||
// rotate sails based on boats current heading
|
||||
rotate(sailRotateAngle, boatPos.getX(), boatPos.getY());
|
||||
gc.drawImage(sailImage, xPos, yPos);
|
||||
gc.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the wake for a given boat.
|
||||
* @param boat Boat to draw wake for.
|
||||
*/
|
||||
private void drawWake(VisualiserBoat boat) {
|
||||
|
||||
//Calculate either end of wake line.
|
||||
// Calculate either end of wake line.
|
||||
GraphCoordinate wakeFrom = this.map.convertGPS(boat.getCurrentPosition());
|
||||
GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake());
|
||||
|
||||
//Draw.
|
||||
drawLine(wakeFrom, wakeTo, boat.getColor());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws all of the {@link Mark}s on the canvas.
|
||||
*/
|
||||
@@ -377,46 +374,30 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws a given mark on the canvas.
|
||||
* @param mark The mark to draw.
|
||||
*/
|
||||
private void drawMark(Mark mark) {
|
||||
|
||||
//Calculate screen position.
|
||||
GraphCoordinate mark1 = this.map.convertGPS(mark.getPosition());
|
||||
|
||||
//Draw.
|
||||
drawPoint(mark1, Color.LIMEGREEN);
|
||||
|
||||
GraphCoordinate markToDraw = this.map.convertGPS(mark.getPosition());
|
||||
drawPoint(markToDraw, Color.LIMEGREEN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws the Race Map.
|
||||
* Called when the canvas is resized.
|
||||
*/
|
||||
public void draw() {
|
||||
|
||||
//Clear canvas.
|
||||
clear();
|
||||
clear(); // clear previous canvas
|
||||
|
||||
//Update our RaceMap using new canvas size.
|
||||
this.map.setWidth((int) getWidth());
|
||||
this.map.setHeight((int) getHeight());
|
||||
|
||||
//Redraw the boundary.
|
||||
redrawBoundaryImage();
|
||||
|
||||
//Draw the race.
|
||||
drawRace();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears the canvas.
|
||||
*/
|
||||
@@ -424,19 +405,16 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.clearRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the race boundary, and saves the image to {@link #background}.
|
||||
* You should call {@link #clear()} before calling this.
|
||||
*/
|
||||
private void redrawBoundaryImage() {
|
||||
|
||||
//Prepare to draw.
|
||||
gc.setLineWidth(1);
|
||||
gc.setFill(Color.AQUA);
|
||||
gc.drawImage(new Image(getClass().getClassLoader().getResourceAsStream("images/WaterBackground.png")), 0, 0);
|
||||
|
||||
|
||||
//Calculate the screen coordinates of the boundary.
|
||||
List<GPSCoordinate> boundary = this.visualiserRace.getBoundary();
|
||||
double[] xpoints = new double[boundary.size()];
|
||||
@@ -456,7 +434,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
|
||||
//Render boundary to image.
|
||||
this.background = snapshot(null, null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,23 +441,14 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
* Called once per frame, and on canvas resize.
|
||||
*/
|
||||
public void drawRace() {
|
||||
|
||||
gc.setLineWidth(2);
|
||||
clear(); // clear the previous canvas
|
||||
|
||||
clear();
|
||||
|
||||
//Race boundary.
|
||||
drawBoundary();
|
||||
|
||||
//Boats.
|
||||
drawBoats();
|
||||
|
||||
//Marks.
|
||||
drawMarks();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draws the race boundary image onto the canvas.
|
||||
* See {@link #background}.
|
||||
@@ -489,13 +457,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.drawImage(this.background, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Draws all track points for a given boat. Colour is set by boat, opacity by track point.
|
||||
* This checks if {@link #annoPath} is enabled.
|
||||
* Draws all track points for a given boat. Colour is set by boat, opacity
|
||||
* by track point. This checks if {@link #annoPath} is enabled.
|
||||
* @param boat The boat to draw tracks for.
|
||||
* @see TrackPoint
|
||||
*/
|
||||
@@ -517,9 +481,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), point.getDiameter(), point.getDiameter());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package visualiser.model;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.paint.Color;
|
||||
import network.Messages.Enums.BoatStatusEnum;
|
||||
import shared.model.Azimuth;
|
||||
@@ -38,7 +36,7 @@ public class VisualiserBoat extends Boat {
|
||||
/**
|
||||
* The minimum period of time, in milliseconds, between the creation of each track point.
|
||||
*/
|
||||
private static final long trackPointTimeInterval = 5000;
|
||||
private static final long trackPointTimeInterval = 500;
|
||||
|
||||
/**
|
||||
* The number of track points that should be created before fully diminishing the alpha of a given track point.
|
||||
|
||||
@@ -16,7 +16,6 @@ import shared.dataInput.RegattaDataSource;
|
||||
import shared.model.*;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 122 B |
Binary file not shown.
|
After Width: | Height: | Size: 126 B |
@@ -1,18 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
|
||||
<GridPane fx:id="arrowGridPane" maxHeight="-Infinity" maxWidth="-Infinity" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ArrowController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ConnectionController">
|
||||
<children>
|
||||
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane fx:id="hostWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.HostController">
|
||||
<children>
|
||||
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane fx:id="lobbyWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" visible="false" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.LobbyController">
|
||||
<children>
|
||||
<GridPane fx:id="connection" prefHeight="600.0" prefWidth="780.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
|
||||
<AnchorPane fx:id="main" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.MainController">
|
||||
<children>
|
||||
<fx:include fx:id="race" source="race.fxml" />
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane fx:id="connectionWrapper" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="780.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.ConnectionController">
|
||||
<children>
|
||||
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.RadioButton?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane fx:id="titleWrapper" maxHeight="600.0" maxWidth="800.0" minHeight="600.0" minWidth="800.0" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="visualiser.Controllers.TitleController">
|
||||
<children>
|
||||
<GridPane layoutY="39.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mock.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MockBoatTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package mock.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MockRaceTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import shared.model.Bearing;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import shared.model.Bearing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class VMGTest {
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ import shared.dataInput.XMLReader;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -2,10 +2,7 @@ package network.Utils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static network.Utils.AC35UnitConverter.convertGPS;
|
||||
import static network.Utils.AC35UnitConverter.convertGPSToInt;
|
||||
import static network.Utils.AC35UnitConverter.convertHeading;
|
||||
import static network.Utils.AC35UnitConverter.convertTrueWindAngle;
|
||||
import static network.Utils.AC35UnitConverter.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package network.Utils;
|
||||
|
||||
import network.Utils.ByteConverter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@@ -9,9 +9,6 @@ import shared.dataInput.XMLReader;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -3,23 +3,17 @@ package shared.dataInput;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidBoatDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
import shared.model.Boat;
|
||||
import shared.model.Mark;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by cbt24 on 10/05/17.
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AngleTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AzimuthTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class BearingTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package shared.model;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MarkTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package shared.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RaceClockTest {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import javafx.scene.Scene;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import visualiser.gameController.InputChecker;
|
||||
|
||||
/**
|
||||
* Start to manually test the game controller
|
||||
|
||||
@@ -4,7 +4,6 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user