lib/App/Asciio/stripes/wirl_arrow.pm

filter: Statementstmt 74.4% 186 / 250 Branchbran 58.8% 40 / 68 Conditioncond 28.8% 13 / 45 MC/DCmcdc 14.2% 4 / 28 Subroutinesub 81.5% 31 / 38 Podpod 0.0% 0 / 27 totaltotal 60.0% 274 / 456 CC 50 SCAR 24.7
CC
50
Cov
66%
resize
72.0
get_selection_action
30.0
get_named_connection
12.0
CRAP 11.8
« blib/lib/App/Asciio.pm ↑ Summary blib/lib/App/Asciio/Actions/Ruler.pm »
1  
2 package App::Asciio::stripes::wirl_arrow ;
3  
4 2 ▶use base App::Asciio::stripes::stripes ;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use List::Util qw(min max) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Readonly ;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Clone ;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #-----------------------------------------------------------------------------
14  
15 2 Readonly my $DEFAULT_ARROW_TYPE =>
16 [
17 #name: $start, $body, $connection, $body_2, $end
18
19 ['origin', '', '*', '', '', '', 1],
20 ['up', '|', '|', '', '', '^', 1],
21 ['down', '|', '|', '', '', 'v', 1],
22 ['left', '-', '-', '', '', '<', 1],
23 ['up-left', '|', '|', '.', '-', '<', 1],
24 ['left-up', '-', '-', '\'', '|', '^', 1],
25 ['down-left', '|', '|', '\'', '-', '<', 1],
26 ['left-down', '-', '-', '.', '|', 'v', 1],
27 ['right', '-', '-', '', '', '>', 1],
28 ['up-right', '|', '|', '.', '-', '>', 1],
29 ['right-up', '-', '-', '\'', '|', '^', 1],
30 ['down-right', '|', '|', '\'', '-', '>', 1],
31 ['right-down', '-', '-', '.', '|', 'v', 1],
32 ['45', '/', '/', '', '', '^', 1],
33 ['135', '\\', '\\', '', '', 'v', 1],
34 ['225', ' /', '/', '', '', 'v', 1],
35 ['315', '\\', '\\', '', '', '^', 1],
36 ] ;
37  
38 sub new
39 192 ▶{
Subroutine new: called CC=2 SCAR=7.4
Pod undocumented
40 192 my ($class, $element_definition) = @_ ;
41  
42 192 my $self = bless {}, __PACKAGE__ ;
43  
44 $self->setup
45 (
46 $element_definition->{ARROW_TYPE} || Clone::clone($DEFAULT_ARROW_TYPE),
47 $element_definition->{END_X}, $element_definition->{END_Y},
48 $element_definition->{DIRECTION},
49 $element_definition->{ALLOW_DIAGONAL_LINES},
50 $element_definition->{EDITABLE},
51 192 ▶ ) ;
Condition33%1/3
$element_definition->{'ARROW_TYPE'} || &Clone::clone($DEFAULT_ARROW_TYPE)
l!l&&r!l&&!r
19200
MC/DC0%0/2
$element_definition->{'ARROW_TYPE'} || &Clone::clone($DEFAULT_ARROW_TYPE)
$element_definition->{'ARROW_TYPE'} &Clone::clone($DEFAULT_ARROW_TYPE)
Truth table33%1/3
A || B
A= $element_definition->{'ARROW_TYPE'}B= &Clone::clone($DEFAULT_ARROW_TYPE)
ABresult
1X1
011
000
52  
53 192 return $self ;
54 }
55  
56 #-----------------------------------------------------------------------------
57  
58 sub setup
59 192 ▶{
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
60 192 my ($self, $arrow_type, $end_x, $end_y, $direction, $allow_diagonal_lines, $editable) = @_ ;
61  
62 192 my ($stripes, $width, $height) ;
63  
64 192 ($stripes, $width, $height, $direction) = get_arrow($arrow_type, $end_x, $end_y, $direction, $allow_diagonal_lines) ;
65  
66 192 $self->set
67 (
68 STRIPES => $stripes,
69 WIDTH => $width,
70 HEIGHT => $height,
71 DIRECTION => $direction,
72 ARROW_TYPE => $arrow_type,
73 END_X => $end_x,
74 END_Y => $end_y,
75 ALLOW_DIAGONAL_LINES => $allow_diagonal_lines,
76 ) ;
77 }
78  
79 #-----------------------------------------------------------------------------
80  
81 2 my %direction_to_arrow =
82 (
83 'origin' => \&draw_origin,
84 'up' => \&draw_up,
85 'down' => \&draw_down,
86 'left' => \&draw_left,
87 'up-left' => \&draw_upleft,
88 'left-up' => \&draw_leftup,
89 'down-left' => \&draw_downleft,
90 'left-down' => \&draw_leftdown,
91 'right' => \&draw_right,
92 'up-right' => \&draw_upright,
93 'right-up' => \&draw_rightup,
94 'down-right' => \&draw_downright,
95 'right-down' => \&draw_rightdown,
96 ) ;
97  
98 sub get_arrow
99 192 ▶{
Subroutine get_arrow: called CC=9 SCAR=22.0
Pod undocumented
100 192 my ($arrow_type, $end_x, $end_y, $direction, $allow_diagonal_lines) = @_ ;
101  
102 2 ▶use constant CENTER => 1 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 2 ▶use constant LEFT => 0 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 2 ▶use constant RIGHT => 2 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 2 ▶use constant UP => 0 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 2 ▶use constant DOWN => 2 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
107  
108 192 ▶my @position_to_direction =
Branch: 4 branches
BranchTrueFalseTotal
$direction =~ /^up/ ? : 33 159 192
$direction =~ /^down/ ? : 31 161 192
$direction =~ /^up/ ? : 33 159 192
$direction =~ /^down/ ? : 31 161 192
109 (
110 [$direction =~ /^up/ ? 'up-left' : 'left-up', 'left', $direction =~ /^down/ ? 'down-left' : 'left-down'] ,
111 ['up', 'origin', 'down'],
112 [$direction =~ /^up/ ? 'up-right' : 'right-up', 'right', $direction =~ /^down/ ? 'down-right' : 'right-down'],
113 ) ;
114  
115 192 ▶$direction = $position_to_direction
Branch: 4 branches
BranchTrueFalseTotal
$end_x == 0 ? : 42 150 192
$end_x < 0 ? : 74 76 150
$end_y == 0 ? : 41 151 192
$end_y < 0 ? : 77 74 151
116 [$end_x == 0 ? CENTER : $end_x < 0 ? LEFT : RIGHT]
117 [$end_y == 0 ? CENTER : $end_y < 0 ? UP : DOWN] ;
118  
119 192 return($direction_to_arrow{$direction}->($arrow_type, $end_x, $end_y, $allow_diagonal_lines), $direction) ;
120 }
121  
122 #-----------------------------------------------------------------------------
123  
124 sub draw_down
125 21 ▶{
Subroutine draw_down: called CC=2 SCAR=7.0
Pod undocumented
126 21 my ($arrow_type, $end_x, $end_y) = @_ ;
127  
128 21 my ($stripes, $width, $height) = ([], 1, $end_y + 1) ;
129 21 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[2]}[1 .. 5] ;
130  
131 21 ▶push @{$stripes},
Branch: 1 branch
BranchTrueFalseTotal
$height == 2 ? : 0 21 21
132 {
133 'HEIGHT' => $height,
134 'TEXT' => $height == 2 ? "$start\n$end" : $start . "\n" . ("$body\n" x ($height -2)) . $end,
135 'WIDTH' => 1,
136 'X_OFFSET' => 0,
137 'Y_OFFSET' => 0,
138 } ;
139  
140 21 return($stripes, $width, $height) ;
141 }
142  
143 #-----------------------------------------------------------------------------
144  
145 sub draw_origin
146 0 ▶{
Subroutine draw_origin: not called CC=1 SCAR=6.9
Pod undocumented
147 0 my ($arrow_type, $end_x, $end_y) = @_ ;
148  
149 0 my ($stripes, $width, $height) = ([], 1, 1) ;
150 0 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[0]}[1 .. 5] ;
151  
152 0 push @{$stripes},
153 {
154 'HEIGHT' => 1,
155 'TEXT' => $body,
156 'WIDTH' => 1,
157 'X_OFFSET' => 0,
158 'Y_OFFSET' => 0,
159 } ;
160  
161 0 return($stripes, $width, $height) ;
162 }
163  
164 #-----------------------------------------------------------------------------
165  
166 sub draw_up
167 21 ▶{
Subroutine draw_up: called CC=2 SCAR=7.0
Pod undocumented
168 21 my ($arrow_type, $end_x, $end_y) = @_ ;
169  
170 21 my ($stripes, $width, $height) = ([], 1, -$end_y + 1) ;
171 21 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[1]}[1 .. 5] ;
172  
173 21 ▶push @{$stripes},
Branch: 1 branch
BranchTrueFalseTotal
$height == 2 ? : 0 21 21
174 {
175 'HEIGHT' => $height,
176 'TEXT' => $height == 2 ? "$end\n$start" : $end . "\n" . ("$body\n" x ($height -2)) . $start,
177 'WIDTH' => 1,
178 'X_OFFSET' => 0,
179 'Y_OFFSET' => $end_y,
180 } ;
181  
182 21 return($stripes, $width, $height) ;
183 }
184  
185 #-----------------------------------------------------------------------------
186  
187 sub draw_left
188 21 ▶{
Subroutine draw_left: called CC=2 SCAR=7.0
Pod undocumented
189 21 my ($arrow_type, $end_x, $end_y) = @_ ;
190  
191 21 my ($stripes, $width, $height) = ([], -$end_x + 1, 1) ;
192 21 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[3]}[1 .. 5] ;
193  
194 21 ▶push @{$stripes},
Branch: 1 branch
BranchTrueFalseTotal
$width == 2 ? : 0 21 21
195 {
196 'HEIGHT' => 1,
197 'TEXT' => $width == 2 ? "$end$start" : $end . $body x ($width -2) . $start,
198 'WIDTH' => $width,
199 'X_OFFSET' => $end_x,
200 'Y_OFFSET' => 0,
201 } ;
202  
203 21 return($stripes, $width, $height) ;
204 }
205  
206 #-----------------------------------------------------------------------------
207  
208 sub draw_upleft # or 315
209 6 ▶{
Subroutine draw_upleft: called CC=3 SCAR=12.9
Pod undocumented
210 6 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
211  
212 6 my ($stripes, $width, $height) = ([], -$end_x + 1, -$end_y + 1) ;
213  
214 6 ▶if($allow_diagonal_lines && $end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and $end_x == $end_y) { } 0 6 6
Condition33%1/3
$allow_diagonal_lines and $end_x == $end_y
!ll&&!rl&&r
600
MC/DC0%0/2
$allow_diagonal_lines and $end_x == $end_y
$allow_diagonal_lines $end_x == $end_y
Truth table33%1/3
A and B
A= $allow_diagonal_linesB= $end_x == $end_y
ABresult
0X0
100
111
215 {
216 0 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[16]}[1 .. 5] ;
217 0 push @{$stripes}, get_315_stripes($end_x, $start, $body, $end) ;
218 }
219 else
220 {
221 6 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[4]}[1 .. 5] ;
222 6 push @{$stripes},
223 {
224 'HEIGHT' => $height ,
225 'TEXT' => "$connection\n" . "$body\n" x ($height - 2) . $start,
226 'WIDTH' => 1,
227 'X_OFFSET' => 0,
228 'Y_OFFSET' => $end_y,
229 },
230 {
231 'HEIGHT' => 1,
232 'TEXT' => $end . $body_2 x ($width - 2),
233 'WIDTH' => $width - 1,
234 'X_OFFSET' => $end_x,
235 'Y_OFFSET' => $end_y ,
236 } ;
237 }
238  
239 6 return($stripes, $width, $height) ;
240 }
241  
242 #-----------------------------------------------------------------------------
243  
244 sub draw_leftup # or 315
245 22 ▶{
Subroutine draw_leftup: called CC=3 SCAR=11.0
Pod undocumented
246 22 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
247  
248 22 my ($stripes, $width, $height) = ([], -$end_x + 1, -$end_y + 1) ;
249 22 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[5]}[1 .. 5] ;
250  
251 22 ▶if($allow_diagonal_lines && $end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and $end_x == $end_y) { } 16 6 22
Condition66%2/3
$allow_diagonal_lines and $end_x == $end_y
!ll&&!rl&&r
6016
MC/DC50%1/2
$allow_diagonal_lines and $end_x == $end_y
$allow_diagonal_lines $end_x == $end_y
Truth table66%2/3
A and B
A= $allow_diagonal_linesB= $end_x == $end_y
ABresult
0X0
100
111
252 {
253 16 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[16]}[1 .. 5] ;
254 16 push @{$stripes}, get_315_stripes($end_x, $start, $body, $end) ;
255 }
256 else
257 {
258 6 push @{$stripes},
259 {
260 'HEIGHT' => 1 ,
261 'TEXT' => $connection . $body x ($width - 2) . $start,
262 'WIDTH' => $width,
263 'X_OFFSET' => $end_x,
264 'Y_OFFSET' => 0,
265 },
266 {
267 'HEIGHT' => $height - 1,
268 'TEXT' => "$end\n" . "$body_2\n" x ($height - 2),
269 'WIDTH' => 1,
270 'X_OFFSET' => $end_x,
271 'Y_OFFSET' => $end_y ,
272 } ;
273 }
274  
275 22 return($stripes, $width, $height) ;
276 }
277  
278 #-----------------------------------------------------------------------------
279  
280 sub get_315_stripes
281 16 ▶{
Subroutine get_315_stripes: called CC=2 SCAR=6.9
Pod undocumented
282 16 my ($position, $start, $body, $end) = @_ ;
283  
284 16 my @stripes ;
285  
286 16 push @stripes,
287 {
288 'HEIGHT' => 1,
289 'TEXT' => $start,
290 'WIDTH' => 1,
291 'X_OFFSET' => 0,
292 'Y_OFFSET' => 0,
293 } ;
294
295 16 ▶for(my $xy = -$position - 1 ; $xy> 0 ; $xy--)
Branch: 1 branch
BranchTrueFalseTotal
if ($xy > 0) 40 16 56
296 {
297 40 push @stripes,
298 {
299 'HEIGHT' => 1,
300 'TEXT' => $body,
301 'WIDTH' => 1,
302 'X_OFFSET' => -$xy,
303 'Y_OFFSET' => -$xy,
304 } ;
305 }
306  
307 16 push @stripes,
308 {
309 'HEIGHT' => 1,
310 'TEXT' => $end,
311 'WIDTH' => 1,
312 'X_OFFSET' => $position ,
313 'Y_OFFSET' => $position ,
314 } ;
315  
316 16 return(@stripes) ;
317 }
318  
319 #-----------------------------------------------------------------------------
320  
321 sub draw_downleft # or 225
322 5 ▶{
Subroutine draw_downleft: called CC=3 SCAR=12.9
Pod undocumented
323 5 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
324  
325 5 my ($stripes, $width, $height) = ([], -$end_x + 1, $end_y + 1) ;
326 5 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[6]}[1 .. 5] ;
327  
328 5 ▶if($allow_diagonal_lines && -$end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and -$end_x == $end_y) { } 0 5 5
Condition33%1/3
$allow_diagonal_lines and -$end_x == $end_y
!ll&&!rl&&r
500
MC/DC0%0/2
$allow_diagonal_lines and -$end_x == $end_y
$allow_diagonal_lines -$end_x == $end_y
Truth table33%1/3
A and B
A= $allow_diagonal_linesB= -$end_x == $end_y
ABresult
0X0
100
111
329 {
330 0 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[15]}[1 .. 5] ;
331 0 push @{$stripes}, get_225_stripes($end_x, $start, $body, $end) ;
332 }
333 else
334 {
335 5 push @{$stripes},
336 {
337 'HEIGHT' => $height ,
338 'TEXT' => "$start\n" . "$body\n" x ($height - 2) . $connection,
339 'WIDTH' => 1,
340 'X_OFFSET' => 0,
341 'Y_OFFSET' => 0,
342 },
343 {
344 'HEIGHT' => 1,
345 'TEXT' => $end . $body_2 x ($width - 2),
346 'WIDTH' => $width - 1,
347 'X_OFFSET' => $end_x,
348 'Y_OFFSET' => $end_y ,
349 } ;
350 }
351  
352 5 return($stripes, $width, $height) ;
353 }
354  
355 #-----------------------------------------------------------------------------
356  
357 sub draw_leftdown # or 225
358 20 ▶{
Subroutine draw_leftdown: called CC=3 SCAR=11.0
Pod undocumented
359 20 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
360  
361 20 my ($stripes, $width, $height) = ([], -$end_x + 1, $end_y + 1) ;
362 20 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[7]}[1 .. 5] ;
363  
364 20 ▶if($allow_diagonal_lines && -$end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and -$end_x == $end_y) { } 16 4 20
Condition66%2/3
$allow_diagonal_lines and -$end_x == $end_y
!ll&&!rl&&r
4016
MC/DC50%1/2
$allow_diagonal_lines and -$end_x == $end_y
$allow_diagonal_lines -$end_x == $end_y
Truth table66%2/3
A and B
A= $allow_diagonal_linesB= -$end_x == $end_y
ABresult
0X0
100
111
365 {
366 16 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[15]}[1 .. 5] ;
367 16 push @{$stripes}, get_225_stripes($end_x, $start, $body, $end) ;
368 }
369 else
370 {
371 4 push @{$stripes},
372 {
373 'HEIGHT' => 1 ,
374 'TEXT' => $connection . $body x ($width - 2) . $start,
375 'WIDTH' => $width,
376 'X_OFFSET' => $end_x,
377 'Y_OFFSET' => 0,
378 },
379 {
380 'HEIGHT' => $height - 1,
381 'TEXT' => "$body_2\n" x ($height - 2) . $end,
382 'WIDTH' => 1,
383 'X_OFFSET' => $end_x,
384 'Y_OFFSET' => 1 ,
385 } ;
386 }
387  
388 20 return($stripes, $width, $height) ;
389 }
390  
391 #-----------------------------------------------------------------------------
392  
393 sub get_225_stripes
394 16 ▶{
Subroutine get_225_stripes: called CC=2 SCAR=6.9
Pod undocumented
395 16 my ($position, $start, $body, $end) = @_ ;
396  
397 16 my @stripes ;
398  
399 16 push @stripes,
400 {
401 'HEIGHT' => 1,
402 'TEXT' => $start,
403 'WIDTH' => 1,
404 'X_OFFSET' => 0,
405 'Y_OFFSET' => 0,
406 } ;
407  
408 16 ▶for(my $xy = -$position - 1 ; $xy> 0 ; $xy--)
Branch: 1 branch
BranchTrueFalseTotal
if ($xy > 0) 40 16 56
409 {
410 40 push @stripes,
411 {
412 'HEIGHT' => 1,
413 'TEXT' => $body,
414 'WIDTH' => 1,
415 'X_OFFSET' => -$xy,
416 'Y_OFFSET' => $xy,
417 } ;
418 }
419  
420 16 push @stripes,
421 {
422 'HEIGHT' => 1,
423 'TEXT' => $end,
424 'WIDTH' => 1,
425 'X_OFFSET' => $position ,
426 'Y_OFFSET' => -$position ,
427 } ;
428  
429 16 return(@stripes) ;
430 }
431  
432 #-----------------------------------------------------------------------------
433  
434 sub draw_right
435 20 ▶{
Subroutine draw_right: called CC=2 SCAR=7.0
Pod undocumented
436 20 my ($arrow_type, $end_x, $end_y) = @_ ;
437  
438 20 my ($stripes, $width, $height) = ([], $end_x + 1, 1) ;
439 20 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[8]}[1 .. 5] ;
440  
441 20 ▶push @{$stripes},
Branch: 1 branch
BranchTrueFalseTotal
$width == 2 ? : 0 20 20
442 {
443 'HEIGHT' => 1,
444 'TEXT' => $width == 2 ? "$start$end" : $start . $body x ($width -2) . $end,
445 'WIDTH' => $width,
446 'X_OFFSET' => 0,
447 'Y_OFFSET' => 0,
448 } ;
449  
450 20 return($stripes, $width, $height) ;
451 }
452  
453 #-----------------------------------------------------------------------------
454  
455 sub draw_upright # or 45
456 6 ▶{
Subroutine draw_upright: called CC=3 SCAR=12.9
Pod undocumented
457 6 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
458  
459 6 my ($stripes, $width, $height) = ([], $end_x + 1, -$end_y + 1) ;
460 6 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[9]}[1 .. 5] ;
461  
462 6 ▶if($allow_diagonal_lines && -$end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and -$end_x == $end_y) { } 0 6 6
Condition33%1/3
$allow_diagonal_lines and -$end_x == $end_y
!ll&&!rl&&r
600
MC/DC0%0/2
$allow_diagonal_lines and -$end_x == $end_y
$allow_diagonal_lines -$end_x == $end_y
Truth table33%1/3
A and B
A= $allow_diagonal_linesB= -$end_x == $end_y
ABresult
0X0
100
111
463 {
464 0 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[13]}[1 .. 5] ;
465 0 push @{$stripes}, get_45_stripes($end_x, $start, $body, $end) ;
466 }
467 else
468 {
469 6 push @{$stripes},
470 {
471 'HEIGHT' => $height ,
472 'TEXT' => "$connection\n". "$body\n" x ($height -2) . $start,
473 'WIDTH' => 1,
474 'X_OFFSET' => 0,
475 'Y_OFFSET' => $end_y,
476 },
477 {
478 'HEIGHT' => 1,
479 'TEXT' => $body_2 x ($width -2) . $end,
480 'WIDTH' => $end_x,
481 'X_OFFSET' => 1,
482 'Y_OFFSET' => $end_y,
483 } ;
484 }
485  
486 6 return($stripes, $width, $height) ;
487 }
488  
489 #-----------------------------------------------------------------------------
490  
491 sub draw_rightup # or 45
492 22 ▶{
Subroutine draw_rightup: called CC=3 SCAR=11.0
Pod undocumented
493 22 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
494  
495 22 my ($stripes, $width, $height) = ([], $end_x + 1, -$end_y + 1) ;
496 22 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[10]}[1 .. 5] ;
497  
498 22 ▶if($allow_diagonal_lines && -$end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and -$end_x == $end_y) { } 16 6 22
Condition66%2/3
$allow_diagonal_lines and -$end_x == $end_y
!ll&&!rl&&r
6016
MC/DC50%1/2
$allow_diagonal_lines and -$end_x == $end_y
$allow_diagonal_lines -$end_x == $end_y
Truth table66%2/3
A and B
A= $allow_diagonal_linesB= -$end_x == $end_y
ABresult
0X0
100
111
499 {
500 16 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[13]}[1 .. 5] ;
501 16 push @{$stripes}, get_45_stripes($end_x, $start, $body, $end) ;
502 }
503 else
504 {
505 6 push @{$stripes},
506 {
507 'HEIGHT' => 1,
508 'TEXT' => $start . $body x ($width -2) . $connection,
509 'WIDTH' => $width,
510 'X_OFFSET' => 0,
511 'Y_OFFSET' => 0,
512 },
513 {
514 'HEIGHT' => $height - 1,
515 'TEXT' => "$end\n" . "$body_2\n" x ($height -2),
516 'WIDTH' => 1,
517 'X_OFFSET' => $end_x,
518 'Y_OFFSET' => $end_y,
519 } ;
520 }
521  
522 22 return($stripes, $width, $height) ;
523 }
524  
525 #-----------------------------------------------------------------------------
526  
527 sub get_45_stripes
528 16 ▶{
Subroutine get_45_stripes: called CC=2 SCAR=6.9
Pod undocumented
529 16 my ($position, $start, $body, $end) = @_ ;
530  
531 16 my @stripes ;
532  
533 16 push @stripes,
534 {
535 'HEIGHT' => 1,
536 'TEXT' => $start,
537 'WIDTH' => 1,
538 'X_OFFSET' => 0,
539 'Y_OFFSET' => 0,
540 } ;
541  
542 16 ▶for(my $xy = $position - 1 ; $xy > 0 ; $xy--)
Branch: 1 branch
BranchTrueFalseTotal
if ($xy > 0) 40 16 56
543 {
544 40 push @stripes,
545 {
546 'HEIGHT' => 1,
547 'TEXT' => $body,
548 'WIDTH' => 1,
549 'X_OFFSET' => $xy,
550 'Y_OFFSET' => -$xy,
551 } ;
552 }
553  
554 16 push @stripes,
555 {
556 'HEIGHT' => 1,
557 'TEXT' => $end,
558 'WIDTH' => 1,
559 'X_OFFSET' => $position ,
560 'Y_OFFSET' => -$position ,
561 } ;
562  
563 16 return(@stripes) ;
564 }
565  
566 #-----------------------------------------------------------------------------
567  
568 sub draw_downright # or 135
569 5 ▶{
Subroutine draw_downright: called CC=3 SCAR=12.9
Pod undocumented
570 5 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
571  
572 5 my ($stripes, $width, $height) = ([], $end_x + 1, $end_y + 1) ;
573 5 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[11]}[1 .. 5] ;
574  
575 5 ▶if($allow_diagonal_lines && $end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and $end_x == $end_y) { } 0 5 5
Condition33%1/3
$allow_diagonal_lines and $end_x == $end_y
!ll&&!rl&&r
500
MC/DC0%0/2
$allow_diagonal_lines and $end_x == $end_y
$allow_diagonal_lines $end_x == $end_y
Truth table33%1/3
A and B
A= $allow_diagonal_linesB= $end_x == $end_y
ABresult
0X0
100
111
576 {
577 0 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[14]}[1 .. 5] ;
578 0 push @{$stripes}, get_135_stripes($end_x, $start, $body, $end) ;
579 }
580 else
581 {
582 5 push @{$stripes},
583 {
584 'HEIGHT' => $height ,
585 'TEXT' => "$start\n" ."$body\n" x ($height -2) . $connection,
586 'WIDTH' => 1,
587 'X_OFFSET' => 0,
588 'Y_OFFSET' => 0,
589 },
590 {
591 'HEIGHT' => 1,
592 'TEXT' => $body_2 x ($width -2) . $end,
593 'WIDTH' => $width - 1,
594 'X_OFFSET' => 1,
595 'Y_OFFSET' => $end_y,
596 } ;
597 }
598  
599 5 return($stripes, $width, $height) ;
600 }
601  
602 #-----------------------------------------------------------------------------
603  
604 sub draw_rightdown # or 135
605 23 ▶{
Subroutine draw_rightdown: called CC=3 SCAR=11.0
Pod undocumented
606 23 my ($arrow_type, $end_x, $end_y, $allow_diagonal_lines) = @_ ;
607  
608 23 my ($stripes, $width, $height) = ([], $end_x + 1, $end_y + 1) ;
609 23 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[12]}[1 .. 5] ;
610  
611 23 ▶if($allow_diagonal_lines && $end_x == $end_y)
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_diagonal_lines and $end_x == $end_y) { } 16 7 23
Condition66%2/3
$allow_diagonal_lines and $end_x == $end_y
!ll&&!rl&&r
7016
MC/DC50%1/2
$allow_diagonal_lines and $end_x == $end_y
$allow_diagonal_lines $end_x == $end_y
Truth table66%2/3
A and B
A= $allow_diagonal_linesB= $end_x == $end_y
ABresult
0X0
100
111
612 {
613 16 my ($start, $body, $connection, $body_2, $end) = @{$arrow_type->[14]}[1 .. 5] ;
614 16 push @{$stripes}, get_135_stripes($end_x, $start, $body, $end) ;
615 }
616 else
617 {
618 7 push @{$stripes},
619 {
620 'HEIGHT' => 1,
621 'TEXT' => $start . $body x ($width -2) . $connection,
622 'WIDTH' => $width,
623 'X_OFFSET' => 0,
624 'Y_OFFSET' => 0,
625 },
626 {
627 'HEIGHT' => $height - 1 ,
628 'TEXT' => "$body_2\n" x ($height -2) . $end,
629 'WIDTH' => 1,
630 'X_OFFSET' => $end_x,
631 'Y_OFFSET' => 1,
632 } ;
633 }
634  
635 23 return($stripes, $width, $height) ;
636 }
637  
638 #-----------------------------------------------------------------------------
639  
640 sub get_135_stripes
641 16 ▶{
Subroutine get_135_stripes: called CC=2 SCAR=6.9
Pod undocumented
642 16 my ($position, $start, $body, $end) = @_ ;
643  
644 16 my @stripes ;
645  
646 16 push @stripes,
647 {
648 'HEIGHT' => 1,
649 'TEXT' => $start,
650 'WIDTH' => 1,
651 'X_OFFSET' => 0 ,
652 'Y_OFFSET' => 0 ,
653 } ;
654  
655 16 ▶for(my $xy = 1 ; $xy < $position ; $xy++)
Branch: 1 branch
BranchTrueFalseTotal
if ($xy < $position) 40 16 56
656 {
657 40 push @stripes,
658 {
659 'HEIGHT' => 1,
660 'TEXT' => $body,
661 'WIDTH' => 1,
662 'X_OFFSET' => $xy,
663 'Y_OFFSET' => $xy,
664 } ;
665 }
666  
667 16 push @stripes,
668 {
669 'HEIGHT' => 1,
670 'TEXT' => $end,
671 'WIDTH' => 1,
672 'X_OFFSET' => $position,
673 'Y_OFFSET' => $position,
674 } ;
675  
676 16 return(@stripes) ;
677 }
678  
679 #-----------------------------------------------------------------------------
680  
681 sub get_selection_action
682 0 ▶{
Subroutine get_selection_action: not called CC=5 SCAR=34.0
Pod undocumented
683 0 my ($self, $x, $y) = @_ ;
684  
685 0 ▶if (
Branch: 1 branch
BranchTrueFalseTotal
if ($x == 0 and $y == 0 or $x == $self->{'END_X'} and $y == $self->{'END_Y'}) { } 0 0 0
Condition0%0/9
$x == 0 and $y == 0 or $x == $self->{"END_X"} and $y == $self->{"END_Y"}
l!l&&r!l&&!r
000
$x == 0 and $y == 0
!ll&&!rl&&r
000
$x == $self->{"END_X"} and $y == $self->{"END_Y"}
!ll&&!rl&&r
000
MC/DC0%0/4
$x == 0 and $y == 0 or $x == $self->{"END_X"} and $y == $self->{"END_Y"}
$x == 0 $y == 0 $x == $self->{"END_X"} $y == $self->{"END_Y"}
Truth table0%0/7
A and B or C and D
A= $x == 0B= $y == 0C= $x == $self->{"END_X"}D= $y == $self->{"END_Y"}
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
686 ($x == 0 && $y == 0)
687 || ($x == $self->{END_X} && $y == $self->{END_Y})
688 )
689 {
690 0 'resize' ;
691 }
692 else
693 {
694 0 'move' ;
695 }
696 }
697  
698 #-----------------------------------------------------------------------------
699  
700 sub get_connector_points
701 384 ▶{
Subroutine get_connector_points: called CC=1 SCAR=0.0
Pod undocumented
702 384 my ($self) = @_ ;
703  
704 return
705 (
706 {X => 0, Y => 0, NAME => 'start'},
707 384 {X => $self->{END_X}, Y => $self->{END_Y}, NAME => 'end'},
708 ) ;
709 }
710 #-----------------------------------------------------------------------------
711  
712 sub get_named_connection
713 0 ▶{
Subroutine get_named_connection: not called CC=3 SCAR=24.8
Pod undocumented
714 0 my ($self, $name) = @_ ;
715  
716 0 ▶if($name eq 'start')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'start') { } 0 0 0
elsif ($name eq 'end') { } 0 0 0
717 {
718 0 return( {X => 0, Y => 0, NAME => 'start', CHAR => 'X'} ) ;
719 }
720 elsif($name eq 'end')
721 {
722 0 return( {X => $self->{END_X}, Y => $self->{END_Y}, NAME => 'end', CHAR => 'Y'} ) ;
723 }
724 else
725 {
726 0 return ;
727 }
728 }
729  
730 #-----------------------------------------------------------------------------
731  
732 sub get_direction
733 0 ▶{
Subroutine get_direction: not called CC=1 SCAR=6.9
Pod undocumented
734 0 my ($self) = @_ ;
735  
736 0 return $self->{DIRECTION} ;
737 }
738  
739 #-----------------------------------------------------------------------------
740  
741 sub move_connector
742 0 ▶{
Subroutine move_connector: not called CC=3 SCAR=24.8
Pod undocumented
743 0 my ($self, $connector_name, $x_offset, $y_offset, $hint) = @_ ;
744  
745 0 ▶if($connector_name eq 'start')
Branch: 2 branches
BranchTrueFalseTotal
if ($connector_name eq 'start') { } 0 0 0
elsif ($connector_name eq 'end') { } 0 0 0
746 {
747 0 my ($x_offset, $y_offset, $width, $height, undef) =
748 $self->resize(0, 0, $x_offset, $y_offset, $hint) ;
749
750 return
751 $x_offset, $y_offset, $width, $height,
752 0 {X => $self->{END_X}, Y => $self->{END_Y}, NAME => 'start'} ;
753 }
754 elsif($connector_name eq 'end')
755 {
756 my ($x_offset, $y_offset, $width, $height, undef) =
757 0 $self->resize(-1, -1, $self->{END_X} + $x_offset, $self->{END_Y} + $y_offset, $hint) ;
758
759 return
760 $x_offset, $y_offset, $width, $height,
761 0 {X => $self->{END_X}, Y => $self->{END_Y}, NAME => 'end'} ;
762 }
763 else
764 {
765 0 die "unknown connector '$connector_name'!\n" ;
766 }
767 }
768  
769 #-----------------------------------------------------------------------------
770  
771 sub resize
772 0 ▶{
Subroutine resize: not called CC=8 SCAR=42.8
Pod undocumented
773 0 my ($self, $reference_x, $reference_y, $new_x, $new_y, $hint, $connector_name) = @_ ;
774  
775 0 my $is_start ;
776  
777 0 ▶if(defined $connector_name)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $connector_name) { } 0 0 0
778 {
779 0 ▶ if($connector_name eq 'start')
Branch: 1 branch
BranchTrueFalseTotal
if ($connector_name eq "start") 0 0 0
780 {
781 0 $is_start++ ;
782 }
783 }
784 else
785 {
786 0 ▶ if($reference_x == 0 && $reference_y == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($reference_x == 0 and $reference_y == 0) 0 0 0
Condition0%0/3
$reference_x == 0 and $reference_y == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$reference_x == 0 and $reference_y == 0
$reference_x == 0 $reference_y == 0
Truth table0%0/3
A and B
A= $reference_x == 0B= $reference_y == 0
ABresult
0X0
100
111
787 {
788 0 $is_start++ ;
789 }
790 }
791  
792 0 ▶if($is_start)
Branch: 1 branch
BranchTrueFalseTotal
if ($is_start) { } 0 0 0
793 {
794 0 my $x_offset = $new_x ;
795 0 my $y_offset = $new_y ;
796
797 0 my $new_end_x = $self->{END_X} - $x_offset ;
798 0 my $new_end_y = $self->{END_Y} - $y_offset ;
799
800 0 ▶ $self->setup($self->{ARROW_TYPE}, $new_end_x, $new_end_y, $hint || $self->{DIRECTION},$self ->{ALLOW_DIAGONAL_LINES}, $self->{EDITABLE}) ;
Condition0%0/3
$hint || $self->{'DIRECTION'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$hint || $self->{'DIRECTION'}
$hint $self->{'DIRECTION'}
Truth table0%0/3
A || B
A= $hintB= $self->{'DIRECTION'}
ABresult
1X1
011
000
801
802 0 return($x_offset, $y_offset, $self->{WIDTH}, $self->{HEIGHT}, 'start') ;
803 }
804 else
805 {
806 0 my $new_end_x = $new_x ;
807 0 my $new_end_y = $new_y ;
808
809 0 ▶ $self->setup($self->{ARROW_TYPE}, $new_end_x, $new_end_y, $hint || $self->{DIRECTION}, $self ->{ALLOW_DIAGONAL_LINES}, $self->{EDITABLE}) ;
Condition0%0/3
$hint || $self->{'DIRECTION'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$hint || $self->{'DIRECTION'}
$hint $self->{'DIRECTION'}
Truth table0%0/3
A || B
A= $hintB= $self->{'DIRECTION'}
ABresult
1X1
011
000
810
811 0 return(0, 0, $self->{WIDTH}, $self->{HEIGHT}, 'end') ;
812 }
813 }
814  
815 #-----------------------------------------------------------------------------
816  
817 sub edit
818 0 ▶{
Subroutine edit: not called CC=2 SCAR=17.9
Pod undocumented
819 0 my ($self, $asciio) = @_ ;
820  
821 0 ▶return unless $self->{EDITABLE} ;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"EDITABLE"} 0 0 0
822  
823 0 $self->display_arrow_edit_dialog() ;
824  
825 my ($stripes, $width, $height, $x_offset, $y_offset) =
826 0 $direction_to_arrow{$self->{DIRECTION}}->($self->{ARROW_TYPE}, $self->{END_X}, $self->{END_Y}) ;
827  
828 0 $self->set(STRIPES => $stripes,) ;
829 }
830  
831 #-----------------------------------------------------------------------------
832  
833 2 1 ;
834  
835  
836  
837  
838  
839  
840  
841  
842  
« blib/lib/App/Asciio.pm ↑ Summary blib/lib/App/Asciio/Actions/Ruler.pm »