Introduce styler objects, and the DEPS::Styler::Node::Group class that brings colorin...
[deps.git] / lib / graphincludes / renderer / tulip.pm
blobaf161d5c16604f02759148e4df8df249ed7c2101
1 # This file is part of the DEPS/graph-includes package
3 # (c) 2005,2006 Yann Dirson <ydirson@altern.org>
4 # Distributed under version 2 of the GNU GPL.
6 package graphincludes::renderer::tulip;
8 use warnings;
9 use strict;
11 use base qw(graphincludes::renderer);
12 use Hash::Util qw(lock_keys);
14 use graphincludes::params;
16 sub new {
17 my $class = shift;
18 my $self = {};
20 bless ($self, $class);
21 lock_keys (%$self);
22 return $self;
25 sub printgraph {
26 my $self = shift;
27 my ($graph, $nodestylers, $edgestylers) = @_;
29 # give unique numeric IDs to nodes, starting at 1
31 my $nodecount = 0;
32 my %nodeids;
34 foreach my $node ($graph->get_nodes) {
35 my $label = $node->{LABEL};
36 unless (defined $nodeids{$label}) {
37 $nodecount++;
38 $nodeids{$label} = $nodecount;
42 # declare nodes
44 print '(nodes';
45 for (my $i=1; $i<=$nodecount; $i++) {
46 print " ", $i;
48 print ")\n";
50 # set node labels
52 print "(property 0 string \"viewLabel\"\n";
53 print " (default \"\" \"\" )\n";
54 foreach my $node (keys %nodeids) {
55 print " (node $nodeids{$node} \"$node\")\n";
57 print ")\n";
60 # simple edges
62 my $edgecount = 0;
64 foreach my $file ($graph->get_edge_origins) {
65 foreach my $dest ($graph->get_dep_names_from($file)) {
66 $edgecount++;
67 print "(edge $edgecount ", $nodeids{$file}, ' ', $nodeids{$dest}, ")\n";
72 sub wait {