mirror of https://github.com/dspinellis/UMLGraph
Merge pull request #53 from kno10/patch-includes
Add an @opt include option for the package view.
This commit is contained in:
commit
5de652cfeb
|
|
@ -27,6 +27,9 @@ be specified through javadoc tags within the diagram, affecting all or some elem
|
|||
in this case it will hide everything (useful in the context of views
|
||||
to selectively unhide some portions of the graph, see the view chapter for
|
||||
further details). </dd>
|
||||
<dt>-include</dt><dd>Match classes to include with a non-anchored match. This is weaker than
|
||||
the <code>-hide</code> option, but can be used to include classes from foreign packages
|
||||
in the package view (which would by default filter to only include package members).</dd>
|
||||
<dt>-operations</dt><dd>Show class operations (Java methods) </dd>
|
||||
<dt>-qualify</dt><dd>Produce fully-qualified class names. </dd>
|
||||
<dt>-types</dt><dd>Add type information to attributes and operations </dd>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
<dl>
|
||||
|
||||
<dt>Version 5.7 Under development </dt><dd>
|
||||
<ul>
|
||||
<li>The <code>@opt include</code> option can be used to include classes from
|
||||
foreign packages in the package view (unless hidden with <code>@opt hide</code>).</li>
|
||||
<li>You can now also use <code>@opt</code> in <code>package-info.java</code>.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt>Version 5.6 2012-05-31 </dt><dd>
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ public class ContextView implements OptionProvider {
|
|||
}
|
||||
|
||||
public Options getOptionsFor(ClassDoc cd) {
|
||||
Options opt;
|
||||
if (globalOptions.matchesHideExpression(cd.toString()) || !matcher.matches(cd)) {
|
||||
Options opt;
|
||||
if (globalOptions.matchesHideExpression(cd.qualifiedName())
|
||||
|| !(matcher.matches(cd) || globalOptions.matchesIncludeExpression(cd.qualifiedName()))) {
|
||||
opt = hideOptions;
|
||||
} else if (cd.equals(this.cd)) {
|
||||
opt = centerOptions;
|
||||
|
|
@ -103,15 +104,16 @@ public class ContextView implements OptionProvider {
|
|||
}
|
||||
|
||||
public void overrideForClass(Options opt, ClassDoc cd) {
|
||||
opt.setOptions(cd);
|
||||
if (opt.matchesHideExpression(cd.toString()) || !matcher.matches(cd))
|
||||
opt.setOptions(cd);
|
||||
if (opt.matchesHideExpression(cd.qualifiedName())
|
||||
|| !(matcher.matches(cd) || opt.matchesIncludeExpression(cd.qualifiedName())))
|
||||
opt.setOption(HIDE_OPTIONS);
|
||||
if (cd.equals(this.cd))
|
||||
opt.nodeFillColor = "lemonChiffon";
|
||||
}
|
||||
|
||||
public void overrideForClass(Options opt, String className) {
|
||||
if (!matcher.matches(className))
|
||||
if (!(matcher.matches(className) || opt.matchesIncludeExpression(className)))
|
||||
opt.setOption(HIDE_OPTIONS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,15 +29,17 @@ import java.io.InputStreamReader;
|
|||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import com.sun.javadoc.ClassDoc;
|
||||
import com.sun.javadoc.Doc;
|
||||
import com.sun.javadoc.Tag;
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +68,8 @@ public class Options implements Cloneable, OptionProvider {
|
|||
}
|
||||
|
||||
// instance fields
|
||||
Vector<Pattern> hidePatterns;
|
||||
List<Pattern> hidePatterns;
|
||||
List<Pattern> includePatterns;
|
||||
boolean showQualified;
|
||||
boolean showAttributes;
|
||||
boolean showEnumerations;
|
||||
|
|
@ -124,7 +127,7 @@ public class Options implements Cloneable, OptionProvider {
|
|||
Visibility inferDependencyVisibility;
|
||||
boolean inferDepInPackage;
|
||||
RelationType inferRelationshipType;
|
||||
private Vector<Pattern> collPackages;
|
||||
private List<Pattern> collPackages;
|
||||
boolean compact;
|
||||
// internal option, used by UMLDoc to generate relative links between classes
|
||||
boolean relativeLinksForSourcePackages;
|
||||
|
|
@ -168,7 +171,8 @@ public class Options implements Cloneable, OptionProvider {
|
|||
outputFileName = "graph.dot";
|
||||
outputDirectory= null;
|
||||
outputEncoding = "ISO-8859-1";
|
||||
hidePatterns = new Vector<Pattern>();
|
||||
hidePatterns = new ArrayList<Pattern>();
|
||||
includePatterns = new ArrayList<Pattern>();
|
||||
apiDocMap = new HashMap<Pattern, String>();
|
||||
apiDocRoot = null;
|
||||
postfixPackage = false;
|
||||
|
|
@ -183,7 +187,7 @@ public class Options implements Cloneable, OptionProvider {
|
|||
inferDepInPackage = false;
|
||||
useImports = false;
|
||||
inferRelationshipType = RelationType.NAVASSOC;
|
||||
collPackages = new Vector<Pattern>();
|
||||
collPackages = new ArrayList<Pattern>();
|
||||
compact = false;
|
||||
relativeLinksForSourcePackages = false;
|
||||
nodeSep = 0.25;
|
||||
|
|
@ -200,8 +204,9 @@ public class Options implements Cloneable, OptionProvider {
|
|||
// Should not happen
|
||||
}
|
||||
// deep clone the hide and collection patterns
|
||||
clone.hidePatterns = new Vector<Pattern>(hidePatterns);
|
||||
clone.collPackages= new Vector<Pattern>(collPackages);
|
||||
clone.hidePatterns = new ArrayList<Pattern>(hidePatterns);
|
||||
clone.includePatterns = new ArrayList<Pattern>(includePatterns);
|
||||
clone.collPackages= new ArrayList<Pattern>(collPackages);
|
||||
clone.apiDocMap = new HashMap<Pattern, String>(apiDocMap);
|
||||
return clone;
|
||||
}
|
||||
|
|
@ -267,6 +272,7 @@ public class Options implements Cloneable, OptionProvider {
|
|||
option.equals("-outputencoding") ||
|
||||
option.equals("-bgcolor") ||
|
||||
option.equals("-hide") ||
|
||||
option.equals("-include") ||
|
||||
option.equals("-apidocroot") ||
|
||||
option.equals("-apidocmap") ||
|
||||
option.equals("-d") ||
|
||||
|
|
@ -432,6 +438,14 @@ public class Options implements Cloneable, OptionProvider {
|
|||
}
|
||||
} else if (opt[0].equals("-!hide")) {
|
||||
hidePatterns.clear();
|
||||
} else if(opt[0].equals("-include")) {
|
||||
try {
|
||||
includePatterns.add(Pattern.compile(opt[1]));
|
||||
} catch (PatternSyntaxException e) {
|
||||
System.err.println("Skipping invalid pattern " + opt[1]);
|
||||
}
|
||||
} else if (opt[0].equals("-!include")) {
|
||||
includePatterns.clear();
|
||||
} else if(opt[0].equals("-apidocroot")) {
|
||||
apiDocRoot = fixApiDocRoot(opt[1]);
|
||||
} else if (opt[0].equals("-!apidocroot")) {
|
||||
|
|
@ -688,7 +702,7 @@ public class Options implements Cloneable, OptionProvider {
|
|||
|
||||
|
||||
/** Set the options based on the tag elements of the ClassDoc parameter */
|
||||
public void setOptions(ClassDoc p) {
|
||||
public void setOptions(Doc p) {
|
||||
if (p == null)
|
||||
return;
|
||||
|
||||
|
|
@ -724,7 +738,26 @@ public class Options implements Cloneable, OptionProvider {
|
|||
|
||||
/**
|
||||
* Check if the supplied string matches an entity specified
|
||||
* with the -hide parameter.
|
||||
* with the -include parameter.
|
||||
* @return true if the string matches.
|
||||
*/
|
||||
public boolean matchesIncludeExpression(String s) {
|
||||
for (Pattern includePattern : includePatterns) {
|
||||
Matcher m = includePattern.matcher(s);
|
||||
if (strictMatching) {
|
||||
if (m.matches()) {
|
||||
return true;
|
||||
}
|
||||
} else if (m.find()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied string matches an entity specified
|
||||
* with the -collpackages parameter.
|
||||
* @return true if the string matches.
|
||||
*/
|
||||
public boolean matchesCollPackageExpression(String s) {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,19 @@ import com.sun.javadoc.RootDoc;
|
|||
*/
|
||||
public class PackageView implements OptionProvider {
|
||||
|
||||
private static final String[] HIDE = new String[] { "-hide" };
|
||||
private PackageDoc pd;
|
||||
private OptionProvider parent;
|
||||
private ClassMatcher matcher;
|
||||
private String outputPath;
|
||||
private Options opt;
|
||||
|
||||
public PackageView(String outputFolder, PackageDoc pd, RootDoc root, OptionProvider parent) {
|
||||
this.parent = parent;
|
||||
this.pd = pd;
|
||||
this.matcher = new PackageMatcher(pd);
|
||||
this.opt = parent.getGlobalOptions();
|
||||
this.opt.setOptions(pd);
|
||||
this.outputPath = pd.name().replace('.', '/') + "/" + pd.name() + ".dot";
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +41,7 @@ public class PackageView implements OptionProvider {
|
|||
Options go = parent.getGlobalOptions();
|
||||
|
||||
go.setOption(new String[] { "-output", outputPath });
|
||||
go.setOption(new String[] { "-hide" });
|
||||
go.setOption(HIDE);
|
||||
|
||||
return go;
|
||||
}
|
||||
|
|
@ -56,15 +60,22 @@ public class PackageView implements OptionProvider {
|
|||
|
||||
public void overrideForClass(Options opt, ClassDoc cd) {
|
||||
opt.setOptions(cd);
|
||||
opt.showQualified = false;
|
||||
if (!matcher.matches(cd) || parent.getGlobalOptions().matchesHideExpression(cd.name()))
|
||||
opt.setOption(new String[] { "-hide" });
|
||||
boolean inPackage = matcher.matches(cd);
|
||||
if (inPackage)
|
||||
opt.showQualified = false;
|
||||
if (!(inPackage || this.opt.matchesIncludeExpression(cd.qualifiedName()))
|
||||
|| this.opt.matchesHideExpression(cd.qualifiedName()))
|
||||
opt.setOption(HIDE);
|
||||
}
|
||||
|
||||
public void overrideForClass(Options opt, String className) {
|
||||
opt.showQualified = false;
|
||||
if (!matcher.matches(className))
|
||||
opt.setOption(new String[] { "-hide" });
|
||||
boolean inPackage = matcher.matches(className);
|
||||
if (inPackage)
|
||||
opt.showQualified = false;
|
||||
if (!(inPackage || this.opt.matchesIncludeExpression(className))
|
||||
|| this.opt.matchesHideExpression(className))
|
||||
opt.setOption(HIDE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue