Exemplo n.º 1
0
  /**
   * Method getGraph.
   *
   * @return IDotGraph
   */
  public final IDotGraph getGraph() {
    if (startNode != null) {
      startNode.accept(this);
    }

    for (final Iterator<Node> iter = graph.getNodes(); iter.hasNext(); ) {
      final Node node = iter.next();
      if ("".equals(node.getName()) || (node == startNode)) {
        continue;
      }
      node.accept(this);
    }

    // Update width and height in nodes.
    Display.getDefault()
        .syncExec(
            new Runnable() {
              public void run() {
                final Font systemFont = Application.getInstance().getFont(Application.NODE_FONT);
                for (final Entry<String, IVertex> entry : nameDimensions.entrySet()) {
                  final String name = entry.getKey();
                  final IVertex vertex = entry.getValue();

                  final Dimension dim = FigureUtilities.getTextExtents(name, systemFont);
                  vertex.setAttr(MINWIDTH_ATTR, Math.max(dim.width, 50));
                  vertex.setAttr(MINHEIGHT_ATTR, Math.max(dim.height, 25));
                }
              }
            });

    for (final Iterator<Node> iter = graph.getNodes(); iter.hasNext(); ) {
      final Node node = iter.next();
      final Collection<Link> deps = node.getLinks();
      int index = 1;
      final int numDeps = deps.size();
      for (final Link link : deps) {
        currentLinkName = "";
        if (numDeps > 1) {
          currentLinkName += index++;
        }
        link.accept(this);
      }
    }

    return dotGraph;
  }