Skip to content
Snippets Groups Projects
Commit 7f1f70f7 authored by Thomas's avatar Thomas
Browse files

added Datastructure for creating PlantUML outputs

parent 61b0c71d
Branches
No related tags found
No related merge requests found
aspect DGtoDotG {
syn DotGraph DependencyGraph.dotGraph() {
DotGraph dg = new DotGraph();
//create DotGraph
dg.setDependencyGraph(this);
Map<Component,DotNode> componentMap = new HashMap<>();
for (Component component: getComponentList()) {
DotNode n = new DotNode();
n.setComponent(component);
dg.addDotNode(n);
componentMap.put(component, n);
}
for (Component from: getComponentList()) {
for (Component to: from.getToList()) {
if (to.getToList().contains(from)) {
if (to.hashCode() < from.hashCode()) {
componentMap.get(from).addRel(componentMap.get(to));
}
} else {
componentMap.get(from).addRef(componentMap.get(to));
}
}
}
return dg;
}
syn DotGraph DependencyGraph.dotGraph(Set<Component> components) {
DotGraph dg = new DotGraph();
//Ensure that components are part of DependencyGraph
Set<Component> subset=new HashSet();
for (Component c:getComponentList())
subset.add(c);
subset.retainAll(components);
//create DotGraph
dg.setDependencyGraph(this);
Map<Component,DotNode> componentMap = new HashMap<>();
for (Component component: subset) {
DotNode n = new DotNode();
n.setComponent(component);
dg.addDotNode(n);
componentMap.put(component, n);
}
for (Component from: subset) {
for (Component to: from.getToList()) {
if (subset.contains(to)) {
if (to.getToList().contains(from)) {
if (to.hashCode() < from.hashCode()) {
componentMap.get(from).addRel(componentMap.get(to));
}
} else {
componentMap.get(from).addRef(componentMap.get(to));
}
}
}
}
return dg;
}
}
rel DotGraph.DependencyGraph -> DependencyGraph;
rel DotNode.Component -> Component;
aspect DotGraphToPlantUML {
inh String DotNode.name();
eq DotGraph.getDotNode(int i).name() = "v" + i;
syn String DotNode.label() = name();
// syn String CycleGraph.toDot() {
// StringBuilder b = new StringBuilder();
// b.append("strict digraph cycles {\n");
// for (Vertex from: getVertexList()) {
// b.append(" ").append(from.name()).append("[label=\"").append(from.label()).append("\"];\n");
// for (Vertex to: from.getRefList()) {
// b.append(" ").append(from.name()).append(" -> ").append(to.name()).append(";\n");
// }
// for (Vertex to: from.getRelList()) {
// b.append(" ").append(from.name()).append(" -> ").append(to.name()).append("[dir=\"both\"];\n");
// }
// }
// b.append("}\n");
// return b.toString();
// }
syn String DotGraph.toPlant(String shape, String relation) {
StringBuilder b = new StringBuilder();
b.append("@startuml\n")
.append("hide circle\n")
.append("skinparam shadowing false\n")
.append("skinparam monochrome true\n")
.append("skinparam classAttributeIconSize 0\n")
.append("/'Remove automatic namespace generation'/\n")
.append("set namespaceSeparator none\n");
for (DotNode from: getDotNodeList()) {
b.append(shape).append(" ")
.append(from.label()).append("\n");
}
for (DotNode from: getDotNodeList()) {
for (DotNode to: from.getRefList()) {
b.append(from.label())
.append(" ").append(relation).append("> ")
.append(to.label()).append("\n");
}
for (DotNode to: from.getRelList()) {
b.append(from.label())
.append(" <").append(relation).append("> ")
.append(to.label()).append("\n");
}
}
b.append("@enduml\n");
return b.toString();
}
}
DotGraph ::= DotNode*;
DotNode;
rel DotNode.Ref* -> DotNode;
rel DotNode.Rel* -> DotNode;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment