public static void generateHtmlTable( Writer writer, Method m, SampleNode node, int tableWidth, int maxDepth) throws IOException { Map<Method, SampleNode> subNodes = node.getSubNodes(); writer .append( "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"overflow:hidden;table-layout:fixed;width:") .append(Integer.toString(tableWidth)) .append("px\">\n"); int totalSamples = node.getSampleCount(); if (subNodes != null && maxDepth > 0) { writer.append("<tr style=\"height:1em\">"); for (Map.Entry<Method, SampleNode> entry : subNodes.entrySet()) { int width = entry.getValue().getSampleCount() * tableWidth / totalSamples; writer .append("<td style=\"vertical-align:bottom; width:") .append(Integer.toString(width)) .append("px\">"); generateHtmlTable(writer, entry.getKey(), entry.getValue(), width, maxDepth - 1); writer.append("</td>"); } writer.append("<td></td>"); writer.append("</tr>\n"); } writer.append("<tr style=\"height:1em\" ><td "); if (subNodes != null) { writer.append("colspan=\"").append(Integer.toString(subNodes.size() + 1)).append("\" "); } writer.append(" title=\""); m.toHtmlWriter(writer); writer.append(":"); writer.append(Integer.toString(node.getSampleCount())); writer .append("\" style=\"overflow:hidden;width:100%;vertical-align:bottom ;background:") .append(COLORS[(int) (Math.random() * COLORS.length)]) .append("\">"); m.toHtmlWriter(writer); writer.append(":"); writer.append(Integer.toString(totalSamples)); writer.append("</td></tr>\n"); writer.append("</table>\n"); }
public static void generateSubSvg( Writer writer, Method m, SampleNode node, int x, int y, int width, int maxDepth, String idPfx) throws IOException { Map<Method, SampleNode> subNodes = node.getSubNodes(); int totalSamples = node.getSampleCount(); String id = idPfx + "ix" + x + "y" + y; String content = HtmlUtils.htmlEscape(m.toString() + ":" + Integer.toString(totalSamples)); writer.append( "<g onmouseover=\"" + idPfx + "ss(evt,'" + content + "'," + x + ", " + y + " )\" onmouseout=\"" + idPfx + "hh()\">"); writer.append( "<rect id=\"" + id + "\" x=\"" + x + "\" y=\"" + y + "\" width=\"" + width + "\" height=\"15\" fill=\"" + COLORS[(int) (Math.random() * COLORS.length)] + "\" />"); writer.append( "<text x=\"" + x + "\" y=\"" + (y + 13) + "\" font-size=\"12\" font-family=\"Verdana\" fill=\"rgb(0,0,0)\" " + " >"); writer.append(content.substring(0, Math.min(width / 9, content.length()))); writer.append("</text>\n"); writer.append("</g>"); if (subNodes != null && maxDepth > 0) { int rx = 0; for (Map.Entry<Method, SampleNode> entry : subNodes.entrySet()) { int cwidth = (int) (((long) entry.getValue().getSampleCount()) * width / totalSamples); generateSubSvg( writer, entry.getKey(), entry.getValue(), rx + x, y + 15, cwidth, maxDepth - 1, idPfx); rx += cwidth; } } }