GraphItems.pm

filter: Statementstmt 42.8% 12 / 28 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 2 / 6 Podpod 75.0% 3 / 4 totaltotal 36.9% 17 / 46 CC 5 SCAR 16.1
CC
5
Cov
33%
TextBox
6.0
Connector
6.0
Circle
6.0
CRAP 5.0
« GraphItems/TiedCoord.pm ↑ Summary GraphItems/Examples/gi_easy.pl »
1 #!/usr/bin/perl
2  
3  
4  
5 =head1 NAME
6  
7 Tk::GraphItems - Display relation-graphs on a Tk::Canvas
8  
9 =head1 DESCRIPTION
10  
11 Tk::GraphItems provides objects TextBox, Circle and Connector to display nodes and edges of given relation-graph models on a Tk::Canvas widget.
12 Tk::GraphItems contain a dependency mechanism to ensure, that edges are updated on changes of position or size of their source- and target-nodes. Edges have view-properties like colour, width, direction(arrows). Nodes support (bg)colour and text (can be multiline). Nodes can be moved and placed programmatically or with drag/drop. To make integration into existing graph-implementations easier, Tk::GraphItems contains a simple tie-module to tie the nodes coords- getter-/setter - methods to given Variables in the underlying model. Bindings to Tk-Events can be set so it's easy to implement e.g. context-menus for the objects.
13  
14  
15  
16  
17 =head1 METHODS
18  
19 B<Tk::GraphItems> supports the following methods:
20  
21 =over 4
22  
23 =item B<TextBox(> canvas=>$can,
24 text=>"new_node",
25 x =>50,
26 y =>50 B<)>
27  
28 Create a new Tk::GraphItems::TextBox instance and display it on the Canvas.
29  
30 =item B<Circle(> canvas => $can,
31 colour => $a_TkColor,
32 size => $size_pixels,
33 x => 50,
34 y => 50 B<)>
35  
36 Create a new Tk::GraphItems::Circle instance and display it on the Canvas.
37  
38 =item B<Connector(> source=> $source_node, target=> $target_node B<)>
39  
40 Create a new Tk::GraphItems::Connector instance.
41  
42 =back
43  
44 =head1 SEE ALSO
45  
46 Documentation of Tk::GraphItems::TextBox, Tk::GraphItems::Connector and
47 Tk::GraphItems::Circle.
48  
49 =head2 Examples
50  
51 Examples can be found in Tk/GraphItems/Examples/
52  
53 =head3 gi_easy.pl
54  
55 Demonstrates how to set up mouse bindings to create nodes and edges. Adds a context menu binding to nodes.
56  
57 =head3 create_and_autolayout.pl
58  
59 Create a 'Graph' object by clicking/dragging and watch Graph::Layout::Aesthetic arranging the nodes.
60  
61  
62 =head1 AUTHOR
63  
64 Christoph Lamprecht, ch.l.ngre@online.de
65  
66 =head1 COPYRIGHT AND LICENSE
67  
68 Copyright (C) 2007 by Christoph Lamprecht
69  
70 This library is free software; you can redistribute it and/or modify
71 it under the same terms as Perl itself, either Perl version 5.8.7 or,
72 at your option, any later version of Perl 5 you may have available.
73  
74  
75 =cut
76 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
77 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 package Tk::GraphItems;
79 1 our $VERSION = '0.12';
80 1 require Tk::GraphItems::TextBox;
81 1 require Tk::GraphItems::Circle;
82 1 require Tk::GraphItems::Connector;
83 1 require Tk::GraphItems::LabeledConnector;
84  
85 0 ▶sub TextBox{
Subroutine TextBox: not called CC=2 SCAR=17.9
Pod documented
86 0 ▶ if ($_[0]){
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
87 0 shift;
88 0 return 'Tk::GraphItems::TextBox'->new(@_);
89 }
90 0 return 'Tk::GraphItems::TextBox';
91 }
92  
93 0 ▶sub Connector{
Subroutine Connector: not called CC=2 SCAR=17.9
Pod documented
94 0 ▶ if ($_[0]){
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
95 0 shift;
96 0 return 'Tk::GraphItems::Connector'->new(@_);
97 }
98 0 return 'Tk::GraphItems::Connector';
99 }
100 0 ▶sub Circle{
Subroutine Circle: not called CC=2 SCAR=17.9
Pod documented
101 0 ▶ if ($_[0]){
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
102 0 shift;
103 0 return 'Tk::GraphItems::Circle'->new(@_);
104 }
105 0 return 'Tk::GraphItems::Circle';
106 }
107 0 ▶sub LabeledConnector{
Subroutine LabeledConnector: not called CC=2 SCAR=17.9
Pod undocumented
108 0 ▶ if ($_[0]){
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 0 0 0
109 0 shift;
110 0 return 'Tk::GraphItems::LabeledConnector'->new(@_);
111 }
112 0 return 'Tk::GraphItems::LabeledConnector';
113 }
114 1 1;
« GraphItems/TiedCoord.pm ↑ Summary GraphItems/Examples/gi_easy.pl »