NAME GraphViz2::Abstract::Edge - Deal with edges independent of a Graph VERSION version 0.001000 SYNOPSIS use GraphViz2::Abstract::Edge; my $edge = GraphViz2::Abstract::Edge->new( color => ... , id => ... , label => ... , ); # Mutate $edge $edge->label("Asdft"); my $fillcolor = $edge->fillcolor(); # Knows that the fill color is light grey despite never setting it. # Later: $graph->add_edge(from => a => to => b => %{ $edge->as_hash }); # Adds only the data that is not the same as GraphViz's defaults $graph->add_edge(from => a => to => b => %{ $edge->as_canon_hash }); # Adds all the data, including hardcoded defaults DESCRIPTION Working with GraphViz2, I found myself frequently needing shared styles for things, and I often had trouble knowing which fields were and weren't valid for given things, for instance: "Edge"s. Its reasonably straight forward to ask the question "What is the attribute "foo" applicable to" using the GraphViz website, but much harder to know "What are all the attributes applicable to "foo"". Let alone work with them in a user friendly way from code. Naming Rationale I tried to choose a name that was not so likely to threaten GraphViz2 if GraphViz2 wanted to make a different variation of what I'm doing, but as part of GraphViz2 itself. As such, I plan on a few "::Abstract" things, that aim to be stepping stones for dealing with complex data independent of "GraphViz2", but in such a way that they make importing that data into "GraphViz2" easy. METHODS "as_hash" This method returns all the values of all properties that DIFFER from the defaults. e.g. Edge->new( color => 'black' )->as_hash(); Will return an empty list, as the default color is normally black. See note about "Special Values" "as_canon_hash" This method returns all the values of all properties, INCLUDING defaults. e.g. Edge->new( color => 'black' )->as_canon_hash(); Will return a very large list containing all the properties that we know the default values for. See note about "Special Values" ATTRIBUTES "URL" Default: "none" "arrowhead" Default: 'normal' "arrowsize" Default: 0.0 "arrowtail" Default: 'normal' "color" Default: 'black' "colorscheme" Default: "" "comment" Default: "" "constraint" Default: "true" "decorate" Default: "false" "dir" Default: "unknown" "edgeURL" Default: "" "edgehref" Default: "" "edgetarget" Default: "none" "edgetooltip" Default: "" "fillcolor" Default: "unknown" "fontcolor" Default: 'black' "fontname" Default: 'Times-Roman' "fontsize" Default: 14.0 "headURL" Default: "" "head_lp" Default: "unknown" "headclip" Default: "true" "headhref" Default: "" "headlabel" Default: "" "headport" Default: 'center' "headtarget" Default: "none" "headtooltip" Default: "" "href" Default: "" "id" Default: "" "label" Default: "" "labelURL" Default: "" "labelangle" Default: -25.0 "labeldistance" Default: 1.0 "labelfloat" Default: "false" "labelfontcolor" Default: 'black' "labelfontname" Default: 'Times-Roman' "labelfontsize" Default: 14.0 "labelhref" Default: "" "labeltarget" Default: "none" "labeltooltip" Default: "" "layer" Default: "" "len" Default: "unknown" Reason: back-end dependent "lhead" Default: "" "lp" Default: "unknown" "ltail" Default: "" "minlen" Default: 1 "nojustify" Default: "false" "penwidth" Default: 1.0 "pos" Default: "unknown" "samehead" Default: "" "sametail" Default: "" "showboxes" Default: 0 "style" Default: "" "tailURL" Default: "" "tail_lp" Default: "unknown" "tailclip" Default: "true" "tailhref" Default: "" "taillabel" Default: "" "tailport" Default: 'center' "tailtarget" Default: "none" "tailtooltip" Default: "" "target" Default: "none" "tooltip" Default: "" "weight" Default: 1 "xlabel" Default: "" "xlp" Default: "unknown" SPECIAL VALUES In the specification, on, there are a number of special values which represent a fundamental incompatibility with native Perl code. * "false" Where the specification shows "false" as a default value, this module instead returns the string "false" This is because under the hood, GraphViz2 doesn't support values for attributes other than defined ones. So its assumed that GraphViz, under the hood, interprets the string "false" the same as the boolean condition "false"; * "true" Where the specification shows "true" as a default value, this module instead returns the string "true" Its assumed that GraphViz, under the hood, interprets the string "true" the same as the boolean condition "true", for similar reasons "false" is. * "NONE" In the GraphViz docs, a few items have a default value specified as: This item was confusing in the specification, and it wasn't clear if it was some sort of magic string, or what. Internally, we use a special value, a reference to a string "none" to represent this default. For instance: my $v = Edge->new()->target(); ok( ref $v, 'target returned a ref' ); is( ref $v, 'SCALAR', 'target returned a scalar ref' ); is( ${ $v }, 'none', 'target returned a scalar ref of "none"' ); However, because its not known how to canonicalize such forms, those values are presently not returned by either "as_hash" methods. So as a result: my $v = Edge->new( color => \"none" )->as_hash() Will emit an empty hash. ( Despite "none" being different from the default ). Also: my $v = Edge->new( color => \"none" )->as_canon_hash() Will not emit a value for "color" in its output, which may have the undesirable effect of reverting to the default, "black" once rendered. * "UNKNOWN" On the GraphViz documentations, there were quite a few fields where the defaults were simply not specified, or their values were cryptic. Internally, those fields have the default value of "\"unknown"" Like "none", those fields with those values will not be emitted during hash production. AUTHOR Kent Fredric COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Kent Fredric . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.