diff --git a/doc/ver.xml b/doc/ver.xml index 433b338..edd8e01 100644 --- a/doc/ver.xml +++ b/doc/ver.xml @@ -8,6 +8,10 @@
  • All code now lives under org.umlgraph. This change requires corresponding modifications to the UMLGraph callers.
  • +
  • Add support for six new shapes: node, component, package, collaboration, +usecase, and activeclass. +These shapes require GraphViz 1.16 or newer. +
  • diff --git a/src/org/umlgraph/doclet/ClassGraph.java b/src/org/umlgraph/doclet/ClassGraph.java index 6d2a5b5..1e12268 100644 --- a/src/org/umlgraph/doclet/ClassGraph.java +++ b/src/org/umlgraph/doclet/ClassGraph.java @@ -177,6 +177,24 @@ class ClassGraph { return s; } + /** + * Convert embedded newlines into HTML line breaks + */ + private String htmlNewline(String s) { + if (s.indexOf('\n') == -1) + return (s); + + StringBuffer sb = new StringBuffer(s); + for (int i = 0; i < sb.length();) { + if (sb.charAt(i) == '\n') { + sb.replace(i, i + 1, "
    "); + i += "
    ".length(); + } else + i++; + } + return sb.toString(); + } + /** * Convert < and > characters in the string to the respective guillemot characters. @@ -349,6 +367,8 @@ class ClassGraph { w.print(", fontname=\"" + opt.nodeFontName + "\""); w.print(", fontcolor=\"" + opt.nodeFontColor + "\""); w.print(", fontsize=" + opt.nodeFontSize); + if (opt.shape != null) + w.print(", shape=" + Options.graphvizShape(opt.shape)); w.println("];"); } @@ -467,7 +487,9 @@ class ClassGraph { idx = qualifiedName.lastIndexOf('.'); else idx = qualifiedName.lastIndexOf('.', startTemplate); - if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) { + if (opt.showComment) + tableLine(Align.LEFT, htmlNewline(escape(c.commentText())), opt, Font.CLASS); + else if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) { String packageName = qualifiedName.substring(0, idx); String cn = className.substring(idx + 1); tableLine(Align.CENTER, escape(cn), opt, font); @@ -1033,8 +1055,9 @@ class ClassGraph { String href = ""; if (url != null) href = " href=\"" + url + "\""; - w.print("<" + linePostfix); + w.print("<
    " + linePostfix); } private void externalTableEnd() { @@ -1058,16 +1081,19 @@ class ClassGraph { String open; String close = ""; String prefix = linePrefix + linePrefix + linePrefix; + String alignText; + if(align == Align.CENTER) - open = prefix + "
    "; + alignText = "center"; else if(align == Align.LEFT) - open = prefix + "
    "; + alignText = "left"; else if(align == Align.RIGHT) - open = prefix + "
    "; + alignText = "right"; else throw new RuntimeException("Unknown alignement type " + align); text = fontWrap(" " + text + " ", opt, font); + open = "
    "; w.print(open + text + close + linePostfix); } diff --git a/src/org/umlgraph/doclet/Options.java b/src/org/umlgraph/doclet/Options.java index 786ae7f..f613a46 100644 --- a/src/org/umlgraph/doclet/Options.java +++ b/src/org/umlgraph/doclet/Options.java @@ -77,6 +77,7 @@ public class Options implements Cloneable, OptionProvider { boolean showVisibility; boolean horizontal; boolean showType; + boolean showComment; String edgeFontName; String edgeFontColor; String edgeColor; @@ -93,6 +94,7 @@ public class Options implements Cloneable, OptionProvider { String nodeFontTagName; double nodeFontPackageSize; String nodeFontPackageName; + String shape; String bgColor; public String outputFileName; String outputEncoding; @@ -134,6 +136,7 @@ public class Options implements Cloneable, OptionProvider { showEnumerations = false; showConstructors = false; showType = false; + showComment = false; edgeFontName = defaultFont; edgeFontColor = "black"; edgeColor = "black"; @@ -151,6 +154,7 @@ public class Options implements Cloneable, OptionProvider { nodeFontPackageName = null; nodeFillColor = null; bgColor = null; + shape = null; outputFileName = "graph.dot"; outputDirectory= null; outputEncoding = "ISO-8859-1"; @@ -211,6 +215,7 @@ public class Options implements Cloneable, OptionProvider { option.equals("-constructors") || option.equals("-visibility") || option.equals("-types") || + option.equals("-commentname") || option.equals("-all") || option.equals("-postfixpackage") || option.equals("-noguillemot") || @@ -240,6 +245,7 @@ public class Options implements Cloneable, OptionProvider { option.equals("-edgecolor") || option.equals("-edgefontsize") || option.equals("-edgefontname") || + option.equals("-shape") || option.equals("-output") || option.equals("-outputencoding") || option.equals("-bgcolor") || @@ -302,6 +308,10 @@ public class Options implements Cloneable, OptionProvider { showType = true; } else if (opt[0].equals("-!types")) { showType = false; + } else if(opt[0].equals("-commentname")) { + showComment = true; + } else if (opt[0].equals("-!commentname")) { + showComment = false; } else if(opt[0].equals("-all")) { setAll(); } else if(opt[0].equals("-bgcolor")) { @@ -372,6 +382,15 @@ public class Options implements Cloneable, OptionProvider { nodeFillColor = opt[1]; } else if (opt[0].equals("-!nodefillcolor")) { nodeFillColor = null; + } else if(opt[0].equals("-shape")) { + if (graphvizShape(opt[1]) != null) + shape = opt[1]; + else { + System.err.println("Ignoring invalid shape " + opt[1]); + shape = null; + } + } else if (opt[0].equals("-!shape")) { + shape = null; } else if(opt[0].equals("-output")) { outputFileName = opt[1]; } else if (opt[0].equals("-!output")) { @@ -694,6 +713,27 @@ public class Options implements Cloneable, OptionProvider { } return sb.toString(); } - -} + /** + * Return the Graphviz shape corresponding to the specified UML shape + * If the shape is return null. + */ + public static String graphvizShape(String s) { + if (s.equals("node")) + return "box3d"; + else if (s.equals("component")) + return "component"; + else if (s.equals("package")) + return "tab"; + else if (s.equals("collaboration")) + return "ellipse, style=dashed"; + else if (s.equals("note")) + return "note"; + else if (s.equals("usecase")) + return "ellipse"; + else if (s.equals("activeclass")) + return "box, style=bold"; + else + return null; + } +}