mirror of https://github.com/dspinellis/UMLGraph
First cut to association/dependency inference. Needs discussion, sharing the code so that you can play with it if you want and examine the inference code behaviour
This commit is contained in:
parent
b9e04f474a
commit
297772ac76
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package gr.spinellis.umlgraph.doclet;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Class's dot-comaptible alias name (for fully qualified class names)
|
||||
* and printed information
|
||||
|
|
@ -34,6 +37,12 @@ class ClassInfo {
|
|||
boolean nodePrinted;
|
||||
/** True if the class class node is hidden */
|
||||
boolean hidden;
|
||||
/**
|
||||
* The list of classes that share a relation with this one. Contains
|
||||
* all the classes linked with a bi-directional relation , and the ones
|
||||
* referred by a directed relation
|
||||
*/
|
||||
Set<String> relatedClasses = new HashSet<String>();
|
||||
|
||||
ClassInfo(boolean p, boolean h) {
|
||||
nodePrinted = p;
|
||||
|
|
@ -41,10 +50,20 @@ class ClassInfo {
|
|||
name = "c" + (new Integer(classNumber)).toString();
|
||||
classNumber++;
|
||||
}
|
||||
|
||||
public void addRelation(String dest) {
|
||||
relatedClasses.add(dest);
|
||||
}
|
||||
|
||||
public boolean isRelated(String dest) {
|
||||
return relatedClasses.contains(dest);
|
||||
}
|
||||
|
||||
/** Start numbering from zero. */
|
||||
public static void reset() {
|
||||
classNumber = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,9 +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();
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
ClassGraph c = new ClassGraph(root.specifiedPackages(), op);
|
||||
ClassGraph c = new ClassGraph(root, op);
|
||||
c.prologue();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printClass(classes[i]);
|
||||
|
|
@ -84,6 +85,10 @@ public class UmlGraph {
|
|||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printRelations(classes[i]);
|
||||
}
|
||||
if(opt.inferAssociations)
|
||||
c.printInferredRelations(classes);
|
||||
if(opt.inferDependencies)
|
||||
c.printInferredDependencies(classes);
|
||||
|
||||
c.printExtraClasses(root);
|
||||
c.epilogue();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
package gr.spinellis.umlgraph.doclet;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Class's dot-comaptible alias name (for fully qualified class names)
|
||||
* and printed information
|
||||
|
|
@ -34,6 +37,12 @@ class ClassInfo {
|
|||
boolean nodePrinted;
|
||||
/** True if the class class node is hidden */
|
||||
boolean hidden;
|
||||
/**
|
||||
* The list of classes that share a relation with this one. Contains
|
||||
* all the classes linked with a bi-directional relation , and the ones
|
||||
* referred by a directed relation
|
||||
*/
|
||||
Set<String> relatedClasses = new HashSet<String>();
|
||||
|
||||
ClassInfo(boolean p, boolean h) {
|
||||
nodePrinted = p;
|
||||
|
|
@ -41,10 +50,20 @@ class ClassInfo {
|
|||
name = "c" + (new Integer(classNumber)).toString();
|
||||
classNumber++;
|
||||
}
|
||||
|
||||
public void addRelation(String dest) {
|
||||
relatedClasses.add(dest);
|
||||
}
|
||||
|
||||
public boolean isRelated(String dest) {
|
||||
return relatedClasses.contains(dest);
|
||||
}
|
||||
|
||||
/** Start numbering from zero. */
|
||||
public static void reset() {
|
||||
classNumber = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,9 +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();
|
||||
ClassDoc[] classes = root.classes();
|
||||
|
||||
ClassGraph c = new ClassGraph(root.specifiedPackages(), op);
|
||||
ClassGraph c = new ClassGraph(root, op);
|
||||
c.prologue();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printClass(classes[i]);
|
||||
|
|
@ -84,6 +85,10 @@ public class UmlGraph {
|
|||
for (int i = 0; i < classes.length; i++) {
|
||||
c.printRelations(classes[i]);
|
||||
}
|
||||
if(opt.inferAssociations)
|
||||
c.printInferredRelations(classes);
|
||||
if(opt.inferDependencies)
|
||||
c.printInferredDependencies(classes);
|
||||
|
||||
c.printExtraClasses(root);
|
||||
c.epilogue();
|
||||
|
|
|
|||
Loading…
Reference in New Issue