Exemplo n.º 1
0
  /**
   * Creates a <em>basic node</em>.
   *
   * @param node Node
   * @return IVertex
   */
  private IVertex addNode(final Node node) {
    final String name = node.getName();
    final IVertex vertex = dotGraph.newVertex(name, node);

    if (node.equals(startNode)) {
      setVertexPreferences(vertex, "start");
    } else if (node.hasAttributes(Node.ATTR_MAIN_NODE)) {
      setVertexPreferences(vertex, "main");
    } else if (node.hasAttributes(Node.ATTR_MISSING_NODE)) {
      setVertexPreferences(vertex, "missing");
    } else {
      setVertexPreferences(vertex, "default");
    }

    if (node.getDescription() != null) {
      vertex.setAttr(DESCRIPTION_ATTR, node.getDescription());
    }

    if (useBusRouting) {
      final GrandUiPrefStore preferenceStore = Application.getInstance().getPreferenceStore();
      vertex.setAttr("inthreshold", preferenceStore.getInt(PreferenceKeys.GRAPH_BUS_IN_THRESHOLD));
      vertex.setAttr(
          "outthreshold", preferenceStore.getInt(PreferenceKeys.GRAPH_BUS_OUT_THRESHOLD));
    }

    vertexLUT.put(name, vertex);
    nameDimensions.put(name, vertex);
    return vertex;
  }
Exemplo n.º 2
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;
  }