Fixed tulip renderer to use current renderer API
[deps.git] / lib / graphincludes / renderer / tulip.pm
blobd8b23fd9d220e04c7ff0490cbeb6b4ab79dc9751
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 ($graphnode, $nodestylers, $edgestylers) = @_;
28 my $graph = eval { defined $graphnode->{DATA} } ? $graphnode->{DATA} : $graphnode;
30 # give unique numeric IDs to nodes, starting at 1
32 my $nodecount = 0;
33 my %nodeids;
35 foreach my $node ($graph->get_nodes) {
36 my $label = $node->{LABEL};
37 unless (defined $nodeids{$label}) {
38 $nodecount++;
39 $nodeids{$label} = $nodecount;
43 # declare nodes
45 print '(nodes';
46 for (my $i=1; $i<=$nodecount; $i++) {
47 print " ", $i;
49 print ")\n";
51 # set node labels
53 print "(property 0 string \"viewLabel\"\n";
54 print " (default \"\" \"\" )\n";
55 foreach my $node (keys %nodeids) {
56 print " (node $nodeids{$node} \"$node\")\n";
58 print ")\n";
61 # simple edges
63 my $edgecount = 0;
65 foreach my $file ($graph->get_edge_origins) {
66 foreach my $dest ($graph->get_dep_names_from($file)) {
67 $edgecount++;
68 print "(edge $edgecount ", $nodeids{$file}, ' ', $nodeids{$dest}, ")\n";
73 sub wait {