diff --git a/src/main/java/kieker/analysis/util/graph/export/dot/DotElementExporter.java b/src/main/java/kieker/analysis/util/graph/export/dot/DotElementExporter.java index 0a3b9a8a2c09a8bb56bbe5514f94e83d07c214f6..472d713e45e54d68349d5d4ab03df443934d55bf 100644 --- a/src/main/java/kieker/analysis/util/graph/export/dot/DotElementExporter.java +++ b/src/main/java/kieker/analysis/util/graph/export/dot/DotElementExporter.java @@ -1,10 +1,10 @@ package kieker.analysis.util.graph.export.dot; import java.io.IOException; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.function.Function; -import java.util.stream.Collectors; import kieker.analysis.util.graph.Direction; import kieker.analysis.util.graph.Edge; @@ -13,6 +13,8 @@ import kieker.analysis.util.graph.Vertex; import kieker.analysis.util.graph.export.AbstractTransformer; import kieker.analysis.util.graph.util.dot.DotGraphWriter; 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.DotNodeAttribute; class DotElementExporter extends AbstractTransformer<Void> { @@ -42,7 +44,7 @@ class DotElementExporter extends AbstractTransformer<Void> { dotGraphWriter.addClusterStop(); } else { - // dotGraphWriter.addNode(vertex.getId().toString(), getAttributes(vertex)); + dotGraphWriter.addNode(vertex.getId().toString(), getAttributes(vertex)); } } catch (IOException e) { handleIOException(e); @@ -67,19 +69,25 @@ class DotElementExporter extends AbstractTransformer<Void> { } protected Map<String, String> getAttributes(final Edge edge) { - // System.out.println("Hi!" + configuration.getEdgeAttributes().entrySet().stream().collect(Collectors.toMap( - // e -> e.getKey().toString(), - // e -> null))); - // return null; // TODO temp - return configuration.getEdgeAttributes().entrySet().stream().collect(Collectors.toMap( - e -> e.getKey().toString(), - e -> e.getValue().apply(edge))); + final Map<String, String> attributes = new HashMap<>(); + for (Entry<DotEdgeAttribute, Function<Edge, String>> entry : configuration.getEdgeAttributes().entrySet()) { + final String value = entry.getValue().apply(edge); + if (value != null) { + attributes.put(entry.getKey().toString(), value); + } + } + return attributes; } protected Map<String, String> getAttributes(final Vertex vertex) { - return configuration.getNodeAttributes().entrySet().stream().collect(Collectors.toMap( - e -> e.getKey().toString(), - e -> e.getValue().apply(vertex))); + final Map<String, String> attributes = new HashMap<>(); + for (Entry<DotNodeAttribute, Function<Vertex, String>> entry : configuration.getNodeAttributes().entrySet()) { + final String value = entry.getValue().apply(vertex); + if (value != null) { + attributes.put(entry.getKey().toString(), value); + } + } + return attributes; } @Override