From 160a7db3a7391c280ad85dc2e5494416733aea97 Mon Sep 17 00:00:00 2001 From: Robert Ross Date: Tue, 21 Mar 2017 13:20:15 -0400 Subject: [PATCH] Added "-autosize" parameter and fixed parameter matching bug with "!" --- .classpath | 16 ++++++----- build.xml | 1 + doc/cd-opt.xml | 5 ++-- pom.xml | 1 + .../java/org/umlgraph/doclet/Options.java | 27 ++++++++++++------- .../java/org/umlgraph/doclet/UmlGraphDoc.java | 13 +++++++-- .../java/org/umlgraph/doclet/Version.java | 2 +- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/.classpath b/.classpath index 4e00818..0c326bc 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,9 @@ - - - - - - - + + + + + + + + + diff --git a/build.xml b/build.xml index ebf912c..7074049 100644 --- a/build.xml +++ b/build.xml @@ -156,6 +156,7 @@ class Version { public static String VERSION = "${VERSION}";} + diff --git a/doc/cd-opt.xml b/doc/cd-opt.xml index 836f8b9..dfe583b 100644 --- a/doc/cd-opt.xml +++ b/doc/cd-opt.xml @@ -39,6 +39,7 @@ be specified through javadoc tags within the diagram, affecting all or some elem

Visual Appearance

-bgcolor
Specify the graph's background color.
+
-autosize
Fits generated graph to the width of the page/window. Defaults to true.
-collapsible
Enhance the javadoc HTML files containing UML diagrams with Javascript that provides a link for showing the (initially collapsed) diagrams.
-edgecolor
Specify the color for drawing edges.
-edgefontcolor
Specify the font color to use for edge labels.
@@ -77,9 +78,9 @@ be specified through javadoc tags within the diagram, affecting all or some elem

All colors can be either a symbolic name (e.g. blue), -a tripple specifying hue-saturation-brightness as values 0-1 +a triple specifying hue-saturation-brightness as values 0-1 (e.g. ".13 0.9 1"), -or a tripple specifying red-green-blue values as hexadecimal +or a triple specifying red-green-blue values as hexadecimal digits prefixed by a # (e.g. "#ff8020"). The symbolic color names are derived from the X Windows System; you can find a complete list in the diff --git a/pom.xml b/pom.xml index bbb7c9e..6c9edd3 100644 --- a/pom.xml +++ b/pom.xml @@ -128,6 +128,7 @@ ${project.build.directory}${file.separator}${project.build.finalName}.jar -inferrel -inferdep + -autosize -collapsible -hide java.* -collpackages diff --git a/src/main/java/org/umlgraph/doclet/Options.java b/src/main/java/org/umlgraph/doclet/Options.java index 22cb359..3bca4a8 100644 --- a/src/main/java/org/umlgraph/doclet/Options.java +++ b/src/main/java/org/umlgraph/doclet/Options.java @@ -77,6 +77,7 @@ public class Options implements Cloneable, OptionProvider { boolean horizontal; boolean showType; boolean showComment; + boolean autoSize; String edgeFontName; String edgeFontColor; String edgeColor; @@ -144,6 +145,7 @@ public class Options implements Cloneable, OptionProvider { showEnumerations = false; showConstructors = false; showType = false; + autoSize = true; showComment = false; edgeFontName = defaultFont; edgeFontColor = "black"; @@ -221,19 +223,20 @@ public class Options implements Cloneable, OptionProvider { * Will return 0 if the option is not supported. */ public static int optionLength(String option) { - if(option.equals("-qualify") || - option.equals("-horizontal") || - option.equals("-attributes") || - option.equals("-operations") || - option.equals("-constructors") || - option.equals("-visibility") || - option.equals("-types") || - option.equals("-commentname") || + if(option.equals("-qualify") || option.equals("-!qualify") || + option.equals("-horizontal") || option.equals("-!horizontal") || + option.equals("-attributes") || option.equals("-!attributes") || + option.equals("-enumconstants") || option.equals("-!enumconstants") || + option.equals("-operations") || option.equals("-!operations") || + option.equals("-enumerations") || option.equals("-!enumerations") || + option.equals("-constructors") || option.equals("-!constructors") || + option.equals("-visibility") || option.equals("-!visibility") || + option.equals("-types") || option.equals("-!types") || + option.equals("-autosize") || option.equals("-!autosize") || + option.equals("-commentname") || option.equals("-!commentname") || option.equals("-all") || option.equals("-postfixpackage") || option.equals("-noguillemot") || - option.equals("-enumconstants") || - option.equals("-enumerations") || option.equals("-views") || option.equals("-inferrel") || option.equals("-useimports") || @@ -326,6 +329,10 @@ public class Options implements Cloneable, OptionProvider { showType = true; } else if (opt[0].equals("-!types")) { showType = false; + } else if(opt[0].equals("-autoSize")) { + autoSize = true; + } else if (opt[0].equals("-!autoSize")) { + autoSize = false; } else if(opt[0].equals("-commentname")) { showComment = true; } else if (opt[0].equals("-!commentname")) { diff --git a/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java b/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java index 0f9a00f..fe6bbf1 100644 --- a/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java +++ b/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java @@ -162,9 +162,14 @@ public class UmlGraphDoc { //Format string for the uml image div tag. private static final String UML_DIV_TAG = "

" + - "" + + "" + "
"; + private static final String UML_AUTO_SIZED_DIV_TAG = + "
" + + "" + + "
"; + private static final String EXPANDABLE_UML_STYLE = "font-family: Arial,Helvetica,sans-serif;font-size: 1.5em; display: block; width: 250px; height: 20px; background: #009933; padding: 5px; text-align: center; border-radius: 8px; color: white; font-weight: bold;"; //Format string for the java script tag. @@ -217,7 +222,11 @@ public class UmlGraphDoc { if (!matched && insertPointPattern.matcher(line).matches()) { matched = true; - String tag = String.format(UML_DIV_TAG, className); + String tag; + if (opt.autoSize) + tag = String.format(UML_AUTO_SIZED_DIV_TAG, className); + else + tag = String.format(UML_DIV_TAG, className); if (opt.collapsibleDiagrams) tag = String.format(EXPANDABLE_UML, tag, "Show UML class diagram", "Hide UML class diagram"); writer.write("