- New -dotexecutable option.

- UmlGraphDoc supports @opt options.

(Contributed by Laird Nelson.)
This commit is contained in:
Diomidis Spinellis 2010-05-24 05:46:57 +00:00
parent d69eda41a3
commit da28a7e4ff
3 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@
* Create a graphviz graph based on the classes in the specified java
* source files.
*
* (C) Copyright 2002-2005 Diomidis Spinellis
* (C) Copyright 2002-2010 Diomidis Spinellis
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
@ -134,6 +134,7 @@ public class Options implements Cloneable, OptionProvider {
// would have been hidden by the hide pattern "java.*"
// TODO: consider making this standard behaviour
boolean strictMatching;
String dotExecutable;
Options() {
showQualified = false;
@ -186,6 +187,7 @@ public class Options implements Cloneable, OptionProvider {
relativeLinksForSourcePackages = false;
nodeSep = 0.25;
rankSep = 0.5;
dotExecutable = "dot";
}
public Object clone() {
@ -271,6 +273,7 @@ public class Options implements Cloneable, OptionProvider {
option.equals("-collpackages") ||
option.equals("-nodesep") ||
option.equals("-ranksep") ||
option.equals("-dotexecutable") ||
option.equals("-link"))
return 2;
else if(option.equals("-contextPattern"))
@ -533,6 +536,8 @@ public class Options implements Cloneable, OptionProvider {
}
} else if (opt[0].equals("-!ranksep")) {
rankSep = 0.5;
} else if (opt[0].equals("-dotexecutable")) {
dotExecutable = opt[1];
} else
; // Do nothing, javadoc will handle the option or complain, if
// needed.

View File

@ -2,7 +2,7 @@
* Create a graphviz graph based on the classes in the specified java
* source files.
*
* (C) Copyright 2002-2005 Diomidis Spinellis
* (C) Copyright 2002-2010 Diomidis Spinellis
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,

View File

@ -52,7 +52,7 @@ public class UmlGraphDoc {
try {
String outputFolder = findOutputPath(root.options());
Options opt = new Options();
Options opt = UmlGraph.buildOptions(root);
opt.setOptions(root.options());
// in javadoc enumerations are always printed
opt.showEnumerations = true;
@ -94,7 +94,7 @@ public class UmlGraphDoc {
packages.add(packageDoc.name());
OptionProvider view = new PackageView(outputFolder, packageDoc, root, opt);
UmlGraph.buildGraph(root, view, packageDoc);
runGraphviz(outputFolder, packageDoc.name(), packageDoc.name(), root);
runGraphviz(opt.dotExecutable, outputFolder, packageDoc.name(), packageDoc.name(), root);
alterHtmlDocs(opt, outputFolder, packageDoc.name(), packageDoc.name(),
"package-summary.html", Pattern.compile("</H2>"), root);
}
@ -113,7 +113,7 @@ public class UmlGraphDoc {
else
view.setContextCenter(classDoc);
UmlGraph.buildGraph(root, view, classDoc);
runGraphviz(outputFolder, classDoc.containingPackage().name(), classDoc.name(), root);
runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root);
alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(),
classDoc.name() + ".html", Pattern.compile("(Class|Interface|Enum) " + classDoc.name() + ".*") , root);
}
@ -121,17 +121,18 @@ public class UmlGraphDoc {
/**
* Runs Graphviz dot building both a diagram (in png format) and a client side map for it.
* <p>
* At the moment, it assumes dot.exe is in the classpahth
*/
private static void runGraphviz(String outputFolder, String packageName, String name, RootDoc root) {
private static void runGraphviz(String dotExecutable, String outputFolder, String packageName, String name, RootDoc root) {
if (dotExecutable == null) {
dotExecutable = "dot";
}
File dotFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".dot");
File pngFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".png");
File mapFile = new File(outputFolder, packageName.replace(".", "/") + "/" + name + ".map");
try {
Process p = Runtime.getRuntime().exec(new String [] {
"dot",
dotExecutable,
"-Tcmapx",
"-o",
mapFile.getAbsolutePath(),