From 867dec5d9c3cfb5d9cc10822a88109c668173e03 Mon Sep 17 00:00:00 2001 From: Erich Schubert Date: Sat, 27 Oct 2018 22:57:37 +0200 Subject: [PATCH] fixup dot formatting --- src/test/java/org/umlgraph/test/DotDiff.java | 23 +++---- testdata/dot-ref/Abstr.dot | 4 +- testdata/dot-ref/Inference.dot | 4 +- testdata/dot-ref/Irp.dot | 2 +- testdata/dot-ref/MyVector.dot | 8 +-- testdata/dot-ref/Root.dot | 8 +-- testdata/dot-ref/Style.dot | 4 +- testdata/dot-ref/ViewContext.dot | 68 ++++++++++---------- testdata/dot-ref/ViewInterfaces.dot | 8 +-- testdata/dot-ref/ViewSubclasses.dot | 44 ++++++------- testdata/dot-ref/advrel.dot | 6 +- testdata/dot-ref/catalina.dot | 24 +++---- testdata/dot-ref/class-eg.dot | 4 +- testdata/dot-ref/general.dot | 20 +++--- 14 files changed, 114 insertions(+), 113 deletions(-) diff --git a/src/test/java/org/umlgraph/test/DotDiff.java b/src/test/java/org/umlgraph/test/DotDiff.java index 6d3ea20..266981a 100644 --- a/src/test/java/org/umlgraph/test/DotDiff.java +++ b/src/test/java/org/umlgraph/test/DotDiff.java @@ -173,9 +173,8 @@ public class DotDiff { } else { // that's a node String attributes = line.substring(openBrackedIdx + 1, closedBracketIdx); Map attMap = parseAttributes(attributes); - String name = line.substring(0, openBrackedIdx - 1).trim(); - String label = attMap.get("label"); - DotNode node = new DotNode(name, label, attMap, line); + String name = trim(line.substring(0, openBrackedIdx - 1)); + DotNode node = new DotNode(name, attMap.get("label"), attMap, line); nodes.put(name, node); nodeList.add(node); } @@ -185,19 +184,21 @@ public class DotDiff { int closedBracketIdx = line.lastIndexOf(']'); String attributes = line.substring(openBrackedIdx + 1, closedBracketIdx); String[] names = line.substring(0, openBrackedIdx).split("->"); - DotNode from = nodes.get(names[0].trim()); - DotNode to = nodes.get(names[1].trim()); - if (from == null) { - from = new DotNode(names[0], "", new HashMap(), ""); - } - if (to == null) { - to = new DotNode(names[1], "", new HashMap(), ""); - } + DotNode from = nodes.get(names[0] = trim(names[0])); + DotNode to = nodes.get(names[1] = trim(names[1])); + from = from != null ? from : new DotNode(names[0], "", new HashMap(), ""); + to = to != null? to : new DotNode(names[1], "", new HashMap(), ""); arcs.add(new DotArc(from, to, parseAttributes(attributes), line)); } return extraLines; } + // Trim space AND port. + private String trim(String name) { + name = name.trim(); + return name.endsWith(":p") ? name.substring(0, name.length() - 2) : name; + } + private Map parseAttributes(String attributes) throws IOException { Map map = new HashMap(); diff --git a/testdata/dot-ref/Abstr.dot b/testdata/dot-ref/Abstr.dot index 1c79e51..df3ff36 100644 --- a/testdata/dot-ref/Abstr.dot +++ b/testdata/dot-ref/Abstr.dot @@ -16,11 +16,11 @@ c1 [label=<
InnerNode
>]; // test.Leaf c3 [label=<
Leaf
>]; -//test.InnerNode extends test.AbstractNode +// test.InnerNode extends test.AbstractNode c1:p -> c2:p [arrowtail=empty,dir=back,weight=10]; // test.InnerNode composed test.AbstractNode c2:p -> c1:p [arrowhead=none,arrowtail=diamond,dir=back,weight=6,taillabel="1", label="has", headlabel="*"]; -//test.Leaf extends test.AbstractNode +// test.Leaf extends test.AbstractNode c1:p -> c3:p [arrowtail=empty,dir=back,weight=10]; } diff --git a/testdata/dot-ref/Inference.dot b/testdata/dot-ref/Inference.dot index 2914986..5f09564 100644 --- a/testdata/dot-ref/Inference.dot +++ b/testdata/dot-ref/Inference.dot @@ -22,9 +22,9 @@ c69 [label=<
MyList
>]; // D c71 [label=<
D
anotherListOfA : MyList
>]; -//MyFunnyList extends java.util.ArrayList +// MyFunnyList extends java.util.ArrayList c72:p -> c69:p [arrowtail=empty,dir=back,weight=10]; -//MyList extends MyFunnyList +// MyList extends MyFunnyList c69:p -> c70:p [arrowtail=empty,dir=back,weight=10]; // A has B c66:p -> c67:p [arrowhead=none,arrowtail=ediamond,dir=back,weight=4]; diff --git a/testdata/dot-ref/Irp.dot b/testdata/dot-ref/Irp.dot index c23a426..4fb7d52 100644 --- a/testdata/dot-ref/Irp.dot +++ b/testdata/dot-ref/Irp.dot @@ -16,7 +16,7 @@ c74 [label=<
IrpApplication
>]; // Main c76 [label=<
Main
>]; -//IrpApplication extends Application +// IrpApplication extends Application c74:p -> c75:p [arrowtail=empty,dir=back,weight=10]; // Main depend IrpApplication c76:p -> c75:p [arrowhead=open,style=dashed,weight=0,label="«friend»"]; diff --git a/testdata/dot-ref/MyVector.dot b/testdata/dot-ref/MyVector.dot index 29c0127..e101790 100644 --- a/testdata/dot-ref/MyVector.dot +++ b/testdata/dot-ref/MyVector.dot @@ -12,13 +12,13 @@ nodesep=0.25; ranksep=0.5; // MyVector c85 [label=<
MyVector<E, P>
~ addAll(index : int, c : Collection<E>) : boolean
~ foo(x : MyVector<P, MyVector<E, E>>) : MyVector<E, P>
~ removeAll(c : Collection<?>) : boolean
~ set(index : int, element : E) : E
>]; -//MyVector extends java.util.Vector +// MyVector extends java.util.Vector c86:p -> c85:p [arrowtail=empty,dir=back,weight=10]; -//MyVector implements java.util.List +// MyVector implements java.util.List c87:p -> c85:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//MyVector implements java.util.RandomAccess +// MyVector implements java.util.RandomAccess c88:p -> c85:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//MyVector implements java.lang.Cloneable +// MyVector implements java.lang.Cloneable c89:p -> c85:p [arrowtail=empty,style=dashed,dir=back,weight=9]; // java.util.RandomAccess c88 [label=<
«interface»
RandomAccess
>, URL="http://docs.oracle.com/javase/7/docs/api/java/util/RandomAccess.html"]; diff --git a/testdata/dot-ref/Root.dot b/testdata/dot-ref/Root.dot index 93499ea..3cc75b7 100644 --- a/testdata/dot-ref/Root.dot +++ b/testdata/dot-ref/Root.dot @@ -34,15 +34,15 @@ c90:p -> c94:p [arrowhead=none,weight=2,headlabel="0..n"]; c90:p -> c95:p [arrowhead=none,weight=2,headlabel="0..n"]; // Root assoc DataOperation c90:p -> c96:p [arrowhead=none,weight=2,headlabel="0..n"]; -//ObjectType extends Element +// ObjectType extends Element c92:p -> c93:p [arrowtail=empty,dir=back,weight=10]; -//ObjectMap extends Element +// ObjectMap extends Element c92:p -> c94:p [arrowtail=empty,dir=back,weight=10]; // ObjectMap has ObjectType c94:p -> c93:p [arrowhead=none,arrowtail=ediamond,dir=back,weight=4,taillabel="1..1", headlabel="1..1"]; -//Table extends Element +// Table extends Element c92:p -> c95:p [arrowtail=empty,dir=back,weight=10]; -//DataOperation extends Element +// DataOperation extends Element c92:p -> c96:p [arrowtail=empty,dir=back,weight=10]; } diff --git a/testdata/dot-ref/Style.dot b/testdata/dot-ref/Style.dot index f4a2200..22911a2 100644 --- a/testdata/dot-ref/Style.dot +++ b/testdata/dot-ref/Style.dot @@ -16,11 +16,11 @@ c112 [label=<
Composite
net.sf.whatever.test
>]; // net.sf.whatever.test.Style c114 [label=<
Style
net.sf.whatever.test
>]; -//net.sf.whatever.test.Composite extends net.sf.whatever.test.AbstractBase +// net.sf.whatever.test.Composite extends net.sf.whatever.test.AbstractBase c112:p -> c113:p [arrowtail=empty,dir=back,weight=10]; // net.sf.whatever.test.Composite composed from.Outer.Space.AlienClass c113:p -> c115:p [arrowhead=none,arrowtail=diamond,dir=back,weight=6,taillabel="1",label="has",headlabel="*"]; -//net.sf.whatever.test.Style extends net.sf.whatever.test.AbstractBase +// net.sf.whatever.test.Style extends net.sf.whatever.test.AbstractBase c112:p -> c114:p [arrowtail=empty,dir=back,weight=10]; // from.Outer.Space.AlienClass c115[label=<
AlienClass
from.Outer.Space
>]; diff --git a/testdata/dot-ref/ViewContext.dot b/testdata/dot-ref/ViewContext.dot index 134c5f9..869c42f 100644 --- a/testdata/dot-ref/ViewContext.dot +++ b/testdata/dot-ref/ViewContext.dot @@ -7,38 +7,38 @@ digraph G { graph [fontnames="svg"] edge [fontname="Helvetica",fontsize=10,labelfontname="Helvetica",labelfontsize=10,color="black"]; -node [fontname="Helvetica",fontcolor="black",fontsize=10,shape=plaintext]; -nodesep=0.25; -ranksep=0.5; -// gr.spinellis.context.classes.AClient -c424 [label=<
AClient
>]; -// gr.spinellis.context.classes.ASubclass -c426 [label=<
ASubclass
>]; -// gr.spinellis.context.classes.E -c427 [label=<
E
>]; -// gr.spinellis.context.classes.D -c429 [label=<
D
>]; -// gr.spinellis.context.classes.B -c432 [label=<
B
>]; -// gr.spinellis.context.classes.ABaseClass -c433 [label=<
ABaseClass
>]; -// gr.spinellis.context.classes.A -c434 [label=<
A
>]; -//gr.spinellis.context.classes.ASubclass extends gr.spinellis.context.classes.A -c434:p -> c426:p [arrowtail=empty,dir=back,weight=10]; -//gr.spinellis.context.classes.A extends gr.spinellis.context.classes.ABaseClass -c433:p -> c434:p [arrowtail=empty,dir=back,weight=10]; -// gr.spinellis.context.classes.D navassoc gr.spinellis.context.classes.A -c429:p -> c434:p [arrowhead=open,weight=1]; -// gr.spinellis.context.classes.A navassoc gr.spinellis.context.classes.B -c434:p -> c432:p [arrowhead=open,weight=1]; -// gr.spinellis.context.classes.A navassoc javax.swing.JComponent -c434:p -> c509:p [arrowhead=open,weight=1]; -// gr.spinellis.context.classes.AClient depend gr.spinellis.context.classes.A -c424:p -> c434:p [arrowhead=open,style=dashed,weight=0]; -// gr.spinellis.context.classes.A depend gr.spinellis.context.classes.E -c434:p -> c427:p [arrowhead=open,style=dashed,weight=0]; -// javax.swing.JComponent -c509 [label=<
JComponent
>, URL="http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html"]; +node [fontname="Helvetica",fontcolor="black",fontsize=10,shape=plaintext]; +nodesep=0.25; +ranksep=0.5; +// gr.spinellis.context.classes.AClient +c424 [label=<
AClient
>]; +// gr.spinellis.context.classes.ASubclass +c426 [label=<
ASubclass
>]; +// gr.spinellis.context.classes.E +c427 [label=<
E
>]; +// gr.spinellis.context.classes.D +c429 [label=<
D
>]; +// gr.spinellis.context.classes.B +c432 [label=<
B
>]; +// gr.spinellis.context.classes.ABaseClass +c433 [label=<
ABaseClass
>]; +// gr.spinellis.context.classes.A +c434 [label=<
A
>]; +// gr.spinellis.context.classes.ASubclass extends gr.spinellis.context.classes.A +c434:p -> c426:p [arrowtail=empty,dir=back,weight=10]; +// gr.spinellis.context.classes.A extends gr.spinellis.context.classes.ABaseClass +c433:p -> c434:p [arrowtail=empty,dir=back,weight=10]; +// gr.spinellis.context.classes.D navassoc gr.spinellis.context.classes.A +c429:p -> c434:p [arrowhead=open,weight=1]; +// gr.spinellis.context.classes.A navassoc gr.spinellis.context.classes.B +c434:p -> c432:p [arrowhead=open,weight=1]; +// gr.spinellis.context.classes.A navassoc javax.swing.JComponent +c434:p -> c509:p [arrowhead=open,weight=1]; +// gr.spinellis.context.classes.AClient depend gr.spinellis.context.classes.A +c424:p -> c434:p [arrowhead=open,style=dashed,weight=0]; +// gr.spinellis.context.classes.A depend gr.spinellis.context.classes.E +c434:p -> c427:p [arrowhead=open,style=dashed,weight=0]; +// javax.swing.JComponent +c509 [label=<
JComponent
>, URL="http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html"]; } - + diff --git a/testdata/dot-ref/ViewInterfaces.dot b/testdata/dot-ref/ViewInterfaces.dot index ddfd00d..4c258fb 100644 --- a/testdata/dot-ref/ViewInterfaces.dot +++ b/testdata/dot-ref/ViewInterfaces.dot @@ -20,13 +20,13 @@ c537 [label=<
«interface»
SubFace
>]; // gr.spinellis.iface.classes.Face c539 [label=<
«interface»
Face
>]; -//gr.spinellis.iface.classes.FarImplementor implements gr.spinellis.iface.classes.SubSubFace +// gr.spinellis.iface.classes.FarImplementor implements gr.spinellis.iface.classes.SubSubFace c537:p -> c534:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//gr.spinellis.iface.classes.DirectImplementor implements gr.spinellis.iface.classes.Face +// gr.spinellis.iface.classes.DirectImplementor implements gr.spinellis.iface.classes.Face c539:p -> c535:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//gr.spinellis.iface.classes.SubSubFace implements gr.spinellis.iface.classes.SubFace +// gr.spinellis.iface.classes.SubSubFace implements gr.spinellis.iface.classes.SubFace c538:p -> c537:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//gr.spinellis.iface.classes.SubFace implements gr.spinellis.iface.classes.Face +// gr.spinellis.iface.classes.SubFace implements gr.spinellis.iface.classes.Face c539:p -> c538:p [arrowtail=empty,style=dashed,dir=back,weight=9]; } diff --git a/testdata/dot-ref/ViewSubclasses.dot b/testdata/dot-ref/ViewSubclasses.dot index af02fd7..980de32 100644 --- a/testdata/dot-ref/ViewSubclasses.dot +++ b/testdata/dot-ref/ViewSubclasses.dot @@ -7,26 +7,26 @@ digraph G { graph [fontnames="svg"] edge [fontname="Helvetica",fontsize=10,labelfontname="Helvetica",labelfontsize=10,color="black"]; -node [fontname="Helvetica",fontcolor="black",fontsize=10,shape=plaintext]; -nodesep=0.25; -ranksep=0.5; -// gr.spinellis.subclass.classes.SubOneTwo -c580 [label=<
SubOneTwo
>]; -// gr.spinellis.subclass.classes.SubOneOne -c581 [label=<
SubOneOne
>]; -// gr.spinellis.subclass.classes.SubTwo -c582 [label=<
SubTwo
>]; -// gr.spinellis.subclass.classes.SubOne -c583 [label=<
SubOne
>]; -// gr.spinellis.subclass.classes.Super -c584 [label=<
Super
>]; -//gr.spinellis.subclass.classes.SubOneTwo extends gr.spinellis.subclass.classes.SubOne -c583:p -> c580:p [arrowtail=empty,dir=back,weight=10]; -//gr.spinellis.subclass.classes.SubOneOne extends gr.spinellis.subclass.classes.SubOne -c583:p -> c581:p [arrowtail=empty,dir=back,weight=10]; -//gr.spinellis.subclass.classes.SubTwo extends gr.spinellis.subclass.classes.Super -c584:p -> c582:p [arrowtail=empty,dir=back,weight=10]; -//gr.spinellis.subclass.classes.SubOne extends gr.spinellis.subclass.classes.Super -c584:p -> c583:p [arrowtail=empty,dir=back,weight=10]; +node [fontname="Helvetica",fontcolor="black",fontsize=10,shape=plaintext]; +nodesep=0.25; +ranksep=0.5; +// gr.spinellis.subclass.classes.SubOneTwo +c580 [label=<
SubOneTwo
>]; +// gr.spinellis.subclass.classes.SubOneOne +c581 [label=<
SubOneOne
>]; +// gr.spinellis.subclass.classes.SubTwo +c582 [label=<
SubTwo
>]; +// gr.spinellis.subclass.classes.SubOne +c583 [label=<
SubOne
>]; +// gr.spinellis.subclass.classes.Super +c584 [label=<
Super
>]; +// gr.spinellis.subclass.classes.SubOneTwo extends gr.spinellis.subclass.classes.SubOne +c583:p -> c580:p [arrowtail=empty,dir=back,weight=10]; +// gr.spinellis.subclass.classes.SubOneOne extends gr.spinellis.subclass.classes.SubOne +c583:p -> c581:p [arrowtail=empty,dir=back,weight=10]; +// gr.spinellis.subclass.classes.SubTwo extends gr.spinellis.subclass.classes.Super +c584:p -> c582:p [arrowtail=empty,dir=back,weight=10]; +// gr.spinellis.subclass.classes.SubOne extends gr.spinellis.subclass.classes.Super +c584:p -> c583:p [arrowtail=empty,dir=back,weight=10]; } - + diff --git a/testdata/dot-ref/advrel.dot b/testdata/dot-ref/advrel.dot index 7b41185..8dd6661 100644 --- a/testdata/dot-ref/advrel.dot +++ b/testdata/dot-ref/advrel.dot @@ -22,11 +22,11 @@ c8 [label=<
ChannelIterator
>]; // URLStreamHandler c10 [label=<
«interface»
URLStreamHandler
OpenConnection()
parseURL()
setURL()
toExternalForm()
>]; -//SetTopController extends Controller +// SetTopController extends Controller c5:p -> c8:p [arrowtail=empty,dir=back,weight=10]; -//SetTopController extends EmbeddedAgent +// SetTopController extends EmbeddedAgent c6:p -> c8:p [arrowtail=empty,dir=back,weight=10]; -//SetTopController implements URLStreamHandler +// SetTopController implements URLStreamHandler c10:p -> c8:p [arrowtail=empty,style=dashed,dir=back,weight=9]; // SetTopController navassoc PowerManager c8:p -> c7:p [arrowhead=open,weight=1]; diff --git a/testdata/dot-ref/catalina.dot b/testdata/dot-ref/catalina.dot index aabe46c..20eeb41 100644 --- a/testdata/dot-ref/catalina.dot +++ b/testdata/dot-ref/catalina.dot @@ -30,29 +30,29 @@ c26 [label=<
«interface»
ServletResponse
>]; // Response c28 [label=<
«interface»
Response
>]; -//HttpResponseBase extends ResponseBase +// HttpResponseBase extends ResponseBase c24:p -> c19:p [arrowtail=empty,dir=back,weight=10]; -//HttpResponseBase implements HttpResponse +// HttpResponseBase implements HttpResponse c23:p -> c19:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//HttpResponseBase implements HttpServletResponse +// HttpResponseBase implements HttpServletResponse c25:p -> c19:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//HttpResponseWrapper extends ResponseWrapper +// HttpResponseWrapper extends ResponseWrapper c22:p -> c20:p [arrowtail=empty,dir=back,weight=10]; -//HttpResponseWrapper implements HttpResponse +// HttpResponseWrapper implements HttpResponse c23:p -> c20:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//HttpResponseFacade extends ResponseFacade +// HttpResponseFacade extends ResponseFacade c26:p -> c21:p [arrowtail=empty,dir=back,weight=10]; -//HttpResponseFacade implements HttpServletResponse +// HttpResponseFacade implements HttpServletResponse c25:p -> c21:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//ResponseWrapper implements Response +// ResponseWrapper implements Response c28:p -> c22:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//HttpResponse implements Response +// HttpResponse implements Response c28:p -> c23:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//ResponseBase implements Response +// ResponseBase implements Response c28:p -> c24:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//ResponseBase implements ServletResponse +// ResponseBase implements ServletResponse c27:p -> c24:p [arrowtail=empty,style=dashed,dir=back,weight=9]; -//ResponseFacade implements ServletResponse +// ResponseFacade implements ServletResponse c27:p -> c26:p [arrowtail=empty,style=dashed,dir=back,weight=9]; } diff --git a/testdata/dot-ref/class-eg.dot b/testdata/dot-ref/class-eg.dot index e600e83..2cc6568 100644 --- a/testdata/dot-ref/class-eg.dot +++ b/testdata/dot-ref/class-eg.dot @@ -16,9 +16,9 @@ c30 [label=<
Employee
>]; // Client c32 [label=<
Client
>]; -//Employee extends Person +// Employee extends Person c30:p -> c31:p [arrowtail=empty,dir=back,weight=10]; -//Client extends Person +// Client extends Person c30:p -> c32:p [arrowtail=empty,dir=back,weight=10]; } diff --git a/testdata/dot-ref/general.dot b/testdata/dot-ref/general.dot index 0427864..40dd6d1 100644 --- a/testdata/dot-ref/general.dot +++ b/testdata/dot-ref/general.dot @@ -30,25 +30,25 @@ c62 [label=<
CheckingAccount
>]; // SavingsAccount c64 [label=<
SavingsAccount
>]; -//BankAccount extends Asset +// BankAccount extends Asset c55:p -> c58:p [arrowtail=empty,dir=back,weight=10]; -//BankAccount extends InsurableItem +// BankAccount extends InsurableItem c57:p -> c58:p [arrowtail=empty,dir=back,weight=10]; -//BankAccount extends InterestBearingItem +// BankAccount extends InterestBearingItem c56:p -> c58:p [arrowtail=empty,dir=back,weight=10]; -//RealEstate extends Asset +// RealEstate extends Asset c55:p -> c59:p [arrowtail=empty,dir=back,weight=10]; -//RealEstate extends InsurableItem +// RealEstate extends InsurableItem c57:p -> c59:p [arrowtail=empty,dir=back,weight=10]; -//Security extends Asset +// Security extends Asset c55:p -> c60:p [arrowtail=empty,dir=back,weight=10]; -//Stock extends Security +// Stock extends Security c60:p -> c61:p [arrowtail=empty,dir=back,weight=10]; -//Bond extends Security +// Bond extends Security c60:p -> c62:p [arrowtail=empty,dir=back,weight=10]; -//CheckingAccount extends BankAccount +// CheckingAccount extends BankAccount c58:p -> c63:p [arrowtail=empty,dir=back,weight=10]; -//SavingsAccount extends BankAccount +// SavingsAccount extends BankAccount c58:p -> c64:p [arrowtail=empty,dir=back,weight=10]; }