private void write(String indent, Node node, Element element) { boolean childAdded = false; addText(indent, element); Element newElement = null; if (node instanceof AbstractNodeContainer) { newElement = addElement(element, "node-container"); } else { newElement = addElement(element, "node"); } addAttribute(newElement, "name", ((NamedElement) node.getSemanticElement()).getName()); addAttribute(newElement, "x", String.valueOf(node.getConstraint().x)); addAttribute(newElement, "y", String.valueOf(node.getConstraint().y)); addAttribute(newElement, "width", String.valueOf(node.getConstraint().width)); addAttribute(newElement, "height", String.valueOf(node.getConstraint().height)); if (node instanceof AbstractNodeContainer) { Iterator nodes = ((AbstractNodeContainer) node).getNodes().iterator(); while (nodes.hasNext()) { childAdded = true; write(indent + " ", (Node) nodes.next(), newElement); } } Iterator edges = node.getLeavingEdges().iterator(); while (edges.hasNext()) { childAdded = true; Edge edge = (Edge) edges.next(); addText(indent + " ", newElement); Element newEdge = addElement(newElement, "edge"); write(indent + " ", edge, newEdge); } if (childAdded) { addText(indent, newElement); } }
private void addConstraint(Node node, Element nodeInfo) { Rectangle constraint = node.getConstraint().getCopy(); Dimension initialDimension = NotationMapping.getInitialDimension(node.getSemanticElement().getElementId()); if (initialDimension != null) { constraint.setSize(initialDimension); } if (nodeInfo != null) { constraint.x = Integer.valueOf(getAttribute(nodeInfo, "x")).intValue(); constraint.y = Integer.valueOf(getAttribute(nodeInfo, "y")).intValue(); constraint.width = Integer.valueOf(getAttribute(nodeInfo, "width")).intValue(); constraint.height = Integer.valueOf(getAttribute(nodeInfo, "height")).intValue(); } node.setConstraint(constraint); }