Avoid having to add/remove hyphens for all options.

This commit is contained in:
Erich Schubert 2018-10-25 02:19:38 +02:00
parent 2f27948475
commit 1b29f70460
6 changed files with 251 additions and 316 deletions

View File

@ -67,9 +67,9 @@ public class ContextMatcher implements ClassMatcher {
this.root = root; this.root = root;
this.keepParentHide = keepParentHide; this.keepParentHide = keepParentHide;
opt = (Options) options.clone(); opt = (Options) options.clone();
opt.setOption(new String[] { "-!hide" }); opt.setOption(new String[] { "!hide" });
opt.setOption(new String[] { "-!attributes" }); opt.setOption(new String[] { "!attributes" });
opt.setOption(new String[] { "-!operations" }); opt.setOption(new String[] { "!operations" });
this.cg = new ClassGraphHack(root, opt); this.cg = new ClassGraphHack(root, opt);
setContextCenter(pattern); setContextCenter(pattern);

View File

@ -26,7 +26,7 @@ public class ContextView implements OptionProvider {
private Options hideOptions; private Options hideOptions;
private Options centerOptions; private Options centerOptions;
private Options packageOptions; private Options packageOptions;
private static final String[] HIDE_OPTIONS = new String[] { "-hide" }; private static final String[] HIDE_OPTIONS = new String[] { "hide" };
public ContextView(String outputFolder, ClassDoc cd, RootDoc root, Options parent) public ContextView(String outputFolder, ClassDoc cd, RootDoc root, Options parent)
throws IOException { throws IOException {
@ -42,7 +42,7 @@ public class ContextView implements OptionProvider {
this.packageOptions.showQualified = false; this.packageOptions.showQualified = false;
this.myGlobalOptions = parent.getGlobalOptions(); this.myGlobalOptions = parent.getGlobalOptions();
this.myGlobalOptions.setOption(new String[] { "-output", outputPath }); this.myGlobalOptions.setOption(new String[] { "output", outputPath });
this.myGlobalOptions.setOption(HIDE_OPTIONS); this.myGlobalOptions.setOption(HIDE_OPTIONS);
this.hideOptions = parent.getGlobalOptions(); this.hideOptions = parent.getGlobalOptions();
@ -61,7 +61,7 @@ public class ContextView implements OptionProvider {
this.cd = contextCenter; this.cd = contextCenter;
String outputPath = cd.containingPackage().name().replace('.', '/') + "/" + cd.name() String outputPath = cd.containingPackage().name().replace('.', '/') + "/" + cd.name()
+ ".dot"; + ".dot";
this.myGlobalOptions.setOption(new String[] { "-output", outputPath }); this.myGlobalOptions.setOption(new String[] { "output", outputPath });
matcher.setContextCenter(Pattern.compile(cd.toString())); matcher.setContextCenter(Pattern.compile(cd.toString()));
} }

View File

@ -154,71 +154,99 @@ public class Options implements Cloneable, OptionProvider {
showType = true; showType = true;
} }
/**
* Match strings, ignoring leading <tt>-</tt>, <tt>-!</tt>, and <tt>!</tt>.
*
* @param given Given string
* @param expect Expected string
* @return {@code true} on success
*/
protected static boolean matchOption(String given, String expect) {
return matchOption(given, expect, false);
}
/**
* Match strings, ignoring leading <tt>-</tt>, <tt>-!</tt>, and <tt>!</tt>.
*
* @param given Given string
* @param expect Expected string
* @param negative May be negative
* @return {@code true} on success
*/
protected static boolean matchOption(String given, String expect, boolean negative) {
int begin = 0, end = given.length();
if (begin < end && given.charAt(begin) == '-')
++begin;
if (negative && begin < end && given.charAt(begin) == '!')
++begin;
return expect.length() == end - begin && expect.regionMatches(0, given, begin, end - begin);
}
/** /**
* Return the number of arguments associated with the specified option. * Return the number of arguments associated with the specified option.
* The return value includes the actual option. * The return value includes the actual option.
* Will return 0 if the option is not supported. * Will return 0 if the option is not supported.
*/ */
public static int optionLength(String option) { public static int optionLength(String option) {
if(option.equals("-qualify") || option.equals("-!qualify") || if(matchOption(option, "qualify", true) ||
option.equals("-qualifyGenerics") || option.equals("-!qualifyGenerics") || matchOption(option, "qualifyGenerics", true) ||
option.equals("-horizontal") || option.equals("-!horizontal") || matchOption(option, "horizontal", true) ||
option.equals("-attributes") || option.equals("-!attributes") || matchOption(option, "attributes", true) ||
option.equals("-enumconstants") || option.equals("-!enumconstants") || matchOption(option, "enumconstants", true) ||
option.equals("-operations") || option.equals("-!operations") || matchOption(option, "operations", true) ||
option.equals("-enumerations") || option.equals("-!enumerations") || matchOption(option, "enumerations", true) ||
option.equals("-constructors") || option.equals("-!constructors") || matchOption(option, "constructors", true) ||
option.equals("-visibility") || option.equals("-!visibility") || matchOption(option, "visibility", true) ||
option.equals("-types") || option.equals("-!types") || matchOption(option, "types", true) ||
option.equals("-autosize") || option.equals("-!autosize") || matchOption(option, "autosize", true) ||
option.equals("-commentname") || option.equals("-!commentname") || matchOption(option, "commentname", true) ||
option.equals("-nodefontabstractitalic") || option.equals("-!nodefontabstractitalic") || matchOption(option, "nodefontabstractitalic", true) ||
option.equals("-all") || matchOption(option, "all") ||
option.equals("-postfixpackage") || matchOption(option, "postfixpackage") ||
option.equals("-noguillemot") || matchOption(option, "noguillemot") ||
option.equals("-views") || matchOption(option, "views") ||
option.equals("-inferrel") || matchOption(option, "inferrel") ||
option.equals("-useimports") || matchOption(option, "useimports") ||
option.equals("-collapsible") || matchOption(option, "collapsible") ||
option.equals("-inferdep") || matchOption(option, "inferdep") ||
option.equals("-inferdepinpackage") || matchOption(option, "inferdepinpackage") ||
option.equals("-compact")) matchOption(option, "compact"))
return 1; return 1;
else if(option.equals("-nodefillcolor") || else if(matchOption(option, "nodefillcolor") ||
option.equals("-nodefontcolor") || matchOption(option, "nodefontcolor") ||
option.equals("-nodefontsize") || matchOption(option, "nodefontsize") ||
option.equals("-nodefontname") || matchOption(option, "nodefontname") ||
option.equals("-nodefontclasssize") || matchOption(option, "nodefontclasssize") ||
option.equals("-nodefontclassname") || matchOption(option, "nodefontclassname") ||
option.equals("-nodefonttagsize") || matchOption(option, "nodefonttagsize") ||
option.equals("-nodefonttagname") || matchOption(option, "nodefonttagname") ||
option.equals("-nodefontpackagesize") || matchOption(option, "nodefontpackagesize") ||
option.equals("-nodefontpackagename") || matchOption(option, "nodefontpackagename") ||
option.equals("-edgefontcolor") || matchOption(option, "edgefontcolor") ||
option.equals("-edgecolor") || matchOption(option, "edgecolor") ||
option.equals("-edgefontsize") || matchOption(option, "edgefontsize") ||
option.equals("-edgefontname") || matchOption(option, "edgefontname") ||
option.equals("-shape") || matchOption(option, "shape") ||
option.equals("-output") || matchOption(option, "output") ||
option.equals("-outputencoding") || matchOption(option, "outputencoding") ||
option.equals("-bgcolor") || matchOption(option, "bgcolor") ||
option.equals("-hide") || matchOption(option, "hide") ||
option.equals("-include") || matchOption(option, "include") ||
option.equals("-apidocroot") || matchOption(option, "apidocroot") ||
option.equals("-apidocmap") || matchOption(option, "apidocmap") ||
option.equals("-d") || matchOption(option, "d") ||
option.equals("-view") || matchOption(option, "view") ||
option.equals("-inferreltype") || matchOption(option, "inferreltype") ||
option.equals("-inferdepvis") || matchOption(option, "inferdepvis") ||
option.equals("-collpackages") || matchOption(option, "collpackages") ||
option.equals("-nodesep") || matchOption(option, "nodesep") ||
option.equals("-ranksep") || matchOption(option, "ranksep") ||
option.equals("-dotexecutable") || matchOption(option, "dotexecutable") ||
option.equals("-link")) matchOption(option, "link"))
return 2; return 2;
else if(option.equals("-contextPattern") || else if(matchOption(option, "contextPattern") ||
option.equals("-linkoffline")) matchOption(option, "linkoffline"))
return 3; return 3;
else else
return 0; return 0;
@ -226,243 +254,164 @@ public class Options implements Cloneable, OptionProvider {
/** Set the options based on a single option and its arguments */ /** Set the options based on a single option and its arguments */
void setOption(String[] opt) { void setOption(String[] opt) {
if(!opt[0].equals("-hide") && optionLength(opt[0]) > opt.length) { if(!matchOption(opt[0], "hide") && optionLength(opt[0]) > opt.length) {
System.err.println("Skipping option '" + opt[0] + "', missing argument"); System.err.println("Skipping option '" + opt[0] + "', missing argument");
return; return;
} }
boolean dash = opt[0].length() > 1 && opt[0].charAt(0) == '-';
boolean positive = !(opt[0].length() > 1 && opt[0].charAt(dash ? 1 : 0) == '!');
if(opt[0].equals("-qualify")) { if(matchOption(opt[0], "qualify", true)) {
showQualified = true; showQualified = positive;
} else if (opt[0].equals("-!qualify")) { } else if(matchOption(opt[0], "qualifyGenerics", true)) {
showQualified = false; showQualifiedGenerics = positive;
} else if(opt[0].equals("-qualifyGenerics")) { } else if(matchOption(opt[0], "horizontal", true)) {
showQualifiedGenerics = true; horizontal = positive;
} else if (opt[0].equals("-!qualifyGenerics")) { } else if(matchOption(opt[0], "attributes", true)) {
showQualifiedGenerics = false; showAttributes = positive;
} else if(opt[0].equals("-horizontal")) { } else if(matchOption(opt[0], "enumconstants", true)) {
horizontal = true; showEnumConstants = positive;
} else if (opt[0].equals("-!horizontal")) { } else if(matchOption(opt[0], "operations", true)) {
horizontal = false; showOperations = positive;
} else if(opt[0].equals("-attributes")) { } else if(matchOption(opt[0], "enumerations", true)) {
showAttributes = true; showEnumerations = positive;
} else if (opt[0].equals("-!attributes")) { } else if(matchOption(opt[0], "constructors", true)) {
showAttributes = false; showConstructors = positive;
} else if(opt[0].equals("-enumconstants")) { } else if(matchOption(opt[0], "visibility", true)) {
showEnumConstants = true; showVisibility = positive;
} else if (opt[0].equals("-!enumconstants")) { } else if(matchOption(opt[0], "types", true)) {
showEnumConstants = false; showType = positive;
} else if(opt[0].equals("-operations")) { } else if(matchOption(opt[0], "autoSize", true)) {
showOperations = true; autoSize = positive;
} else if (opt[0].equals("-!operations")) { } else if(matchOption(opt[0], "commentname", true)) {
showOperations = false; showComment = positive;
} else if(opt[0].equals("-enumerations")) { } else if(matchOption(opt[0], "all")) {
showEnumerations = true;
} else if (opt[0].equals("-!enumerations")) {
showEnumerations = false;
} else if(opt[0].equals("-constructors")) {
showConstructors = true;
} else if (opt[0].equals("-!constructors")) {
showConstructors = false;
} else if(opt[0].equals("-visibility")) {
showVisibility = true;
} else if (opt[0].equals("-!visibility")) {
showVisibility = false;
} else if(opt[0].equals("-types")) {
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")) {
showComment = false;
} else if(opt[0].equals("-all")) {
setAll(); setAll();
} else if(opt[0].equals("-bgcolor")) { } else if(matchOption(opt[0], "bgcolor", true)) {
bgColor = opt[1]; bgColor = positive ? opt[1] : null;
} else if (opt[0].equals("-!bgcolor")) { } else if(matchOption(opt[0], "edgecolor", true)) {
bgColor = null; edgeColor = positive ? opt[1] : "black";
} else if(opt[0].equals("-edgecolor")) { } else if(matchOption(opt[0], "edgefontcolor", true)) {
edgeColor = opt[1]; edgeFontColor = positive ? opt[1] : "black";
} else if (opt[0].equals("-!edgecolor")) { } else if(matchOption(opt[0], "edgefontname", true)) {
edgeColor = "black"; edgeFontName = positive ? opt[1] : Font.DEFAULT_FONT;
} else if(opt[0].equals("-edgefontcolor")) { } else if(matchOption(opt[0], "edgefontsize", true)) {
edgeFontColor = opt[1]; edgeFontSize = positive ? Double.parseDouble(opt[1]) : 10;
} else if (opt[0].equals("-!edgefontcolor")) { } else if(matchOption(opt[0], "nodefontcolor", true)) {
edgeFontColor = "black"; nodeFontColor = positive ? opt[1] : "black";
} else if(opt[0].equals("-edgefontname")) { } else if(matchOption(opt[0], "nodefontname", true)) {
edgeFontName = opt[1]; nodeFontName = positive ? opt[1] : Font.DEFAULT_FONT;
} else if (opt[0].equals("-!edgefontname")) { } else if(matchOption(opt[0], "nodefontabstractitalic", true)) {
edgeFontName = Font.DEFAULT_FONT; nodeFontAbstractItalic = positive;
} else if(opt[0].equals("-edgefontsize")) { } else if(matchOption(opt[0], "nodefontsize", true)) {
edgeFontSize = Double.parseDouble(opt[1]); nodeFontSize = positive ? Double.parseDouble(opt[1]) : 10;
} else if (opt[0].equals("-!edgefontsize")) { } else if(matchOption(opt[0], "nodefontclassname", true)) {
edgeFontSize = 10; nodeFontClassName = positive ? opt[1] : null;
} else if(opt[0].equals("-nodefontcolor")) { } else if(matchOption(opt[0], "nodefontclasssize", true)) {
nodeFontColor = opt[1]; nodeFontClassSize = positive ? Double.parseDouble(opt[1]) : -1;
} else if (opt[0].equals("-!nodefontcolor")) { } else if(matchOption(opt[0], "nodefonttagname", true)) {
nodeFontColor = "black"; nodeFontTagName = positive ? opt[1] : null;
} else if(opt[0].equals("-nodefontname")) { } else if(matchOption(opt[0], "nodefonttagsize", true)) {
nodeFontName = opt[1]; nodeFontTagSize = positive ? Double.parseDouble(opt[1]) : -1;
} else if (opt[0].equals("-!nodefontname")) { } else if(matchOption(opt[0], "nodefontpackagename", true)) {
nodeFontName = Font.DEFAULT_FONT; nodeFontPackageName = positive ? opt[1] : null;
} else if(opt[0].equals("-nodefontabstractitalic")) { } else if(matchOption(opt[0], "nodefontpackagesize", true)) {
nodeFontAbstractItalic = true; nodeFontPackageSize = positive ? Double.parseDouble(opt[1]) : -1;
} else if (opt[0].equals("-!nodefontabstractitalic")) { } else if(matchOption(opt[0], "nodefillcolor", true)) {
nodeFontAbstractItalic = false; nodeFillColor = positive ? opt[1] : null;
} else if(opt[0].equals("-nodefontsize")) { } else if(matchOption(opt[0], "shape", true)) {
nodeFontSize = Double.parseDouble(opt[1]); shape = positive ? Shape.of(opt[1]) : Shape.CLASS;
} else if (opt[0].equals("-!nodefontsize")) { } else if(matchOption(opt[0], "output", true)) {
nodeFontSize = 10; outputFileName = positive ? opt[1] : "graph.dot";
} else if(opt[0].equals("-nodefontclassname")) { } else if(matchOption(opt[0], "outputencoding", true)) {
nodeFontClassName = opt[1]; outputEncoding = positive ? opt[1] : "ISO-8859-1";
} else if (opt[0].equals("-!nodefontclassname")) { } else if(matchOption(opt[0], "hide", true)) {
nodeFontClassName = null; if (positive) {
} else if(opt[0].equals("-nodefontclasssize")) { if (opt.length == 1) {
nodeFontClassSize = Double.parseDouble(opt[1]); hidePatterns.clear();
} else if (opt[0].equals("-!nodefontclasssize")) { hidePatterns.add(allPattern);
nodeFontClassSize = -1; } else {
} else if(opt[0].equals("-nodefonttagname")) { try {
nodeFontTagName = opt[1]; hidePatterns.add(Pattern.compile(opt[1]));
} else if (opt[0].equals("-!nodefonttagname")) { } catch (PatternSyntaxException e) {
nodeFontTagName = null; System.err.println("Skipping invalid pattern " + opt[1]);
} else if(opt[0].equals("-nodefonttagsize")) { }
nodeFontTagSize = Double.parseDouble(opt[1]); }
} else if (opt[0].equals("-!nodefonttagsize")) { } else
nodeFontTagSize = -1;
} else if(opt[0].equals("-nodefontpackagename")) {
nodeFontPackageName = opt[1];
} else if (opt[0].equals("-!nodefontpackagename")) {
nodeFontPackageName = null;
} else if(opt[0].equals("-nodefontpackagesize")) {
nodeFontPackageSize = Double.parseDouble(opt[1]);
} else if (opt[0].equals("-!nodefontpackagesize")) {
nodeFontPackageSize = -1;
} else if(opt[0].equals("-nodefillcolor")) {
nodeFillColor = opt[1];
} else if (opt[0].equals("-!nodefillcolor")) {
nodeFillColor = null;
} else if(opt[0].equals("-shape")) {
shape = Shape.of(opt[1]);
} else if (opt[0].equals("-!shape")) {
shape = Shape.CLASS;
} else if(opt[0].equals("-output")) {
outputFileName = opt[1];
} else if (opt[0].equals("-!output")) {
outputFileName = "graph.dot";
} else if(opt[0].equals("-outputencoding")) {
outputEncoding = opt[1];
} else if (opt[0].equals("-!outputencoding")) {
outputEncoding = "ISO-8859-1";
} else if(opt[0].equals("-hide")) {
if(opt.length == 1) {
hidePatterns.clear(); hidePatterns.clear();
hidePatterns.add(allPattern); } else if(matchOption(opt[0], "include", true)) {
} else { if (positive) {
try { try {
hidePatterns.add(Pattern.compile(opt[1])); includePatterns.add(Pattern.compile(opt[1]));
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
System.err.println("Skipping invalid pattern " + opt[1]); System.err.println("Skipping invalid pattern " + opt[1]);
} }
} } else
} else if (opt[0].equals("-!hide")) { includePatterns.clear();
hidePatterns.clear(); } else if(matchOption(opt[0], "apidocroot", true)) {
} else if(opt[0].equals("-include")) { apiDocRoot = positive ? fixApiDocRoot(opt[1]) : null;
try { } else if(matchOption(opt[0], "apidocmap", true)) {
includePatterns.add(Pattern.compile(opt[1])); if (positive)
} catch (PatternSyntaxException e) { setApiDocMapFile(opt[1]);
System.err.println("Skipping invalid pattern " + opt[1]); else
} apiDocMap.clear();
} else if (opt[0].equals("-!include")) { } else if(matchOption(opt[0], "noguillemot", true)) {
includePatterns.clear(); guilOpen = positive ? "&lt;&lt;" : "\u00ab";
} else if(opt[0].equals("-apidocroot")) { guilClose = positive ? "&gt;&gt;" : "\u00bb";
apiDocRoot = fixApiDocRoot(opt[1]); } else if (matchOption(opt[0], "view", true)) {
} else if (opt[0].equals("-!apidocroot")) { viewName = positive ? opt[1] : null;
apiDocRoot = null; } else if (matchOption(opt[0], "views", true)) {
} else if(opt[0].equals("-apidocmap")) { findViews = positive;
setApiDocMapFile(opt[1]); } else if (matchOption(opt[0], "d", true)) {
} else if (opt[0].equals("-!apidocmap")) { outputDirectory = positive ? opt[1] : null;
apiDocMap.clear(); } else if(matchOption(opt[0], "inferrel", true)) {
} else if(opt[0].equals("-noguillemot")) { inferRelationships = positive;
guilOpen = "&lt;&lt;"; } else if(matchOption(opt[0], "inferreltype", true)) {
guilClose = "&gt;&gt;"; if (positive) {
} else if (opt[0].equals("-!noguillemot")) {
guilOpen = "\u00ab";
guilClose = "\u00bb";
} else if (opt[0].equals("-view")) {
viewName = opt[1];
} else if (opt[0].equals("-!view")) {
viewName = null;
} else if (opt[0].equals("-views")) {
findViews = true;
} else if (opt[0].equals("-!views")) {
findViews = false;
} else if (opt[0].equals("-d")) {
outputDirectory = opt[1];
} else if (opt[0].equals("-!d")) {
outputDirectory = null;
} else if(opt[0].equals("-inferrel")) {
inferRelationships = true;
} else if(opt[0].equals("-!inferrel")) {
inferRelationships = false;
} else if(opt[0].equals("-inferreltype")) {
try { try {
inferRelationshipType = RelationType.valueOf(opt[1].toUpperCase()); inferRelationshipType = RelationType.valueOf(opt[1].toUpperCase());
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
System.err.println("Unknown association type " + opt[1]); System.err.println("Unknown association type " + opt[1]);
} }
} else if(opt[0].equals("-!inferreltype")) { } else
inferRelationshipType = RelationType.NAVASSOC; inferRelationshipType = RelationType.NAVASSOC;
} else if(opt[0].equals("-inferdepvis")) { } else if(matchOption(opt[0], "inferdepvis", true)) {
try { if (positive) {
Visibility vis = Visibility.valueOf(opt[1].toUpperCase()); try {
inferDependencyVisibility = vis; Visibility vis = Visibility.valueOf(opt[1].toUpperCase());
} catch(IllegalArgumentException e) { inferDependencyVisibility = vis;
System.err.println("Ignoring invalid visibility specification for " + } catch(IllegalArgumentException e) {
"dependency inference: " + opt[1]); System.err.println("Ignoring invalid visibility specification for " +
} "dependency inference: " + opt[1]);
} else if(opt[0].equals("-!inferdepvis")) { }
inferDependencyVisibility = Visibility.PRIVATE; } else
} else if(opt[0].equals("-collapsible")) { inferDependencyVisibility = Visibility.PRIVATE;
collapsibleDiagrams = true; } else if(matchOption(opt[0], "collapsible", true)) {
} else if(opt[0].equals("-!collapsible")) { collapsibleDiagrams = positive;
collapsibleDiagrams = false; } else if(matchOption(opt[0], "inferdep", true)) {
} else if(opt[0].equals("-inferdep")) { inferDependencies = positive;
inferDependencies = true; } else if(matchOption(opt[0], "inferdepinpackage", true)) {
} else if(opt[0].equals("-!inferdep")) { inferDepInPackage = positive;
inferDependencies = false; } else if(matchOption(opt[0], "useimports", true)) {
} else if(opt[0].equals("-inferdepinpackage")) { useImports = positive;
inferDepInPackage = true; } else if (matchOption(opt[0], "collpackages", true)) {
} else if(opt[0].equals("-!inferdepinpackage")) { if (positive) {
inferDepInPackage = false; try {
} else if(opt[0].equals("-useimports")) { collPackages.add(Pattern.compile(opt[1]));
useImports = true; } catch (PatternSyntaxException e) {
} else if(opt[0].equals("-!useimports")) { System.err.println("Skipping invalid pattern " + opt[1]);
useImports = false; }
} else if (opt[0].equals("-collpackages")) { } else
try { collPackages.clear();
collPackages.add(Pattern.compile(opt[1])); } else if (matchOption(opt[0], "compact", true)) {
} catch (PatternSyntaxException e) { compact = positive;
System.err.println("Skipping invalid pattern " + opt[1]); } else if (matchOption(opt[0], "postfixpackage", true)) {
} postfixPackage = positive;
} else if (opt[0].equals("-!collpackages")) { } else if (matchOption(opt[0], "link")) {
collPackages.clear();
} else if (opt[0].equals("-compact")) {
compact = true;
} else if (opt[0].equals("-!compact")) {
compact = false;
} else if (opt[0].equals("-postfixpackage")) {
postfixPackage = true;
} else if (opt[0].equals("-!postfixpackage")) {
postfixPackage = false;
} else if (opt[0].equals("-link")) {
addApiDocRoots(opt[1]); addApiDocRoots(opt[1]);
} else if (opt[0].equals("-linkoffline")) { } else if (matchOption(opt[0], "linkoffline")) {
addApiDocRootsOffline(opt[1], opt[2]); addApiDocRootsOffline(opt[1], opt[2]);
} else if(opt[0].equals("-contextPattern")) { } else if(matchOption(opt[0], "contextPattern")) {
RelationDirection d; RelationType rt; RelationDirection d; RelationType rt;
try { try {
d = RelationDirection.valueOf(opt[2].toUpperCase()); d = RelationDirection.valueOf(opt[2].toUpperCase());
@ -476,27 +425,22 @@ public class Options implements Cloneable, OptionProvider {
} }
} else if (opt[0].equals("-nodesep")) { } else if (matchOption(opt[0], "nodesep", true)) {
try { try {
nodeSep = Double.parseDouble(opt[1]); nodeSep = positive ? Double.parseDouble(opt[1]) : 0.25;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.err.println("Skipping invalid nodesep " + opt[1]); System.err.println("Skipping invalid nodesep " + opt[1]);
} }
} else if (opt[0].equals("-!nodesep")) { } else if (matchOption(opt[0], "ranksep", true)) {
nodeSep = 0.25;
} else if (opt[0].equals("-ranksep")) {
try { try {
rankSep = Double.parseDouble(opt[1]); rankSep = positive ? Double.parseDouble(opt[1]) : 0.5;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
System.err.println("Skipping invalid ranksep " + opt[1]); System.err.println("Skipping invalid ranksep " + opt[1]);
} }
} else if (opt[0].equals("-!ranksep")) { } else if (matchOption(opt[0], "dotexecutable")) {
rankSep = 0.5; dotExecutable = opt[1];
} else if (opt[0].equals("-dotexecutable")) {
dotExecutable = opt[1];
} else } else
; // Do nothing, javadoc will handle the option or complain, if ; // Do nothing, javadoc will handle the option or complain, if needed.
// needed.
} }
/** /**
@ -634,11 +578,8 @@ public class Options implements Cloneable, OptionProvider {
if (p == null) if (p == null)
return; return;
for (Tag tag : p.tags("opt")) { for (Tag tag : p.tags("opt"))
String[] opt = StringUtil.tokenize(tag.text()); setOption(StringUtil.tokenize(tag.text()));
opt[0] = "-" + opt[0];
setOption(opt);
}
} }
/** /**

View File

@ -17,7 +17,7 @@ import com.sun.javadoc.RootDoc;
*/ */
public class PackageView implements OptionProvider { public class PackageView implements OptionProvider {
private static final String[] HIDE = new String[] { "-hide" }; private static final String[] HIDE = new String[] { "hide" };
private PackageDoc pd; private PackageDoc pd;
private OptionProvider parent; private OptionProvider parent;
private ClassMatcher matcher; private ClassMatcher matcher;
@ -40,7 +40,7 @@ public class PackageView implements OptionProvider {
public Options getGlobalOptions() { public Options getGlobalOptions() {
Options go = parent.getGlobalOptions(); Options go = parent.getGlobalOptions();
go.setOption(new String[] { "-output", outputPath }); go.setOption(new String[] { "output", outputPath });
go.setOption(HIDE); go.setOption(HIDE);
return go; return go;

View File

@ -1,4 +1,4 @@
/* Automatically generated file */ /* Automatically generated file */
package org.umlgraph.doclet; package org.umlgraph.doclet;
class Version { public static String VERSION = "R5_7_2-49-ge25953";} class Version { public static String VERSION = "R5_7_2-60-g0e99a6";}

View File

@ -140,36 +140,30 @@ public class View implements OptionProvider {
boolean outputSet = false; boolean outputSet = false;
for (String[] opts : globalOptions) { for (String[] opts : globalOptions) {
if (opts[0].equals("-output")) if (Options.matchOption(opts[0], "output"))
outputSet = true; outputSet = true;
go.setOption(opts); go.setOption(opts);
} }
if (!outputSet) if (!outputSet)
go.setOption(new String[] { "-output", viewDoc.name() + ".dot" }); go.setOption(new String[] { "output", viewDoc.name() + ".dot" });
return go; return go;
} }
public void overrideForClass(Options opt, ClassDoc cd) { public void overrideForClass(Options opt, ClassDoc cd) {
provider.overrideForClass(opt, cd); provider.overrideForClass(opt, cd);
for (ClassMatcher cm : optionOverrides.keySet()) { for (ClassMatcher cm : optionOverrides.keySet())
if(cm.matches(cd)) { if(cm.matches(cd))
for (String[] override : optionOverrides.get(cm)) { for (String[] override : optionOverrides.get(cm))
opt.setOption(override); opt.setOption(override);
}
}
}
} }
public void overrideForClass(Options opt, String className) { public void overrideForClass(Options opt, String className) {
provider.overrideForClass(opt, className); provider.overrideForClass(opt, className);
for (ClassMatcher cm : optionOverrides.keySet()) { for (ClassMatcher cm : optionOverrides.keySet())
if(cm.matches(className)) { if(cm.matches(className))
for (String[] override : optionOverrides.get(cm)) { for (String[] override : optionOverrides.get(cm))
opt.setOption(override); opt.setOption(override);
}
}
}
} }
public String getDisplayName() { public String getDisplayName() {