line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Tree::Visualize::ASCII::Layouts::Binary::TopDown; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
1217
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
82
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
9
|
use base qw(Tree::Visualize::ASCII::Layouts::Binary); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
642
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
11
|
use Tree::Visualize::Exceptions; |
|
2
|
|
|
|
|
31
|
|
|
2
|
|
|
|
|
48
|
|
12
|
2
|
|
|
2
|
|
513
|
use Tree::Visualize::Connector::Factory; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
642
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub drawConnections { |
15
|
15
|
|
|
15
|
1
|
21
|
my ($self, $current, $left, $right) = @_; |
16
|
|
|
|
|
|
|
# prepare the connections |
17
|
15
|
|
|
|
|
16
|
my ($left_connection, $right_connection) = (undef, undef); |
18
|
15
|
|
|
|
|
53
|
my $conn_factory = Tree::Visualize::Connector::Factory->new(); |
19
|
|
|
|
|
|
|
# get the left connection if we need it |
20
|
15
|
100
|
|
|
|
50
|
$left_connection = $conn_factory->get( |
21
|
|
|
|
|
|
|
output => 'ASCII', |
22
|
|
|
|
|
|
|
layout => 'TopDown', |
23
|
|
|
|
|
|
|
connector_type => 'LeftRightConnector' |
24
|
|
|
|
|
|
|
)->drawLeftConnector($current, $left) |
25
|
|
|
|
|
|
|
if defined $left; |
26
|
|
|
|
|
|
|
# get the right connection if we need it |
27
|
15
|
100
|
|
|
|
61
|
$right_connection = $conn_factory->get( |
28
|
|
|
|
|
|
|
output => 'ASCII', |
29
|
|
|
|
|
|
|
layout => 'TopDown', |
30
|
|
|
|
|
|
|
connector_type => 'LeftRightConnector' |
31
|
|
|
|
|
|
|
)->drawRightConnector($current, $right) |
32
|
|
|
|
|
|
|
if defined $right; |
33
|
|
|
|
|
|
|
# return our connections |
34
|
15
|
|
|
|
|
102
|
return ($left_connection, $right_connection); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub assembleDrawing { |
38
|
15
|
|
|
15
|
1
|
19
|
my ($self, $current, $children, $connections) = @_; |
39
|
|
|
|
|
|
|
# get the children ... |
40
|
15
|
|
|
|
|
15
|
my ($left, $right) = @{$children}; |
|
15
|
|
|
|
|
20
|
|
41
|
|
|
|
|
|
|
# if we have no left of no right, then just return |
42
|
|
|
|
|
|
|
# otherwise we need to process them ... |
43
|
15
|
100
|
66
|
|
|
51
|
unless (!$left && !$right) { |
44
|
|
|
|
|
|
|
# stash the width of the current for later |
45
|
7
|
|
|
|
|
17
|
my $orig_current_width = $current->width(); |
46
|
|
|
|
|
|
|
# get the connections ... |
47
|
7
|
|
|
|
|
8
|
my ($left_connection, $right_connection) = @{$connections}; |
|
7
|
|
|
|
|
10
|
|
48
|
|
|
|
|
|
|
# paste the connections |
49
|
7
|
50
|
|
|
|
26
|
$current->pasteLeft($left_connection) if defined $left_connection; |
50
|
7
|
50
|
|
|
|
26
|
$current->pasteRight($right_connection) if defined $right_connection; |
51
|
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
8
|
my $bottom = ""; |
53
|
7
|
50
|
|
|
|
25
|
if ($left) { |
|
|
0
|
|
|
|
|
|
54
|
7
|
|
|
|
|
22
|
$left->padRight(" " x $orig_current_width); |
55
|
7
|
50
|
|
|
|
13
|
if ($right) { |
56
|
7
|
|
|
|
|
26
|
$bottom = $left->pasteRight($right); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
$bottom = $left; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ($right) { |
63
|
0
|
|
|
|
|
0
|
$bottom = $right->padLeft(" " x $orig_current_width); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
# however, if we have them, then add them to the output |
66
|
7
|
|
|
|
|
21
|
$current = $current->pasteBottom($bottom); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
# # just debugging |
69
|
|
|
|
|
|
|
# if (DEBUG) { |
70
|
|
|
|
|
|
|
# debug->log("=" x 80); |
71
|
|
|
|
|
|
|
# debug->log(join "\n" => map { "[$_]" } $current->getLinesAsArray()); |
72
|
|
|
|
|
|
|
# debug->log("=" x 80); |
73
|
|
|
|
|
|
|
# } |
74
|
15
|
|
|
|
|
81
|
return $current; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |