Label/NodeLabel.pm

filter: Statementstmt 91.8% 56 / 61 Branchbran 50.0% 14 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 5 / 5 totaltotal 81.7% 85 / 104 CC 15 SCAR 26.0
CC
15
Cov
79%
_build
20.9
BEGIN
1.0
BEGIN
1.0
CRAP 13.4
« Label.pm ↑ Summary Label/EdgeLabel.pm »
1 package yEd::Label::NodeLabel;
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::NodeLabel - Textlabels for Nodes
10  
11 =head1 DESCRIPTION
12  
13 Use this class to label your Nodes.
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 an Edge class element use L<yEd::Label::EdgeLabel>.
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: 'internal-c'
34  
35 Describes how to position the Label on the Node.
36  
37 =head3 free
38  
39 Free positioning (use C<x>, C<y> properties)
40  
41 =head3 internal-X
42  
43 Within the Node.
44  
45 Where X is one of:
46  
47 =over 4
48  
49 =item *
50  
51 c : centered
52  
53 =item *
54  
55 t : top
56  
57 =item *
58  
59 b : bottom
60  
61 =item *
62  
63 l : left
64  
65 =item *
66  
67 r : right
68  
69 =item *
70  
71 tl : top left
72  
73 =item *
74  
75 tr : top right
76  
77 =item *
78  
79 bl : bottom left
80  
81 =item *
82  
83 br : bottom right
84  
85 =back
86  
87 =head3 corners-X
88  
89 Outside of the Node.
90  
91 Where X is one of:
92  
93 =over 4
94  
95 =item *
96  
97 nw : north west
98  
99 =item *
100  
101 ne : north east
102  
103 =item *
104  
105 se : south east
106  
107 =item *
108  
109 sw : south west
110  
111 =back
112  
113 =head3 sandwich-X
114  
115 Outside of the Node.
116  
117 Where X is one of:
118  
119 =over 4
120  
121 =item *
122  
123 n : north
124  
125 =item *
126  
127 s : south
128  
129 =back
130  
131 =head3 sides-X
132  
133 Outside of the Node.
134  
135 Where X is one of:
136  
137 =over 4
138  
139 =item *
140  
141 n : north
142  
143 =item *
144  
145 s : south
146  
147 =item *
148  
149 w : west
150  
151 =item *
152  
153 e : east
154  
155 =back
156  
157 =head3 eight_pos-X
158  
159 Outside of the Node.
160  
161 Where X is one of:
162  
163 =over 4
164  
165 =item *
166  
167 n : north
168  
169 =item *
170  
171 s : south
172  
173 =item *
174  
175 w : west
176  
177 =item *
178  
179 e : east
180  
181 =item *
182  
183 nw : north west
184  
185 =item *
186  
187 ne : north east
188  
189 =item *
190  
191 se : south east
192  
193 =item *
194  
195 sw : south west
196  
197 =back
198  
199 =head3 edge_opposite
200  
201 Outside of the Node, opposing the side that is connected to an Edge.
202  
203 =head2 borderDistance
204  
205 Type: float
206  
207 Default: 0
208  
209 Effect unknown ...
210  
211 =head2 autoSizePolicy
212  
213 Type: descrete values ( content | node_size | node_height | node_width )
214  
215 Default: 'content'
216  
217 The way to automatically determine the Labels C<height> and/or C<witdh>.
218  
219 =head2 cropping
220  
221 Type: bool
222  
223 Default: false
224  
225 Whether to wrap the text at Node boundaries (true) or let it emerge (false).
226  
227 =head1 SUBROUTINES/METHODS
228  
229 =head2 all functions from base class
230  
231 L<yEd::Label>
232  
233 =cut
234  
235 3 my $modellmatch = '^(?:free|internal-(?:c|t|b|l|r|tl|tr|bl|br)|corners-(?:nw|ne|se|sw)|sandwich-(?:n|s)|sides-(?:n|s|w|e)|eight_pos-(?:n|s|e|w|nw|ne|sw|se)|edge_opposite)$';
236  
237 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
238 1 my ($class, @args) = @_;
239 1 my $self = bless {}, $class;
240 1 return $self->_init(@args);
241 }
242  
243 1 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
244 1 my ($self, @args) = @_;
245 1 $self->borderDistance(0);
246 1 $self->cropping(0);
247 1 $self->autoSizePolicy('content');
248 1 $self->positionModell('internal-c');
249 1 $self->SUPER::_init(@args);
250 1 return $self;
251 }
252  
253 4 ▶sub positionModell {
Subroutine positionModell: called CC=1 SCAR=0.0
Pod documented
254 4 return _PROPERTY($modellmatch, @_);
255 }
256 2 ▶sub borderDistance {
Subroutine borderDistance: called CC=1 SCAR=0.0
Pod documented
257 2 return _PROPERTY($match{'float'}, @_);
258 }
259 2 ▶sub autoSizePolicy {
Subroutine autoSizePolicy: called CC=1 SCAR=0.0
Pod documented
260 2 return _PROPERTY($match{'autosizepolicy'}, @_);
261 }
262 2 ▶sub cropping {
Subroutine cropping: called CC=1 SCAR=0.0
Pod documented
263 2 return _PROPERTY('bool', @_);
264 }
265  
266 1 ▶sub _build {
Subroutine _build: called CC=15 SCAR=30.4
267 1 my $self = shift;
268 1 my $node = XML::LibXML::Element->new('y:NodeLabel');
269 1 $node->appendText($self->getTextString());
270 1 $node->setAttribute('alignment', $self->alignment());
271 1 $node->setAttribute('fontFamily', $self->fontFamily());
272 1 $node->setAttribute('fontSize', $self->fontSize());
273 1 $node->setAttribute('fontStyle', $self->fontStyle());
274 1 ▶ if ($self->backgroundColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->backgroundColor eq 'none') { } 1 0 1
275 1 $node->setAttribute('hasBackgroundColor', 'false');
276 } else {
277 0 $node->setAttribute('backgroundColor', $self->backgroundColor());
278 }
279 1 ▶ if ($self->lineColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lineColor eq 'none') { } 1 0 1
280 1 $node->setAttribute('hasLineColor', 'false');
281 } else {
282 0 $node->setAttribute('lineColor', $self->lineColor());
283 }
284 1 $node->setAttribute('x', $self->x());
285 1 $node->setAttribute('y', $self->y());
286 1 $node->setAttribute('height', $self->height());
287 1 $node->setAttribute('width', $self->width());
288 1 ▶ $node->setAttribute('textColor', $self->textColor() eq 'none' ? '#000000' : $self->textColor());
Branch: 1 branch
BranchTrueFalseTotal
$self->textColor eq 'none' ? : 0 1 1
289 1 ▶ $node->setAttribute('visible', $self->visible() ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$self->visible ? : 1 0 1
290 1 ▶ $node->setAttribute('bottomInset', $self->bottomInset()) unless ($self->bottomInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->bottomInset =~ /^0*$/ 0 1 1
291 1 ▶ $node->setAttribute('topInset', $self->topInset()) unless ($self->topInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->topInset =~ /^0*$/ 0 1 1
292 1 ▶ $node->setAttribute('rightInset', $self->rightInset()) unless ($self->rightInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rightInset =~ /^0*$/ 0 1 1
293 1 ▶ $node->setAttribute('leftInset', $self->leftInset()) unless ($self->leftInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->leftInset =~ /^0*$/ 0 1 1
294 1 ▶ $node->setAttribute('rotationAngle', $self->rotationAngle()) unless ($self->rotationAngle() =~ m/^-?0*\.?0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rotationAngle =~ /^-?0*\.?0*$/ 0 1 1
295 1 ▶ $node->setAttribute('underlinedText', 'true') if ($self->underlinedText());
Branch: 1 branch
BranchTrueFalseTotal
if $self->underlinedText 0 1 1
296 # NodeLabel
297 1 ▶ if ($self->positionModell() eq 'free') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->positionModell eq 'free') { } 0 1 1
elsif ($self->positionModell eq 'edge_opposite') { } 0 1 1
298 0 $node->setAttribute('modelName', $self->positionModell());
299 0 $node->setAttribute('modelPosition', 'anywhere');
300 } elsif ($self->positionModell() eq 'edge_opposite') {
301 0 $node->setAttribute('modelName', $self->positionModell());
302 } else {
303 1 my ($m, $p) = split '-', $self->positionModell();
304 1 $node->setAttribute('modelName', $m);
305 1 $node->setAttribute('modelPosition', $p);
306 }
307 1 $node->setAttribute('autoSizePolicy', $self->autoSizePolicy());
308 1 ▶ $node->setAttribute('borderDistance', $self->borderDistance()) unless ($self->borderDistance() =~ m/^-?0*\.?0*$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->borderDistance =~ /^-?0*\.?0*$/ 0 1 1
309 1 ▶ $node->setAttribute('configuration', 'CroppingLabel') if $self->cropping();
Branch: 1 branch
BranchTrueFalseTotal
if $self->cropping 0 1 1
310 1 return $node;
311 }
312  
313 =head1 SEE ALSO
314  
315 L<yEd::Document> for further informations about the whole package
316  
317 L<yEd::PropertyBasedObject> for further basic information about properties and their additional functions
318  
319 L<yEd::Label> for information about the Label base class
320  
321 L<yEd::Label::EdgeLabel> for information about specialized Label elements for Edges
322  
323 =cut
324  
325 3 1;
« Label.pm ↑ Summary Label/EdgeLabel.pm »