コード例 #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 addEdge(Node node, SemanticElement semanticElement, Element notationInfoElement) {
   NotationElement notationElement = node.getRegisteredNotationElementFor(semanticElement);
   if (notationElement == null) {
     String notationElementId =
         NotationMapping.getNotationElementId(semanticElement.getElementId());
     notationElement = (NotationElement) node.getFactory().create(notationElementId);
     notationElement.setSemanticElement(semanticElement);
     notationElement.register();
     node.addLeavingEdge((Edge) notationElement);
     semanticElement.addPropertyChangeListener(notationElement);
   }
   processEdge((Edge) notationElement, notationInfoElement);
 }
コード例 #3
0
 protected void addNode(
     NodeContainer nodeContainer, SemanticElement semanticElement, Element notationInfoElement) {
   String notationElementId = NotationMapping.getNotationElementId(semanticElement.getElementId());
   Node notationElement = (Node) nodeContainer.getFactory().create(notationElementId);
   notationElement.setSemanticElement(semanticElement);
   notationElement.register();
   nodeContainer.addNode(notationElement);
   semanticElement.addPropertyChangeListener(notationElement);
   processNode(notationElement, notationInfoElement);
   if (notationElement instanceof NodeContainer) {
     addNodes((NodeContainer) notationElement, notationInfoElement);
   }
 }
コード例 #4
0
 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);
 }
コード例 #5
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);
     }
   }
 }