line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gtk2::Ex::MindMapView::Layout::Column; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.000001'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1695
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
61
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use List::Util; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
370
|
use Gtk2::Ex::MindMapView::Layout::Group; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
12
|
1
|
|
|
1
|
|
619
|
use Gtk2::Ex::MindMapView::Layout::Cluster; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use base 'Gtk2::Ex::MindMapView::Layout::Group'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
780
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
|
|
0
|
1
|
|
my $class = shift(@_); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if (!defined $self->{column_no}) |
23
|
|
|
|
|
|
|
{ |
24
|
0
|
|
|
|
|
|
croak "Gtk2::Ex::MindMapView::Layout::Column requires a 'column_no'\n"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$self->{clusters} = {}; # Hash of clusters. |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# $column->add($predecessor_item, $item) |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub add |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
|
my ($self, $predecessor_item, $item) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
my $cluster_item = (defined $predecessor_item) ? $predecessor_item : $item; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $cluster = $self->{clusters}{$cluster_item}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if (!defined $cluster) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
|
$cluster = Gtk2::Ex::MindMapView::Layout::Cluster->new(column=>$self, |
46
|
|
|
|
|
|
|
predecessor=>$predecessor_item, |
47
|
0
|
|
|
|
|
|
cluster_no=>(scalar keys(%{$self->{clusters}}))); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->{clusters}{$cluster_item} = $cluster; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$cluster->add($item); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my @clusters = values (%{$self->{clusters}}); |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$self->set(height=>_column_height($self, \@clusters)); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$self->set(width=>_column_width($self, \@clusters)); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# $column->layout(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub layout |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
1
|
|
my $self = shift(@_); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my ($x, $y) = $self->get(qw(x y)); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my @clusters = values (%{$self->{clusters}}); |
|
0
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my @sorted_clusters = sort { $a->seq_no() <=> $b->seq_no() } @clusters; |
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# my @sorted_clusters = sort { $a->get('cluster_no') <=> $b->get('cluster_no') } @clusters; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my @visible_clusters = grep { $_->get('height') > 0 } @sorted_clusters; |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
foreach my $cluster (@visible_clusters) |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
|
|
|
|
|
$cluster->set(x=>$x); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$cluster->set(y=>$y); |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
$cluster->layout(); |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$y += ($cluster->get('height') + $self->get_vertical_padding()); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _column_height |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
0
|
|
|
my ($self, $clusters_ref) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my @clusters = @$clusters_ref; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my @visible_clusters = grep { $_->get('height') > 0 } @clusters; |
|
0
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
return 0 if (scalar @visible_clusters == 0); |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $total_height = List::Util::sum (map { $_->get('height'); } @visible_clusters); |
|
0
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $total_pad = ($#visible_clusters * $self->get_vertical_padding()); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# print "Column, height: $total_height pad: $total_pad\n"; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return ($total_height + $total_pad); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _column_width |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
0
|
|
|
my ($self, $clusters_ref) = @_; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my @clusters = @$clusters_ref; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $max_width = List::Util::max (map { $_->get('width'); } @clusters); |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my $width = List::Util::min($max_width, $self->get_max_width()); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# print "Column, max_width: $max_width width: $width\n"; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $width; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
128
|
|
|
|
|
|
|
__END__ |