Exemplo n.º 1
0
  public static void generateSvg(
      Writer writer, Method m, SampleNode node, int x, int y, int width, int maxDepth, String idPfx)
      throws IOException {
    if (width < 200) {
      throw new IllegalArgumentException("width must be greater than 200, it is " + width);
    }
    writer.append(
        "<svg width=\""
            + width
            + "\" height= \""
            + (15 * node.height() + 15)
            + "\" onload=\""
            + idPfx
            + "init(evt)\" >\n");
    writer.append(
        "<script type=\"text/ecmascript\">\n"
            + "<![CDATA[\n"
            + "var "
            + idPfx
            + "tooltip;\n"
            + "var "
            + idPfx
            + "tooltip_bg;\n"
            + "function "
            + idPfx
            + "init(evt)\n"
            + "  {\n"
            + "    if ( window.svgDocument == null )\n"
            + "    {\n"
            + "      svgDocument = evt.target.ownerDocument;\n"
            + "    }\n"
            + "    "
            + idPfx
            + "tooltip = svgDocument.getElementById('"
            + idPfx
            + "tooltip');"
            + ""
            + idPfx
            + "tooltip_bg = svgDocument.getElementById('"
            + idPfx
            + "tooltip_bg');"
            + "  }\n"
            + "function "
            + idPfx
            + "ss(evt, mouseovertext, xx, yy)\n"
            + "{\n"
            + "  "
            + idPfx
            + "tooltip.setAttributeNS(null,\"x\",xx );\n"
            + "  "
            + idPfx
            + "tooltip.setAttributeNS(null,\"y\",yy+13 );\n"
            + "  "
            + idPfx
            + "tooltip.firstChild.data = mouseovertext;\n"
            + "  "
            + idPfx
            + "tooltip.setAttributeNS(null,\"visibility\",\"visible\");\n"
            + "length = "
            + idPfx
            + "tooltip.getComputedTextLength();\n"
            + ""
            + idPfx
            + "tooltip_bg.setAttributeNS(null,\"width\",length+8);\n"
            + " "
            + idPfx
            + "tooltip_bg.setAttributeNS(null,\"x\",xx);\n"
            + ""
            + idPfx
            + "tooltip_bg.setAttributeNS(null,\"y\",yy);\n"
            + ""
            + idPfx
            + "tooltip_bg.setAttributeNS(null,\"visibility\",\"visibile\");"
            + "}"
            + "\n"
            + "function "
            + idPfx
            + "hh()\n"
            + "{\n"
            + "  "
            + idPfx
            + "tooltip.setAttributeNS(null,\"visibility\",\"hidden\");\n"
            + ""
            + idPfx
            + "tooltip_bg.setAttributeNS(null,\"visibility\",\"hidden\");\n"
            + "}"
            + "]]>"
            + "</script>");

    generateSubSvg(writer, m, node, x, y + 15, width - 100, maxDepth, idPfx);

    writer.append(
        "<rect fill=\"rgb(255,255,255)\" id=\""
            + idPfx
            + "tooltip_bg\"\n"
            + "      x=\"0\" y=\"0\" rx=\"4\" ry=\"4\"\n"
            + "      width=\"55\" height=\"17\" visibility=\"hidden\"/>");
    writer.append(
        "<text font-size=\"12\" font-family=\"Verdana\" fill=\"rgb(0,0,0)\"  id=\""
            + idPfx
            + "tooltip\" x=\"0\" y=\"0\" visibility=\"hidden\">Tooltip</text>");
    writer.append("</svg>\n");
  }