File Coverage

blib/lib/Autodia/Diagram/Inheritance.pm
Criterion Covered Total %
statement 12 74 16.2
branch 0 6 0.0
condition 0 3 0.0
subroutine 4 15 26.6
pod 0 9 0.0
total 16 107 14.9


line stmt bran cond sub pod time code
1             ################################################################
2             # Autodia - Automatic Dia XML. Copyright 2001 - 2008 A Trevena #
3             # #
4             # AutoDIA comes with ABSOLUTELY NO WARRANTY; see COPYING file #
5             # This is free software, and you are welcome to redistribute #
6             # it under certain conditions; see COPYING file for details #
7             ################################################################
8             package Autodia::Diagram::Inheritance;
9              
10 1     1   5 use strict;
  1         2  
  1         37  
11              
12 1     1   5 use vars qw($VERSION @ISA @EXPORT);
  1         3  
  1         63  
13 1     1   5 use Exporter;
  1         2  
  1         34  
14              
15 1     1   5 use Autodia::Diagram::Object;
  1         2  
  1         906  
16              
17             @ISA = qw(Autodia::Diagram::Object);
18              
19             my $inheritance_count = 0;
20              
21             #--------------------------------------------------------------------
22             # Constructor Methods
23              
24             sub new
25             {
26 0     0 0   my $class = shift;
27 0           my $child = shift;
28 0           my $parent = shift;
29 0           my $DiagramInheritance = {};
30              
31 0   0       bless ($DiagramInheritance, ref($class) || $class);
32 0           $DiagramInheritance->_initialise($child, $parent);
33              
34 0           return $DiagramInheritance;
35             }
36              
37              
38             #--------------------------------------------------------------------
39             # Access Methods
40              
41             sub Parent
42             {
43 0     0 0   my $self = shift;
44 0           my $parent = shift;
45 0           my $return_val = 1;
46              
47 0 0         if (defined $parent)
48 0           { $self->{"parent"} = $parent; }
49             else
50 0           { $return_val = $self->{"parent"}; }
51              
52 0           return $return_val;
53             }
54              
55             sub Child
56             {
57 0     0 0   my $self = shift;
58 0           my $child = shift;
59 0           my $return_val = 1;
60              
61 0 0         if (defined $child)
62 0           { $self->{"child"} = $child; }
63             else
64 0           { $return_val = $self->{"child"}; }
65              
66 0           return $return_val;
67             }
68              
69             sub Name
70             {
71 0     0 0   my $self = shift;
72 0           my $name = shift;
73              
74 0 0         if (defined $name)
75             {
76 0           $self->{"name"} = $name;
77 0           return 1;
78             }
79             else
80 0           { return $self->{"name"}; }
81             }
82              
83              
84             sub Orth_Top_Left
85             {
86 0     0 0   my $self = shift;
87 0           return $self->{"top_connection"};
88             }
89              
90             sub Orth_Bottom_Right
91             {
92 0     0 0   my $self = shift;
93 0           return $self->{"bottom_connection"};
94             }
95              
96             sub Orth_Mid_Left
97             {
98 0     0 0   my $self = shift;
99 0           my $return = ($self->{"left_x"}). "," . $self->{"mid_y"};
100              
101 0           return $return;
102             }
103              
104             sub Orth_Mid_Right
105             {
106 0     0 0   my $self = shift;
107 0           my $return = ($self->{"right_x"}). "," . $self->{"mid_y"};
108              
109 0           return $return;
110             }
111              
112             sub Reposition
113             {
114 0     0 0   my $self = shift;
115              
116 0           my $child = $self->{"_child"};
117              
118 0           my ($right_x,$bottom_y) = split (",",$child->TopLeftPos);
119 0           my $mid_y = $bottom_y - 1.5;
120 0           my $top_y= $mid_y - 1.5;
121              
122 0           $right_x += 2 + ($child->Width / 2);
123 0           my $left_x = $right_x - 5;
124              
125 0           $self->{"left_x"} = $left_x;
126 0           ($self->{"right_x"}, $self->{"top_y"},
127             $self->{"mid_y"}, $self->{"bottom_y"}) = ($right_x, $top_y, $mid_y, $bottom_y);
128 0           $self->{"top_connection"} = $self->{left_x} . "," . $self->{"top_y"};
129 0           $self->{"bottom_connection"} = $right_x . "," . $bottom_y;
130              
131 0           return 1;
132             }
133              
134              
135             #------------------------------------------------------
136             # Internal Methods
137              
138             sub _initialise # over-rides method in DiagramObject
139             {
140 0     0     my $self = shift;
141 0           my $child = shift;
142 0           my $parent = shift;
143              
144 0           $self->{"_child"} = $child;
145 0           $self->{"child"} = $child->Id;
146 0           $self->{"type"} = "inheritance";
147 0           $self->{"_parent"} = $parent;
148 0           $self->{"parent"} = $parent->Id;
149 0           $self->{"name"} = $self->{"parent"}."-".$self->{"child"};
150              
151 0           return 1;
152             }
153              
154             sub _update # over-rides method in DiagramObject
155             {
156 0     0     my $self = shift;
157 0           $self->reposition();
158 0           return 1;
159             }
160              
161             1;
162              
163             ##############################################################
164              
165             =head1
166              
167             =cut
168