Skip to content

michal-josef-spacek/SCPN-Schema-GraphViz

Repository files navigation

NAME
    SCPN::Schema::GraphViz - Class for drawing SCPN::Schema via GraphViz.

SYNOPSIS
     use SCPN::GraphViz;
     my $obj = SCPN::GraphViz->new(%params);
     $obj->to_png($scpn_schema, $output_png_file);

METHODS
    "new(%params)"
             Constructor.

            *       "graph_title"

                     Graph title.
                     Default value is 'Petri net'.

            *       "rank_dir"

                     Rank direction.
                     Default value is 'LR'.

            *       "print_titles"

                     Print titles.
                     Default value is 0.

    "to_png($scpn_schema)"
             Generate diagram to PNG file via GraphViz.
             Returns GraphViz object.

ERRORS
     new():
             From Class::Utils::set_params():
                     Unknown parameter '%s'.

     to_png():
             to_png: Bad SCPN::Schema object.

EXAMPLE
     use strict;
     use warnings;

     use SCPN::Schema;
     use SCPN::Schema::GraphViz;
     use File::Temp;
     use IO::Barf qw(barf);

     # Schema.
     my $schema = <<'END';
     {
             "events":{
                     "copier":{
                             "input_edges":[
                                     {"condition":"entry_point_condition"}
                             ],
                             "output_edges":[
                                     {"condition":"copy_resutls", "count":3}
                             ]
                     }
             },
             "case":{
                     "entry_point_condition":{
                             "init_config":{"value":"bullet"}
                     }
             }
     }
     END
     my $temp1 = File::Temp->new->filename;
     barf($temp1, $schema);

     # Schema object.
     my $scpn_schema = SCPN::Schema->new;
     $scpn_schema->build_schema_from_json($temp1);
     unlink $temp1;

     # Object.
     my $obj = SCPN::Schema::GraphViz->new;

     # Generate PNG file.
     my $temp2 = File::Temp->new->filename;
     $obj->to_png($scpn_schema, $temp2);

     # List file.
     system('ls -l '.$temp2);

     # Output like:
     # -rw-r--r-- 1 skim skim 508 Nov 29 22:13 /tmp/PsYcWWsZmI

DEPENDENCIES
    Class::Utils, GraphViz2, Mojo::Exception, Scalar::Util.

AUTHOR
    Michal Josef Špaček <mailto:skim@cpan.org>

    <http://skim.cz>

LICENSE AND COPYRIGHT
     © Michal Špaček 2017
     BSD 2-Clause License

VERSION
    0.01

About

Class for GraphViz image from SCPN schema.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages