From d0f1b4e7b7f55d1c589268d739ee48d1686326c9 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Mon, 6 Feb 2006 22:40:29 +0000 Subject: [PATCH] Factorized style application in renderer::dot This is much more generic really. Must think about a suitable place to move it to. --- lib/graphincludes/renderer/dot.pm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/graphincludes/renderer/dot.pm b/lib/graphincludes/renderer/dot.pm index 45cc79f..9edec4f 100644 --- a/lib/graphincludes/renderer/dot.pm +++ b/lib/graphincludes/renderer/dot.pm @@ -97,6 +97,17 @@ sub _edge_stylestring { join ',', @attrs; } +# apply sequence of stylers on an object +# FIXME: move to where ? +sub style { + my ($object, $graphnode, $stylers) = @_; + my $style = {}; + foreach my $styler (@$stylers) { + $styler->apply($object, $graphnode, $style); + } + return $style; +} + sub printgraph { my $self = shift; my ($graphnode, $nodestylers, $edgestylers) = @_; @@ -115,20 +126,12 @@ sub printgraph { print "strict digraph dependencies {\nrankdir=LR;\n"; foreach my $node ($graph->get_nodes) { - my $style = {}; - foreach my $styler (@$nodestylers) { - $styler->apply($node, $graphnode, $style); - } - print "\"$node->{LABEL}\" [", _node_stylestring($node, $style), "]\n"; + print "\"$node->{LABEL}\" [", _node_stylestring($node, style($node, $graphnode, $nodestylers)), "]\n"; } foreach my $file ($graph->get_edge_origins) { foreach my $edge ($graph->get_edges_from($file)) { - my $style = {}; - foreach my $styler (@$edgestylers) { - $styler->apply($edge, $graphnode, $style); - } - print "\"$file\" -> \"$edge->{DST}{LABEL}\" [", _edge_stylestring($edge, $style), "]\n"; + print "\"$file\" -> \"$edge->{DST}{LABEL}\" [", _edge_stylestring($edge, style($edge, $graphnode, $edgestylers)), "]\n"; } } -- 2.11.4.GIT