diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 00000000..5352bdf8 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf33..00000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/racevisionGame/src/main/java/mock/app/Event.java b/racevisionGame/src/main/java/mock/app/Event.java index bba2306b..dce4e244 100644 --- a/racevisionGame/src/main/java/mock/app/Event.java +++ b/racevisionGame/src/main/java/mock/app/Event.java @@ -4,7 +4,9 @@ import mock.dataInput.PolarParser; import mock.exceptions.EventConstructionException; import mock.model.*; import mock.model.commandFactory.CompositeCommand; +import mock.xml.RaceXMLCreator; import network.Messages.LatestMessages; +import org.xml.sax.SAXException; import shared.dataInput.*; import shared.enums.XMLFileType; import shared.exceptions.InvalidBoatDataException; @@ -14,6 +16,8 @@ import shared.exceptions.XMLReaderException; import shared.model.Bearing; import shared.model.Constants; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import java.io.IOException; import java.net.UnknownHostException; @@ -86,12 +90,23 @@ public class Event { //Read XML files. try { - this.raceXML = getRaceXMLAtCurrentTime(XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8)); + this.raceXML = RaceXMLCreator.alterRaceToWind(raceXMLFile, 90); + //this.raceXML = XMLReader.readXMLFileToString(raceXMLFile, StandardCharsets.UTF_8); this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8); this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8); } catch (XMLReaderException e) { throw new EventConstructionException("Could not read XML files.", e); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); + } catch (InvalidRaceDataException e) { + e.printStackTrace(); + } catch (JAXBException e) { + e.printStackTrace(); } this.xmlFileType = XMLFileType.Contents; @@ -183,27 +198,4 @@ public class Event { connectionAcceptor.setBoatsXml(boatXML); } - - /** - * Sets the xml description of the race to show the race was created now, and starts in 4 minutes - * @param raceXML The race.xml contents. - * @return String containing edited xml - */ - private String getRaceXMLAtCurrentTime(String raceXML) { - - //The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute. - long millisecondsToAdd = Constants.RacePreStartTime + Duration.ofMinutes(1).toMillis(); - long secondsToAdd = millisecondsToAdd / 1000; - //Scale the time using our time scalar. - secondsToAdd = secondsToAdd / Constants.RaceTimeScale; - - DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"); - ZonedDateTime creationTime = ZonedDateTime.now(); - raceXML = raceXML.replace("CREATION_TIME", dateFormat.format(creationTime)); - - raceXML = raceXML.replace("START_TIME", dateFormat.format(creationTime.plusSeconds(secondsToAdd))); - - return raceXML; - - } -} +} \ No newline at end of file diff --git a/racevisionGame/src/main/java/mock/model/MockRace.java b/racevisionGame/src/main/java/mock/model/MockRace.java index e25c0909..159e2951 100644 --- a/racevisionGame/src/main/java/mock/model/MockRace.java +++ b/racevisionGame/src/main/java/mock/model/MockRace.java @@ -1,5 +1,9 @@ package mock.model; +import javafx.animation.AnimationTimer; +import mock.xml.*; +import network.Messages.BoatLocation; +import network.Messages.BoatStatus; import network.Messages.Enums.BoatStatusEnum; import network.Messages.Enums.RaceStatusEnum; import shared.dataInput.BoatDataSource; @@ -8,6 +12,8 @@ import shared.dataInput.RegattaDataSource; import shared.exceptions.BoatNotFoundException; import shared.enums.RoundingType; import shared.model.*; +import shared.model.Bearing; +import shared.model.Race; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; @@ -392,7 +398,7 @@ public class MockRace extends Race { double lastAngle = -1; boolean lastAngleWasGood = false; - //Check all bearings between [0, 360). + //Check all bearings between [0, 360) for (double angle = 0; angle < 360; angle += 1) { //Create bearing from angle. @@ -628,7 +634,6 @@ public class MockRace extends Race { protected int getNumberOfActiveBoats() { int numberOfActiveBoats = 0; - for (MockBoat boat : this.boats) { //If the boat is currently racing, count it. @@ -701,6 +706,7 @@ public class MockRace extends Race { } - - + public List getCompoundMarks() { + return compoundMarks; + } } diff --git a/racevisionGame/src/main/java/mock/model/RaceLogic.java b/racevisionGame/src/main/java/mock/model/RaceLogic.java index a1afc76c..ccd3381b 100644 --- a/racevisionGame/src/main/java/mock/model/RaceLogic.java +++ b/racevisionGame/src/main/java/mock/model/RaceLogic.java @@ -194,9 +194,9 @@ public class RaceLogic implements RunnableWithFramePeriod, Observer { public void update(Observable o, Object arg) { Collision e = (Collision)arg; - if(e.getBearing().degrees() == 0) System.out.println("Ahead"); - else if(e.getBearing().degrees() < 90) System.out.println("Starboard"); - else if(e.getBearing().degrees() > 270) System.out.println("Port"); - else System.out.println("Behind"); +// if(e.getBearing().degrees() == 0) System.out.println("Ahead"); +// else if(e.getBearing().degrees() < 90) System.out.println("Starboard"); +// else if(e.getBearing().degrees() > 270) System.out.println("Port"); +// else System.out.println("Behind"); } } diff --git a/racevisionGame/src/main/java/mock/xml/RaceXMLCreator.java b/racevisionGame/src/main/java/mock/xml/RaceXMLCreator.java new file mode 100644 index 00000000..f1b83479 --- /dev/null +++ b/racevisionGame/src/main/java/mock/xml/RaceXMLCreator.java @@ -0,0 +1,207 @@ +package mock.xml; + +import org.w3c.dom.Document; +import org.xml.sax.SAXException; +import shared.dataInput.RaceXMLReader; +import shared.enums.XMLFileType; +import shared.exceptions.InvalidRaceDataException; +import shared.exceptions.XMLReaderException; +import shared.model.*; +import shared.xml.Race.*; +import shared.xml.XMLUtilities; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.util.JAXBSource; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.math.BigInteger; +import java.net.URL; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Helper Class for creating a Race XML + */ +public class RaceXMLCreator { + + + /** + * get the windward gate in a race + * @param reader reads in the mark + * @return the windward gate. + */ + public static CompoundMark getWindwardGate(RaceXMLReader reader){ + for (CompoundMark mark: reader.getCompoundMarks()){ + if (mark.getName().equals("Windward Gate")) return mark; + } + return null; + } + + /** + * get the leeward gate in a race + * @param reader reads in the mark + * @return the leeward gate. + */ + public static CompoundMark getLeewardGate(RaceXMLReader reader){ + for (CompoundMark mark: reader.getCompoundMarks()){ + if (mark.getName().equals("Leeward Gate")) return mark; + } + return null; + } + + /** + * Rotates the race in a specified direction. + * @param s xml file name + * @param degrees degrees to rotate + * @return the new xml file as a string + * @throws XMLReaderException if the xml is not readable + * @throws InvalidRaceDataException if the race is invalid + * @throws JAXBException if the Race class cannot be parsed into a xml. + * @throws IOException if the schema file cannot be found + * @throws SAXException error in schema file + * @throws ParserConfigurationException error in parsing the schema file + */ + public static String alterRaceToWind(String s, double degrees) throws XMLReaderException, InvalidRaceDataException, JAXBException, IOException, SAXException, ParserConfigurationException { + RaceXMLReader reader = new RaceXMLReader(s, XMLFileType.ResourcePath); + + XMLRace race = (XMLRace) XMLUtilities.xmlToClass(RaceXMLCreator.class.getClassLoader().getResourceAsStream(s), + RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"), + XMLRace.class); + + setRaceXMLAtCurrentTimeToNow(race); + + double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position()); + + double degreesToRotate = degrees - raceOriginalBearing; + + alterRaceRotation(race, degreesToRotate); + + JAXBContext context = JAXBContext.newInstance(XMLRace.class); + Marshaller jaxbMarshaller = context.createMarshaller(); + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + StringWriter sw = new StringWriter(); + + jaxbMarshaller.marshal(race, sw); + return sw.toString(); + } + + /** + * Rotate the features in a race such as the boundary, and the marks. + * @param race the race to alter + * @param degrees the degrees to rotate by. + */ + public static void alterRaceRotation(XMLRace race, double degrees){ + GPSCoordinate center = getCenter(race); + for(XMLLimit limit: race.getCourseLimit().getLimit()){ + GPSCoordinate rotatedLim = rotate(center, limitToGPSCoordinate(limit), degrees); + limit.setLat(rotatedLim.getLatitude()); + limit.setLon(rotatedLim.getLongitude()); + } + + for(XMLCompoundMark compoundMark: race.getCourse().getCompoundMark()){ + for (XMLMark mark: compoundMark.getMark()){ + GPSCoordinate rotatedMark = rotate(center, markToGPSCoordinate(mark), degrees); + mark.setTargetLat(rotatedMark.getLatitude()); + mark.setTargetLng(rotatedMark.getLongitude()); + } + } + } + + /** + * Converts a Race.CourseLimit.Limit to a GPS coordinate + * @param limit limit to convert + * @return gps coordinate corresponding to the limit + */ + public static GPSCoordinate limitToGPSCoordinate(XMLLimit limit){ + return new GPSCoordinate(limit.getLat(), limit.getLon()); + } + + /** + * get new gps coordinate after rotating + * @param pivot center point to rotating from. + * @param point point to rotate + * @param degrees number of degress to rotate by + * @return the new GPSCoordinate of the transformed point. + */ + public static GPSCoordinate rotate(GPSCoordinate pivot, GPSCoordinate point, double degrees){ + double radDeg = Math.toRadians(degrees); + double deltaLat = (point.getLatitude() - pivot.getLatitude()); + double deltaLon = (point.getLongitude() - pivot.getLongitude()); + //map to (0,1) vector and use vector maths to rotate. + double resLat = deltaLat * Math.cos(radDeg) - deltaLon * Math.sin(radDeg) + pivot.getLatitude(); + double resLon = deltaLat * Math.sin(radDeg) + deltaLon * Math.cos(radDeg) + pivot.getLongitude(); + return new GPSCoordinate(resLat, resLon); + } + + /** + * obtains the GPSCoordinates of a mark + * @param mark mark to obtain the GPSCoordinates of + * @return the GPSCOordinatess of a mark + */ + public static GPSCoordinate markToGPSCoordinate(XMLMark mark){ + return new GPSCoordinate(mark.getTargetLat(), mark.getTargetLng()); + } + + /** + * get the center of a race + * @param race race to get the center of + * @return GPSCoordinates of the center + */ + public static GPSCoordinate getCenter(XMLRace race){ + double avgLat = 0; + double avgLng = 0; + for (XMLLimit limit: race.getCourseLimit().getLimit()){ + avgLat += limit.getLat(); + avgLng += limit.getLon(); + } + avgLat = avgLat/race.getCourseLimit().getLimit().size(); + avgLng = avgLng/race.getCourseLimit().getLimit().size(); + return new GPSCoordinate(avgLat, avgLng); + } + + /** + * gets the angle of a line + * @param coord1 point a of the line + * @param coord2 point b of the line + * @return the angle in degrees that the bearing of the line is [-180, 180] + */ + public static double getLineAngle(GPSCoordinate coord1, GPSCoordinate coord2){ + double dx = coord1.getLongitude() - coord2.getLongitude(); + double dy = coord1.getLatitude() - coord2.getLatitude(); + return Math.atan2(dy, dx)/Math.PI * 180; + } + + + /** + * Sets the xml description of the race to show the race was created now, and starts in 4 minutes + * @param raceXML The race.xml contents. + */ + public static void setRaceXMLAtCurrentTimeToNow(XMLRace raceXML) { + + //The start time is current time + 4 minutes. prestart is 3 minutes, and we add another minute. + long millisecondsToAdd = Constants.RacePreStartTime + (1 * 60 * 1000); + long secondsToAdd = millisecondsToAdd / 1000; + //Scale the time using our time scalar. + secondsToAdd = secondsToAdd / Constants.RaceTimeScale; + + DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"); + ZonedDateTime creationTime = ZonedDateTime.now(); + raceXML.setCreationTimeDate(dateFormat.format(creationTime)); + raceXML.getRaceStartTime().setTime(dateFormat.format(creationTime.plusSeconds(secondsToAdd))); + } + +} diff --git a/racevisionGame/src/main/java/shared/dataInput/RaceXMLReader.java b/racevisionGame/src/main/java/shared/dataInput/RaceXMLReader.java index 02e1afc6..c2faea69 100644 --- a/racevisionGame/src/main/java/shared/dataInput/RaceXMLReader.java +++ b/racevisionGame/src/main/java/shared/dataInput/RaceXMLReader.java @@ -52,6 +52,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource { */ private final List legs = new ArrayList<>(); + /** + * List of corners in the race + */ + private final List cornersList = new ArrayList<>(); /** * The time that the race.xml file was created. @@ -337,6 +341,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource { //gets the Rounding of this corner element String cornerRounding = getCompoundMarkRounding(cornerElement); + int cornerSeq = Integer.parseInt(getAttribute(cornerElement, "SeqID")); + + cornersList.add(new Corner(cornerID, cornerSeq, "SP", 3)); + //Gets the CompoundMark associated with this corner. CompoundMark lastCompoundMark = this.compoundMarkMap.get(cornerID); @@ -356,6 +364,9 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource { //Gets the ID number of this corner element. cornerID = getCompoundMarkID(cornerElement); + cornerSeq = Integer.parseInt(getAttribute(cornerElement, "SeqID")); + + cornersList.add(new Corner(cornerID, cornerSeq, "Port", 3)); //gets the Rounding of this corner element cornerRounding = getCompoundMarkRounding(cornerElement); @@ -476,4 +487,8 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource { public List getParticipants() { return participants; } + + public List getCornersList() { + return cornersList; + } } diff --git a/racevisionGame/src/main/java/shared/model/CompoundMark.java b/racevisionGame/src/main/java/shared/model/CompoundMark.java index cabf3a02..e7c6c1af 100644 --- a/racevisionGame/src/main/java/shared/model/CompoundMark.java +++ b/racevisionGame/src/main/java/shared/model/CompoundMark.java @@ -1,11 +1,14 @@ package shared.model; + +import shared.xml.Race.XMLCompoundMark; + import shared.enums.RoundingType; /** * Represents a compound mark - that is, either one or two individual marks which form a single compound mark. */ -public class CompoundMark { +public class CompoundMark extends XMLCompoundMark{ /** * The ID of the compound mark. @@ -45,11 +48,7 @@ public class CompoundMark { * @param mark1 The individual mark that comprises this compound mark. */ public CompoundMark(int id, String name, Mark mark1) { - this.id = id; - this.name = name; - this.mark1 = mark1; - this.averageGPSCoordinate = calculateAverage(); - + this(id, name, mark1, null); } @@ -61,6 +60,14 @@ public class CompoundMark { * @param mark2 The second individual mark that comprises this compound mark. */ public CompoundMark(int id, String name, Mark mark1, Mark mark2) { + //parent set up + super(); + setName(name); + setCompoundMarkID(id); + /*TODO need to talk to connor about this as Mark should be extending XMLMark + getMark().add(mark1); + if (mark2 != null) getMark().add(mark2);*/ + this.id = id; this.name = name; this.mark1 = mark1; @@ -78,14 +85,6 @@ public class CompoundMark { return id; } - /** - * Returns the name of this compound mark - * @return The name of this compound mark. - */ - public String getName() { - return name; - } - /** * Returns the first mark of the compound mark. * @return The first mark of the compound mark. diff --git a/racevisionGame/src/main/java/shared/model/Corner.java b/racevisionGame/src/main/java/shared/model/Corner.java new file mode 100644 index 00000000..a8f72b82 --- /dev/null +++ b/racevisionGame/src/main/java/shared/model/Corner.java @@ -0,0 +1,25 @@ +package shared.model; + +import shared.xml.Race.XMLCorner; + +/** + * Created by Gondr on 3/08/2017. + */ +public class Corner extends XMLCorner{ + + private int id; + + public Corner(int id, int seqID, String rounding, int zoneSize){ + super(); + setCompoundMarkID(id); + setSeqID(seqID); + setRounding(rounding); + setZoneSize(zoneSize); + + this.id = id; + } + + public int getId() { + return id; + } +} diff --git a/racevisionGame/src/main/java/shared/model/Mark.java b/racevisionGame/src/main/java/shared/model/Mark.java index 77a59ede..d236d076 100644 --- a/racevisionGame/src/main/java/shared/model/Mark.java +++ b/racevisionGame/src/main/java/shared/model/Mark.java @@ -1,5 +1,10 @@ package shared.model; +import shared.xml.Race.XMLMark; + +import java.math.BigDecimal; +import java.math.BigInteger; + import mock.model.collider.Collider; import mock.model.collider.Collision; @@ -7,7 +12,7 @@ import mock.model.collider.Collision; * Represents an individual mark. * Has a source ID, name, and position. */ -public class Mark extends Collider { +public class Mark extends Collider{ /** * The source ID of the mark. @@ -36,6 +41,13 @@ public class Mark extends Collider { * @param position The position of the mark. */ public Mark(int sourceID, String name, GPSCoordinate position) { + super(); + /* TODO need to talk to connor about this as this class should be extending XMLMark + targetLat = position.getLatitude(); + targetLng = position.getLongitude(); + setSourceID(sourceID); + setName(name);*/ + this.sourceID = sourceID; this.name = name; this.position = position; @@ -60,8 +72,8 @@ public class Mark extends Collider { } /** - * Returns the source ID of the mark. - * @return The source ID of the mark. + * Returns the source ID of the mark + * @return the source ID of the mark */ public int getSourceID() { return sourceID; diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMark.java b/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMark.java new file mode 100644 index 00000000..7149c4f1 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMark.java @@ -0,0 +1,135 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Mark" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="SeqId" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                 <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="TargetLat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                 <attribute name="TargetLng" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                 <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "mark" +}) +public class XMLCompoundMark { + + @XmlElement(name = "Mark", required = true) + protected List mark; + @XmlAttribute(name = "CompoundMarkID", required = true) + protected int compoundMarkID; + @XmlAttribute(name = "Name", required = true) + protected String name; + + /** + * Gets the value of the mark property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the mark property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getMark().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link XMLMark } + * + * @return list of marks + */ + public List getMark() { + if (mark == null) { + mark = new ArrayList(); + } + return this.mark; + } + + /** + * Gets the value of the compoundMarkID property. + * @return the id of the compound mark + */ + public int getCompoundMarkID() { + return compoundMarkID; + } + + /** + * Sets the value of the compoundMarkID property. + * @param value sets ID of the compound mark + */ + public void setCompoundMarkID(int value) { + this.compoundMarkID = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMarkSequence.java b/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMarkSequence.java new file mode 100644 index 00000000..cca11aa5 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLCompoundMarkSequence.java @@ -0,0 +1,87 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Corner" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                 <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                 <attribute name="Rounding" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="ZoneSize" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "corner" +}) +public class XMLCompoundMarkSequence { + + @XmlElement(name = "Corner", required = true) + protected List corner; + + /** + * Gets the value of the corner property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the corner property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCorner().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link XMLCorner } + * + * @return getCorners/legs that the boats are to sequentially pass + */ + public List getCorner() { + if (corner == null) { + corner = new ArrayList(); + } + return this.corner; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLCorner.java b/racevisionGame/src/main/java/shared/xml/Race/XMLCorner.java new file mode 100644 index 00000000..fa6237ac --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLCorner.java @@ -0,0 +1,122 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="Rounding" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="ZoneSize" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +public class XMLCorner { + + @XmlAttribute(name = "CompoundMarkID", required = true) + protected int compoundMarkID; + @XmlAttribute(name = "SeqID", required = true) + protected int seqID; + @XmlAttribute(name = "Rounding", required = true) + protected String rounding; + @XmlAttribute(name = "ZoneSize", required = true) + protected int zoneSize; + + /** + * Gets the value of the compoundMarkID property. + * @return Id of the compound mark + */ + public int getCompoundMarkID() { + return compoundMarkID; + } + + /** + * Sets the value of the compoundMarkID property. + * @param value sets the id of the compound mark + */ + public void setCompoundMarkID(int value) { + this.compoundMarkID = value; + } + + /** + * Gets the value of the seqID property. + * @return the order that the mark is to be passed at + */ + public int getSeqID() { + return seqID; + } + + /** + * Sets the value of the seqID property. + * @param value sets the order that this corner is to appear in a race at. + */ + public void setSeqID(int value) { + this.seqID = value; + } + + /** + * Gets the value of the rounding property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRounding() { + return rounding; + } + + /** + * Sets the value of the rounding property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRounding(String value) { + this.rounding = value; + } + + /** + * Gets the value of the zoneSize property. + * @return the size of the leg + */ + public int getZoneSize() { + return zoneSize; + } + + /** + * Sets the value of the zoneSize property. + * @param value sets the size of the corner. + */ + public void setZoneSize(int value) { + this.zoneSize = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLCourse.java b/racevisionGame/src/main/java/shared/xml/Race/XMLCourse.java new file mode 100644 index 00000000..8fe22193 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLCourse.java @@ -0,0 +1,100 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="CompoundMark" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="Mark" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="SeqId" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                           <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="TargetLat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                           <attribute name="TargetLng" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                           <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                 <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "compoundMark" +}) +public class XMLCourse { + + @XmlElement(name = "CompoundMark", required = true) + protected List compoundMark; + + /** + * Gets the value of the compoundMark property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the compoundMark property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getCompoundMark().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link XMLCompoundMark } + * + * @return the compound marks in the course. + */ + public List getCompoundMark() { + if (compoundMark == null) { + compoundMark = new ArrayList(); + } + return this.compoundMark; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLCourseLimit.java b/racevisionGame/src/main/java/shared/xml/Race/XMLCourseLimit.java new file mode 100644 index 00000000..5218128f --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLCourseLimit.java @@ -0,0 +1,86 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Limit" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="Lat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                 <attribute name="Lon" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                 <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "limit" +}) +public class XMLCourseLimit { + + @XmlElement(name = "Limit", required = true) + protected List limit; + + /** + * Gets the value of the limit property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the limit property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getLimit().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link XMLLimit } + * + * @return the limits of the race + */ + public List getLimit() { + if (limit == null) { + limit = new ArrayList(); + } + return this.limit; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLLimit.java b/racevisionGame/src/main/java/shared/xml/Race/XMLLimit.java new file mode 100644 index 00000000..b6519069 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLLimit.java @@ -0,0 +1,95 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="Lat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *       <attribute name="Lon" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *       <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +public class XMLLimit { + + @XmlAttribute(name = "Lat", required = true) + protected double lat; + @XmlAttribute(name = "Lon", required = true) + protected double lon; + @XmlAttribute(name = "SeqID", required = true) + protected int seqID; + + /** + * Gets the value of the lat property. + * @return get the latitude of the limit + */ + public double getLat() { + return lat; + } + + /** + * Sets the value of the lat property. + * @param value sets the latitude of the limit + */ + public void setLat(double value) { + this.lat = value; + } + + /** + * Gets the value of the lon property. + * @return sets the longitude of the limit + */ + public double getLon() { + return lon; + } + + /** + * Sets the value of the lon property. + * @param value sets the longitude of the limit + */ + public void setLon(double value) { + this.lon = value; + } + + /** + * Gets the value of the seqID property. + * @return gets the sequence that the limit is at. + */ + public int getSeqID() { + return seqID; + } + + /** + * Sets the value of the seqID property. + * @param value sets the order that this limit is to appear in. + */ + public void setSeqID(int value) { + this.seqID = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLMark.java b/racevisionGame/src/main/java/shared/xml/Race/XMLMark.java new file mode 100644 index 00000000..0ad01ce4 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLMark.java @@ -0,0 +1,151 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import mock.model.collider.Collider; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="SeqId" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="TargetLat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *       <attribute name="TargetLng" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *       <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +public class XMLMark{ + + @XmlAttribute(name = "SeqId") + protected Integer seqId; + @XmlAttribute(name = "Name", required = true) + protected String name; + @XmlAttribute(name = "TargetLat", required = true) + protected double targetLat; + @XmlAttribute(name = "TargetLng", required = true) + protected double targetLng; + @XmlAttribute(name = "SourceID", required = true) + protected int sourceID; + + /** + * Gets the value of the seqId property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getSeqId() { + return seqId; + } + + /** + * Sets the value of the seqId property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setSeqId(Integer value) { + this.seqId = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the targetLat property. + * @return latitude that mark is at + */ + public double getTargetLat() { + return targetLat; + } + + /** + * Sets the value of the targetLat property. + * @param value sets the latitude that the mark is at. + */ + public void setTargetLat(double value) { + this.targetLat = value; + } + + /** + * Gets the value of the targetLng property. + * @return the longitude the mark is at + */ + public double getTargetLng() { + return targetLng; + } + + /** + * Sets the value of the targetLng property. + * @param value sets the longitude that the value is at + */ + public void setTargetLng(double value) { + this.targetLng = value; + } + + /** + * Gets the value of the sourceID property. + * @return the markerboats source ID + */ + public int getSourceID() { + return sourceID; + } + + /** + * Sets the value of the sourceID property. + * @param value sets the id of the boat that the mark is referencing to. + */ + public void setSourceID(int value) { + this.sourceID = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLParticipants.java b/racevisionGame/src/main/java/shared/xml/Race/XMLParticipants.java new file mode 100644 index 00000000..331cc861 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLParticipants.java @@ -0,0 +1,85 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="Yacht" maxOccurs="unbounded">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                 <attribute name="Entry" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "yacht" +}) +public class XMLParticipants { + + @XmlElement(name = "Yacht", required = true) + protected List yacht; + + /** + * Gets the value of the yacht property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the yacht property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getYacht().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link XMLYacht } + * + * @return the yachts that are part of the race. + */ + public List getYacht() { + if (yacht == null) { + yacht = new ArrayList(); + } + return this.yacht; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLRace.java b/racevisionGame/src/main/java/shared/xml/Race/XMLRace.java new file mode 100644 index 00000000..2bbc21d4 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLRace.java @@ -0,0 +1,362 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 03:20:03 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="RaceID" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="RaceType" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="CreationTimeDate" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="RaceStartTime">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="Postpone" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="Time" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="Participants">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="Yacht" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                           <attribute name="Entry" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="CompoundMarkSequence">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="Corner" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                           <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                           <attribute name="Rounding" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="ZoneSize" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="Course">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="CompoundMark" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="Mark" maxOccurs="unbounded">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <attribute name="SeqId" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                                     <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="TargetLat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                                     <attribute name="TargetLng" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                                     <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                           </sequence>
+ *                           <attribute name="CompoundMarkID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                           <attribute name="Name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="CourseLimit">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="Limit" maxOccurs="unbounded">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="Lat" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                           <attribute name="Lon" use="required" type="{http://www.w3.org/2001/XMLSchema}double" />
+ *                           <attribute name="SeqID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "raceID", + "raceType", + "creationTimeDate", + "raceStartTime", + "participants", + "compoundMarkSequence", + "course", + "courseLimit" +}) +@XmlRootElement(name = "Race") +public class XMLRace { + + @XmlElement(name = "RaceID") + protected int raceID; + @XmlElement(name = "RaceType", required = true) + protected String raceType; + @XmlElement(name = "CreationTimeDate", required = true) + protected String creationTimeDate; + @XmlElement(name = "RaceStartTime", required = true) + protected XMLRaceStartTime raceStartTime; + @XmlElement(name = "Participants", required = true) + protected XMLParticipants participants; + @XmlElement(name = "CompoundMarkSequence", required = true) + protected XMLCompoundMarkSequence compoundMarkSequence; + @XmlElement(name = "Course", required = true) + protected XMLCourse course; + @XmlElement(name = "CourseLimit", required = true) + protected XMLCourseLimit courseLimit; + + /** + * Gets the value of the raceID property. + * @return the id of the race + */ + public int getRaceID() { + return raceID; + } + + /** + * Sets the value of the raceID property. + * @param value sets the id of the race + */ + public void setRaceID(int value) { + this.raceID = value; + } + + /** + * Gets the value of the raceType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRaceType() { + return raceType; + } + + /** + * Sets the value of the raceType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRaceType(String value) { + this.raceType = value; + } + + /** + * Gets the value of the creationTimeDate property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCreationTimeDate() { + return creationTimeDate; + } + + /** + * Sets the value of the creationTimeDate property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCreationTimeDate(String value) { + this.creationTimeDate = value; + } + + /** + * Gets the value of the raceStartTime property. + * + * @return + * possible object is + * {@link XMLRaceStartTime } + * + */ + public XMLRaceStartTime getRaceStartTime() { + return raceStartTime; + } + + /** + * Sets the value of the raceStartTime property. + * + * @param value + * allowed object is + * {@link XMLRaceStartTime } + * + */ + public void setRaceStartTime(XMLRaceStartTime value) { + this.raceStartTime = value; + } + + /** + * Gets the value of the participants property. + * + * @return + * possible object is + * {@link XMLParticipants } + * + */ + public XMLParticipants getParticipants() { + return participants; + } + + /** + * Sets the value of the participants property. + * + * @param value + * allowed object is + * {@link XMLParticipants } + * + */ + public void setParticipants(XMLParticipants value) { + this.participants = value; + } + + /** + * Gets the value of the compoundMarkSequence property. + * + * @return + * possible object is + * {@link XMLCompoundMarkSequence } + * + */ + public XMLCompoundMarkSequence getCompoundMarkSequence() { + return compoundMarkSequence; + } + + /** + * Sets the value of the compoundMarkSequence property. + * + * @param value + * allowed object is + * {@link XMLCompoundMarkSequence } + * + */ + public void setCompoundMarkSequence(XMLCompoundMarkSequence value) { + this.compoundMarkSequence = value; + } + + /** + * Gets the value of the course property. + * + * @return + * possible object is + * {@link XMLCourse } + * + */ + public XMLCourse getCourse() { + return course; + } + + /** + * Sets the value of the course property. + * + * @param value + * allowed object is + * {@link XMLCourse } + * + */ + public void setCourse(XMLCourse value) { + this.course = value; + } + + /** + * Gets the value of the courseLimit property. + * + * @return + * possible object is + * {@link XMLCourseLimit } + * + */ + public XMLCourseLimit getCourseLimit() { + return courseLimit; + } + + /** + * Sets the value of the courseLimit property. + * + * @param value + * allowed object is + * {@link XMLCourseLimit } + * + */ + public void setCourseLimit(XMLCourseLimit value) { + this.courseLimit = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLRaceFactory.java b/racevisionGame/src/main/java/shared/xml/Race/XMLRaceFactory.java new file mode 100644 index 00000000..35a45cbb --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLRaceFactory.java @@ -0,0 +1,127 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:41:51 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the shared.xml.Race package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class XMLRaceFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: shared.xml.Race + * + */ + public XMLRaceFactory() { + } + + /** + * Create an instance of {@link XMLRace } + * @return a new instance of a race. + */ + public XMLRace createRace() { + return new XMLRace(); + } + + /** + * Create an instance of {@link XMLRaceStartTime } + * @return a new start time for the race + */ + public XMLRaceStartTime createXMLRaceStartTime() { + return new XMLRaceStartTime(); + } + + /** + * Create an instance of {@link XMLParticipants } + * @return a new participant of the race + */ + public XMLParticipants createXMLParticipants() { + return new XMLParticipants(); + } + + /** + * Create an instance of {@link XMLCompoundMarkSequence } + * @return a new Compound Mark Sequence that hte race is to follow. + */ + public XMLCompoundMarkSequence createXMLCompoundMarkSequence() { + return new XMLCompoundMarkSequence(); + } + + /** + * Create an instance of {@link XMLCourse } + * @return the course the race is to use. + */ + public XMLCourse createXMLCourse() { + return new XMLCourse(); + } + + /** + * Create an instance of {@link XMLCourseLimit } + * @return the limits/boundaries of the course. + */ + public XMLCourseLimit createXMLCourseLimit() { + return new XMLCourseLimit(); + } + + /** + * Create an instance of {@link XMLLimit } + * @return a point on hte boundaries + */ + public XMLLimit createXMLLimit() { + return new XMLLimit(); + } + + /** + * Create an instance of {@link XMLCompoundMark } + * @return a compound mark (made out of multiple marks) + */ + public XMLCompoundMark createXMLCompoundMark() { + return new XMLCompoundMark(); + } + + /** + * Create an instance of {@link XMLMark } + * @return a mark + */ + public XMLMark createXMLMark() { + return new XMLMark(); + } + + /** + * Create an instance of {@link XMLCorner } + * @return a corner of a compound mark sequence + */ + public XMLCorner createXMLCorner() { + return new XMLCorner(); + } + + /** + * Create an instance of {@link XMLYacht } + * @return creates a new Yacht. + */ + public XMLYacht createXMLYacht() { + return new XMLYacht(); + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLRaceStartTime.java b/racevisionGame/src/main/java/shared/xml/Race/XMLRaceStartTime.java new file mode 100644 index 00000000..ceaa124d --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLRaceStartTime.java @@ -0,0 +1,92 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="Postpone" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *       <attribute name="Time" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +public class XMLRaceStartTime { + + @XmlAttribute(name = "Postpone", required = true) + protected String postpone; + @XmlAttribute(name = "Time", required = true) + protected String time; + + /** + * Gets the value of the postpone property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPostpone() { + return postpone; + } + + /** + * Sets the value of the postpone property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPostpone(String value) { + this.postpone = value; + } + + /** + * Gets the value of the time property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTime() { + return time; + } + + /** + * Sets the value of the time property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTime(String value) { + this.time = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/Race/XMLYacht.java b/racevisionGame/src/main/java/shared/xml/Race/XMLYacht.java new file mode 100644 index 00000000..652af26a --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/Race/XMLYacht.java @@ -0,0 +1,84 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.08.14 at 02:54:32 AM NZST +// + + +package shared.xml.Race; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="SourceID" use="required" type="{http://www.w3.org/2001/XMLSchema}int" />
+ *       <attribute name="Entry" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +public class XMLYacht { + + @XmlAttribute(name = "SourceID", required = true) + protected int sourceID; + @XmlAttribute(name = "Entry") + protected String entry; + + /** + * Gets the value of the sourceID property. + * @return the id of the yacht + */ + public int getSourceID() { + return sourceID; + } + + /** + * Sets the value of the sourceID property. + * @param value sets the source ID of the a yacht that is participating in the race + */ + public void setSourceID(int value) { + this.sourceID = value; + } + + /** + * Gets the value of the entry property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEntry() { + return entry; + } + + /** + * Sets the value of the entry property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEntry(String value) { + this.entry = value; + } + +} diff --git a/racevisionGame/src/main/java/shared/xml/XMLUtilities.java b/racevisionGame/src/main/java/shared/xml/XMLUtilities.java new file mode 100644 index 00000000..8e01cb76 --- /dev/null +++ b/racevisionGame/src/main/java/shared/xml/XMLUtilities.java @@ -0,0 +1,90 @@ +package shared.xml; + +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.dom.DOMSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import java.io.*; +import java.net.URL; + +/** + * Created by fwy13 on 13/08/17. + */ +public class XMLUtilities { + + public static String classToXML(Object o) throws JAXBException { + JAXBContext context = JAXBContext.newInstance(o.getClass()); + Marshaller jaxbMarshaller = context.createMarshaller(); + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + StringWriter sw = new StringWriter(); + + jaxbMarshaller.marshal(o, sw); + return sw.toString(); + } + + public static Object xmlToClass(File file, URL schemaURL, Class c) throws ParserConfigurationException, IOException, SAXException, JAXBException { + DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = parser.parse(file); + + return xmlToClass(document, schemaURL, c); + } + + public static Object xmlToClass(String xml, URL schemaURL, Class c) throws ParserConfigurationException, IOException, SAXException, JAXBException { + DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = parser.parse(new InputSource(new ByteArrayInputStream(xml.getBytes("utf-8")))); + + return xmlToClass(document, schemaURL, c); + } + + public static Object xmlToClass(InputStream i, URL schemaURL, Class c) throws ParserConfigurationException, IOException, SAXException, JAXBException { + DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = parser.parse(i); + + return xmlToClass(document, schemaURL, c); + } + + public static Object xmlToClass(Document document, URL schemaURL, Class c) throws ParserConfigurationException, IOException, SAXException, JAXBException { + JAXBContext jc = JAXBContext.newInstance(c); + Unmarshaller unmarshaller = jc.createUnmarshaller(); + + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(schemaURL); + unmarshaller.setSchema(schema); + + return unmarshaller.unmarshal(new DOMSource(document)); + } + + public static boolean validateXML(String file, URL schemaURL){ + try { + DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + Document document = parser.parse(new File(file)); + + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = sf.newSchema(schemaURL); + Validator validator = schema.newValidator(); + validator.validate(new DOMSource(document)); + } catch (ParserConfigurationException e) { + return false; + } catch (IOException e) { + return false; + } catch (SAXException e) { + return false; + } + return true; + } + + +} diff --git a/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java b/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java index 9efc7b65..28692488 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java @@ -6,12 +6,15 @@ import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import mock.app.Event; +import org.xml.sax.SAXException; import shared.exceptions.InvalidBoatDataException; import shared.exceptions.InvalidRaceDataException; import shared.exceptions.InvalidRegattaDataException; import shared.exceptions.XMLReaderException; import visualiser.model.RaceConnection; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.soap.Text; import java.io.IOException; import java.net.Socket; diff --git a/racevisionGame/src/main/java/visualiser/Controllers/HostController.java b/racevisionGame/src/main/java/visualiser/Controllers/HostController.java index 621f7e0d..0eec1137 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/HostController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/HostController.java @@ -6,6 +6,7 @@ import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import mock.app.Event; +import org.xml.sax.SAXException; import mock.exceptions.EventConstructionException; import shared.exceptions.InvalidBoatDataException; import shared.exceptions.InvalidRaceDataException; @@ -13,6 +14,8 @@ import shared.exceptions.InvalidRegattaDataException; import shared.exceptions.XMLReaderException; import visualiser.model.RaceConnection; +import javax.xml.bind.JAXBException; +import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.net.Socket; import java.net.URL; diff --git a/racevisionGame/src/main/java/visualiser/Controllers/RaceController.java b/racevisionGame/src/main/java/visualiser/Controllers/RaceController.java index e6029eb9..cbaa5a47 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/RaceController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/RaceController.java @@ -486,14 +486,20 @@ public class RaceController extends Controller { }.start(); } + /** + * toggles if the info table is shown + */ private void toggleTable() { + double tablePercent = 1 - (boatPlacingColumn.getPrefWidth() + boatTeamColumn.getPrefWidth() + boatMarkColumn.getPrefWidth() + boatSpeedColumn.getPrefWidth())/race.getWidth(); + if (infoTableShow){ - race.setDividerPositions(0.4); + race.setDividerPositions(tablePercent); arrowPane.setScaleX(0.5); arrowPane.setScaleY(0.5); - arrowPane.setTranslateX(0 + (arrowPane.getScene().getWidth()/4)*0.4); + arrowPane.setTranslateX(0 + (arrowPane.getScene().getWidth()/4)*tablePercent); arrowPane.setTranslateY(0 - arrowPane.getScene().getHeight()/4); + }else{ race.setDividerPositions(1); @@ -501,7 +507,9 @@ public class RaceController extends Controller { arrowPane.setScaleY(1); arrowPane.setTranslateX(0); arrowPane.setTranslateY(0); + } + boatInfoTable.refresh(); infoTableShow = !infoTableShow; } diff --git a/racevisionGame/src/main/java/visualiser/model/ResizableRaceCanvas.java b/racevisionGame/src/main/java/visualiser/model/ResizableRaceCanvas.java index 57c864b5..1c17b540 100644 --- a/racevisionGame/src/main/java/visualiser/model/ResizableRaceCanvas.java +++ b/racevisionGame/src/main/java/visualiser/model/ResizableRaceCanvas.java @@ -2,7 +2,9 @@ package visualiser.model; import javafx.scene.paint.Color; +import javafx.scene.paint.LinearGradient; import javafx.scene.paint.Paint; +import javafx.scene.text.Font; import javafx.scene.transform.Rotate; import network.Messages.Enums.BoatStatusEnum; import shared.dataInput.RaceDataSource; @@ -10,6 +12,8 @@ import shared.enums.RoundingType; import shared.model.*; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import java.util.List; /** @@ -139,8 +143,14 @@ public class ResizableRaceCanvas extends ResizableCanvas { * Draws a circle with a given diameter, centred on a given graph coordinate. * @param center The center coordinate of the circle. * @param diameter The diameter of the circle. + * @param paint The paint to use for the circle. */ - private void drawCircle(GraphCoordinate center, double diameter) { + private void drawCircle(GraphCoordinate center, double diameter, Paint paint) { + + gc.save(); + + gc.setFill(paint); + gc.setStroke(paint); //The graphCoordinates are for the center of the point, so we offset them to get the corner coordinate. gc.fillOval( @@ -148,6 +158,7 @@ public class ResizableRaceCanvas extends ResizableCanvas { center.getY() - (diameter / 2), diameter, diameter ); + gc.restore(); } /** @@ -156,20 +167,16 @@ public class ResizableRaceCanvas extends ResizableCanvas { * @param graphCoordinateA Starting Point of the line in GraphCoordinate. * @param graphCoordinateB End Point of the line in GraphCoordinate. * @param paint Colour the line is to coloured. + * @param lineWidth The width of the line. */ - private void drawLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint) { + private void drawLine(GraphCoordinate graphCoordinateA, GraphCoordinate graphCoordinateB, Paint paint, double lineWidth) { + + gc.save(); gc.setStroke(paint); gc.setFill(paint); - - double endPointDiameter = 6; - - //Draw first end-point. - drawCircle(graphCoordinateA, endPointDiameter); - - //Draw second end-point. - drawCircle(graphCoordinateB, endPointDiameter); + gc.setLineWidth(lineWidth); //Draw line between them. gc.strokeLine( @@ -178,26 +185,12 @@ public class ResizableRaceCanvas extends ResizableCanvas { graphCoordinateB.getX(), graphCoordinateB.getY() ); - } - - /** - * Display a point on the Canvas. It has a diameter of 10 pixels. - * - * @param graphCoordinate Coordinate that the point is to be displayed at. - * @param paint Paint to use for the point. - */ - private void drawPoint(GraphCoordinate graphCoordinate, Paint paint) { - - //Set paint. - gc.setFill(paint); - - double pointDiameter = 10; + gc.restore(); - //Draw the point. - drawCircle(graphCoordinate, pointDiameter); } + /** * Display given name and speed of boat at a graph coordinate * @@ -207,8 +200,10 @@ public class ResizableRaceCanvas extends ResizableCanvas { * @param coordinate coordinate the text appears * @param timeToNextMark The time until the boat reaches the next mark. * @param timeSinceLastMark The time since the boat passed the last mark. + * @param textPaint The color of the text. + * @param fontSize The size of the font. */ - private void drawText(String name, String abbrev, double speed, GraphCoordinate coordinate, String timeToNextMark, String timeSinceLastMark) { + private void drawText(String name, String abbrev, double speed, GraphCoordinate coordinate, String timeToNextMark, String timeSinceLastMark, Paint textPaint, double fontSize) { //The text to draw. Built during the function. String text = ""; @@ -254,8 +249,16 @@ public class ResizableRaceCanvas extends ResizableCanvas { yCoord += 30; } + gc.save(); + + gc.setStroke(textPaint); + gc.setFill(textPaint); + gc.setFont(new Font(gc.getFont().getName(), fontSize)); + //Draw text. gc.fillText(text, xCoord, yCoord); + + gc.restore(); } @@ -271,7 +274,9 @@ public class ResizableRaceCanvas extends ResizableCanvas { boat.getCurrentSpeed(), this.map.convertGPS(boat.getPosition()), boat.getTimeToNextMarkFormatted(this.visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()), - boat.getTimeSinceLastMarkFormatted(this.visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()) ); + boat.getTimeSinceLastMarkFormatted(this.visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()), + Color.BLACK, + 20 ); } @@ -283,29 +288,51 @@ public class ResizableRaceCanvas extends ResizableCanvas { */ private void drawBoats() { - for (VisualiserBoat boat : new ArrayList<>(visualiserRace.getVisualiserRaceState().getBoats())) { + List boats = new ArrayList<>(visualiserRace.getVisualiserRaceState().getBoats()); + //Sort to ensure we draw boats in consistent order. + boats.sort(Comparator.comparingInt(Boat::getSourceID)); - //Draw the boat. - drawBoat(boat); + //Current draw order: + // track points + // wake + // boat + // text + //Track points. + for (VisualiserBoat boat : boats) { + drawTrack(boat); + } + + //Wake. + for (VisualiserBoat boat : boats) { //Only draw wake if they are currently racing. if (boat.getStatus() == BoatStatusEnum.RACING) { drawWake(boat); } + } + + //Boat. + for (VisualiserBoat boat : boats) { + drawBoat(boat); + } + + //Text. + for (VisualiserBoat boat : boats) { + drawBoatText(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)) { boat.setTimeAtLastMark(visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime()); } +*/ - //Draw boat label. - drawBoatText(boat); - //Draw track. - drawTrack(boat); - } } @@ -338,12 +365,14 @@ public class ResizableRaceCanvas extends ResizableCanvas { //The above shape is essentially a triangle 12px wide, and 24px long. + + gc.save(); + //Draw the boat. gc.setFill(boat.getColor()); - gc.save(); rotate(boat.getBearing().degrees(), pos.getX(), pos.getY()); - gc.fillPolygon(x, y, 3); + gc.fillPolygon(x, y, x.length); gc.restore(); @@ -372,12 +401,14 @@ public class ResizableRaceCanvas extends ResizableCanvas { //The above shape is essentially a triangle 24px wide, and 48 long. + + gc.save(); + //Draw the boat. gc.setFill(Color.BLACK); - gc.save(); rotate(boat.getBearing().degrees(), pos.getX(), pos.getY()); - gc.fillPolygon(x, y, 3); + gc.fillPolygon(x, y, x.length); gc.restore(); } @@ -393,8 +424,15 @@ public class ResizableRaceCanvas extends ResizableCanvas { GraphCoordinate wakeFrom = this.map.convertGPS(boat.getPosition()); GraphCoordinate wakeTo = this.map.convertGPS(boat.getWake()); - //Draw. - drawLine(wakeFrom, wakeTo, boat.getColor()); + double lineWidth = 4; + double endPointDiameter = 12; + + //Line. + drawLine(wakeFrom, wakeTo, Color.DARKBLUE, lineWidth); + + //Draw end-point. + //drawCircle(wakeTo, endPointDiameter, Color.BLACK); + } @@ -420,8 +458,10 @@ public class ResizableRaceCanvas extends ResizableCanvas { //Calculate screen position. GraphCoordinate mark1 = this.map.convertGPS(mark.getPosition()); + double diameter = 10; + //Draw. - drawPoint(mark1, Color.LIMEGREEN); + drawCircle(mark1, diameter, Color.DARKGREEN); } @@ -459,6 +499,8 @@ public class ResizableRaceCanvas extends ResizableCanvas { */ private void drawBoundary() { + gc.save(); + //Prepare to draw. gc.setLineWidth(1); gc.setFill(Color.AQUA); @@ -481,6 +523,8 @@ public class ResizableRaceCanvas extends ResizableCanvas { //Draw the boundary. gc.fillPolygon(xpoints, ypoints, xpoints.length); + gc.restore(); + } /** @@ -493,7 +537,6 @@ public class ResizableRaceCanvas extends ResizableCanvas { this.map.setGPSTopLeft(visualiserRace.getVisualiserRaceState().getRaceDataSource().getMapTopLeft()); this.map.setGPSBotRight(visualiserRace.getVisualiserRaceState().getRaceDataSource().getMapBottomRight()); - gc.setLineWidth(2); clear(); @@ -601,6 +644,8 @@ public class ResizableRaceCanvas extends ResizableCanvas { GraphCoordinate c1 = this.map.convertGPS(controlPoint); GraphCoordinate c2 = this.map.convertGPS(controlPoint2); + gc.save(); + gc.setLineWidth(2); gc.setStroke(Color.MEDIUMAQUAMARINE); @@ -611,20 +656,26 @@ public class ResizableRaceCanvas extends ResizableCanvas { gc.bezierCurveTo(c1.getX(), c1.getY(), c2.getX(), c2.getY(), curvePointEnd.getX(), curvePointEnd.getY()); gc.stroke(); gc.closePath(); - gc.save(); + //gc.save(); + gc.restore(); return pointToEndCurve; }else{//last leg so no curve GraphCoordinate startPath = this.map.convertGPS(legStartPoint); GraphCoordinate endPath = this.map.convertGPS(legs.get(index).getEndCompoundMark().getAverageGPSCoordinate()); + gc.save(); + gc.beginPath(); gc.moveTo(startPath.getX(), startPath.getY()); gc.lineTo(endPath.getX(), endPath.getY()); gc.stroke(); gc.closePath(); - gc.save(); + //gc.save(); drawArrowHead(legStartPoint, legs.get(index).getEndCompoundMark().getAverageGPSCoordinate()); + + gc.restore(); + return null; } } @@ -661,17 +712,43 @@ public class ResizableRaceCanvas extends ResizableCanvas { //Check that track points are enabled. if (this.annoPath) { - //Apply the boat color. - gc.setFill(boat.getColor()); + List trackPoints = new ArrayList<>(boat.getTrack()); + + if (trackPoints.size() > 2 ) { + + gc.save(); + + gc.setLineWidth(3); + + + //Draw a line between each adjacent pair of track points. + for (int i = 0; i < trackPoints.size() - 1; i++) { + + //Convert the GPSCoordinate to a screen coordinate. + GraphCoordinate scaledCoordinate1 = this.map.convertGPS(trackPoints.get(i).getCoordinate()); + GraphCoordinate scaledCoordinate2 = this.map.convertGPS(trackPoints.get(i + 1).getCoordinate()); + + double alpha = trackPoints.get(i).getAlpha(); + Paint fadedPaint = new Color( + boat.getColor().getRed(), + boat.getColor().getGreen(), + boat.getColor().getBlue(), + alpha ); + + //Apply the faded boat color. + gc.setFill(fadedPaint); + gc.setStroke(fadedPaint); + + gc.strokeLine( + scaledCoordinate1.getX(), + scaledCoordinate1.getY(), + scaledCoordinate2.getX(), + scaledCoordinate2.getY() ); + } - //Draw each TrackPoint. - for (TrackPoint point : new ArrayList<>(boat.getTrack())) { - //Convert the GPSCoordinate to a screen coordinate. - GraphCoordinate scaledCoordinate = this.map.convertGPS(point.getCoordinate()); + gc.restore(); - //Draw a circle for the trackpoint. - gc.fillOval(scaledCoordinate.getX(), scaledCoordinate.getY(), point.getDiameter(), point.getDiameter()); } } diff --git a/racevisionGame/src/main/java/visualiser/model/TrackPoint.java b/racevisionGame/src/main/java/visualiser/model/TrackPoint.java index 4e0c76c0..f3378a43 100644 --- a/racevisionGame/src/main/java/visualiser/model/TrackPoint.java +++ b/racevisionGame/src/main/java/visualiser/model/TrackPoint.java @@ -34,11 +34,6 @@ public class TrackPoint { */ private final double minAlpha; - /** - * The diameter to draw the track point with. - */ - private final double diameter; - /** * Creates a new track point with fixed GPS coordinates and time, to reach minimum opacity on expiry. @@ -53,7 +48,6 @@ public class TrackPoint { this.expiry = expiry; this.minAlpha = 0.1; - this.diameter = 5d; } @@ -97,12 +91,4 @@ public class TrackPoint { return timeAdded; } - - /** - * Returns the diameter to draw the track point with. - * @return The diameter to draw the track point with. - */ - public double getDiameter() { - return diameter; - } } diff --git a/racevisionGame/src/main/java/visualiser/model/VisualiserBoat.java b/racevisionGame/src/main/java/visualiser/model/VisualiserBoat.java index a02706a6..6cbfdaa3 100644 --- a/racevisionGame/src/main/java/visualiser/model/VisualiserBoat.java +++ b/racevisionGame/src/main/java/visualiser/model/VisualiserBoat.java @@ -36,12 +36,12 @@ 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 = 1000; /** * The number of track points that should be created before fully diminishing the alpha of a given track point. */ - private static final int trackPointLimit = 10; + private static final int trackPointLimit = 50; /** @@ -53,7 +53,7 @@ public class VisualiserBoat extends Boat { /** * Scalar used to scale the boat's wake. */ - private static final double wakeScale = 5; + private static final double wakeScale = 25; /** * If true then this boat has been allocated to the client. diff --git a/racevisionGame/src/main/java/visualiser/model/VisualiserRaceState.java b/racevisionGame/src/main/java/visualiser/model/VisualiserRaceState.java index 3315cbfa..77db4f7c 100644 --- a/racevisionGame/src/main/java/visualiser/model/VisualiserRaceState.java +++ b/racevisionGame/src/main/java/visualiser/model/VisualiserRaceState.java @@ -224,11 +224,7 @@ public class VisualiserRaceState extends RaceState { Leg startingLeg = getLegs().get(0); for (VisualiserBoat boat : boats) { - boat.setCurrentLeg(startingLeg); - boat.setTimeAtLastMark(getRaceClock().getCurrentTime()); - boat.setPosition(new GPSCoordinate(0, 0)); - } } diff --git a/racevisionGame/src/main/resources/css/dayMode.css b/racevisionGame/src/main/resources/css/dayMode.css index d0f62fb7..aa14c68b 100644 --- a/racevisionGame/src/main/resources/css/dayMode.css +++ b/racevisionGame/src/main/resources/css/dayMode.css @@ -52,4 +52,6 @@ -fx-background-color: -fx-mark-highlight-color, rgb(255, 255, 255); } - +#arrowImage { + -fx-image: url("/visualiser/images/arrow.png"); +} diff --git a/racevisionGame/src/main/resources/mock/mockXML/raceSchemaTest.xml b/racevisionGame/src/main/resources/mock/mockXML/raceSchemaTest.xml new file mode 100644 index 00000000..168e3c31 --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/raceSchemaTest.xml @@ -0,0 +1,52 @@ + + + 5326 + FLEET + 2017-08-03T02:13:14+1200 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/main/resources/mock/mockXML/raceSinglePlayer.xml b/racevisionGame/src/main/resources/mock/mockXML/raceSinglePlayer.xml index 553c2571..f939b16d 100644 --- a/racevisionGame/src/main/resources/mock/mockXML/raceSinglePlayer.xml +++ b/racevisionGame/src/main/resources/mock/mockXML/raceSinglePlayer.xml @@ -2,8 +2,8 @@ 5326 FLEET - CREATION_TIME - + 2017-08-03T02:13:14+1200 + diff --git a/racevisionGame/src/main/resources/mock/mockXML/raceTest.xml b/racevisionGame/src/main/resources/mock/mockXML/raceTest.xml index edd634dc..761b9b91 100644 --- a/racevisionGame/src/main/resources/mock/mockXML/raceTest.xml +++ b/racevisionGame/src/main/resources/mock/mockXML/raceTest.xml @@ -2,8 +2,8 @@ 5326 FLEET - CREATION_TIME - + 2017-08-03T02:13:14+1200 + diff --git a/racevisionGame/src/main/resources/mock/mockXML/schema/binding.xml b/racevisionGame/src/main/resources/mock/mockXML/schema/binding.xml new file mode 100644 index 00000000..b1d2a55e --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/schema/binding.xml @@ -0,0 +1,6 @@ + + + diff --git a/racevisionGame/src/main/resources/mock/mockXML/schema/bindingwp.xjb b/racevisionGame/src/main/resources/mock/mockXML/schema/bindingwp.xjb new file mode 100644 index 00000000..7d19360a --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/schema/bindingwp.xjb @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/main/resources/mock/mockXML/schema/raceSchema.xsd b/racevisionGame/src/main/resources/mock/mockXML/schema/raceSchema.xsd new file mode 100644 index 00000000..3752209e --- /dev/null +++ b/racevisionGame/src/main/resources/mock/mockXML/schema/raceSchema.xsd @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/racevisionGame/src/test/java/mock/xml/RaceXMLCreatorTest.java b/racevisionGame/src/test/java/mock/xml/RaceXMLCreatorTest.java new file mode 100644 index 00000000..1cda9efd --- /dev/null +++ b/racevisionGame/src/test/java/mock/xml/RaceXMLCreatorTest.java @@ -0,0 +1,31 @@ +package mock.xml; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import shared.dataInput.RaceXMLReader; +import shared.exceptions.InvalidRaceDataException; +import shared.exceptions.XMLReaderException; + +import javax.xml.bind.JAXBException; + +import static org.mockito.Mockito.mock; + +public class RaceXMLCreatorTest { + + String fileToTest = "mock/mockXML/raceSchemaTest.xml"; + @Mock + RaceXMLReader reader; + + + @Before + public void setup() throws XMLReaderException, JAXBException, InvalidRaceDataException { + + } + + @Test + public void getLineAngleTest(){ + + } + +}