Catalyst::Helper::View::GraphView - Helper for GraphView Views


Catalyst-View-GraphViz documentation Contained in the Catalyst-View-GraphViz distribution.

Index


Code Index:

NAME

Top

Catalyst::Helper::View::GraphView - Helper for GraphView Views

SYNOPSIS

Top

    script/create.pl view GraphView GraphView

DESCRIPTION

Top

Helper for GraphView Views.

METHODS

mk_compclass

SEE ALSO

Top

Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response, Catalyst::Helper

AUTHOR

Top

Johan Lindstrom, johanl@cpan.org

LICENSE

Top

This library is free software . You can redistribute it and/or modify it under the same terms as perl itself.

NAME

Top

[% class %] - Catalyst GraphView View

SYNOPSIS

Top

See [% app %]

DESCRIPTION

Top

Catalyst GraphView View.

METHODS

Top

process

Render the object specified in $c->stash->{graphview}->{object} and store the output in $c->response->output.

AUTHOR

Top

[% author %]

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


Catalyst-View-GraphViz documentation Contained in the Catalyst-View-GraphViz distribution.
package Catalyst::Helper::View::GraphView;

use strict;

sub mk_compclass {
    my ( $self, $helper ) = @_;
    my $file = $helper->{file};
    $helper->render_file( 'compclass', $file );
}

1;

__DATA__

__compclass__
package [% class %];

use strict;
use base 'Catalyst::View';

sub process {
    my ($self, $c) = @_;


    #This is an example. Adjust to your needs.


    #1. This is your model object containing the abstract graph you are about
    #   to render into a GraphViz object.
    my $graph = $c->stash->{graphview}->{object} or die('No object specified in $c->stash->{graphview}->{object} for rendering');


    #2. Render the model object. This is your View code where you adapt the
    #   look of the graph (node shape, color, etc.)
    my $graphViz = GraphViz->new(node => {
        fontname => "Verdana", fontsize => 7,
        name => "graph",
    });
    $graphViz->add_node("something from $graph", shape => "triangle", color => "black");


    #3. Forward to the GraphViz View
    $c->stash->{graphviz}->{graph} = $graphViz;
    $c->forward('[% app %]::V::GraphViz');


    if($c->res->content_type eq "text/plain") {   #imap
        #4. You may want to post-process imagemap output
        #   Transform it here using something more interesting
        #   than lc(). Useful e.g. for adding javascript events.
        $c->response->body( lc( $c->response->body ) ); 
    }

    return 1;
}





1;