Label/EdgeLabel.pm

filter: Statementstmt 90.5% 67 / 74 Branchbran 50.0% 14 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 5 / 5 totaltotal 82.0% 96 / 117 CC 15 SCAR 25.3
CC
15
Cov
79%
_build
19.6
BEGIN
1.0
BEGIN
1.0
CRAP 12.6
« Label/NodeLabel.pm ↑ Summary Document.pm »
1 package yEd::Label::EdgeLabel;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use yEd::PropertyBasedObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base qw(yEd::Label);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 yEd::Label::EdgeLabel - Textlabels for Edges
10  
11 =head1 DESCRIPTION
12  
13 Use this class to label your Edges.
14  
15 Make sure to have a look at L<yEd::Label>, the properties and functions described there will not be repeated here.
16  
17 If you want to label a Node class element use L<yEd::Label::NodeLabel>.
18  
19 =head1 SUPPORTED FEATURES
20  
21 see L<yEd::Label>
22  
23 =head1 PROPERTIES
24  
25 =head2 all properties from base class
26  
27 L<yEd::Label>
28  
29 =head2 positionModell
30  
31 Type: descrete values ( see below )
32  
33 Default: 'two_pos-head'
34  
35 Describes how to position the Label on the Edge.
36  
37 =head3 free
38  
39 Free positioning (use C<x>, C<y> properties)
40  
41 =head3 two_pos-X
42  
43 Where X is one of:
44  
45 =over 4
46  
47 =item *
48  
49 head : Centered above line
50  
51 =item *
52  
53 tail : Centered below line
54  
55 =back
56  
57 =head3 centered
58  
59 Centered on line
60  
61 =head3 six_pos-X
62  
63 Where X is one of:
64  
65 =over 4
66  
67 =item *
68  
69 head : Centered above line
70  
71 =item *
72  
73 shead : At source above line
74  
75 =item *
76  
77 thead : At target above line
78  
79 =item *
80  
81 tail : Centered below line
82  
83 =item *
84  
85 stail : At source below line
86  
87 =item *
88  
89 ttail : At target below line
90  
91 =back
92  
93 =head3 three_center-X
94  
95 Where X is one of:
96  
97 =over 4
98  
99 =item *
100  
101 center : Centered on line
102  
103 =item *
104  
105 scentr : At source on line
106  
107 =item *
108  
109 tcentr : At target on line
110  
111 =back
112  
113 =head3 center_slider
114  
115 On the line position defined by ratio
116  
117 =head3 side_slider
118  
119 Above or below the line position defined by ratio and y value for above/below (?)
120  
121 =head2 ratio
122  
123 Type: ration (ufloat [0-1])
124  
125 Default: 0.5
126  
127 Defines the Label position for slider positioning modells, where 0 is at source, 1 is at target and 0.5 is centered.
128  
129 =head2 distance
130  
131 Type: float
132  
133 Default: 2
134  
135 Defines the distance of the Label from the Edge (may have no effect depending on positioning modell).
136  
137 =head2 autoFlip
138  
139 Type: bool
140  
141 Default: true
142  
143 Automatically flip the Label if it gets upside-down (because of effective direction of the Edge).
144  
145 =head1 SUBROUTINES/METHODS
146  
147 =head2 all functions from base class
148  
149 L<yEd::Label>
150  
151 =cut
152  
153 3 my $modellmatch = '^(?:free|two_pos-(?:head|tail)|centered|six_pos-(?:head|shead|thead|tail|stail|ttail)|three_center-(?:center|scentr|tcentr)|center_slider|side_slider)$';
154  
155 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
156 1 my ($class, @args) = @_;
157 1 my $self = bless {}, $class;
158 1 return $self->_init(@args);
159 }
160  
161 1 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
162 1 my ($self, @args) = @_;
163 1 $self->distance(2);
164 1 $self->autoFlip(1);
165 1 $self->ratio(0.5);
166 1 $self->positionModell('two_pos-head');
167 1 $self->SUPER::_init(@args);
168 1 return $self;
169 }
170  
171 5 ▶sub positionModell {
Subroutine positionModell: called CC=1 SCAR=0.0
Pod documented
172 5 return _PROPERTY($modellmatch, @_);
173 }
174 2 ▶sub distance { # to edge
Subroutine distance: called CC=1 SCAR=0.0
Pod documented
175 2 return _PROPERTY($match{'float'}, @_);
176 }
177 2 ▶sub ratio { # position on sliders
Subroutine ratio: called CC=1 SCAR=0.0
Pod documented
178 2 return _PROPERTY($match{'ratio'}, @_);
179 }
180 2 ▶sub autoFlip {
Subroutine autoFlip: called CC=1 SCAR=0.0
Pod documented
181 2 return _PROPERTY('bool', @_);
182 }
183  
184 1 ▶sub _build {
Subroutine _build: called CC=15 SCAR=29.7
185 1 my $self = shift;
186 1 my $node = XML::LibXML::Element->new('y:EdgeLabel');
187 1 $node->appendText($self->getTextString());
188 1 $node->setAttribute('alignment', $self->alignment());
189 1 $node->setAttribute('fontFamily', $self->fontFamily());
190 1 $node->setAttribute('fontSize', $self->fontSize());
191 1 $node->setAttribute('fontStyle', $self->fontStyle());
192 1 ▶ if ($self->backgroundColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->backgroundColor eq 'none') { } 1 0 1
193 1 $node->setAttribute('hasBackgroundColor', 'false');
194 } else {
195 0 $node->setAttribute('backgroundColor', $self->backgroundColor());
196 }
197 1 ▶ if ($self->lineColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lineColor eq 'none') { } 1 0 1
198 1 $node->setAttribute('hasLineColor', 'false');
199 } else {
200 0 $node->setAttribute('lineColor', $self->lineColor());
201 }
202 1 $node->setAttribute('x', $self->x());
203 1 $node->setAttribute('y', $self->y());
204 1 $node->setAttribute('height', $self->height());
205 1 $node->setAttribute('width', $self->width());
206 1 ▶ $node->setAttribute('textColor', $self->textColor() eq 'none' ? '#000000' : $self->textColor());
Branch: 1 branch
BranchTrueFalseTotal
$self->textColor eq 'none' ? : 0 1 1
207 1 ▶ $node->setAttribute('visible', $self->visible() ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$self->visible ? : 1 0 1
208 1 ▶ $node->setAttribute('bottomInset', $self->bottomInset()) unless ($self->bottomInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->bottomInset =~ /^0*$/ 0 1 1
209 1 ▶ $node->setAttribute('topInset', $self->topInset()) unless ($self->topInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->topInset =~ /^0*$/ 0 1 1
210 1 ▶ $node->setAttribute('rightInset', $self->rightInset()) unless ($self->rightInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rightInset =~ /^0*$/ 0 1 1
211 1 ▶ $node->setAttribute('leftInset', $self->leftInset()) unless ($self->leftInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->leftInset =~ /^0*$/ 0 1 1
212 1 ▶ $node->setAttribute('rotationAngle', $self->rotationAngle()) unless ($self->rotationAngle() =~ m/^-?0*\.?0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rotationAngle =~ /^-?0*\.?0*$/ 0 1 1
213 1 ▶ $node->setAttribute('underlinedText', 'true') if ($self->underlinedText());
Branch: 1 branch
BranchTrueFalseTotal
if $self->underlinedText 0 1 1
214 # EdgeLabel
215 1 ▶ if ($self->positionModell() eq 'free') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->positionModell eq 'free') { } 0 1 1
elsif ($self->positionModell eq 'centered') { } 0 1 1
elsif ($self->positionModell =~ /^(?:center|side)_slider$/) { } 0 1 1
216 0 $node->setAttribute('modelName', $self->positionModell());
217 0 $node->setAttribute('modelPosition', 'anywhere');
218 } elsif ($self->positionModell() eq 'centered') {
219 0 $node->setAttribute('modelName', $self->positionModell());
220 0 $node->setAttribute('modelPosition', 'center');
221 } elsif ($self->positionModell() =~ m/^(?:center|side)_slider$/) {
222 0 $node->setAttribute('modelName', $self->positionModell());
223 } else {
224 1 my ($m, $p) = split '-', $self->positionModell();
225 1 $node->setAttribute('modelName', $m);
226 1 $node->setAttribute('modelPosition', $p);
227 }
228 1 ▶ $node->setAttribute('configuration', 'AutoFlippingLabel') if ($self->autoFlip());
Branch: 1 branch
BranchTrueFalseTotal
if $self->autoFlip 1 0 1
229 1 $node->setAttribute('distance', $self->distance());
230 1 $node->setAttribute('ratio', $self->ratio());
231 1 $node->setAttribute('preferredPlacement', 'anywhere');
232 1 my $ppdNode = $node->addNewChild('', 'y:PreferredPlacementDescriptor');
233 1 $ppdNode->setAttribute('angle', '0.0');
234 1 $ppdNode->setAttribute('angleOffsetOnRightSide', '0');
235 1 $ppdNode->setAttribute('angleReference', 'relative_to_edge_flow');
236 1 $ppdNode->setAttribute('angleRotationOnRightSide', 'co');
237 1 $ppdNode->setAttribute('distance', '-1.0');
238 1 $ppdNode->setAttribute('placement', 'anywhere');
239 1 $ppdNode->setAttribute('side', 'anywhere');
240 1 $ppdNode->setAttribute('sideReference', 'relative_to_edge_flow');
241 1 $ppdNode->setAttribute('preferredPlacement', 'anywhere');
242 1 return $node;
243 }
244  
245 =head1 SEE ALSO
246  
247 L<yEd::Document> for further informations about the whole package
248  
249 L<yEd::PropertyBasedObject> for further basic information about properties and their additional functions
250  
251 L<yEd::Label> for information about the Label base class
252  
253 L<yEd::Label::NodeLabel> for information about specialized Label elements for Nodes
254  
255 =cut
256  
257 3 1;
« Label/NodeLabel.pm ↑ Summary Document.pm »