コード例 #1
0
 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);
   }
 }
コード例 #2
0
 protected void postProcess(NodeContainer nodeContainer) {
   List nodes = nodeContainer.getNodes();
   for (int i = 0; i < nodes.size(); i++) {
     Node node = (Node) nodes.get(i);
     List edges = node.getLeavingEdges();
     for (int j = 0; j < edges.size(); j++) {
       Edge edge = (Edge) edges.get(j);
       SemanticElement destination = findDestination(edge, node);
       Node target = (Node) edge.getFactory().getRegisteredNotationElementFor(destination);
       if (target != null && edge.getTarget() == null) {
         target.addArrivingEdge(edge);
       }
     }
     if (node instanceof NodeContainer) {
       postProcess((NodeContainer) node);
     }
   }
 }