The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Graph::Renderer - draw the graph onto a real plane

SYNOPSIS

  my $graph = new Graph;
  ...

  use Graph::Layouter;
  Graph::Layouter::layout($graph);

  use Graph::Renderer;
  Graph::Renderer::render($graph, $img);

DESCRIPTION

This module provides an abstract class for drawing a given layouted graph (created usually by Graph::Layouter) through various image creation interfaces (GD, Imager).

All the relevant layouting information used for nodes positioning is load from the graph, as saved by Graph::Layouter (see its documentation for the relevant attributes description). In addition, relevant rendering information can be load from the graph attributes as well, if necessary and available.

This module contains only the abstract class, you will probably want to get an instance of some particular drawing tool interface instead; Graph::Renderer::Imager is bundled with this distribution. The general interface for all the subclasses is described below, but be sure consult also the particular class' documentation for remarks, special notes and specific extensions.

render()

This subroutine is the only entry point of this module, taking a given graph and rendering it accordingly to its attributes. The subroutine can be called in several ways:

Functional interface

The subroutine can be called as a function (it is not automatically exported, but you can import it on your own if you really want; see the synopsis above). It takes two parameters, the Graph class (or any descendant) instance and instance of the appropriate image object (see subclasses documentation). It will load the rendering information from graph's both global and per-vertex attributes.

Class constructor interface

TODO

Class method interface

TODO

The subroutine returns the image object if it all went well, undef otherwise.

The common rendering attributes not generated by the layouter are:

Global attributes
renderer_vertex_font

This should contain information about the font used for vertex titles; the specific format depends on the subclass. If this information is not made available by the caller, the given backend can try to figure it out but it might well fail.

Vertex attributes
renderer_vertex_font

This is identical to the global renderer_vertex_font attribute, but used only for the single vertex.

renderer_vertex_title

Title of the vertex, which is displayed nearby. The vertex number is displayed if no title is attached. You can attach an empty string to the vertex if you want no title shown at all.

SEE ALSO

Graph, Graph::Layouter

BUGS

The object-oriented interface is missing as well as some more universal render calling interface (hash parameters). Also, some more rendering attributes (ie. color settings, own dimensions) are missing.

COPYRIGHT

Copyright 2004 by Petr Baudis <pasky@ucw.cz>.

This code is distributed under the same copyright terms as Perl itself.

VERSION

Version 0.03

$Id: Renderer.pm,v 1.4 2006/02/11 17:11:39 pasky Exp $