Marks display correctly on the canvas, no double ups or anything like that left.

#[issue10]
This commit is contained in:
alistairjmcintyre
2017-05-22 13:22:55 +12:00
parent b692ddcbe6
commit be633c0e60
6 changed files with 20 additions and 8 deletions
@@ -39,12 +39,10 @@ public class GateMark extends Mark {
}
public double getLatitude(){
//return (this.getSingleMark1().getLatitude() + this.getSingleMark2().getLatitude()) / 2;
return (this.getSingleMark1().getLatitude());
}
public double getLongitude(){
//return (this.getSingleMark1().getLongitude() + this.getSingleMark2().getLongitude()) / 2;
return (this.getSingleMark1().getLongitude());
}
@@ -90,6 +90,7 @@ public class MarkGroup extends Group {
{
if (mainMark.getMarkType() == MarkType.SINGLE_MARK) {
Circle markCircle = (Circle) super.getChildren().get(0);
markCircle.setCenterX(x);
markCircle.setCenterY(y);
} else {
@@ -11,7 +11,6 @@ public class SingleMark extends Mark {
private String name;
private int id;
/**
* Represents a marker
*
@@ -239,6 +239,9 @@ public class XMLParser {
private ArrayList<Corner> compoundMarkSequence;
private ArrayList<Limit> courseLimit;
// ensures there's no duplicate marks.
private List<Long> seenSourceIDs = new ArrayList<Long>();
/**
* Constructor for a RaceXMLObject.
* Takes the information from a Document object and creates a more usable format.
@@ -312,6 +315,7 @@ public class XMLParser {
private Map<Integer, Mark> createCompoundMarks(Element docEle) {
Map<Integer, Mark> cMarks = new HashMap<>();
NodeList cMarkList = docEle.getElementsByTagName("Course").item(0).getChildNodes();
for (int i = 0; i < cMarkList.getLength(); i++) {
Node cMarkNode = cMarkList.item(i);
@@ -319,14 +323,15 @@ public class XMLParser {
if (cMarkNode.getNodeName().equals("CompoundMark")) {
Integer markID = getNodeAttributeInt(cMarkNode, "CompoundMarkID");
Mark mark = createMark(cMarkNode);
cMarks.put(markID, mark);
if (mark != null) {
cMarks.put(markID, mark);
}
}
}
return cMarks;
}
private Mark createMark(Node compoundMark) {
List<SingleMark> marksList = new ArrayList<>();
@@ -348,6 +353,14 @@ public class XMLParser {
}
}
for (SingleMark mark : marksList) {
if (seenSourceIDs.contains(mark.getId())) {
return null;
} else {
seenSourceIDs.add(mark.getId());
}
}
if (marksList.size() == 1) {
return marksList.get(0);
} else if (marksList.size() == 2) {