Skip to content
Snippets Groups Projects
Commit ba601cc9 authored by Sören Henning's avatar Sören Henning
Browse files

worked on ConfigurationFactory for dot export

parent 2c8bf8b2
No related branches found
No related tags found
No related merge requests found
package kieker.analysis.dev.dependencygraphs; package kieker.analysis.dev.dependencygraphs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import kieker.analysis.util.graph.Vertex;
import kieker.analysis.util.graph.export.dot.DotExportConfiguration; import kieker.analysis.util.graph.export.dot.DotExportConfiguration;
import kieker.analysis.util.graph.util.dot.attributes.DotClusterAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotEdgeAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotGraphAttribute; import kieker.analysis.util.graph.util.dot.attributes.DotGraphAttribute;
import kieker.analysis.util.graph.util.dot.attributes.DotNodeAttribute;
public class DotDependencyGraphConfigurationFactory { public class DotDependencyGraphConfigurationFactory {
...@@ -10,6 +20,8 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -10,6 +20,8 @@ public class DotDependencyGraphConfigurationFactory {
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<assembly component>>"));
return configuration; return configuration;
} }
...@@ -18,6 +30,9 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -18,6 +30,9 @@ public class DotDependencyGraphConfigurationFactory {
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<assembly component>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper());
return configuration; return configuration;
} }
...@@ -25,6 +40,10 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -25,6 +40,10 @@ public class DotDependencyGraphConfigurationFactory {
DotExportConfiguration configuration = new DotExportConfiguration(); DotExportConfiguration configuration = new DotExportConfiguration();
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addEdgeAttribute(DotEdgeAttribute.LABEL, (e -> e.getProperty("calls").toString()));
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box3d");
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<execution container>>"));
return configuration; return configuration;
} }
...@@ -33,6 +52,11 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -33,6 +52,11 @@ public class DotDependencyGraphConfigurationFactory {
DotExportConfiguration configuration = new DotExportConfiguration(); DotExportConfiguration configuration = new DotExportConfiguration();
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addEdgeAttribute(DotEdgeAttribute.LABEL, (e -> e.getProperty("calls").toString()));
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "box");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper("<<deployment component>>"));
return configuration; return configuration;
} }
...@@ -41,8 +65,83 @@ public class DotDependencyGraphConfigurationFactory { ...@@ -41,8 +65,83 @@ public class DotDependencyGraphConfigurationFactory {
DotExportConfiguration configuration = new DotExportConfiguration(); DotExportConfiguration configuration = new DotExportConfiguration();
configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR"); configuration.addGraphAttribute(DotGraphAttribute.RANKDIR, g -> "LR");
configuration.addEdgeAttribute(DotEdgeAttribute.LABEL, (e -> e.getProperty("calls").toString()));
configuration.addDefaultNodeAttribute(DotNodeAttribute.SHAPE, g -> "oval");
configuration.addClusterAttribute(DotClusterAttribute.LABEL, new ClusterLabelMapper("<<execution container>>", "<<deployment component>>"));
configuration.addNodeAttribute(DotNodeAttribute.LABEL, new VertexLabelMapper());
return configuration; return configuration;
} }
private class VertexLabelMapper implements Function<Vertex, String> {
private final String annotation;
public VertexLabelMapper() {
this.annotation = "";
}
public VertexLabelMapper(final String annotation) {
this.annotation = annotation;
}
@Override
public String apply(final Vertex vertex) {
final StringBuilder statistics = new StringBuilder();
statistics.append(this.annotation);
statistics.append("\\n");
statistics.append(vertex.getProperty("Name").toString());
statistics.append("\\n");
statistics.append(generateStatistics(vertex));
return statistics.toString();
}
private String generateStatistics(final Vertex vertex) {
final String temporalUnit = "xs"; // TODO temp
final List<String> statisticStrings = new ArrayList<>(5);
if (vertex.getProperty("MinDuration") != null) {
statisticStrings.add("min: " + vertex.getProperty("MinDuration").toString() + temporalUnit);
}
if (vertex.getProperty("MaxDuration") != null) {
statisticStrings.add("max: " + vertex.getProperty("MaxDuration").toString() + temporalUnit);
}
if (vertex.getProperty("TotalDuration") != null) {
statisticStrings.add("total: " + vertex.getProperty("TotalDuration").toString() + temporalUnit);
}
if (vertex.getProperty("MeanDuration") != null) {
statisticStrings.add("avg: " + vertex.getProperty("MeanDuration").toString() + temporalUnit);
}
if (vertex.getProperty("MedianDuration") != null) {
statisticStrings.add("med: " + vertex.getProperty("MedianDuration").toString() + temporalUnit);
}
// If there are more than 3 statistics elements add a line break after the 3rd last
if (statisticStrings.size() > 3) {
final int thirdLast = statisticStrings.size() - 3;
statisticStrings.set(thirdLast, statisticStrings.get(thirdLast).concat("\\n"));
}
return statisticStrings.stream().collect(Collectors.joining(", "));
}
}
private class ClusterLabelMapper implements Function<Vertex, String> {
private final List<String> annotations;
public ClusterLabelMapper(final String... annotations) {
this.annotations = Arrays.asList(annotations);
}
@Override
public String apply(final Vertex vertex) {
// TODO Get "level" of this vertex
return this.annotations.get(0) + "\\n" + vertex.getProperty("Name").toString();
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment