File: Dependancy.pm

package info (click to toggle)
autodia 2.14-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 508 kB
  • sloc: perl: 6,102; makefile: 13
file content (158 lines) | stat: -rw-r--r-- 3,295 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
################################################################
# AutoDIAL - Automatic Dia XML.   (C)Copyright 2001 A Trevena  #
#                                                              #
# AutoDIAL comes with ABSOLUTELY NO WARRANTY; see COPYING file #
# This is free software, and you are welcome to redistribute   #
# it under certain conditions; see COPYING file for details    #
################################################################
package Autodia::Diagram::Dependancy;

use strict;

use vars qw($VERSION @ISA @EXPORT);
use Exporter;
use Autodia::Diagram::Object;

use Data::Dumper;

@ISA = qw(Autodia::Diagram::Object);

my $dependancy_count = 0;

#---------------------------------------------------------------------
# Constructor Methods

sub new
{
  my $class = shift;
  my $child = shift;
  my $parent = shift;
  my $DiagramDependancy = {};
  bless ($DiagramDependancy, ref($class) || $class);
  $DiagramDependancy->_initialise($child, $parent);
  return $DiagramDependancy;
}

#-----------------------------------------------------------------------
# Access Methods

sub Parent
{
  my $self = shift;
  my $parent = shift;
  my $return_val = 1;

  if (defined $parent)
  { $self->{"parent"} = $parent; }
  else
  { $return_val = $self->{"parent"}; }

  return $return_val;
}

sub Child
{
  my $self = shift;
  my $child = shift;
  my $return_val = 1;

  if (defined $child)
  { $self->{"child"} = $child; }
  else
  { $return_val = $self->{"child"}; }

  return $return_val;
}

sub Name
{
  my $self = shift;
  my $name = shift;

  if (defined $name)
    {
      $self->{"name"} = $name;
      return 1;
    }
  else
    { return $self->{"name"}; }
}

sub Orth_Top_Right
{
  my $self = shift;
  return $self->{"top_connection"};
}

sub Orth_Bottom_Left
{
  my $self = shift;
  return $self->{"bottom_connection"};
}

sub Orth_Mid_Left
{
  my $self = shift;
  my $return = ($self->{"left_x"}). "," . $self->{"mid_y"};

  return $return;
}

sub Orth_Mid_Right
{
  my $self = shift;
  my $return = ($self->{"right_x"}). "," . $self->{"mid_y"};

  return $return;
}

sub Reposition
{
  my $self = shift;

  my $child =  $self->{"_child"};

  my ($left_x,$bottom_y) = split (",",$child->TopLeftPos);
  my $mid_y = $bottom_y - 1.5;
  my $top_y= $mid_y - 1.5;
  $left_x += 2 + ($child->Width / 2);
  my $right_x = $left_x + 5;

  $self->{"left_x"} = $left_x;
  ($self->{"right_x"}, $self->{"top_y"},
   $self->{"mid_y"}, $self->{"bottom_y"}) = ($right_x, $top_y, $mid_y, $bottom_y);
  $self->{"top_connection"} = $self->{right_x} . "," . $self->{"top_y"};
  $self->{"bottom_connection"} = $left_x . "," . $bottom_y;

  return 1;
}

#-----------------------------------------------------------
# Internal Methods

sub _initialise # over-rides method in DiagramObject
{
  my $self = shift;
  my $child = shift;
  my $parent = shift;

  $self->{"_child"} = $child;
  $self->{"child"} = $child->Id;
  $self->{"type"} = "dependancy";
  $self->{"_parent"} = $parent;
  $self->{"parent"} = $parent->Id;
  $self->{"name"} = $self->{"parent"}."-".$self->{"child"};

  return 1;
}

sub _update # over-rides method in DiagramObject
  {
    my $self = shift;
    $self->Reposition();
    return 1;
  }

1;

############################################################################