mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Marks display correctly on the canvas, no double ups or anything like that left.
#[issue10]
This commit is contained in:
@@ -63,7 +63,7 @@ public class App extends Application {
|
||||
//Change the StreamReceiver in this else block to change the default data source.
|
||||
else{
|
||||
// sr = new StreamReceiver("localhost", 4949, "RaceStream");
|
||||
sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941, "RaceStream");
|
||||
sr = new StreamReceiver("localhost", 4949, "RaceStream");
|
||||
}
|
||||
|
||||
sr.start();
|
||||
|
||||
@@ -255,7 +255,7 @@ public class CanvasController {
|
||||
|
||||
private void initializeMarks() {
|
||||
Map<Integer, Mark> allMarks = StreamParser.getXmlObject().getRaceXML().getCompoundMarks();
|
||||
|
||||
System.out.println(allMarks);
|
||||
for (Mark mark : allMarks.values()) {
|
||||
if (mark.getMarkType() == MarkType.SINGLE_MARK) {
|
||||
SingleMark sMark = (SingleMark) mark;
|
||||
@@ -270,6 +270,7 @@ public class CanvasController {
|
||||
}
|
||||
}
|
||||
group.getChildren().addAll(markGroups);
|
||||
System.out.println(group.getChildren());
|
||||
}
|
||||
|
||||
class ResizableCanvas extends Canvas {
|
||||
|
||||
@@ -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);
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user