use of com.cburch.draw.model.AbstractCanvasObject in project logisim-evolution by reds-heig.
the class XmlCircuitReader method buildCircuit.
private void buildCircuit(XmlReader.CircuitData circData, CircuitMutator mutator) {
Element elt = circData.circuitElement;
Circuit dest = circData.circuit;
Map<Element, Component> knownComponents = circData.knownComponents;
if (knownComponents == null)
knownComponents = Collections.emptyMap();
try {
/* Here we check the attribute circuitnamedbox for backwards compatibility */
boolean HasNamedBox = false;
for (Element attrElt : XmlIterator.forChildElements(circData.circuitElement, "a")) {
if (attrElt.hasAttribute("name")) {
String Name = attrElt.getAttribute("name");
if (Name.equals("circuitnamedbox")) {
HasNamedBox = true;
}
}
}
reader.initAttributeSet(circData.circuitElement, dest.getStaticAttributes(), null);
if ((!HasNamedBox) && circData.circuitElement.hasChildNodes()) {
dest.getStaticAttributes().setValue(CircuitAttributes.NAMED_CIRCUIT_BOX, false);
}
} catch (XmlReaderException e) {
reader.addErrors(e, circData.circuit.getName() + ".static");
}
for (Element sub_elt : XmlIterator.forChildElements(elt)) {
String sub_elt_name = sub_elt.getTagName();
if (sub_elt_name.equals("comp")) {
try {
Component comp = knownComponents.get(sub_elt);
if (comp == null) {
comp = getComponent(sub_elt, reader);
}
if (comp != null) {
mutator.add(dest, comp);
}
} catch (XmlReaderException e) {
reader.addErrors(e, circData.circuit.getName() + "." + toComponentString(sub_elt));
}
} else if (sub_elt_name.equals("wire")) {
try {
addWire(dest, mutator, sub_elt);
} catch (XmlReaderException e) {
reader.addErrors(e, circData.circuit.getName() + "." + toWireString(sub_elt));
}
}
}
List<AbstractCanvasObject> appearance = circData.appearance;
if (appearance != null && !appearance.isEmpty()) {
dest.getAppearance().setObjectsForce(appearance);
dest.getAppearance().setDefaultAppearance(false);
}
}
Aggregations