/**
   * Method render.
   *
   * @param dotGraph IDotGraph
   * @return Draw2dGraph
   */
  public final Draw2dGraph render(final IDotGraph dotGraph) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Rendering Draw2d Graph");
    }
    final Draw2dGraph contents = new Draw2dGraph();
    // Add a margin on the right & bottom edge.
    // The 24 is a magic number which seems to be the same margin JzGraph is
    // applying on the top & left edges.
    // FIXME find out the real dot margin.
    contents.setBorder(new MarginBorder(0, 0, 24, 24));

    return createGraph(dotGraph, contents);
  }
  /**
   * 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);
    }
  }
 /**
  * @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;
 }
 /**
  * Fill an existing graph with a IDotGraph.
  *
  * @param contents Draw2dGraph
  * @param dotGraph IDotGraph
  * @return Draw2dGraph
  */
 public final Draw2dGraph render(final Draw2dGraph contents, final IDotGraph dotGraph) {
   contents.removeAll();
   return createGraph(dotGraph, contents);
 }