コード例 #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;
  }
コード例 #2
0
  /**
   * Builds a Figure for the given node and adds it to contents.
   *
   * @param contents the parent Figure to add the node to
   * @param node the node to add
   */
  private void buildNodeFigure(final Draw2dGraph contents, final IVertex node) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Building node " + node.getName());
    }
    final Draw2dNode polygon = contents.createNode(node);
    polygon.setToolTip(new NodeTooltip(node));

    if (node.hasAttr("inbus")) {
      final PolylineConnection conn =
          createBusConnexion(contents, node, ColorConstants.red, "inbus", "bus to");
      conn.setLineWidth(2);
    }
    if (node.hasAttr("outbus")) {
      final PolylineConnection conn =
          createBusConnexion(contents, node, ColorConstants.blue, "outbus", "bus from");
      conn.setLineWidth(2);
    }
    if (node.hasAttr("tobus")) {
      @SuppressWarnings("unused")
      final PolylineConnection conn =
          createBusConnexion(contents, node, ColorConstants.blue, "tobus", "bus from");
    }
    if (node.hasAttr("frombus")) {
      final PolylineConnection conn =
          createBusConnexion(contents, node, ColorConstants.red, "frombus", "bus to");
      final PolygonDecoration dec = new PolygonDecoration();
      conn.setTargetDecoration(dec);
    }
  }
コード例 #3
0
 /**
  * @param vertex IVertex
  * @param nodeType String
  */
 private void setVertexPreferences(final IVertex vertex, final String nodeType) {
   final GrandUiPrefStore preferenceStore = Application.getInstance().getPreferenceStore();
   final String keyPrefix = PreferenceKeys.NODE_PREFIX + nodeType;
   vertex.setAttr(SHAPE_ATTR, preferenceStore.getString(keyPrefix + ".shape"));
   vertex.setAttr(DRAW2DFGCOLOR_ATTR, preferenceStore.getColor(keyPrefix + ".fgcolor"));
   vertex.setAttr(DRAW2DFILLCOLOR_ATTR, preferenceStore.getColor(keyPrefix + ".fillcolor"));
   vertex.setAttr(DRAW2DLINEWIDTH_ATTR, preferenceStore.getInt(keyPrefix + ".linewidth"));
 }
コード例 #4
0
  /**
   * Method visitNode.
   *
   * @param node AntTargetNode
   * @see net.ggtools.grand.graph.visit.NodeVisitor#visitNode(net.ggtools.grand.ant.AntTargetNode)
   */
  public final void visitNode(final AntTargetNode node) {
    final IVertex vertex = addNode(node);
    final String ifCondition = node.getIfCondition();
    if (ifCondition != null) {
      vertex.setAttr(IF_CONDITION_ATTR, ifCondition);
    }

    final String unlessCondition = node.getUnlessCondition();
    if (unlessCondition != null) {
      vertex.setAttr(UNLESS_CONDITION_ATTR, unlessCondition);
    }

    final String buildFile = node.getBuildFile();
    if (buildFile != null) {
      vertex.setAttr(BUILD_FILE_ATTR, buildFile);
    }
  }
コード例 #5
0
 /**
  * @param contents Draw2dGraph
  * @param node IVertex
  * @param color Color
  * @param busLabel String
  * @param busId String String
  * @return PolylineConnection
  */
 private PolylineConnection createBusConnexion(
     final Draw2dGraph contents,
     final IVertex node,
     final Color color,
     final String busId,
     final String busLabel) {
   final PolylineConnection conn =
       addConnectionFromRoute(contents, null, (DotRoute) node.getAttr(busId));
   conn.setForegroundColor(color);
   contents.add(conn, conn.getBounds());
   final Label label =
       new Label(
           busLabel + " " + node.getName(),
           Application.getInstance().getImage(Application.LINK_ICON));
   label.setFont(Application.getInstance().getBoldFont(Application.TOOLTIP_FONT));
   conn.setToolTip(label);
   return conn;
 }