From 65db0cfab26b12aa04e3845eb6a626c124f762e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <stu114708@informatik.uni-kiel.de> Date: Mon, 30 May 2016 14:10:20 +0200 Subject: [PATCH] fixed #39 --- .../graph/export/dot/DotElementExporter.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) 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 0a3b9a8a..472d713e 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 -- GitLab