From a4ab6f179aa95b9d999b3db3ae8febbe480cb807 Mon Sep 17 00:00:00 2001 From: Erich Schubert Date: Sun, 21 Oct 2018 16:56:20 +0200 Subject: [PATCH] Have relation styles in a single place. --- .../java/org/umlgraph/doclet/ClassGraph.java | 26 ++++++------------- .../org/umlgraph/doclet/RelationType.java | 22 +++++++++++----- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/umlgraph/doclet/ClassGraph.java b/src/main/java/org/umlgraph/doclet/ClassGraph.java index e6255b1..4051a77 100644 --- a/src/main/java/org/umlgraph/doclet/ClassGraph.java +++ b/src/main/java/org/umlgraph/doclet/ClassGraph.java @@ -80,16 +80,7 @@ class ClassGraph { this.lower = toString().toLowerCase(); } }; - public static Map associationMap = new HashMap(); - static { - associationMap.put(RelationType.ASSOC, "arrowhead=none"); - associationMap.put(RelationType.NAVASSOC, "arrowhead=open"); - associationMap.put(RelationType.HAS, "arrowhead=none, arrowtail=ediamond, dir=both"); - associationMap.put(RelationType.NAVHAS, "arrowhead=open, arrowtail=ediamond, dir=both"); - associationMap.put(RelationType.COMPOSED, "arrowhead=none, arrowtail=diamond, dir=both"); - associationMap.put(RelationType.NAVCOMPOSED, "arrowhead=open, arrowtail=diamond, dir=both"); - associationMap.put(RelationType.DEPEND, "arrowhead=open, style=dashed"); - } + protected Map classnames = new HashMap(); protected Set rootClasses; protected Map rootClassdocs = new HashMap(); @@ -558,8 +549,7 @@ class ClassGraph { ClassDoc to, String toName, String tailLabel, String label, String headLabel) { // print relation - String edgetype = associationMap.get(rt); - w.println("\t// " + fromName + " " + rt.toString() + " " + toName); + w.println("\t// " + fromName + " " + rt.lower + " " + toName); w.println("\t" + relationNode(from, fromName) + " -> " + relationNode(to, toName) + " [" + "taillabel=\"" + tailLabel + "\", " + ((label == null || label.isEmpty()) ? "label=\"\", " : "label=\"" + guillemize(opt, label) + "\", ") + @@ -568,7 +558,7 @@ class ClassGraph { "fontcolor=\"" + opt.edgeFontColor + "\", " + "fontsize=" + opt.edgeFontSize + ", " + "color=\"" + opt.edgeColor + "\", " + - edgetype + "];" + rt.style + "];" ); // update relation info @@ -624,7 +614,8 @@ class ClassGraph { !hidden(s.asClassDoc())) { ClassDoc sc = s.asClassDoc(); w.println("\t//" + c + " extends " + s + "\n" + - "\t" + relationNode(sc) + " -> " + relationNode(c) + " [dir=back,arrowtail=empty];"); + "\t" + relationNode(sc) + " -> " + relationNode(c) + + " [" + RelationType.EXTENDS.style + "];"); getClassInfo(className).addRelation(sc.toString(), RelationType.EXTENDS, RelationDirection.OUT); getClassInfo(sc.toString()).addRelation(className, RelationType.EXTENDS, RelationDirection.IN); } @@ -634,7 +625,7 @@ class ClassGraph { if (!hidden(tag.text())) { ClassDoc from = c.findClass(tag.text()); w.println("\t//" + c + " extends " + tag.text() + "\n" + - "\t" + relationNode(from, tag.text()) + " -> " + relationNode(c) + " [dir=back,arrowtail=empty];"); + "\t" + relationNode(from, tag.text()) + " -> " + relationNode(c) + " [" + RelationType.EXTENDS.style + "];"); getClassInfo(className).addRelation(tag.text(), RelationType.EXTENDS, RelationDirection.OUT); getClassInfo(tag.text()).addRelation(className, RelationType.EXTENDS, RelationDirection.IN); } @@ -642,9 +633,8 @@ class ClassGraph { for (Type iface : c.interfaceTypes()) { ClassDoc ic = iface.asClassDoc(); if (!hidden(ic)) { - w.println("\t//" + c + " implements " + ic + "\n\t" + - relationNode(ic) + " -> " + relationNode(c) + " [dir=back,arrowtail=empty,style=dashed];" - ); + w.println("\t//" + c + " implements " + ic + "\n\t" + relationNode(ic) + " -> " + relationNode(c) + + " [" + RelationType.IMPLEMENTS.style + "];"); getClassInfo(className).addRelation(ic.toString(), RelationType.IMPLEMENTS, RelationDirection.OUT); getClassInfo(ic.toString()).addRelation(className, RelationType.IMPLEMENTS, RelationDirection.IN); } diff --git a/src/main/java/org/umlgraph/doclet/RelationType.java b/src/main/java/org/umlgraph/doclet/RelationType.java index ba4eeb5..7965b68 100644 --- a/src/main/java/org/umlgraph/doclet/RelationType.java +++ b/src/main/java/org/umlgraph/doclet/RelationType.java @@ -1,16 +1,26 @@ package org.umlgraph.doclet; /** - * The type of relation that links two entities - * @author wolf + * The type of relation that links two entities, and the graphviz format * + * @author Erich Schubert */ public enum RelationType { - ASSOC(), NAVASSOC(), HAS(), NAVHAS(), COMPOSED(), NAVCOMPOSED(), DEPEND(), EXTENDS(), IMPLEMENTS(); + ASSOC("arrowhead=none"), // + NAVASSOC("arrowhead=open"), // + HAS("arrowhead=none, arrowtail=ediamond, dir=both"), // + NAVHAS("arrowhead=open, arrowtail=ediamond, dir=both"), // + COMPOSED("arrowhead=none, arrowtail=diamond, dir=both"), // + NAVCOMPOSED("arrowhead=open, arrowtail=diamond, dir=both"), // + DEPEND("arrowhead=open, style=dashed"), // + EXTENDS("arrowtail=empty, dir=back"), // + IMPLEMENTS("arrowtail=empty, dir=back, style=dashed"); - public final String lower; + public final String lower, style; - private RelationType() { - this.lower = toString().toLowerCase(); + /** Enum constructors must be private */ + private RelationType(String style) { + this.lower = toString().toLowerCase(); + this.style = style; } }