Moving stuff from school pc to home

This commit is contained in:
Fan-Wu Yang
2017-08-13 23:03:16 +12:00
parent 8999cddf8b
commit 70d5447e88
25 changed files with 4995 additions and 282 deletions
File diff suppressed because it is too large Load Diff
@@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2017.08.03 at 01:07:33 AM NZST
// Generated on: 2017.08.13 at 10:39:29 PM NZST
//
@@ -12,33 +12,33 @@ import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the main.java.mock.xml package.
* <p>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
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the scd package.
* <p>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 RaceFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: main.java.mock.xml
*
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: scd
*
*/
public RaceFactory() {
}
/**
* Create an instance of {@link Race }
* @return new Race instance
*
*/
public Race createRace() {
return new Race();
@@ -46,7 +46,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.CourseLimit }
* @return new RaceCourseLimit Instance
*
*/
public Race.CourseLimit createRaceCourseLimit() {
return new Race.CourseLimit();
@@ -54,7 +54,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.Course }
* @return new Course Instance
*
*/
public Race.Course createRaceCourse() {
return new Race.Course();
@@ -62,7 +62,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.Course.CompoundMark }
* @return new CompoundMark Instance
*
*/
public Race.Course.CompoundMark createRaceCourseCompoundMark() {
return new Race.Course.CompoundMark();
@@ -70,7 +70,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.CompoundMarkSequence }
* @return new CompoundMarkSequence Instance
*
*/
public Race.CompoundMarkSequence createRaceCompoundMarkSequence() {
return new Race.CompoundMarkSequence();
@@ -78,7 +78,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.Participants }
* @return new Race.Participants Instance
*
*/
public Race.Participants createRaceParticipants() {
return new Race.Participants();
@@ -86,7 +86,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.RaceStartTime }
* @return new RaceStartTime instance
*
*/
public Race.RaceStartTime createRaceRaceStartTime() {
return new Race.RaceStartTime();
@@ -94,7 +94,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.CourseLimit.Limit }
* @return new Limit instance
*
*/
public Race.CourseLimit.Limit createRaceCourseLimitLimit() {
return new Race.CourseLimit.Limit();
@@ -102,7 +102,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.Course.CompoundMark.Mark }
* @return new CompoundMark.Mark instance
*
*/
public Race.Course.CompoundMark.Mark createRaceCourseCompoundMarkMark() {
return new Race.Course.CompoundMark.Mark();
@@ -110,7 +110,7 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.CompoundMarkSequence.Corner }
* @return new Race.CompoundMarkSequence.Corner instance
*
*/
public Race.CompoundMarkSequence.Corner createRaceCompoundMarkSequenceCorner() {
return new Race.CompoundMarkSequence.Corner();
@@ -118,10 +118,10 @@ public class RaceFactory {
/**
* Create an instance of {@link Race.Participants.Yacht }
* @return new Race.Participants.Yacht Instance.
*
*/
public Race.Participants.Yacht createRaceParticipantsYacht() {
return new Race.Participants.Yacht();
}
}
}
@@ -10,6 +10,7 @@ import shared.model.CompoundMark;
import shared.model.Corner;
import shared.model.GPSCoordinate;
import shared.model.Mark;
import shared.xml.XMLUtilities;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
@@ -157,7 +158,9 @@ public class RaceXMLCreator {
public static String alterRaceToWind(String s, double degrees) throws XMLReaderException, InvalidRaceDataException, JAXBException, IOException, SAXException, ParserConfigurationException {
RaceXMLReader reader = new RaceXMLReader(s, XMLFileType.ResourcePath);
Race race = readRace(RaceXMLCreator.class.getClassLoader().getResource(s).getFile());
Race race = (Race) XMLUtilities.xmlToClass(new File(RaceXMLCreator.class.getClassLoader().getResource(s).getFile()),
RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"),
Race.class);
double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position());
@@ -262,33 +265,4 @@ public class RaceXMLCreator {
return Math.atan2(dy, dx)/Math.PI * 180;
}
public static Race readRace(String file) throws IOException, SAXException, JAXBException, ParserConfigurationException {
//validateRace(file);
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File(file));
JAXBContext jc = JAXBContext.newInstance(Race.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL schemaURL = RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd");// The URL to your XML Schema;
Schema schema = sf.newSchema(schemaURL);
unmarshaller.setSchema(schema);
return (Race) unmarshaller.unmarshal(new DOMSource(document));
}
public static boolean validateRace(String file) throws SAXException, IOException, ParserConfigurationException {
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = parser.parse(new File(file));
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL schemaURL = RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd");// The URL to your XML Schema;
Schema schema = sf.newSchema(schemaURL);
Validator validator = schema.newValidator();
validator.validate(new DOMSource(document));
return true;
}
}