Label/NodeLabel.pm

filter: Statementstmt 18.0% 11 / 61 Branchbran 0.0% 0 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 100% 5 / 5 totaltotal 18.2% 19 / 104 SCAR 51.1
CC
15
Cov
12%
_build
240.0
new
2.0
_init
2.0
CRAP 166.5
« Label/EdgeLabel.pm ↑ Summary Node.pm »
1 package yEd::Label::NodeLabel;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use yEd::PropertyBasedObject;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶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 a 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 x, y)
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 height and/or 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 1 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 =head2 new
238  
239 Creates a new instance of NodeLabel.
240  
241 A value for the text property must be provided as first parameter.
242  
243 Further parameters to set properties are optional (property => value, ...).
244  
245 =cut
246  
247 sub new {
248 0 ▶ my ($class, @args) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
249 0 my $self = bless {}, $class;
250 0 return $self->_init(@args);
251 }
252  
253 sub _init {
254 0 ▶ my ($self, @args) = @_;
Subroutine _init: not called CC=1 SCAR=6.9
255 0 $self->borderDistance(0);
256 0 $self->cropping(0);
257 0 $self->autoSizePolicy('content');
258 0 $self->positionModell('internal-c');
259 0 $self->SUPER::_init(@args);
260 0 return $self;
261 }
262  
263 sub positionModell {
264 0 ▶ return _PROPERTY($modellmatch, @_);
Subroutine positionModell: not called CC=1 SCAR=6.9
Pod documented
265 }
266 sub borderDistance {
267 0 ▶ return _PROPERTY($match{'float'}, @_);
Subroutine borderDistance: not called CC=1 SCAR=6.9
Pod documented
268 }
269 sub autoSizePolicy {
270 0 ▶ return _PROPERTY($match{'autosizepolicy'}, @_);
Subroutine autoSizePolicy: not called CC=1 SCAR=6.9
Pod documented
271 }
272 sub cropping {
273 0 ▶ return _PROPERTY('bool', @_);
Subroutine cropping: not called CC=1 SCAR=6.9
Pod documented
274 }
275  
276 sub _build {
277 0 ▶ my $self = shift;
Subroutine _build: not called CC=15 SCAR=54.8
278 0 my $node = XML::LibXML::Element->new('y:NodeLabel');
279 0 $node->appendText($self->getTextString());
280 0 $node->setAttribute('alignment', $self->alignment());
281 0 $node->setAttribute('fontFamily', $self->fontFamily());
282 0 $node->setAttribute('fontSize', $self->fontSize());
283 0 $node->setAttribute('fontStyle', $self->fontStyle());
284 0 ▶ if ($self->backgroundColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->backgroundColor eq 'none') { } 0 0 0
285 0 $node->setAttribute('hasBackgroundColor', 'false');
286 } else {
287 0 $node->setAttribute('backgroundColor', $self->backgroundColor());
288 }
289 0 ▶ if ($self->lineColor() eq 'none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lineColor eq 'none') { } 0 0 0
290 0 $node->setAttribute('hasLineColor', 'false');
291 } else {
292 0 $node->setAttribute('lineColor', $self->lineColor());
293 }
294 0 $node->setAttribute('x', $self->x());
295 0 $node->setAttribute('y', $self->y());
296 0 $node->setAttribute('height', $self->height());
297 0 $node->setAttribute('width', $self->width());
298 0 ▶ $node->setAttribute('textColor', $self->textColor() eq 'none' ? '#000000' : $self->textColor());
Branch: 1 branch
BranchTrueFalseTotal
$self->textColor eq 'none' ? : 0 0 0
299 0 ▶ $node->setAttribute('visible', $self->visible() ? 'true' : 'false');
Branch: 1 branch
BranchTrueFalseTotal
$self->visible ? : 0 0 0
300 0 ▶ $node->setAttribute('bottomInset', $self->bottomInset()) unless ($self->bottomInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->bottomInset =~ /^0*$/ 0 0 0
301 0 ▶ $node->setAttribute('topInset', $self->topInset()) unless ($self->topInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->topInset =~ /^0*$/ 0 0 0
302 0 ▶ $node->setAttribute('rightInset', $self->rightInset()) unless ($self->rightInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rightInset =~ /^0*$/ 0 0 0
303 0 ▶ $node->setAttribute('leftInset', $self->leftInset()) unless ($self->leftInset() =~ m/^0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->leftInset =~ /^0*$/ 0 0 0
304 0 ▶ $node->setAttribute('rotationAngle', $self->rotationAngle()) unless ($self->rotationAngle() =~ m/^-?0*\.?0*$/);;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->rotationAngle =~ /^-?0*\.?0*$/ 0 0 0
305 0 ▶ $node->setAttribute('underlinedText', 'true') if ($self->underlinedText());
Branch: 1 branch
BranchTrueFalseTotal
if $self->underlinedText 0 0 0
306 # NodeLabel
307 0 ▶ if ($self->positionModell() eq 'free') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->positionModell eq 'free') { } 0 0 0
elsif ($self->positionModell eq 'edge_opposite') { } 0 0 0
308 0 $node->setAttribute('modelName', $self->positionModell());
309 0 $node->setAttribute('modelPosition', 'anywhere');
310 } elsif ($self->positionModell() eq 'edge_opposite') {
311 0 $node->setAttribute('modelName', $self->positionModell());
312 } else {
313 0 my ($m, $p) = split '-', $self->positionModell();
314 0 $node->setAttribute('modelName', $m);
315 0 $node->setAttribute('modelPosition', $p);
316 }
317 0 $node->setAttribute('autoSizePolicy', $self->autoSizePolicy());
318 0 ▶ $node->setAttribute('borderDistance', $self->borderDistance()) unless ($self->borderDistance() =~ m/^-?0*\.?0*$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->borderDistance =~ /^-?0*\.?0*$/ 0 0 0
319 0 ▶ $node->setAttribute('configuration', 'CroppingLabel') if $self->cropping();
Branch: 1 branch
BranchTrueFalseTotal
if $self->cropping 0 0 0
320 0 return $node;
321 }
322  
323 =head1 SEE ALSO
324  
325 L<yEd::Document> for further informations about the whole package
326  
327 L<yEd::PropertyBasedObject> for further basic information about properties and their additional functions
328  
329 L<yEd::Label> for information about the Label base class
330  
331 L<yEd::Label::EdgeLabel> for information about specialized Label elements for Edges
332  
333 =cut
334  
335 1 1;
« Label/EdgeLabel.pm ↑ Summary Node.pm »