示例#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;
  }
  /*
   * (non-Javadoc)
   *
   * @see net.ggtools.grand.graph.GraphProducer#getGraph()
   */
  public Graph getGraph() throws GrandException {
    log.debug("Triggering AbstractGraphFilter");
    final Graph graph = getProducersGraph();

    if (graph != null) {
      final Collection<Node> nodeList = getFilteredNodes();

      for (final Iterator<Node> iter = graph.getNodes(); iter.hasNext(); ) {
        final Node node = iter.next();

        if (!nodeList.contains(node)) {
          iter.remove();
        }
      }
    }

    // The graph had been filtered so it must not be used if the filter is
    // called
    // again.
    producersGraph = null;

    return graph;
  }