mirror of https://github.com/dspinellis/UMLGraph
Updated umlgraph tags (no need for package spec now)
Moved all output handling into ClassGraph (it's cleared, and it's needed because otherwise the cloned Options would have needed a way to share the output writer even when opened in a cloned class) Added support for view inheritance
This commit is contained in:
parent
dceb851073
commit
c4a3b07ea2
|
|
@ -30,9 +30,11 @@ import com.sun.javadoc.RootDoc;
|
|||
|
||||
/**
|
||||
* Doclet API implementation
|
||||
* @navassoc - - - gr.spinellis.umlgraph.doclet.Options
|
||||
* @depend - - - gr.spinellis.umlgraph.doclet.ClassGraph
|
||||
* @depend - - - gr.spinellis.umlgraph.doclet.Version
|
||||
* @depend - - * OptionProvider
|
||||
* @depend - - * Options
|
||||
* @depend - - * View
|
||||
* @depend - - - ClassGraph
|
||||
* @depend - - - Version
|
||||
*
|
||||
* @version $Revision$
|
||||
* @author <a href="http://www.spinellis.gr">Diomidis Spinellis</a>
|
||||
|
|
@ -72,12 +74,10 @@ public class UmlGraph {
|
|||
* Builds and outputs a single graph according to the view overrides
|
||||
*/
|
||||
private static void buildGraph(RootDoc root, OptionProvider op) throws IOException {
|
||||
Options opt = op.getGlobalOptions();
|
||||
opt.openFile();
|
||||
prologue(opt);
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
ClassGraph c = new ClassGraph(root.specifiedPackages(), op);
|
||||
c.prologue();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printClass(classes[i]);
|
||||
}
|
||||
|
|
@ -86,8 +86,7 @@ public class UmlGraph {
|
|||
}
|
||||
|
||||
c.printExtraClasses(root);
|
||||
epilogue(opt);
|
||||
opt.closeFile();
|
||||
c.epilogue();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -96,27 +95,48 @@ public class UmlGraph {
|
|||
* Builds the views according to the parameters on the command line
|
||||
*/
|
||||
private static View[] buildViews(Options opt, RootDoc root) {
|
||||
if (opt.findViews) {
|
||||
List<View> views = new ArrayList<View>();
|
||||
ClassDoc[] classes = root.classes();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].tags("view").length > 0) {
|
||||
views.add(new View(classes[i], opt));
|
||||
}
|
||||
}
|
||||
return views.toArray(new View[views.size()]);
|
||||
} else if (opt.viewName != null) {
|
||||
if (opt.viewName != null) {
|
||||
ClassDoc viewClass = root.classNamed(opt.viewName);
|
||||
if(viewClass == null) {
|
||||
System.out.println("View " + opt.viewName + " not found! Exiting without generating any output.");
|
||||
return null;
|
||||
}
|
||||
return new View[] { new View(viewClass, opt) };
|
||||
if(viewClass.tags("view").length == 0) {
|
||||
System.out.println(viewClass + " is not a view!");
|
||||
return null;
|
||||
}
|
||||
if(viewClass.isAbstract()) {
|
||||
System.out.println(viewClass + " is an abstract view, no output will be generated!");
|
||||
return null;
|
||||
}
|
||||
return new View[] { buildView(viewClass, opt) };
|
||||
} else if (opt.findViews) {
|
||||
List<View> views = new ArrayList<View>();
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
// find view classes
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].tags("view").length > 0 && !classes[i].isAbstract()) {
|
||||
views.add(buildView(classes[i], opt));
|
||||
}
|
||||
}
|
||||
|
||||
return views.toArray(new View[views.size()]);
|
||||
} else {
|
||||
return new View[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a view along with its parent views, recursively
|
||||
*/
|
||||
private static View buildView(ClassDoc viewClass, OptionProvider provider) {
|
||||
ClassDoc superClass = viewClass.superclass();
|
||||
if(superClass == null || superClass.tags("view").length == 0)
|
||||
return new View(viewClass, provider);
|
||||
|
||||
return new View(viewClass, buildView(superClass, provider));
|
||||
}
|
||||
|
||||
/** Option checking */
|
||||
public static int optionLength(String option) {
|
||||
|
|
@ -128,31 +148,5 @@ public class UmlGraph {
|
|||
return LanguageVersion.JAVA_1_5;
|
||||
}
|
||||
|
||||
/** Dot prologue */
|
||||
private static void prologue(Options opt) {
|
||||
opt.w.println(
|
||||
"#!/usr/local/bin/dot\n" +
|
||||
"#\n" +
|
||||
"# Class diagram \n" +
|
||||
"# Generated by UmlGraph version " +
|
||||
Version.VERSION + " (http://www.spinellis.gr/sw/umlgraph)\n" +
|
||||
"#\n\n" +
|
||||
"digraph G {\n" +
|
||||
"\tedge [fontname=\"" + opt.edgeFontName +
|
||||
"\",fontsize=10,labelfontname=\"" + opt.edgeFontName +
|
||||
"\",labelfontsize=10];\n" +
|
||||
"\tnode [fontname=\"" + opt.nodeFontName +
|
||||
"\",fontsize=10,shape=record];"
|
||||
);
|
||||
if (opt.horizontal)
|
||||
opt.w.println("\trankdir=LR;\n\tranksep=1;");
|
||||
if (opt.bgColor != null)
|
||||
opt.w.println("\tbgcolor=\"" + opt.bgColor + "\";\n");
|
||||
}
|
||||
|
||||
/** Dot epilogue */
|
||||
private static void epilogue(Options opt) {
|
||||
opt.w.println("}\n");
|
||||
opt.w.flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,11 @@ import com.sun.javadoc.RootDoc;
|
|||
|
||||
/**
|
||||
* Doclet API implementation
|
||||
* @navassoc - - - gr.spinellis.umlgraph.doclet.Options
|
||||
* @depend - - - gr.spinellis.umlgraph.doclet.ClassGraph
|
||||
* @depend - - - gr.spinellis.umlgraph.doclet.Version
|
||||
* @depend - - * OptionProvider
|
||||
* @depend - - * Options
|
||||
* @depend - - * View
|
||||
* @depend - - - ClassGraph
|
||||
* @depend - - - Version
|
||||
*
|
||||
* @version $Revision$
|
||||
* @author <a href="http://www.spinellis.gr">Diomidis Spinellis</a>
|
||||
|
|
@ -72,12 +74,10 @@ public class UmlGraph {
|
|||
* Builds and outputs a single graph according to the view overrides
|
||||
*/
|
||||
private static void buildGraph(RootDoc root, OptionProvider op) throws IOException {
|
||||
Options opt = op.getGlobalOptions();
|
||||
opt.openFile();
|
||||
prologue(opt);
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
ClassGraph c = new ClassGraph(root.specifiedPackages(), op);
|
||||
c.prologue();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printClass(classes[i]);
|
||||
}
|
||||
|
|
@ -86,8 +86,7 @@ public class UmlGraph {
|
|||
}
|
||||
|
||||
c.printExtraClasses(root);
|
||||
epilogue(opt);
|
||||
opt.closeFile();
|
||||
c.epilogue();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -96,27 +95,48 @@ public class UmlGraph {
|
|||
* Builds the views according to the parameters on the command line
|
||||
*/
|
||||
private static View[] buildViews(Options opt, RootDoc root) {
|
||||
if (opt.findViews) {
|
||||
List<View> views = new ArrayList<View>();
|
||||
ClassDoc[] classes = root.classes();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].tags("view").length > 0) {
|
||||
views.add(new View(classes[i], opt));
|
||||
}
|
||||
}
|
||||
return views.toArray(new View[views.size()]);
|
||||
} else if (opt.viewName != null) {
|
||||
if (opt.viewName != null) {
|
||||
ClassDoc viewClass = root.classNamed(opt.viewName);
|
||||
if(viewClass == null) {
|
||||
System.out.println("View " + opt.viewName + " not found! Exiting without generating any output.");
|
||||
return null;
|
||||
}
|
||||
return new View[] { new View(viewClass, opt) };
|
||||
if(viewClass.tags("view").length == 0) {
|
||||
System.out.println(viewClass + " is not a view!");
|
||||
return null;
|
||||
}
|
||||
if(viewClass.isAbstract()) {
|
||||
System.out.println(viewClass + " is an abstract view, no output will be generated!");
|
||||
return null;
|
||||
}
|
||||
return new View[] { buildView(viewClass, opt) };
|
||||
} else if (opt.findViews) {
|
||||
List<View> views = new ArrayList<View>();
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
// find view classes
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].tags("view").length > 0 && !classes[i].isAbstract()) {
|
||||
views.add(buildView(classes[i], opt));
|
||||
}
|
||||
}
|
||||
|
||||
return views.toArray(new View[views.size()]);
|
||||
} else {
|
||||
return new View[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a view along with its parent views, recursively
|
||||
*/
|
||||
private static View buildView(ClassDoc viewClass, OptionProvider provider) {
|
||||
ClassDoc superClass = viewClass.superclass();
|
||||
if(superClass == null || superClass.tags("view").length == 0)
|
||||
return new View(viewClass, provider);
|
||||
|
||||
return new View(viewClass, buildView(superClass, provider));
|
||||
}
|
||||
|
||||
/** Option checking */
|
||||
public static int optionLength(String option) {
|
||||
|
|
@ -128,31 +148,5 @@ public class UmlGraph {
|
|||
return LanguageVersion.JAVA_1_5;
|
||||
}
|
||||
|
||||
/** Dot prologue */
|
||||
private static void prologue(Options opt) {
|
||||
opt.w.println(
|
||||
"#!/usr/local/bin/dot\n" +
|
||||
"#\n" +
|
||||
"# Class diagram \n" +
|
||||
"# Generated by UmlGraph version " +
|
||||
Version.VERSION + " (http://www.spinellis.gr/sw/umlgraph)\n" +
|
||||
"#\n\n" +
|
||||
"digraph G {\n" +
|
||||
"\tedge [fontname=\"" + opt.edgeFontName +
|
||||
"\",fontsize=10,labelfontname=\"" + opt.edgeFontName +
|
||||
"\",labelfontsize=10];\n" +
|
||||
"\tnode [fontname=\"" + opt.nodeFontName +
|
||||
"\",fontsize=10,shape=record];"
|
||||
);
|
||||
if (opt.horizontal)
|
||||
opt.w.println("\trankdir=LR;\n\tranksep=1;");
|
||||
if (opt.bgColor != null)
|
||||
opt.w.println("\tbgcolor=\"" + opt.bgColor + "\";\n");
|
||||
}
|
||||
|
||||
/** Dot epilogue */
|
||||
private static void epilogue(Options opt) {
|
||||
opt.w.println("}\n");
|
||||
opt.w.flush();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue