Tk-GraphViz

 view release on metacpan or  search on metacpan

lib/Tk/GraphViz.pm  view on Meta::CPAN

# -*-Perl-*-
package Tk::GraphViz;

use strict;
use warnings;

our $VERSION = '1.10';

use Tk 800.020;
use Tk::Font;
use Tk::IO;

use base qw(Tk::Derived Tk::Canvas);

use IO qw(Handle File Pipe);
use Carp;

use IPC::Open3;
use POSIX qw( :sys_wait_h :errno_h );
use Fcntl;
use Text::ParseWords qw(parse_line);

# Initialize as a derived Tk widget
Construct Tk::Widget 'GraphViz';


######################################################################
# Class initializer
#
######################################################################
sub ClassInit
{
  my ($class, $mw) = @_;


  $class->SUPER::ClassInit($mw);
}


######################################################################
# Instance initializer
#
######################################################################
sub Populate
{
  my ($self, $args) = @_;

  $self->SUPER::Populate($args);


  # Default resolution, for scaling
  $self->{dpi} = 72;
  $self->{margin} = .15 * $self->{dpi};

  # Keep track of fonts used, so they can be scaled
  # when the canvas is scaled
  $self->{fonts} = {};
}


######################################################################
# Show a GraphViz graph
#
# Major steps:
# - generate layout of the graph, which includes
#   locations / color info
# - clear canvas
# - parse layout to add nodes, edges, subgraphs, etc
# - resize to fit the graph
######################################################################
sub show
{
  my ($self, $graph, %opt) = @_;



( run in 0.890 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )