From 6a16efccf3d263e89778f9d081406c6469b56604 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Sun, 12 Feb 2006 09:37:21 +0000 Subject: [PATCH] Fixes for dot's font platform dependence, so that we can get italic fonts on windows too. Added a flag to generated "compact", that is, all HTML on one line, output, to ease testing, leaving the more human readable HTML multiline output as default --- src/gr/spinellis/umlgraph/doclet/Options.java | 42 +++++++++++++++---- src/org/umlgraph/doclet/Options.java | 42 +++++++++++++++---- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/src/gr/spinellis/umlgraph/doclet/Options.java b/src/gr/spinellis/umlgraph/doclet/Options.java index 86b5078..2381313 100644 --- a/src/gr/spinellis/umlgraph/doclet/Options.java +++ b/src/gr/spinellis/umlgraph/doclet/Options.java @@ -33,6 +33,23 @@ import java.util.regex.PatternSyntaxException; * @author Diomidis Spinellis */ class Options implements Cloneable, OptionProvider { + // dot's font platform dependence workaround + private static String defaultFont; + private static String defaultItalicFont; + + static { + // use an appropriate font depending on the current operating system + // (on windows graphviz is unable to locate "Helvetica-Oblique" + if(System.getProperty("os.name").toLowerCase().contains("windows")) { + defaultFont = "arial"; + defaultItalicFont = "ariali"; + } else { + defaultFont = "Helvetica"; + defaultItalicFont = "Helvetica-Oblique"; + } + } + + // instance fields private Vector hidePatterns; boolean showQualified; boolean showAttributes; @@ -62,15 +79,16 @@ class Options implements Cloneable, OptionProvider { String viewName; String outputDirectory; /** Guillemot left (open) */ - String guilOpen = "\u00ab"; + String guilOpen = "«"; // "\u00ab"; /** Guillemot right (close) */ - String guilClose = "\u00bb"; + String guilClose = "»"; // "\u00bb"; boolean inferRelationships; boolean inferDependencies; boolean useImports; boolean verbose2; String inferRelationshipType; private Vector collPackages; + public boolean compact; Options() { showQualified = false; @@ -81,12 +99,12 @@ class Options implements Cloneable, OptionProvider { showEnumerations = false; showConstructors = false; showType = false; - edgeFontName = "Helvetica"; + edgeFontName = defaultFont; edgeFontColor = "black"; edgeColor = "black"; edgeFontSize = 10; - nodeFontName = "Helvetica"; - nodeFontAbstractName = "Helvetica-Oblique"; + nodeFontName = defaultFont; + nodeFontAbstractName = defaultItalicFont; nodeFontColor = "black"; nodeFontSize = 10; nodeFillColor = null; @@ -106,6 +124,7 @@ class Options implements Cloneable, OptionProvider { verbose2 = false; inferRelationshipType = "navassoc"; collPackages = new Vector(); + compact = false; } public Object clone() { @@ -153,7 +172,8 @@ class Options implements Cloneable, OptionProvider { option.equals("-inferrel") || option.equals("-useimports") || option.equals("-verbose2") || - option.equals("-inferdep")) + option.equals("-inferdep") || + option.equals("-compact")) return 1; else if(option.equals("-nodefillcolor") || @@ -241,7 +261,7 @@ class Options implements Cloneable, OptionProvider { } else if(opt[0].equals("-edgefontname")) { edgeFontName = opt[1]; } else if (opt[0].equals("-!edgefontname")) { - edgeFontName = "Helvetica"; + edgeFontName = defaultFont; } else if(opt[0].equals("-edgefontsize")) { edgeFontSize = Integer.parseInt(opt[1]); } else if (opt[0].equals("-!edgefontsize")) { @@ -253,11 +273,11 @@ class Options implements Cloneable, OptionProvider { } else if(opt[0].equals("-nodefontname")) { nodeFontName = opt[1]; } else if (opt[0].equals("-!nodefontname")) { - nodeFontName = "Helvetica"; + nodeFontName = defaultFont; } else if(opt[0].equals("-nodefontabstractname")) { nodeFontAbstractName = opt[1]; } else if (opt[0].equals("-!nodefontabstractname")) { - nodeFontAbstractName = "Helvetica-Oblique"; + nodeFontAbstractName = defaultItalicFont; } else if(opt[0].equals("-nodefontsize")) { nodeFontSize = Integer.parseInt(opt[1]); } else if (opt[0].equals("-!nodefontsize")) { @@ -343,6 +363,10 @@ class Options implements Cloneable, OptionProvider { } } else if (opt[0].equals("-!collpackages")) { collPackages.clear(); + } else if (opt[0].equals("-compact")) { + compact = true; + } else if(opt[0].equals("-!compact")) { + compact = false; } else ; // Do nothing, javadoc will handle the option or complain, if needed. } diff --git a/src/org/umlgraph/doclet/Options.java b/src/org/umlgraph/doclet/Options.java index 86b5078..2381313 100644 --- a/src/org/umlgraph/doclet/Options.java +++ b/src/org/umlgraph/doclet/Options.java @@ -33,6 +33,23 @@ import java.util.regex.PatternSyntaxException; * @author Diomidis Spinellis */ class Options implements Cloneable, OptionProvider { + // dot's font platform dependence workaround + private static String defaultFont; + private static String defaultItalicFont; + + static { + // use an appropriate font depending on the current operating system + // (on windows graphviz is unable to locate "Helvetica-Oblique" + if(System.getProperty("os.name").toLowerCase().contains("windows")) { + defaultFont = "arial"; + defaultItalicFont = "ariali"; + } else { + defaultFont = "Helvetica"; + defaultItalicFont = "Helvetica-Oblique"; + } + } + + // instance fields private Vector hidePatterns; boolean showQualified; boolean showAttributes; @@ -62,15 +79,16 @@ class Options implements Cloneable, OptionProvider { String viewName; String outputDirectory; /** Guillemot left (open) */ - String guilOpen = "\u00ab"; + String guilOpen = "«"; // "\u00ab"; /** Guillemot right (close) */ - String guilClose = "\u00bb"; + String guilClose = "»"; // "\u00bb"; boolean inferRelationships; boolean inferDependencies; boolean useImports; boolean verbose2; String inferRelationshipType; private Vector collPackages; + public boolean compact; Options() { showQualified = false; @@ -81,12 +99,12 @@ class Options implements Cloneable, OptionProvider { showEnumerations = false; showConstructors = false; showType = false; - edgeFontName = "Helvetica"; + edgeFontName = defaultFont; edgeFontColor = "black"; edgeColor = "black"; edgeFontSize = 10; - nodeFontName = "Helvetica"; - nodeFontAbstractName = "Helvetica-Oblique"; + nodeFontName = defaultFont; + nodeFontAbstractName = defaultItalicFont; nodeFontColor = "black"; nodeFontSize = 10; nodeFillColor = null; @@ -106,6 +124,7 @@ class Options implements Cloneable, OptionProvider { verbose2 = false; inferRelationshipType = "navassoc"; collPackages = new Vector(); + compact = false; } public Object clone() { @@ -153,7 +172,8 @@ class Options implements Cloneable, OptionProvider { option.equals("-inferrel") || option.equals("-useimports") || option.equals("-verbose2") || - option.equals("-inferdep")) + option.equals("-inferdep") || + option.equals("-compact")) return 1; else if(option.equals("-nodefillcolor") || @@ -241,7 +261,7 @@ class Options implements Cloneable, OptionProvider { } else if(opt[0].equals("-edgefontname")) { edgeFontName = opt[1]; } else if (opt[0].equals("-!edgefontname")) { - edgeFontName = "Helvetica"; + edgeFontName = defaultFont; } else if(opt[0].equals("-edgefontsize")) { edgeFontSize = Integer.parseInt(opt[1]); } else if (opt[0].equals("-!edgefontsize")) { @@ -253,11 +273,11 @@ class Options implements Cloneable, OptionProvider { } else if(opt[0].equals("-nodefontname")) { nodeFontName = opt[1]; } else if (opt[0].equals("-!nodefontname")) { - nodeFontName = "Helvetica"; + nodeFontName = defaultFont; } else if(opt[0].equals("-nodefontabstractname")) { nodeFontAbstractName = opt[1]; } else if (opt[0].equals("-!nodefontabstractname")) { - nodeFontAbstractName = "Helvetica-Oblique"; + nodeFontAbstractName = defaultItalicFont; } else if(opt[0].equals("-nodefontsize")) { nodeFontSize = Integer.parseInt(opt[1]); } else if (opt[0].equals("-!nodefontsize")) { @@ -343,6 +363,10 @@ class Options implements Cloneable, OptionProvider { } } else if (opt[0].equals("-!collpackages")) { collPackages.clear(); + } else if (opt[0].equals("-compact")) { + compact = true; + } else if(opt[0].equals("-!compact")) { + compact = false; } else ; // Do nothing, javadoc will handle the option or complain, if needed. }