예제 #1
0
  private void addChild(Container context, Element e) throws LoadFailedException {
    ModelObject model = null;
    boolean port = false;
    if (e.getLocalName().equals("node")) {
      String controlName = getAttributeNS(e, BIGRAPH, "control");
      Control c = bigraph.getSignature().getControl(controlName);
      if (c == null)
        throw new LoadFailedException(
            "The control \"" + controlName + "\" isn't defined by " + "this bigraph's signature.");

      model = new Node(c);
    } else if (e.getLocalName().equals("port") && context instanceof Node) {
      /*
       * <port /> tags shouldn't actually create anything, so let the
       * special handling commence!
       */
      port = true;
    } else if (e.getLocalName().equals("edge")) {
      String linksort = getAttributeNS(e, BIGRAPH, "linksort");
      if (linksort == null || linksort.equals("none")) {
        linksort = "";
      }
      model = new Edge();
      addChange(((Edge) model).changeLinkSort(linksort));
    } else if (e.getLocalName().equals("innername")) {
      String innersort = getAttributeNS(e, BIGRAPH, "innersort");
      if (innersort == null || innersort.equals("none")) {
        innersort = "";
      }
      model = new InnerName();
      addChange(((InnerName) model).changeInnerSort(innersort));
    } else if (e.getLocalName().equals("outername")) {
      String linksort = getAttributeNS(e, BIGRAPH, "linksort");
      if (linksort == null || linksort.equals("none")) {
        linksort = "";
      }
      model = new OuterName();
      ((OuterName) model).setLinkSort(linksort);
    } else {
      model = BigraphXMLLoader.getNewObject(e.getLocalName());
    }

    if (model instanceof Layoutable)
      addChange(context.changeAddChild((Layoutable) model, getAttributeNS(e, BIGRAPH, "name")));

    if (model instanceof Container) {
      processContainer(e, (Container) model);
    } else if (port) {
      Node n = (Node) context;
      processPoint(e, n.getPort(getAttributeNS(e, BIGRAPH, "name")));
    } else if (model instanceof InnerName) {
      processPoint(e, (InnerName) model);
    }

    if (model != null) executeUndecorators(model, e);
  }
예제 #2
0
  @Override
  public void prepare() {
    cg.clear();
    if (layout == null || containerPart == null || child == null) return;

    Container container = containerPart.getModel();
    setTarget(container.getBigraph());
    String name = container.getBigraph().getFirstUnusedName(child);

    if (child instanceof Node) {
      if (layout.width < 30) {
        layout.width = 30;
      }
      if (layout.height < 30) {
        layout.height = 30;
      }
    }

    cg.add(container.changeAddChild(child, name));
    cg.add(LayoutUtilities.changeLayout(child, layout));
  }