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:
Andrea Aime 2006-01-03 21:30:08 +00:00
parent b9e04f474a
commit 297772ac76
4 changed files with 50 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();