diff --git a/src/org/umlgraph/doclet/ClassGraph.java b/src/org/umlgraph/doclet/ClassGraph.java index dfa6560..242526c 100644 --- a/src/org/umlgraph/doclet/ClassGraph.java +++ b/src/org/umlgraph/doclet/ClassGraph.java @@ -367,8 +367,7 @@ 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.print(opt.shape.graphvizAttribute()); w.println("];"); } @@ -671,7 +670,7 @@ class ClassGraph { private String relationNode(ClassDoc c) { Options opt = optionProvider.getOptionsFor(c); String name = getNodeName(c); - return ((opt.shape == null) ? (name + ":p") : name); + return name + opt.shape.landingPort(); } /** Return the full name of a relation's node c. @@ -687,7 +686,7 @@ class ClassGraph { else opt = optionProvider.getOptionsFor(c); String name = getNodeName(cName); - return ((opt.shape == null) ? (name + ":p") : name); + return name + opt.shape.landingPort(); } /** Print a class's relations */ @@ -1109,9 +1108,10 @@ class ClassGraph { String href = ""; if (url != null) href = " href=\"" + url + "\""; - w.print("<" + linePostfix); + + w.print("<
" + linePostfix); } private void externalTableEnd() { diff --git a/src/org/umlgraph/doclet/Options.java b/src/org/umlgraph/doclet/Options.java index f613a46..8a6465b 100644 --- a/src/org/umlgraph/doclet/Options.java +++ b/src/org/umlgraph/doclet/Options.java @@ -94,7 +94,7 @@ public class Options implements Cloneable, OptionProvider { String nodeFontTagName; double nodeFontPackageSize; String nodeFontPackageName; - String shape; + Shape shape; String bgColor; public String outputFileName; String outputEncoding; @@ -154,7 +154,7 @@ public class Options implements Cloneable, OptionProvider { nodeFontPackageName = null; nodeFillColor = null; bgColor = null; - shape = null; + shape = new Shape(); outputFileName = "graph.dot"; outputDirectory= null; outputEncoding = "ISO-8859-1"; @@ -383,14 +383,9 @@ public class Options implements Cloneable, OptionProvider { } 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; - } + shape = new Shape(opt[1]); } else if (opt[0].equals("-!shape")) { - shape = null; + shape = new Shape(); } else if(opt[0].equals("-output")) { outputFileName = opt[1]; } else if (opt[0].equals("-!output")) { @@ -714,26 +709,4 @@ 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; - } } diff --git a/src/org/umlgraph/doclet/Shape.java b/src/org/umlgraph/doclet/Shape.java new file mode 100644 index 0000000..a11adad --- /dev/null +++ b/src/org/umlgraph/doclet/Shape.java @@ -0,0 +1,98 @@ +/* + * Manage the GraphViz interface for node shapes + * + * (C) Copyright 2007 Diomidis Spinellis + * + * Permission to use, copy, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appear in all copies and that + * both that copyright notice and this permission notice appear in + * supporting documentation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * $Id$ + * + */ + +package org.umlgraph.doclet; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.List; + +import com.sun.javadoc.ClassDoc; +import com.sun.javadoc.Doc; +import com.sun.javadoc.LanguageVersion; +import com.sun.javadoc.RootDoc; + +/** + * Properties of node shapes + * + * @version $Revision$ + * @author Diomidis Spinellis + */ +public class Shape { + + /** Shape's UMLGraph name */ + private String name; + + /** Construct a default (class) Shape */ + public Shape() { + name = "class"; + } + + /** Construct a Shape through the specified UMLGraph name */ + public Shape(String n) { + name = n; + if (graphvizAttribute() == null) { + System.err.println("Ignoring invalid shape " + n); + name = "class"; + } + } + + /** + * Return the GraphViz shape name corresponding to the shape + */ + public String graphvizAttribute() { + if (name.equals("class")) + return ""; // Default; plaintext + else if (name.equals("note")) + return ", shape=note"; + else if (name.equals("node")) + return ", shape=box3d"; + else if (name.equals("component")) + return ", shape=component"; + else if (name.equals("package")) + return ", shape=tab"; + else if (name.equals("collaboration")) + return ", shape=ellipse, style=dashed"; + else if (name.equals("usecase")) + return ", shape=ellipse"; + else if (name.equals("activeclass")) + return ""; // Default; plaintext + else + return null; + } + + /** Return the shape's GraphViz landing port */ + String landingPort() { + if (name.equals("class") || name.equals("activeclass")) + return ":p"; + else + return ""; + } + + /** Return the table border required for the shape */ + String border() { + return name.equals("activeclass") ? "2" : "0"; + } + + /** Return the cell border required for the shape */ + String cellBorder() { + return (name.equals("class") || name.equals("activeclass")) ? "1" : "0"; + } +} diff --git a/src/org/umlgraph/doclet/UmlGraph.java b/src/org/umlgraph/doclet/UmlGraph.java index 24d5fa7..73cc532 100644 --- a/src/org/umlgraph/doclet/UmlGraph.java +++ b/src/org/umlgraph/doclet/UmlGraph.java @@ -85,7 +85,7 @@ public class UmlGraph { commentOptions = new Options(); commentOptions.setOptions(root.options()); commentOptions.setOptions(findClass(root, "UMLCommentOptions")); - commentOptions.shape = "note"; + commentOptions.shape = new Shape("note"); Options opt = new Options(); opt.setOptions(root.options());