line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Cladogram; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2236
|
use File::Slurper 'read_lines'; |
|
2
|
|
|
|
|
29642
|
|
|
2
|
|
|
|
|
151
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1201
|
use Moo; |
|
2
|
|
|
|
|
26026
|
|
|
2
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
6817
|
use Tree::DAG_Node; |
|
2
|
|
|
|
|
39504
|
|
|
2
|
|
|
|
|
112
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1589
|
use Types::Standard qw/Any Int Str/; |
|
2
|
|
|
|
|
160689
|
|
|
2
|
|
|
|
|
30
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has branch_color => |
12
|
|
|
|
|
|
|
( |
13
|
|
|
|
|
|
|
default => sub{return '#7e7e7e'}, |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => Str, |
16
|
|
|
|
|
|
|
required => 0, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has branch_width => |
20
|
|
|
|
|
|
|
( |
21
|
|
|
|
|
|
|
default => sub{return 3}, |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => Int, |
24
|
|
|
|
|
|
|
required => 0, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has draw_frame => |
28
|
|
|
|
|
|
|
( |
29
|
|
|
|
|
|
|
default => sub{return 0}, |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => Int, |
32
|
|
|
|
|
|
|
required => 0, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has debug => |
36
|
|
|
|
|
|
|
( |
37
|
|
|
|
|
|
|
default => sub{return 0}, |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => Int, |
40
|
|
|
|
|
|
|
required => 0, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has final_x_step => |
44
|
|
|
|
|
|
|
( |
45
|
|
|
|
|
|
|
default => sub{return 30}, |
46
|
|
|
|
|
|
|
is => 'rw', |
47
|
|
|
|
|
|
|
isa => Int, |
48
|
|
|
|
|
|
|
required => 0, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has frame_color => |
52
|
|
|
|
|
|
|
( |
53
|
|
|
|
|
|
|
default => sub{return '#0000ff'}, |
54
|
|
|
|
|
|
|
is => 'rw', |
55
|
|
|
|
|
|
|
isa => Str, |
56
|
|
|
|
|
|
|
required => 0, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has input_file => |
60
|
|
|
|
|
|
|
( |
61
|
|
|
|
|
|
|
default => sub{return ''}, |
62
|
|
|
|
|
|
|
is => 'rw', |
63
|
|
|
|
|
|
|
isa => Str, |
64
|
|
|
|
|
|
|
required => 0, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has leaf_font_color => |
68
|
|
|
|
|
|
|
( |
69
|
|
|
|
|
|
|
default => sub{return '#0000ff'}, |
70
|
|
|
|
|
|
|
is => 'rw', |
71
|
|
|
|
|
|
|
isa => Str, |
72
|
|
|
|
|
|
|
required => 0, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has leaf_font_file => |
76
|
|
|
|
|
|
|
( |
77
|
|
|
|
|
|
|
default => sub{return '/usr/share/fonts/truetype/freefont/FreeMono.ttf'}, |
78
|
|
|
|
|
|
|
is => 'rw', |
79
|
|
|
|
|
|
|
isa => Str, |
80
|
|
|
|
|
|
|
required => 0, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has leaf_font_size => |
84
|
|
|
|
|
|
|
( |
85
|
|
|
|
|
|
|
default => sub{return 16}, |
86
|
|
|
|
|
|
|
is => 'rw', |
87
|
|
|
|
|
|
|
isa => Int, |
88
|
|
|
|
|
|
|
required => 0, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has left_margin => |
92
|
|
|
|
|
|
|
( |
93
|
|
|
|
|
|
|
default => sub{return 15}, |
94
|
|
|
|
|
|
|
is => 'rw', |
95
|
|
|
|
|
|
|
isa => Int, |
96
|
|
|
|
|
|
|
required => 0, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has maximum_x => |
100
|
|
|
|
|
|
|
( |
101
|
|
|
|
|
|
|
default => sub{return 0}, |
102
|
|
|
|
|
|
|
is => 'rw', |
103
|
|
|
|
|
|
|
isa => Int, |
104
|
|
|
|
|
|
|
required => 0, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has maximum_y => |
108
|
|
|
|
|
|
|
( |
109
|
|
|
|
|
|
|
default => sub{return 0}, |
110
|
|
|
|
|
|
|
is => 'rw', |
111
|
|
|
|
|
|
|
isa => Int, |
112
|
|
|
|
|
|
|
required => 0, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
has minimum_sister_separation => |
116
|
|
|
|
|
|
|
( |
117
|
|
|
|
|
|
|
default => sub{return 0}, |
118
|
|
|
|
|
|
|
is => 'rw', |
119
|
|
|
|
|
|
|
isa => Int, |
120
|
|
|
|
|
|
|
required => 0, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
has minimum_y => |
124
|
|
|
|
|
|
|
( |
125
|
|
|
|
|
|
|
default => sub{return 0}, |
126
|
|
|
|
|
|
|
is => 'rw', |
127
|
|
|
|
|
|
|
isa => Int, |
128
|
|
|
|
|
|
|
required => 0, |
129
|
|
|
|
|
|
|
); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
has output_file => |
132
|
|
|
|
|
|
|
( |
133
|
|
|
|
|
|
|
default => sub{return ''}, |
134
|
|
|
|
|
|
|
is => 'rw', |
135
|
|
|
|
|
|
|
isa => Str, |
136
|
|
|
|
|
|
|
required => 0, |
137
|
|
|
|
|
|
|
); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
has print_tree => |
140
|
|
|
|
|
|
|
( |
141
|
|
|
|
|
|
|
default => sub{return 0}, |
142
|
|
|
|
|
|
|
is => 'rw', |
143
|
|
|
|
|
|
|
isa => Int, |
144
|
|
|
|
|
|
|
required => 0, |
145
|
|
|
|
|
|
|
); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
has root => |
148
|
|
|
|
|
|
|
( |
149
|
|
|
|
|
|
|
default => sub{return ''}, |
150
|
|
|
|
|
|
|
is => 'rw', |
151
|
|
|
|
|
|
|
isa => Any, |
152
|
|
|
|
|
|
|
required => 0, |
153
|
|
|
|
|
|
|
); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
has title => |
156
|
|
|
|
|
|
|
( |
157
|
|
|
|
|
|
|
default => sub{return ''}, |
158
|
|
|
|
|
|
|
is => 'rw', |
159
|
|
|
|
|
|
|
isa => Str, |
160
|
|
|
|
|
|
|
required => 0, |
161
|
|
|
|
|
|
|
); |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
has title_font_color => |
164
|
|
|
|
|
|
|
( |
165
|
|
|
|
|
|
|
default => sub{return '#000000'}, |
166
|
|
|
|
|
|
|
is => 'rw', |
167
|
|
|
|
|
|
|
isa => Str, |
168
|
|
|
|
|
|
|
required => 0, |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
has title_font_file => |
172
|
|
|
|
|
|
|
( |
173
|
|
|
|
|
|
|
default => sub{return '/usr/share/fonts/truetype/freefont/FreeMono.ttf'}, |
174
|
|
|
|
|
|
|
is => 'rw', |
175
|
|
|
|
|
|
|
isa => Str, |
176
|
|
|
|
|
|
|
required => 0, |
177
|
|
|
|
|
|
|
); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
has title_font_size => |
180
|
|
|
|
|
|
|
( |
181
|
|
|
|
|
|
|
default => sub{return 16}, |
182
|
|
|
|
|
|
|
is => 'rw', |
183
|
|
|
|
|
|
|
isa => Int, |
184
|
|
|
|
|
|
|
required => 0, |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
has title_width => |
188
|
|
|
|
|
|
|
( |
189
|
|
|
|
|
|
|
default => sub{return 0}, |
190
|
|
|
|
|
|
|
is => 'rw', |
191
|
|
|
|
|
|
|
isa => Int, |
192
|
|
|
|
|
|
|
required => 0, |
193
|
|
|
|
|
|
|
); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
has top_margin => |
196
|
|
|
|
|
|
|
( |
197
|
|
|
|
|
|
|
default => sub{return 15}, |
198
|
|
|
|
|
|
|
is => 'rw', |
199
|
|
|
|
|
|
|
isa => Int, |
200
|
|
|
|
|
|
|
required => 0, |
201
|
|
|
|
|
|
|
); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
has uid => |
204
|
|
|
|
|
|
|
( |
205
|
|
|
|
|
|
|
default => sub{return 0}, |
206
|
|
|
|
|
|
|
is => 'rw', |
207
|
|
|
|
|
|
|
isa => Int, |
208
|
|
|
|
|
|
|
required => 0, |
209
|
|
|
|
|
|
|
); |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
has x_step => |
212
|
|
|
|
|
|
|
( |
213
|
|
|
|
|
|
|
default => sub{return 50}, |
214
|
|
|
|
|
|
|
is => 'rw', |
215
|
|
|
|
|
|
|
isa => Int, |
216
|
|
|
|
|
|
|
required => 0, |
217
|
|
|
|
|
|
|
); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
has y_step => |
220
|
|
|
|
|
|
|
( |
221
|
|
|
|
|
|
|
default => sub{return 36}, |
222
|
|
|
|
|
|
|
is => 'rw', |
223
|
|
|
|
|
|
|
isa => Int, |
224
|
|
|
|
|
|
|
required => 0, |
225
|
|
|
|
|
|
|
); |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
our $VERSION = '1.04'; |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
# ------------------------------------------------ |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub BUILD |
232
|
|
|
|
|
|
|
{ |
233
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
$self -> root($self -> new_node('0', {place => 'middle'}) ); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
} # End of BUILD. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# ------------------------------------------------ |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub _adjust_minimum_sister_separation |
242
|
|
|
|
|
|
|
{ |
243
|
0
|
|
|
0
|
|
|
my($self) = @_; |
244
|
0
|
|
|
|
|
|
my($minimum_y) = 0; |
245
|
0
|
|
|
|
|
|
my($minimum_sister_separation) = $self -> minimum_sister_separation; |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
my(@attributes, $actual_sister_separation); |
248
|
0
|
|
|
|
|
|
my(@bounds); |
249
|
0
|
|
|
|
|
|
my(@daughters); |
250
|
0
|
|
|
|
|
|
my(@names, $new_sister_separation); |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
$self -> root -> walk_down |
253
|
|
|
|
|
|
|
({ |
254
|
|
|
|
|
|
|
callback => |
255
|
|
|
|
|
|
|
sub |
256
|
|
|
|
|
|
|
{ |
257
|
0
|
|
|
0
|
|
|
my($node) = @_; |
258
|
0
|
|
|
|
|
|
@daughters = $node -> daughters; |
259
|
|
|
|
|
|
|
|
260
|
0
|
0
|
|
|
|
|
if ($#daughters == 2) |
261
|
|
|
|
|
|
|
{ |
262
|
0
|
|
|
|
|
|
@attributes = map{$_ -> attributes} @daughters; |
|
0
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
@names = map{$_ -> name} @daughters; |
|
0
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
0
|
0
|
|
|
|
|
return 1 if ($names[2] =~ /^\d+$/); |
266
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
$actual_sister_separation = ${$attributes[2]}{y} - ${$attributes[1]}{y}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
0
|
0
|
|
|
|
|
if ($actual_sister_separation >= $minimum_sister_separation) |
270
|
|
|
|
|
|
|
{ |
271
|
0
|
0
|
|
|
|
|
$new_sister_separation = ($actual_sister_separation == $minimum_sister_separation) ? 6 : int( ($actual_sister_separation - $minimum_sister_separation) / 2); |
272
|
0
|
|
|
|
|
|
${$attributes[1]}{y} += $new_sister_separation; |
|
0
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
|
${$attributes[2]}{y} -= $new_sister_separation; |
|
0
|
|
|
|
|
|
|
274
|
0
|
|
|
|
|
|
@bounds = map{$$_{bounds} } @attributes; |
|
0
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
${$bounds[1]}[1] += $new_sister_separation; |
|
0
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
${$bounds[1]}[3] += $new_sister_separation; |
|
0
|
|
|
|
|
|
|
277
|
0
|
|
|
|
|
|
${$bounds[2]}[1] -= $new_sister_separation; |
|
0
|
|
|
|
|
|
|
278
|
0
|
|
|
|
|
|
${$bounds[2]}[3] -= $new_sister_separation; |
|
0
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# What's really scary is that I don't have to do this: |
281
|
|
|
|
|
|
|
# ${$attributes[1]}{bounds} = $bounds[1]; |
282
|
|
|
|
|
|
|
# ${$attributes[2]}{bounds} = $bounds[2]; |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
|
|
|
|
$daughters[1] -> attributes($attributes[1]); |
285
|
0
|
|
|
|
|
|
$daughters[2] -> attributes($attributes[2]); |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
290
|
|
|
|
|
|
|
}, |
291
|
0
|
|
|
|
|
|
_depth => 0, |
292
|
|
|
|
|
|
|
}); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
} # End of _adjust_minimum_sister_separation. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# ------------------------------------------------ |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub _calculate_basic_attributes |
299
|
|
|
|
|
|
|
{ |
300
|
0
|
|
|
0
|
|
|
my($self) = @_; |
301
|
0
|
|
|
|
|
|
my($x_step) = $self -> x_step; |
302
|
0
|
|
|
|
|
|
my($y_step) = $self -> y_step; |
303
|
|
|
|
|
|
|
|
304
|
0
|
|
|
|
|
|
my($attributes); |
305
|
|
|
|
|
|
|
my($parent_attributes); |
306
|
0
|
|
|
|
|
|
my($scale); |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
$self -> root -> walk_down |
309
|
|
|
|
|
|
|
({ |
310
|
|
|
|
|
|
|
callback => |
311
|
|
|
|
|
|
|
sub |
312
|
|
|
|
|
|
|
{ |
313
|
0
|
|
|
0
|
|
|
my($node, $options) = @_; |
314
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
# Set defaults if steps are not provided. |
317
|
|
|
|
|
|
|
|
318
|
0
|
|
0
|
|
|
|
$$attributes{x_step} ||= $x_step; |
319
|
0
|
|
0
|
|
|
|
$$attributes{y_step} ||= $y_step; |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
# Set co-ords. |
322
|
|
|
|
|
|
|
|
323
|
0
|
0
|
|
|
|
|
if ($node -> is_root) |
324
|
|
|
|
|
|
|
{ |
325
|
0
|
|
|
|
|
|
$$attributes{x} = 0; |
326
|
0
|
|
|
|
|
|
$$attributes{y} = 0; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
else |
329
|
|
|
|
|
|
|
{ |
330
|
|
|
|
|
|
|
# $scale is a multiplier for the sister step. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
$scale = $$attributes{place} eq 'above' |
333
|
|
|
|
|
|
|
? -1 |
334
|
0
|
0
|
|
|
|
|
: $$attributes{place} eq 'middle' |
|
|
0
|
|
|
|
|
|
335
|
|
|
|
|
|
|
? 0 |
336
|
|
|
|
|
|
|
: 1; |
337
|
0
|
|
|
|
|
|
$parent_attributes = $node -> mother -> attributes; |
338
|
0
|
|
|
|
|
|
$$attributes{x} = $$parent_attributes{x} + $$attributes{x_step}; |
339
|
0
|
|
|
|
|
|
$$attributes{y} = $$parent_attributes{y} + $scale * $$attributes{y_step}; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
$node -> attributes($attributes); |
343
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
345
|
|
|
|
|
|
|
}, |
346
|
0
|
|
|
|
|
|
_depth => 0, |
347
|
|
|
|
|
|
|
}); |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
} # End of _calculate_basic_attributes. |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
# ------------------------------------------------ |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
sub _calculate_minimum_sister_separation |
354
|
|
|
|
|
|
|
{ |
355
|
0
|
|
|
0
|
|
|
my($self) = @_; |
356
|
0
|
|
|
|
|
|
my($minimum_y) = 0; |
357
|
0
|
|
|
|
|
|
my($minimum_sister_separation) = $self -> maximum_y; |
358
|
|
|
|
|
|
|
|
359
|
0
|
|
|
|
|
|
$self -> minimum_sister_separation($minimum_sister_separation); |
360
|
|
|
|
|
|
|
|
361
|
0
|
|
|
|
|
|
my(@attributes); |
362
|
|
|
|
|
|
|
my(@daughters); |
363
|
0
|
|
|
|
|
|
my(@names); |
364
|
0
|
|
|
|
|
|
my($sister_separation); |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
$self -> root -> walk_down |
367
|
|
|
|
|
|
|
({ |
368
|
|
|
|
|
|
|
callback => |
369
|
|
|
|
|
|
|
sub |
370
|
|
|
|
|
|
|
{ |
371
|
0
|
|
|
0
|
|
|
my($node) = @_; |
372
|
0
|
|
|
|
|
|
@daughters = $node -> daughters; |
373
|
|
|
|
|
|
|
|
374
|
0
|
0
|
|
|
|
|
if ($#daughters == 2) |
375
|
|
|
|
|
|
|
{ |
376
|
0
|
|
|
|
|
|
@attributes = map{$_ -> attributes} @daughters; |
|
0
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
@names = map{$_ -> name} @daughters; |
|
0
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
|
379
|
0
|
0
|
|
|
|
|
return 1 if ($names[2] =~ /^\d+$/); |
380
|
|
|
|
|
|
|
|
381
|
0
|
|
|
|
|
|
$sister_separation = ${$attributes[2]}{y} - ${$attributes[1]}{y}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
|
383
|
0
|
0
|
|
|
|
|
if ($sister_separation < $minimum_sister_separation) |
384
|
|
|
|
|
|
|
{ |
385
|
0
|
|
|
|
|
|
$minimum_sister_separation = $sister_separation; |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
390
|
|
|
|
|
|
|
}, |
391
|
0
|
|
|
|
|
|
_depth => 0, |
392
|
|
|
|
|
|
|
}); |
393
|
|
|
|
|
|
|
|
394
|
0
|
|
|
|
|
|
$self -> minimum_sister_separation($minimum_sister_separation); |
395
|
0
|
|
|
|
|
|
$self -> _adjust_minimum_sister_separation; |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
} # End of _calculate_minimum_sister_separation. |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
# ------------------------------------------------ |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
sub _check_point_within_rectangle |
402
|
|
|
|
|
|
|
{ |
403
|
0
|
|
|
0
|
|
|
my($self, $bounds_1, $x, $y) = @_; |
404
|
0
|
|
|
|
|
|
my($result) = 0; |
405
|
0
|
|
|
|
|
|
my($x_min) = $$bounds_1[0]; |
406
|
0
|
|
|
|
|
|
my($y_min) = $$bounds_1[1]; |
407
|
0
|
|
|
|
|
|
my($x_max) = $$bounds_1[2]; |
408
|
0
|
|
|
|
|
|
my($y_max) = $$bounds_1[3]; |
409
|
|
|
|
|
|
|
|
410
|
0
|
0
|
0
|
|
|
|
if ( ($x >= $x_min) && ($x <= $x_max) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
411
|
|
|
|
|
|
|
&& ($y >= $y_min) && ($y <= $y_max) ) |
412
|
|
|
|
|
|
|
{ |
413
|
0
|
|
|
|
|
|
$result = 1; |
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
0
|
|
|
|
|
|
return $result; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
} # End of _check_point_within_rectangle. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
# ------------------------------------------------ |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub _check_rectangle_within_rectangle |
423
|
|
|
|
|
|
|
{ |
424
|
0
|
|
|
0
|
|
|
my($self, $bounds_1, $bounds_2) = @_; |
425
|
0
|
|
|
|
|
|
my($result) = 0; |
426
|
0
|
|
|
|
|
|
my($x_min_2) = $$bounds_2[0]; |
427
|
0
|
|
|
|
|
|
my($y_min_2) = $$bounds_2[1]; |
428
|
0
|
|
|
|
|
|
my($x_max_2) = $$bounds_2[2]; |
429
|
0
|
|
|
|
|
|
my($y_max_2) = $$bounds_2[3]; |
430
|
|
|
|
|
|
|
|
431
|
0
|
0
|
0
|
|
|
|
if ($self -> _check_point_within_rectangle($bounds_1, $x_min_2, $y_min_2) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
432
|
|
|
|
|
|
|
|| $self -> _check_point_within_rectangle($bounds_1, $x_max_2, $y_min_2) |
433
|
|
|
|
|
|
|
|| $self -> _check_point_within_rectangle($bounds_1, $x_min_2, $y_max_2) |
434
|
|
|
|
|
|
|
|| $self -> _check_point_within_rectangle($bounds_1, $x_max_2, $y_max_2) ) |
435
|
|
|
|
|
|
|
{ |
436
|
0
|
|
|
|
|
|
$result = 1; |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
0
|
|
|
|
|
|
return $result; |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
} # End of _check_rectangle_within_rectangle. |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
# ------------------------------------------------ |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
sub _check_node_bounds |
446
|
|
|
|
|
|
|
{ |
447
|
0
|
|
|
0
|
|
|
my($self, $node_1) = @_; |
448
|
0
|
|
|
|
|
|
my($leaf_font_size) = $self -> leaf_font_size; |
449
|
0
|
|
|
|
|
|
my($attributes_1) = $node_1 -> attributes; |
450
|
0
|
|
|
|
|
|
my($bounds_1) = $$attributes_1{bounds}; |
451
|
0
|
|
|
|
|
|
my($uid_1) = $$attributes_1{uid}; |
452
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
|
my($attributes_2); |
454
|
|
|
|
|
|
|
my($bounds_2); |
455
|
0
|
|
|
|
|
|
my($candidate_step); |
456
|
0
|
|
|
|
|
|
my($parent_attributes); |
457
|
0
|
|
|
|
|
|
my($uid_2); |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
$self -> root -> walk_down |
460
|
|
|
|
|
|
|
({ |
461
|
|
|
|
|
|
|
callback => |
462
|
|
|
|
|
|
|
sub |
463
|
|
|
|
|
|
|
{ |
464
|
0
|
|
|
0
|
|
|
my($node_2) = @_; |
465
|
0
|
|
|
|
|
|
$attributes_2 = $node_2 -> attributes; |
466
|
0
|
|
|
|
|
|
$bounds_2 = $$attributes_2{bounds}; |
467
|
0
|
|
|
|
|
|
$uid_2 = $$attributes_2{uid}; |
468
|
|
|
|
|
|
|
|
469
|
0
|
0
|
|
|
|
|
if ($uid_1 < $uid_2) |
470
|
|
|
|
|
|
|
{ |
471
|
0
|
0
|
|
|
|
|
if ($self -> _check_rectangle_within_rectangle($bounds_1, $bounds_2) ) |
472
|
|
|
|
|
|
|
{ |
473
|
|
|
|
|
|
|
# Move the node down to avoid the overlap. |
474
|
|
|
|
|
|
|
# This assumes it's an 'above' node. |
475
|
|
|
|
|
|
|
# The formula for $candidate_step is my own invention, |
476
|
|
|
|
|
|
|
# selected after many experiments. |
477
|
|
|
|
|
|
|
|
478
|
0
|
|
|
|
|
|
$candidate_step = int($leaf_font_size / 2) + 8; |
479
|
0
|
|
|
|
|
|
$$bounds_2[1] += $candidate_step; |
480
|
0
|
|
|
|
|
|
$$bounds_2[3] += $candidate_step; |
481
|
0
|
|
|
|
|
|
$$attributes_2{bounds} = $bounds_2; |
482
|
0
|
|
|
|
|
|
$$attributes_2{y} += $candidate_step; |
483
|
|
|
|
|
|
|
|
484
|
0
|
|
|
|
|
|
$node_2 -> attributes($attributes_2); |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
489
|
|
|
|
|
|
|
}, |
490
|
0
|
|
|
|
|
|
_depth => 0, |
491
|
|
|
|
|
|
|
}); |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
} # End of _check_node_bounds. |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
# ------------------------------------------------ |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
sub _check_for_overlap |
498
|
|
|
|
|
|
|
{ |
499
|
0
|
|
|
0
|
|
|
my($self) = @_; |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
$self -> root -> walk_down |
502
|
|
|
|
|
|
|
({ |
503
|
|
|
|
|
|
|
callback => |
504
|
|
|
|
|
|
|
sub |
505
|
|
|
|
|
|
|
{ |
506
|
0
|
|
|
0
|
|
|
my($node) = @_; |
507
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
|
$self -> _check_node_bounds($node); |
509
|
|
|
|
|
|
|
|
510
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
511
|
|
|
|
|
|
|
}, |
512
|
0
|
|
|
|
|
|
_depth => 0, |
513
|
|
|
|
|
|
|
}); |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
} # End of _check_for_overlap. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
# ------------------------------------------------ |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
sub draw_image |
520
|
|
|
|
|
|
|
{ |
521
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
522
|
0
|
|
|
|
|
|
my($final_x_step) = $self -> final_x_step; |
523
|
0
|
|
|
|
|
|
my($maximum_x) = $self -> maximum_x + $self -> left_margin; |
524
|
0
|
|
|
|
|
|
my($maximum_y) = $self -> maximum_y + $self -> top_margin; |
525
|
0
|
|
|
|
|
|
my($image) = $self -> create_image($maximum_x, $maximum_y); |
526
|
0
|
|
|
|
|
|
my($x_step) = $self -> x_step; |
527
|
|
|
|
|
|
|
|
528
|
0
|
0
|
|
|
|
|
if ($self -> title_width > $maximum_x) |
529
|
|
|
|
|
|
|
{ |
530
|
0
|
|
|
|
|
|
$maximum_x = $self -> title_width + $self -> left_margin; |
531
|
0
|
|
|
|
|
|
$image = $self -> create_image($maximum_x, $maximum_y); |
532
|
|
|
|
|
|
|
|
533
|
0
|
|
|
|
|
|
$self -> maximum_x($maximum_x); |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
0
|
|
|
|
|
|
my($attributes); |
537
|
0
|
|
|
|
|
|
my(@daughters, @daughter_attributes, $daughter_attributes); |
538
|
0
|
|
|
|
|
|
my(@final_daughters, $final_offset); |
539
|
0
|
|
|
|
|
|
my($index); |
540
|
0
|
|
|
|
|
|
my($middle_attributes); |
541
|
0
|
|
|
|
|
|
my($name); |
542
|
0
|
|
|
|
|
|
my($place, %place); |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
$self -> root -> walk_down |
545
|
|
|
|
|
|
|
({ |
546
|
|
|
|
|
|
|
callback => |
547
|
|
|
|
|
|
|
sub |
548
|
|
|
|
|
|
|
{ |
549
|
0
|
|
|
0
|
|
|
my($node) = @_; |
550
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
551
|
0
|
|
|
|
|
|
@daughters = $node -> daughters; |
552
|
0
|
|
|
|
|
|
%place = (); |
553
|
|
|
|
|
|
|
|
554
|
0
|
|
|
|
|
|
for (0 .. $#daughters) |
555
|
|
|
|
|
|
|
{ |
556
|
0
|
|
|
|
|
|
$daughter_attributes[$_] = $daughters[$_] -> attributes; |
557
|
0
|
|
|
|
|
|
$place = $daughter_attributes[$_]{place}; |
558
|
0
|
|
|
|
|
|
$place{$place} = $_; |
559
|
0
|
0
|
|
|
|
|
$middle_attributes = $daughter_attributes[$_] if ($place eq 'middle'); |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
# Connect above and below daughters to middle daughter. |
563
|
|
|
|
|
|
|
|
564
|
0
|
|
|
|
|
|
for $place (keys %place) |
565
|
|
|
|
|
|
|
{ |
566
|
0
|
|
|
|
|
|
$index = $place{$place}; |
567
|
0
|
|
|
|
|
|
$name = $daughters[$index] -> name; |
568
|
0
|
|
|
|
|
|
$daughter_attributes = $daughter_attributes[$index]; |
569
|
|
|
|
|
|
|
|
570
|
0
|
|
|
|
|
|
$self -> draw_vertical_branch($image, $middle_attributes, $daughter_attributes); |
571
|
|
|
|
|
|
|
|
572
|
0
|
0
|
0
|
|
|
|
if ( ($node -> name ne $name) && ($name ne 'root') ) |
573
|
|
|
|
|
|
|
{ |
574
|
|
|
|
|
|
|
# Stretch the horizontal lines, but only for leaves. |
575
|
|
|
|
|
|
|
|
576
|
0
|
|
|
|
|
|
@final_daughters = $daughters[$index] -> daughters; |
577
|
0
|
0
|
|
|
|
|
$final_offset = $#final_daughters < 0 ? $final_x_step : 0; |
578
|
|
|
|
|
|
|
|
579
|
0
|
|
|
|
|
|
$self -> draw_horizontal_branch($image, $middle_attributes, $daughter_attributes, $final_offset); |
580
|
0
|
|
|
|
|
|
$self -> draw_leaf_name($image, $name, $daughter_attributes, $final_offset); |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
586
|
|
|
|
|
|
|
}, |
587
|
0
|
|
|
|
|
|
_depth => 0, |
588
|
|
|
|
|
|
|
}); |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
# Draw a line off to the left of the middle daughter of the root. |
591
|
|
|
|
|
|
|
|
592
|
0
|
|
|
|
|
|
$self -> draw_root_branch($image); |
593
|
0
|
|
|
|
|
|
$self -> draw_title($image, $maximum_x, $maximum_y); |
594
|
|
|
|
|
|
|
|
595
|
0
|
|
|
|
|
|
my($output_file) = $self -> output_file; |
596
|
|
|
|
|
|
|
|
597
|
0
|
0
|
|
|
|
|
$self -> write($image, $output_file) if (length($output_file) ); |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
} # End of draw_image. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
# ------------------------------------------------ |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
sub find_maximum_x |
604
|
|
|
|
|
|
|
{ |
605
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
606
|
0
|
|
|
|
|
|
my($maximum_x) = 0; |
607
|
|
|
|
|
|
|
|
608
|
0
|
|
|
|
|
|
my($attributes); |
609
|
|
|
|
|
|
|
my($bounds); |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
$self -> root -> walk_down |
612
|
|
|
|
|
|
|
({ |
613
|
|
|
|
|
|
|
callback => |
614
|
|
|
|
|
|
|
sub |
615
|
|
|
|
|
|
|
{ |
616
|
0
|
|
|
0
|
|
|
my($node) = @_; |
617
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
618
|
0
|
|
|
|
|
|
$bounds = $$attributes{bounds}; |
619
|
0
|
0
|
|
|
|
|
$maximum_x = $$bounds[2] if ($$bounds[2] > $maximum_x); |
620
|
|
|
|
|
|
|
|
621
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
622
|
|
|
|
|
|
|
}, |
623
|
0
|
|
|
|
|
|
_depth => 0, |
624
|
|
|
|
|
|
|
}); |
625
|
|
|
|
|
|
|
|
626
|
0
|
|
|
|
|
|
$maximum_x += $self -> final_x_step; |
627
|
0
|
0
|
|
|
|
|
$maximum_x = $self -> title_width if ($self -> title_width > $maximum_x); |
628
|
|
|
|
|
|
|
|
629
|
0
|
|
|
|
|
|
$self -> maximum_x($maximum_x); |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
} # End of find_maximum_x. |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# ------------------------------------------------ |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
sub find_maximum_y |
636
|
|
|
|
|
|
|
{ |
637
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
638
|
0
|
|
|
|
|
|
my($maximum_y) = 0; |
639
|
|
|
|
|
|
|
|
640
|
0
|
|
|
|
|
|
my($attributes); |
641
|
|
|
|
|
|
|
my($bounds); |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
$self -> root -> walk_down |
644
|
|
|
|
|
|
|
({ |
645
|
|
|
|
|
|
|
callback => |
646
|
|
|
|
|
|
|
sub |
647
|
|
|
|
|
|
|
{ |
648
|
0
|
|
|
0
|
|
|
my($node) = @_; |
649
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
650
|
0
|
|
|
|
|
|
$bounds = $$attributes{bounds}; |
651
|
0
|
0
|
|
|
|
|
$maximum_y = $$bounds[3] if ($$bounds[3] > $maximum_y); |
652
|
|
|
|
|
|
|
|
653
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
654
|
|
|
|
|
|
|
}, |
655
|
0
|
|
|
|
|
|
_depth => 0, |
656
|
|
|
|
|
|
|
}); |
657
|
|
|
|
|
|
|
|
658
|
0
|
|
|
|
|
|
$self -> maximum_y($maximum_y + 2 * $self -> title_font_size); |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
} # End of find_maximum_y. |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
# ------------------------------------------------ |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
sub find_minimum_y |
665
|
|
|
|
|
|
|
{ |
666
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
667
|
0
|
|
|
|
|
|
my($minimum_y) = 0; |
668
|
|
|
|
|
|
|
|
669
|
0
|
|
|
|
|
|
my($attributes); |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
$self -> root -> walk_down |
672
|
|
|
|
|
|
|
({ |
673
|
|
|
|
|
|
|
callback => |
674
|
|
|
|
|
|
|
sub |
675
|
|
|
|
|
|
|
{ |
676
|
0
|
|
|
0
|
|
|
my($node) = @_; |
677
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
678
|
0
|
0
|
|
|
|
|
$minimum_y = $$attributes{y} if ($$attributes{y} < $minimum_y); |
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
681
|
|
|
|
|
|
|
}, |
682
|
0
|
|
|
|
|
|
_depth => 0, |
683
|
|
|
|
|
|
|
}); |
684
|
|
|
|
|
|
|
|
685
|
0
|
|
|
|
|
|
$self -> minimum_y($minimum_y); |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
} # End of find_minimum_y. |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
# ------------------------------------------------ |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
sub log |
692
|
|
|
|
|
|
|
{ |
693
|
0
|
|
|
0
|
0
|
|
my($self, $message) = @_; |
694
|
|
|
|
|
|
|
|
695
|
0
|
|
|
|
|
|
print "$message\n"; |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
} # End of log. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
# ------------------------------------------------ |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
sub move_away_from_frame |
702
|
|
|
|
|
|
|
{ |
703
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
704
|
0
|
|
|
|
|
|
my($minimum_y) = $self -> minimum_y; |
705
|
0
|
|
|
|
|
|
my($top_margin) = $self -> top_margin; |
706
|
0
|
|
|
|
|
|
my($x_offset) = $self -> left_margin; |
707
|
0
|
0
|
|
|
|
|
my($y_offset) = $minimum_y <= 0 |
|
|
0
|
|
|
|
|
|
708
|
|
|
|
|
|
|
? $top_margin - $minimum_y |
709
|
|
|
|
|
|
|
: $minimum_y < $top_margin |
710
|
|
|
|
|
|
|
? $top_margin - $minimum_y |
711
|
|
|
|
|
|
|
: - $minimum_y + $top_margin; |
712
|
|
|
|
|
|
|
|
713
|
0
|
|
|
|
|
|
my($attributes); |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
$self -> root -> walk_down |
716
|
|
|
|
|
|
|
({ |
717
|
|
|
|
|
|
|
callback => |
718
|
|
|
|
|
|
|
sub |
719
|
|
|
|
|
|
|
{ |
720
|
0
|
|
|
0
|
|
|
my($node) = @_; |
721
|
0
|
|
|
|
|
|
$attributes = $node -> attributes; |
722
|
0
|
|
|
|
|
|
$$attributes{x} += $x_offset; |
723
|
0
|
|
|
|
|
|
$$attributes{y} += $y_offset; |
724
|
|
|
|
|
|
|
|
725
|
0
|
|
|
|
|
|
return 1; # Keep walking. |
726
|
|
|
|
|
|
|
}, |
727
|
0
|
|
|
|
|
|
_depth => 0, |
728
|
|
|
|
|
|
|
}); |
729
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
|
$self -> minimum_y($minimum_y); |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
} # End of move_away_from_frame. |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
# ------------------------------------------------ |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
sub new_node |
737
|
|
|
|
|
|
|
{ |
738
|
0
|
|
|
0
|
0
|
|
my($self, $name, $attributes) = @_; |
739
|
0
|
|
|
|
|
|
$$attributes{bounds} = []; |
740
|
0
|
|
|
|
|
|
$$attributes{uid} = $self -> uid($self -> uid + 1); |
741
|
|
|
|
|
|
|
|
742
|
0
|
|
|
|
|
|
return Tree::DAG_Node -> new({name => $name, attributes => $attributes}); |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
} # End of new_node. |
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
# ------------------------------------------------ |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
sub read |
749
|
|
|
|
|
|
|
{ |
750
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
751
|
0
|
|
|
|
|
|
my($count) = 0; |
752
|
0
|
|
|
|
|
|
my($parent) = $self -> root; |
753
|
|
|
|
|
|
|
|
754
|
0
|
|
|
|
|
|
my(%cache); |
755
|
|
|
|
|
|
|
my(@field); |
756
|
0
|
|
|
|
|
|
my($node); |
757
|
0
|
|
|
|
|
|
my(%seen); |
758
|
|
|
|
|
|
|
|
759
|
0
|
|
|
|
|
|
for my $line (read_lines($self -> input_file) ) |
760
|
|
|
|
|
|
|
{ |
761
|
0
|
|
|
|
|
|
$line =~ s/^\s+//; |
762
|
0
|
|
|
|
|
|
$line =~ s/\s+$//; |
763
|
|
|
|
|
|
|
|
764
|
0
|
0
|
0
|
|
|
|
next if ( (length($line) == 0) || ($line =~ /^\s*#/) ); |
765
|
|
|
|
|
|
|
|
766
|
0
|
|
|
|
|
|
$count++; |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
# Format expected (see data/wikipedia.01.clad): |
769
|
|
|
|
|
|
|
# |
770
|
|
|
|
|
|
|
# Parent Place Node |
771
|
|
|
|
|
|
|
# Root above Beetles |
772
|
|
|
|
|
|
|
# Root below 1 |
773
|
|
|
|
|
|
|
# 1 above Wasps, bees, ants |
774
|
|
|
|
|
|
|
# 1 below 2 |
775
|
|
|
|
|
|
|
# 2 above Butterflies, moths |
776
|
|
|
|
|
|
|
# 2 below Flies |
777
|
|
|
|
|
|
|
|
778
|
0
|
|
|
|
|
|
@field = split(/\s+/, $line, 3); |
779
|
0
|
|
|
|
|
|
$field[$_] = lc $field[$_] for (0 .. 1); |
780
|
|
|
|
|
|
|
|
781
|
0
|
0
|
|
|
|
|
if ($count == 1) |
782
|
|
|
|
|
|
|
{ |
783
|
0
|
|
|
|
|
|
$field[2] = lc $field[2]; |
784
|
|
|
|
|
|
|
|
785
|
0
|
0
|
0
|
|
|
|
if ( ($field[0] ne 'parent') || ($field[1] ne 'place') || ($field[2] ne 'node') ) |
|
|
|
0
|
|
|
|
|
786
|
|
|
|
|
|
|
{ |
787
|
0
|
|
|
|
|
|
die "Error. Input file line $count is in the wrong format. It must be 'Parent Place Node'\n"; |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
|
790
|
0
|
|
|
|
|
|
next; |
791
|
|
|
|
|
|
|
} |
792
|
|
|
|
|
|
|
|
793
|
0
|
0
|
|
|
|
|
if ($#field <= 1) |
794
|
|
|
|
|
|
|
{ |
795
|
0
|
|
|
|
|
|
die "Error. Input file line $count does not have enough columns\n"; |
796
|
|
|
|
|
|
|
} |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
# Count the # of times each node appears. This serves several purposes. |
799
|
|
|
|
|
|
|
|
800
|
0
|
0
|
|
|
|
|
$seen{$field[0]} = 0 if (! defined $seen{$field[0]}); |
801
|
0
|
|
|
|
|
|
$seen{$field[0]}++; |
802
|
|
|
|
|
|
|
|
803
|
0
|
0
|
|
|
|
|
if ($seen{$field[0]} > 2) |
|
|
0
|
|
|
|
|
|
804
|
|
|
|
|
|
|
{ |
805
|
0
|
|
|
|
|
|
die "Error. Input file line $count has $seen{$field[0]} copies of $field[0], but the maximum must be 2\n"; |
806
|
|
|
|
|
|
|
} |
807
|
|
|
|
|
|
|
elsif ($field[1] !~ /above|below/) |
808
|
|
|
|
|
|
|
{ |
809
|
0
|
|
|
|
|
|
die "Error. Input file line $count has a unknown place: '$field[1]'. It must be 'above' or 'below'\n"; |
810
|
|
|
|
|
|
|
} |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
# The first time each node appears, give its parent a middle daughter. |
813
|
|
|
|
|
|
|
# Note: The node called 'root' is not cached. |
814
|
|
|
|
|
|
|
|
815
|
0
|
0
|
|
|
|
|
if ($seen{$field[0]} == 1) |
816
|
|
|
|
|
|
|
{ |
817
|
0
|
|
|
|
|
|
$node = $self -> new_node($field[0], {place => 'middle'}); |
818
|
|
|
|
|
|
|
|
819
|
0
|
0
|
|
|
|
|
if ($cache{$field[0]}) |
820
|
|
|
|
|
|
|
{ |
821
|
0
|
|
|
|
|
|
$parent = $cache{$field[0]}; |
822
|
|
|
|
|
|
|
|
823
|
0
|
|
|
|
|
|
$parent -> add_daughter($node); |
824
|
|
|
|
|
|
|
} |
825
|
|
|
|
|
|
|
else |
826
|
|
|
|
|
|
|
{ |
827
|
0
|
|
|
|
|
|
$parent -> add_daughter($node); |
828
|
|
|
|
|
|
|
} |
829
|
|
|
|
|
|
|
} |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
# Now give the middle daughter its above and below sisters, one each time thru the loop. |
832
|
|
|
|
|
|
|
|
833
|
0
|
|
|
|
|
|
$cache{$field[2]} = $self -> new_node($field[2], {place => $field[1]}); |
834
|
|
|
|
|
|
|
|
835
|
0
|
|
|
|
|
|
$parent -> add_daughter($cache{$field[2]}); |
836
|
|
|
|
|
|
|
} |
837
|
|
|
|
|
|
|
|
838
|
|
|
|
|
|
|
} # End of read. |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
# ------------------------------------------------ |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
sub run |
843
|
|
|
|
|
|
|
{ |
844
|
0
|
|
|
0
|
1
|
|
my($self) = @_; |
845
|
|
|
|
|
|
|
|
846
|
0
|
|
|
|
|
|
$self -> read; |
847
|
0
|
|
|
|
|
|
$self -> _calculate_basic_attributes; |
848
|
0
|
|
|
|
|
|
$self -> find_minimum_y; |
849
|
0
|
0
|
|
|
|
|
$self -> move_away_from_frame if ($self -> minimum_y <= $self -> top_margin); |
850
|
0
|
|
|
|
|
|
$self -> _calculate_leaf_name_bounds; |
851
|
0
|
|
|
|
|
|
$self -> _check_for_overlap; |
852
|
0
|
|
|
|
|
|
$self -> find_maximum_x; |
853
|
0
|
|
|
|
|
|
$self -> find_maximum_y; |
854
|
0
|
|
|
|
|
|
$self -> _calculate_minimum_sister_separation; |
855
|
0
|
|
|
|
|
|
$self -> draw_image; |
856
|
|
|
|
|
|
|
|
857
|
0
|
0
|
|
|
|
|
$self -> log(join('', map("$_\n", @{$self -> root -> tree2string}) ) ) if ($self -> print_tree); |
|
0
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
# Return 0 for success and 1 for failure. |
860
|
|
|
|
|
|
|
|
861
|
0
|
|
|
|
|
|
return 0; |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
} # End of run. |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
# ------------------------------------------------ |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
1; |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=pod |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
=head1 NAME |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
C - Render a cladogram using Imager or Image::Magick |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
=head1 Synopsis |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
This is scripts/imager.pl: |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
#!/usr/bin/env perl |
880
|
|
|
|
|
|
|
|
881
|
|
|
|
|
|
|
use strict; |
882
|
|
|
|
|
|
|
use warnings; |
883
|
|
|
|
|
|
|
|
884
|
|
|
|
|
|
|
use Getopt::Long; |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
use Pod::Usage; |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
use Tree::Cladogram::Imager; # Or Tree::Cladogram::ImageMagick. |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
# ---------------------------------------------- |
891
|
|
|
|
|
|
|
|
892
|
|
|
|
|
|
|
my($option_parser) = Getopt::Long::Parser -> new; |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
my(%option); |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
if ($option_parser -> getoptions |
897
|
|
|
|
|
|
|
( |
898
|
|
|
|
|
|
|
\%option, |
899
|
|
|
|
|
|
|
'draw_frame=i', |
900
|
|
|
|
|
|
|
'frame_color=s', |
901
|
|
|
|
|
|
|
'help', |
902
|
|
|
|
|
|
|
'input_file=s', |
903
|
|
|
|
|
|
|
'leaf_font_file=s', |
904
|
|
|
|
|
|
|
'leaf_font_size=i', |
905
|
|
|
|
|
|
|
'output_file=s', |
906
|
|
|
|
|
|
|
'print_tree=i', |
907
|
|
|
|
|
|
|
'title=s', |
908
|
|
|
|
|
|
|
'title_font_file=s', |
909
|
|
|
|
|
|
|
'title_font_size=s', |
910
|
|
|
|
|
|
|
) ) |
911
|
|
|
|
|
|
|
{ |
912
|
|
|
|
|
|
|
pod2usage(1) if ($option{'help'}); |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
exit Tree::Cladogram::Imager -> new(%option) -> run; |
915
|
|
|
|
|
|
|
} |
916
|
|
|
|
|
|
|
else |
917
|
|
|
|
|
|
|
{ |
918
|
|
|
|
|
|
|
pod2usage(2); |
919
|
|
|
|
|
|
|
} |
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
See also scripts/image.magick.pl. |
922
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
As you can see, you create an object and then call L. |
924
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
And this is the heart of scripts/imager.sh: |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
perl -Ilib scripts/plot.pl \ |
928
|
|
|
|
|
|
|
-debug 0 \ |
929
|
|
|
|
|
|
|
-draw_frame $FRAME \ |
930
|
|
|
|
|
|
|
-input_file data/$i.01.clad \ |
931
|
|
|
|
|
|
|
-leaf_font_file $LEAF_FONT_FILE \ |
932
|
|
|
|
|
|
|
-output_file data/$i.01.png \ |
933
|
|
|
|
|
|
|
-title "$TITLE" \ |
934
|
|
|
|
|
|
|
-title_font_file $TITLE_FONT_FILE |
935
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
See also scripts/image.magick.sh. |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
=head1 Description |
939
|
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
C provides a mechanism to turn a tree into a cladogram image. |
941
|
|
|
|
|
|
|
The image is generated using L or L. |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
The image type created is determined by the suffix of the output file. See |
944
|
|
|
|
|
|
|
L for details. |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
The details of the cladogram are read from a text file. See the L for details. |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
For information about cladograms, see L. |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
For another sample of a cladogram, see |
951
|
|
|
|
|
|
|
L. |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
Sample input is shipped as data/*.clad. |
954
|
|
|
|
|
|
|
The corresponding output is shipped as data/*.png, and is on-line: |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
L |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
L |
959
|
|
|
|
|
|
|
|
960
|
|
|
|
|
|
|
L |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
L |
963
|
|
|
|
|
|
|
|
964
|
|
|
|
|
|
|
=head1 Distributions |
965
|
|
|
|
|
|
|
|
966
|
|
|
|
|
|
|
This module is available as a Unix-style distro (*.tgz). |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
See L |
969
|
|
|
|
|
|
|
for help on unpacking and installing distros. |
970
|
|
|
|
|
|
|
|
971
|
|
|
|
|
|
|
=head1 Installation |
972
|
|
|
|
|
|
|
|
973
|
|
|
|
|
|
|
Install L as you would for any C module: |
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
Run: |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
cpanm Tree::Cladogram |
978
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
or run: |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
sudo cpan Tree::Cladogram |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
or unpack the distro, and then: |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
perl Makefile.PL |
986
|
|
|
|
|
|
|
make (or dmake or nmake) |
987
|
|
|
|
|
|
|
make test |
988
|
|
|
|
|
|
|
make install |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
=head1 Constructor and Initialization |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
C is called as |
993
|
|
|
|
|
|
|
C<< my($cladotron) = Tree::Cladogram::Imager -> new(k1 => v1, k2 => v2, ...) >> or as |
994
|
|
|
|
|
|
|
C<< my($cladotron) = Tree::Cladogram::ImageMagick -> new(k1 => v1, k2 => v2, ...) >>. |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
It returns a new object of type C or C. |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
Key-value pairs accepted in the parameter list (see corresponding methods for details |
999
|
|
|
|
|
|
|
[e.g. L]): |
1000
|
|
|
|
|
|
|
|
1001
|
|
|
|
|
|
|
=over 4 |
1002
|
|
|
|
|
|
|
|
1003
|
|
|
|
|
|
|
=item o branch_color => $string |
1004
|
|
|
|
|
|
|
|
1005
|
|
|
|
|
|
|
Specify the color of the branches in the tree. |
1006
|
|
|
|
|
|
|
|
1007
|
|
|
|
|
|
|
See (in the FAQ) L for details about colors. |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
Default: '#7e7e7e' (gray). |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=item o branch_width => $integer |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
Specify the thickness of the branches. |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
Default: 3 (px). |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
=item o debug => $Boolean |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
Specify non-production effects. |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
Currently, the only extra effect is to draw fuchsia boxes around the leaf names. |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
Frankly, this helped me debug the L side of things. |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
Default: 0 (no extra effects). |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
=item o draw_frame => $Boolean |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
Specify that you want a frame around the image. |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
Default: 0 (no frame). |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
=item o final_x_step => $integer |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
Specify an extra bit for the length of the final branch leading to the names of the leaves. |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
Default: 30 (px). |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
=item o frame_color => $string |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
Specify the color of the frame, if any. |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
See also C. |
1044
|
|
|
|
|
|
|
|
1045
|
|
|
|
|
|
|
Default: '#0000ff' (blue). |
1046
|
|
|
|
|
|
|
|
1047
|
|
|
|
|
|
|
=item o input_file => $string |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
|
|
|
Specify the name of the *.clad file to read. Of course, the suffix does not have to be 'clad'. |
1050
|
|
|
|
|
|
|
|
1051
|
|
|
|
|
|
|
The format of this file is specified in the L. |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
Default: ''. |
1054
|
|
|
|
|
|
|
|
1055
|
|
|
|
|
|
|
=item o leaf_font_color => $string |
1056
|
|
|
|
|
|
|
|
1057
|
|
|
|
|
|
|
Specify the font color of the name of each leaf. |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
Default: '#0000ff' (blue). |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
=item o leaf_font_file => $string |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
Specify the name of the font file to use for the names of the leaves. |
1064
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
You can use path names, as per the default, or - using Image::Magick -, you can just use the name |
1066
|
|
|
|
|
|
|
of the font, such as 'DejaVu-Sans-ExtraLight'. |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
Default: '/usr/share/fonts/truetype/freefont/FreeMono.ttf'. |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
=item o leaf_font_size => $integer |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
Specify the size of the text used for the name of each leaf. |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
Default: 16 (points). |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
=item o left_margin => $integer |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
Specify the distance from the left of the image to the left-most point at which something is drawn. |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
This also sets the right-hand margin. |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
Default: 15 (px). |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=item o output_file => $string |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
Specify the name of the image file to write. |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
Image formats supported are anything supported by L or L. |
1089
|
|
|
|
|
|
|
See the L for details. |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
Default: '' (no output). |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
=item o print_tree => $Boolean |
1094
|
|
|
|
|
|
|
|
1095
|
|
|
|
|
|
|
Specify that you want to print the tree constructed by the code. |
1096
|
|
|
|
|
|
|
|
1097
|
|
|
|
|
|
|
This option is really a debugging aid. |
1098
|
|
|
|
|
|
|
|
1099
|
|
|
|
|
|
|
Default: 0 (no tree). |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
=item o title => $string |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
Specify the title to draw at the bottom of the image. |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
Default: '' (no title). |
1106
|
|
|
|
|
|
|
|
1107
|
|
|
|
|
|
|
=item o title_font_color => $string |
1108
|
|
|
|
|
|
|
|
1109
|
|
|
|
|
|
|
Specify the font color of the title. |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
Default: '#000000' (black). |
1112
|
|
|
|
|
|
|
|
1113
|
|
|
|
|
|
|
=item o title_font_file => $string |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
Specify the name of the font file to use for the title. |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
You can use path names, as per the default, or - using Image::Magick -, you can just use the name |
1118
|
|
|
|
|
|
|
of the font, such as 'DejaVu-Sans-ExtraLight'. |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
Default: '/usr/share/fonts/truetype/freefont/FreeSansBold.ttf'. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
=item o title_font_size => $integer |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
Specify the size of the text used for the name of the title. |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
Default: 16 (points). |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=item o top_margin => $integer |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
Specify the distance from the top of the image to the top-most point at which something is drawn. |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
This also sets the bottom margin. |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
Default: 15 (px). |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=item o x_step => $integer |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
The horizontal length of branches. |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
See also L and L. |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
Default: 50 (px). |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
=item o y_step => $integer |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
The vertical length of the branches. |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
Note: Some vertical branches will be shortened if the code detects overlapping when leaf names are |
1149
|
|
|
|
|
|
|
drawn. |
1150
|
|
|
|
|
|
|
|
1151
|
|
|
|
|
|
|
See also L. |
1152
|
|
|
|
|
|
|
|
1153
|
|
|
|
|
|
|
Default: 40 (px). |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
=back |
1156
|
|
|
|
|
|
|
|
1157
|
|
|
|
|
|
|
=head1 Methods |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
=head2 branch_color([$string]) |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
Get or set the color used to draw branches. |
1162
|
|
|
|
|
|
|
|
1163
|
|
|
|
|
|
|
See (in the FAQ) L for details about colors. |
1164
|
|
|
|
|
|
|
|
1165
|
|
|
|
|
|
|
C is a parameter to L. |
1166
|
|
|
|
|
|
|
|
1167
|
|
|
|
|
|
|
=head2 branch_width([$integer]) |
1168
|
|
|
|
|
|
|
|
1169
|
|
|
|
|
|
|
Get or set the width of branches. |
1170
|
|
|
|
|
|
|
|
1171
|
|
|
|
|
|
|
C is a parameter to L. |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
=head2 debug([$Boolean]) |
1174
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
Get or set the option to activate debug mode. |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
C is a parameter to L. |
1178
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
=head2 draw_frame([$Boolean]) |
1180
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
Get or set the option to draw a frame on the image. |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
C is a parameter to L. |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
=head2 final_x_step([$integer]) |
1186
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
Get or set a bit extra for the horizontal length of the branch leading to leaf names. |
1188
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
C is a parameter to L. |
1190
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
=head2 frame_color([$string]) |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
Get or set the color of the frame. |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
C is a parameter to L. |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
=head2 input_file([$string]) |
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
Get or set the name of the input file. |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
C is a parameter to L. |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
=head2 leaf_font_color([$string]) |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
Get or set the font color of the text used to draw leaf names. |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
C is a parameter to L. |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
=head2 leaf_font_file([$string]) |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
Get or set the name of the font file used for leaf names. |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
You can use path names, as per the default, or - using Image::Magick -, you can just use the name |
1214
|
|
|
|
|
|
|
of the font, such as 'DejaVu-Sans-ExtraLight'. |
1215
|
|
|
|
|
|
|
|
1216
|
|
|
|
|
|
|
C is a parameter to L. |
1217
|
|
|
|
|
|
|
|
1218
|
|
|
|
|
|
|
=head2 leaf_font_size([$integer]) |
1219
|
|
|
|
|
|
|
|
1220
|
|
|
|
|
|
|
Get or set the size of the font used to draw leaf names. |
1221
|
|
|
|
|
|
|
|
1222
|
|
|
|
|
|
|
C is a parameter to L. |
1223
|
|
|
|
|
|
|
|
1224
|
|
|
|
|
|
|
=head2 left_margin([$integer]) |
1225
|
|
|
|
|
|
|
|
1226
|
|
|
|
|
|
|
Get or set the distance from the left edge at which drawing starts. |
1227
|
|
|
|
|
|
|
|
1228
|
|
|
|
|
|
|
This also sets the right margin. |
1229
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
C is a parameter to L. |
1231
|
|
|
|
|
|
|
|
1232
|
|
|
|
|
|
|
=head2 maximum_x() |
1233
|
|
|
|
|
|
|
|
1234
|
|
|
|
|
|
|
Get the right-most point at which something was drawn. |
1235
|
|
|
|
|
|
|
|
1236
|
|
|
|
|
|
|
This value is determined by examining the bounding boxes of all leaf names. |
1237
|
|
|
|
|
|
|
|
1238
|
|
|
|
|
|
|
In the case that the title is wider that the right-most leaf's name, C reflects this |
1239
|
|
|
|
|
|
|
fact. |
1240
|
|
|
|
|
|
|
|
1241
|
|
|
|
|
|
|
=head2 maximum_y() |
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
Get the bottom-most point at which something was drawn. |
1244
|
|
|
|
|
|
|
|
1245
|
|
|
|
|
|
|
This value includes the title, if any. |
1246
|
|
|
|
|
|
|
|
1247
|
|
|
|
|
|
|
=head2 new() |
1248
|
|
|
|
|
|
|
|
1249
|
|
|
|
|
|
|
See L for details on the parameters accepted by L. |
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
=head2 output_file([$string]) |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
Get or set the name of the output file. |
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
The file suffix determines what type of file is written. |
1256
|
|
|
|
|
|
|
|
1257
|
|
|
|
|
|
|
For more on supported image types, see the L. |
1258
|
|
|
|
|
|
|
|
1259
|
|
|
|
|
|
|
C is a parameter to L. |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
=head2 print_tree([$Boolean]) |
1262
|
|
|
|
|
|
|
|
1263
|
|
|
|
|
|
|
Get or set the option to print the tree constructed by the code. This is basically a debugging |
1264
|
|
|
|
|
|
|
option. |
1265
|
|
|
|
|
|
|
|
1266
|
|
|
|
|
|
|
C is a parameter to L. |
1267
|
|
|
|
|
|
|
|
1268
|
|
|
|
|
|
|
=head2 root() |
1269
|
|
|
|
|
|
|
|
1270
|
|
|
|
|
|
|
Get the root of the tree built by calling run(). This tree is an object of type L. |
1271
|
|
|
|
|
|
|
|
1272
|
|
|
|
|
|
|
For printing the tree, see L. |
1273
|
|
|
|
|
|
|
|
1274
|
|
|
|
|
|
|
Normally, end-users would never call this method. |
1275
|
|
|
|
|
|
|
|
1276
|
|
|
|
|
|
|
=head2 run() |
1277
|
|
|
|
|
|
|
|
1278
|
|
|
|
|
|
|
After calling L, this is the only other method you would normally call. |
1279
|
|
|
|
|
|
|
|
1280
|
|
|
|
|
|
|
=head2 title([$string]) |
1281
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
Get or set the title to be drawn at the bottom of the image. |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
Note: It's vital you set the title before calling L, since the width of the title might |
1285
|
|
|
|
|
|
|
be greater that the width of the tree, and the width of the title would then be used to determine |
1286
|
|
|
|
|
|
|
the width of the image to create. |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
C is a parameter to L. |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
=head2 title_font_color([$string]) |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
Get or set the font color of the text used to draw the title. |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
C is a parameter to L. |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
=head2 title_font_file([$string]) |
1297
|
|
|
|
|
|
|
|
1298
|
|
|
|
|
|
|
Get or set the name of the font file used for the title. |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
You can use path names, as per the default, or - using Image::Magick -, you can just use the name |
1301
|
|
|
|
|
|
|
of the font, such as 'DejaVu-Sans-ExtraLight'. |
1302
|
|
|
|
|
|
|
|
1303
|
|
|
|
|
|
|
C is a parameter to L. |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
=head2 title_font_size([$integer]) |
1306
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
Get or set the size of the font used to draw the title. |
1308
|
|
|
|
|
|
|
|
1309
|
|
|
|
|
|
|
C is a parameter to L. |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
=head2 top_margin([$integer]) |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
Get or set the distance from the top edge at which drawing starts. |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
This also sets the bottom margin. |
1316
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
C is a parameter to L. |
1318
|
|
|
|
|
|
|
|
1319
|
|
|
|
|
|
|
=head2 x_step([$integer]) |
1320
|
|
|
|
|
|
|
|
1321
|
|
|
|
|
|
|
Get or set the length of horizontal branches. |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
See also C. |
1324
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
C is a parameter to L. |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
=head2 y_step([$integer]) |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
Get or set the length of vertical branches. |
1330
|
|
|
|
|
|
|
|
1331
|
|
|
|
|
|
|
Note: Some vertical branches will be shortened if the code detects overlapping when leaf names are |
1332
|
|
|
|
|
|
|
drawn. |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
C is a parameter to L. |
1335
|
|
|
|
|
|
|
|
1336
|
|
|
|
|
|
|
=head1 Scripts and data files shipped with this module |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
=head2 Scripts |
1339
|
|
|
|
|
|
|
|
1340
|
|
|
|
|
|
|
See scripts/*.pl and scripts/*.sh. |
1341
|
|
|
|
|
|
|
|
1342
|
|
|
|
|
|
|
=over 4 |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
=item o Debian.font.list.pl |
1345
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
Outputs to my web server's doc root, which is in Debian's RAM disk, a file called |
1347
|
|
|
|
|
|
|
"$ENV{DR}/misc/Debian.font.list.png". |
1348
|
|
|
|
|
|
|
|
1349
|
|
|
|
|
|
|
The output file is not part of the distro (being 3.3 Mb), but is on line at |
1350
|
|
|
|
|
|
|
L. |
1351
|
|
|
|
|
|
|
|
1352
|
|
|
|
|
|
|
=item o image.magick.pl |
1353
|
|
|
|
|
|
|
|
1354
|
|
|
|
|
|
|
The program you would normally use to drive Tree::Cladogram::ImageMagick. |
1355
|
|
|
|
|
|
|
|
1356
|
|
|
|
|
|
|
See also image.magick.sh. |
1357
|
|
|
|
|
|
|
|
1358
|
|
|
|
|
|
|
=item o image.magick.sh |
1359
|
|
|
|
|
|
|
|
1360
|
|
|
|
|
|
|
A convenient way to run image.magick.pl. |
1361
|
|
|
|
|
|
|
|
1362
|
|
|
|
|
|
|
=item o imager.pl |
1363
|
|
|
|
|
|
|
|
1364
|
|
|
|
|
|
|
The program you would normally use to drive Tree::Cladogram::Imager. |
1365
|
|
|
|
|
|
|
|
1366
|
|
|
|
|
|
|
See also imager.sh. |
1367
|
|
|
|
|
|
|
|
1368
|
|
|
|
|
|
|
=item o imager.sh |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
A convenient way to run imager.pl. |
1371
|
|
|
|
|
|
|
|
1372
|
|
|
|
|
|
|
=item o pod2html.sh |
1373
|
|
|
|
|
|
|
|
1374
|
|
|
|
|
|
|
A simple way for me to convert the docs into HTML. |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
=item o test.image.magick.pl |
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
Outputs data/test.image.magick.png. I used this program to experiment with L while |
1379
|
|
|
|
|
|
|
converting Tree::Cladogram::Imager into Tree::Cladogram::ImageMagick. |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
=item o test.image.magick.sh |
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
A convenient way to run test.image.magick.pl. |
1384
|
|
|
|
|
|
|
|
1385
|
|
|
|
|
|
|
=back |
1386
|
|
|
|
|
|
|
|
1387
|
|
|
|
|
|
|
=head2 Data files |
1388
|
|
|
|
|
|
|
|
1389
|
|
|
|
|
|
|
See data/*. |
1390
|
|
|
|
|
|
|
|
1391
|
|
|
|
|
|
|
=over 4 |
1392
|
|
|
|
|
|
|
|
1393
|
|
|
|
|
|
|
=item o nationalgeographic.01.clad |
1394
|
|
|
|
|
|
|
|
1395
|
|
|
|
|
|
|
This sample input file is discussed just below, at the start of the L. |
1396
|
|
|
|
|
|
|
|
1397
|
|
|
|
|
|
|
=item o nationalgeographic.01.png |
1398
|
|
|
|
|
|
|
|
1399
|
|
|
|
|
|
|
This is the output of rendering nationalgeographic.01.clad with L. |
1400
|
|
|
|
|
|
|
|
1401
|
|
|
|
|
|
|
=item o nationalgeographic.02.png |
1402
|
|
|
|
|
|
|
|
1403
|
|
|
|
|
|
|
This is the output of rendering nationalgeographic.01.clad with L. |
1404
|
|
|
|
|
|
|
|
1405
|
|
|
|
|
|
|
=item o test.image.magick.png |
1406
|
|
|
|
|
|
|
|
1407
|
|
|
|
|
|
|
The is is output of scripts/test.image.magick.pl. |
1408
|
|
|
|
|
|
|
|
1409
|
|
|
|
|
|
|
=item o wikipedia.01.clad |
1410
|
|
|
|
|
|
|
|
1411
|
|
|
|
|
|
|
This sample input file is discussed just below, at the start of the L. |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
=item o wikipedia.01.png |
1414
|
|
|
|
|
|
|
|
1415
|
|
|
|
|
|
|
This is the output of rendering wikipedia.01.clad with L. |
1416
|
|
|
|
|
|
|
|
1417
|
|
|
|
|
|
|
=item o wikipedia.02.png |
1418
|
|
|
|
|
|
|
|
1419
|
|
|
|
|
|
|
This is the output of rendering wikipedia.01.clad with L. |
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
=back |
1422
|
|
|
|
|
|
|
|
1423
|
|
|
|
|
|
|
=head1 FAQ |
1424
|
|
|
|
|
|
|
|
1425
|
|
|
|
|
|
|
=head2 What is the format of the input file? |
1426
|
|
|
|
|
|
|
|
1427
|
|
|
|
|
|
|
Sample 1 - L: |
1428
|
|
|
|
|
|
|
|
1429
|
|
|
|
|
|
|
+---- Beetles |
1430
|
|
|
|
|
|
|
| |
1431
|
|
|
|
|
|
|
| |
1432
|
|
|
|
|
|
|
Root ---+ +---- Wasps, bees, ants |
1433
|
|
|
|
|
|
|
| | |
1434
|
|
|
|
|
|
|
| | |
1435
|
|
|
|
|
|
|
1---+ +---- Butterflies, moths |
1436
|
|
|
|
|
|
|
| | |
1437
|
|
|
|
|
|
|
| | |
1438
|
|
|
|
|
|
|
2---+ |
1439
|
|
|
|
|
|
|
| |
1440
|
|
|
|
|
|
|
| |
1441
|
|
|
|
|
|
|
+---- Flies |
1442
|
|
|
|
|
|
|
|
1443
|
|
|
|
|
|
|
This is the data file (shipped as data/cladogram.01.clad). The format is defined formally below: |
1444
|
|
|
|
|
|
|
|
1445
|
|
|
|
|
|
|
Parent Place Node |
1446
|
|
|
|
|
|
|
root above Beetles |
1447
|
|
|
|
|
|
|
root below 1 |
1448
|
|
|
|
|
|
|
1 above Wasps, bees, ants |
1449
|
|
|
|
|
|
|
1 below 2 |
1450
|
|
|
|
|
|
|
2 above Butterflies, moths |
1451
|
|
|
|
|
|
|
2 below Flies |
1452
|
|
|
|
|
|
|
|
1453
|
|
|
|
|
|
|
Output: L and |
1454
|
|
|
|
|
|
|
L. |
1455
|
|
|
|
|
|
|
|
1456
|
|
|
|
|
|
|
Sample 2 - L: |
1457
|
|
|
|
|
|
|
|
1458
|
|
|
|
|
|
|
+--- Archaeopterix lithographica |
1459
|
|
|
|
|
|
|
| |
1460
|
|
|
|
|
|
|
| |
1461
|
|
|
|
|
|
|
| |
1462
|
|
|
|
|
|
|
Root ---+ +--- Apsaravis ukhaana |
1463
|
|
|
|
|
|
|
| | |
1464
|
|
|
|
|
|
|
| | |
1465
|
|
|
|
|
|
|
| | |
1466
|
|
|
|
|
|
|
1---+ +--- Gansus yumemensis |
1467
|
|
|
|
|
|
|
| | |
1468
|
|
|
|
|
|
|
| | |
1469
|
|
|
|
|
|
|
| | |
1470
|
|
|
|
|
|
|
2---+ +--- Ichthyornis dispar |
1471
|
|
|
|
|
|
|
| | |
1472
|
|
|
|
|
|
|
| | +--- Gallus gallus |
1473
|
|
|
|
|
|
|
| | | |
1474
|
|
|
|
|
|
|
3---+ 5---+ |
1475
|
|
|
|
|
|
|
| | | |
1476
|
|
|
|
|
|
|
| | +--- Anas clypeata |
1477
|
|
|
|
|
|
|
| | |
1478
|
|
|
|
|
|
|
4---+ |
1479
|
|
|
|
|
|
|
| +--- Pasquiaornis |
1480
|
|
|
|
|
|
|
| | |
1481
|
|
|
|
|
|
|
| | |
1482
|
|
|
|
|
|
|
6---+ +--- Enaliornis |
1483
|
|
|
|
|
|
|
| | |
1484
|
|
|
|
|
|
|
| | |
1485
|
|
|
|
|
|
|
| | |
1486
|
|
|
|
|
|
|
7---+ +--- Baptornis advenus |
1487
|
|
|
|
|
|
|
| | |
1488
|
|
|
|
|
|
|
| | +--- Brodavis varnei |
1489
|
|
|
|
|
|
|
| | | |
1490
|
|
|
|
|
|
|
8---+ 10--+ |
1491
|
|
|
|
|
|
|
| | | |
1492
|
|
|
|
|
|
|
| | +--- Brodavis baileyi |
1493
|
|
|
|
|
|
|
| | |
1494
|
|
|
|
|
|
|
9---+ |
1495
|
|
|
|
|
|
|
| +--- Fumicollis hoffmani |
1496
|
|
|
|
|
|
|
| | |
1497
|
|
|
|
|
|
|
| | |
1498
|
|
|
|
|
|
|
11--+ +--- Parahesperornis alexi |
1499
|
|
|
|
|
|
|
| | |
1500
|
|
|
|
|
|
|
| | |
1501
|
|
|
|
|
|
|
12--+ |
1502
|
|
|
|
|
|
|
| |
1503
|
|
|
|
|
|
|
| |
1504
|
|
|
|
|
|
|
+--- Hesperornis regalis |
1505
|
|
|
|
|
|
|
|
1506
|
|
|
|
|
|
|
This is the data file (shipped as data/nationalgeographic.01.clad). The format is defined formally |
1507
|
|
|
|
|
|
|
below: |
1508
|
|
|
|
|
|
|
|
1509
|
|
|
|
|
|
|
Parent Place Node |
1510
|
|
|
|
|
|
|
root above Archaeopterix lithographica |
1511
|
|
|
|
|
|
|
root below 1 |
1512
|
|
|
|
|
|
|
1 above Apsaravis ukhaana |
1513
|
|
|
|
|
|
|
1 below 2 |
1514
|
|
|
|
|
|
|
2 above Gansus yumemensis |
1515
|
|
|
|
|
|
|
2 below 3 |
1516
|
|
|
|
|
|
|
3 above Ichthyornis dispar |
1517
|
|
|
|
|
|
|
3 below 4 |
1518
|
|
|
|
|
|
|
4 above 5 |
1519
|
|
|
|
|
|
|
4 below 6 |
1520
|
|
|
|
|
|
|
5 above Gallus gallus |
1521
|
|
|
|
|
|
|
5 below Anas clypeata |
1522
|
|
|
|
|
|
|
6 above Pasquiaornis |
1523
|
|
|
|
|
|
|
6 below 7 |
1524
|
|
|
|
|
|
|
7 above Enaliornis |
1525
|
|
|
|
|
|
|
7 below 8 |
1526
|
|
|
|
|
|
|
8 above Baptornis advenus |
1527
|
|
|
|
|
|
|
8 below 9 |
1528
|
|
|
|
|
|
|
9 above 10 |
1529
|
|
|
|
|
|
|
9 below 11 |
1530
|
|
|
|
|
|
|
10 above Brodavis varnei |
1531
|
|
|
|
|
|
|
10 below Brodavis baileyi |
1532
|
|
|
|
|
|
|
11 above Fumicollis hoffmani |
1533
|
|
|
|
|
|
|
11 below 12 |
1534
|
|
|
|
|
|
|
12 above Parahesperornis alexi |
1535
|
|
|
|
|
|
|
12 below Hesperornis regalis |
1536
|
|
|
|
|
|
|
|
1537
|
|
|
|
|
|
|
Output: L and |
1538
|
|
|
|
|
|
|
L. |
1539
|
|
|
|
|
|
|
|
1540
|
|
|
|
|
|
|
File format: |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
=over 4 |
1543
|
|
|
|
|
|
|
|
1544
|
|
|
|
|
|
|
=item o Words and numbers on each line are tab separated |
1545
|
|
|
|
|
|
|
|
1546
|
|
|
|
|
|
|
Oh, all right. You can use any number of spaces too, but why bother? |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
=item o There are 3 columns |
1549
|
|
|
|
|
|
|
|
1550
|
|
|
|
|
|
|
=over 4 |
1551
|
|
|
|
|
|
|
|
1552
|
|
|
|
|
|
|
=item o The first line must match /Parent\tPlace\tNode/i |
1553
|
|
|
|
|
|
|
|
1554
|
|
|
|
|
|
|
For non-programmers, the /.../ is a regular expression, just saying the program tests for that |
1555
|
|
|
|
|
|
|
exact string. The '\t's represent tabs and the suffix 'i' means use a case-insensitive test. |
1556
|
|
|
|
|
|
|
|
1557
|
|
|
|
|
|
|
=item o Thereafter, column 1 is the name of the node |
1558
|
|
|
|
|
|
|
|
1559
|
|
|
|
|
|
|
=item o The word 'root' is (also) case-insensitive |
1560
|
|
|
|
|
|
|
|
1561
|
|
|
|
|
|
|
=item o Every node has 2 mandatory lines |
1562
|
|
|
|
|
|
|
|
1563
|
|
|
|
|
|
|
One for the daughter 'above' the current node, and one for the daughter 'below'. |
1564
|
|
|
|
|
|
|
|
1565
|
|
|
|
|
|
|
=item o Column 2 specifies where the daughter appears in relation to the node |
1566
|
|
|
|
|
|
|
|
1567
|
|
|
|
|
|
|
=item o All words after the 2nd column are the name of that daughter |
1568
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
=back |
1570
|
|
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
=item o Fabricate skeleton nodes to hold together the nodes you are interested in |
1572
|
|
|
|
|
|
|
|
1573
|
|
|
|
|
|
|
=item o Use digits for the skeleton nodes' names |
1574
|
|
|
|
|
|
|
|
1575
|
|
|
|
|
|
|
The code hides the name of nodes which match /^(\d+|root)$/. |
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
=back |
1578
|
|
|
|
|
|
|
|
1579
|
|
|
|
|
|
|
=head2 Which versions of the renderers did you use? |
1580
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
L V 1.004. |
1582
|
|
|
|
|
|
|
|
1583
|
|
|
|
|
|
|
L V 6.9.3-0 Q16. |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
For help installing Image::Magick under Debian, see |
1586
|
|
|
|
|
|
|
L. |
1587
|
|
|
|
|
|
|
|
1588
|
|
|
|
|
|
|
=head2 What image formats are supported? |
1589
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
My default install of L lists: |
1591
|
|
|
|
|
|
|
|
1592
|
|
|
|
|
|
|
bmp |
1593
|
|
|
|
|
|
|
ft2 |
1594
|
|
|
|
|
|
|
ifs |
1595
|
|
|
|
|
|
|
png |
1596
|
|
|
|
|
|
|
pnm |
1597
|
|
|
|
|
|
|
raw |
1598
|
|
|
|
|
|
|
|
1599
|
|
|
|
|
|
|
L supports a huge range of formats (221 actually). To list them, run |
1600
|
|
|
|
|
|
|
scripts/test.image.magick.pl. Note: This program writes to data/test.image.magick.png. |
1601
|
|
|
|
|
|
|
|
1602
|
|
|
|
|
|
|
=head2 What colors are supported? |
1603
|
|
|
|
|
|
|
|
1604
|
|
|
|
|
|
|
See L for Imager's docs on color. But you're probably better off using |
1605
|
|
|
|
|
|
|
L's table mentioned next, since my module only accepts colors. It does not allow |
1606
|
|
|
|
|
|
|
you to provide an Imager::Color object as a parameter. |
1607
|
|
|
|
|
|
|
|
1608
|
|
|
|
|
|
|
See L for a huge table of both |
1609
|
|
|
|
|
|
|
names and hex values. |
1610
|
|
|
|
|
|
|
|
1611
|
|
|
|
|
|
|
=head2 What fonts are supported? |
1612
|
|
|
|
|
|
|
|
1613
|
|
|
|
|
|
|
Check these directories: |
1614
|
|
|
|
|
|
|
|
1615
|
|
|
|
|
|
|
=over |
1616
|
|
|
|
|
|
|
|
1617
|
|
|
|
|
|
|
=item o /usr/local/share/fonts |
1618
|
|
|
|
|
|
|
|
1619
|
|
|
|
|
|
|
=item o /usr/share/fonts |
1620
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
=back |
1622
|
|
|
|
|
|
|
|
1623
|
|
|
|
|
|
|
If you're using L, run C for a list of installed fonts. |
1624
|
|
|
|
|
|
|
|
1625
|
|
|
|
|
|
|
More information on Debian's support for fonts can be found on Debian's |
1626
|
|
|
|
|
|
|
L. |
1627
|
|
|
|
|
|
|
|
1628
|
|
|
|
|
|
|
See L for the fonts on my laptop. |
1629
|
|
|
|
|
|
|
Note: This file is 3.3 Mb, so you may have to zoom it to 500% to make it readable. |
1630
|
|
|
|
|
|
|
|
1631
|
|
|
|
|
|
|
See scripts/imager.sh and scripts/image.magick.sh for lists of fonts I have played with while |
1632
|
|
|
|
|
|
|
developing this module. |
1633
|
|
|
|
|
|
|
|
1634
|
|
|
|
|
|
|
Further, note this text copied from the docs for L: |
1635
|
|
|
|
|
|
|
|
1636
|
|
|
|
|
|
|
This module handles creating Font objects used by Imager. The module also handles querying |
1637
|
|
|
|
|
|
|
fonts for sizes and such. If both T1lib and FreeType were available at the time of compilation |
1638
|
|
|
|
|
|
|
then Imager should be able to work with both TrueType fonts and t1 Postscript fonts. To check |
1639
|
|
|
|
|
|
|
if Imager is t1 or TrueType capable you can use something like this: |
1640
|
|
|
|
|
|
|
|
1641
|
|
|
|
|
|
|
use Imager; |
1642
|
|
|
|
|
|
|
|
1643
|
|
|
|
|
|
|
print "Has truetype\n" if $Imager::formats{tt}; |
1644
|
|
|
|
|
|
|
print "Has t1 postscript\n" if $Imager::formats{t1}; |
1645
|
|
|
|
|
|
|
print "Has Win32 fonts\n" if $Imager::formats{w32}; |
1646
|
|
|
|
|
|
|
print "Has Freetype2\n" if $Imager::formats{ft2}; |
1647
|
|
|
|
|
|
|
|
1648
|
|
|
|
|
|
|
My default install of L reports: |
1649
|
|
|
|
|
|
|
|
1650
|
|
|
|
|
|
|
Has Freetype2 |
1651
|
|
|
|
|
|
|
|
1652
|
|
|
|
|
|
|
=head2 How does leaf_font_size interact with y_step? |
1653
|
|
|
|
|
|
|
|
1654
|
|
|
|
|
|
|
This might depend on the font, but here are some tests I ran with the one leaf font: |
1655
|
|
|
|
|
|
|
|
1656
|
|
|
|
|
|
|
=over 4 |
1657
|
|
|
|
|
|
|
|
1658
|
|
|
|
|
|
|
=item o leaf_font_size 12 works with y_step values of 28 .. 40 |
1659
|
|
|
|
|
|
|
|
1660
|
|
|
|
|
|
|
=item o leaf_font_size 16 works with y_step values of 36 .. 44 |
1661
|
|
|
|
|
|
|
|
1662
|
|
|
|
|
|
|
=item o leaf_font_size 20 works with y_step values of 40 .. 48 |
1663
|
|
|
|
|
|
|
|
1664
|
|
|
|
|
|
|
=item o leaf_font_size 24 works with a y_step value of 48 |
1665
|
|
|
|
|
|
|
|
1666
|
|
|
|
|
|
|
=item o leaf_font_size 28 works with a y_step value of 54 |
1667
|
|
|
|
|
|
|
|
1668
|
|
|
|
|
|
|
=item o leaf_font_size 32 works with a y_step value of 54 |
1669
|
|
|
|
|
|
|
|
1670
|
|
|
|
|
|
|
=item o leaf_font_size 36 works with a y_step value of 72 |
1671
|
|
|
|
|
|
|
|
1672
|
|
|
|
|
|
|
=item o leaf_font_size 40 works with a y_step value of 72 |
1673
|
|
|
|
|
|
|
|
1674
|
|
|
|
|
|
|
=back |
1675
|
|
|
|
|
|
|
|
1676
|
|
|
|
|
|
|
=head2 Why did you use Tree::DAG_Node and not something like Tree::Simple? |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
I started with L precisely because it's simple, but found it awkward to use. |
1679
|
|
|
|
|
|
|
|
1680
|
|
|
|
|
|
|
I did use Tree::Simple in L. That module was deliberately kept simple, |
1681
|
|
|
|
|
|
|
but before that, and since, I've always gone back to L. |
1682
|
|
|
|
|
|
|
|
1683
|
|
|
|
|
|
|
=head2 How is overlap between leaves detected? |
1684
|
|
|
|
|
|
|
|
1685
|
|
|
|
|
|
|
The process starts by calling the undocumented method C<_check_for_overlap()>. |
1686
|
|
|
|
|
|
|
|
1687
|
|
|
|
|
|
|
=head1 See Also |
1688
|
|
|
|
|
|
|
|
1689
|
|
|
|
|
|
|
L |
1690
|
|
|
|
|
|
|
|
1691
|
|
|
|
|
|
|
L |
1692
|
|
|
|
|
|
|
|
1693
|
|
|
|
|
|
|
L |
1694
|
|
|
|
|
|
|
|
1695
|
|
|
|
|
|
|
L |
1696
|
|
|
|
|
|
|
|
1697
|
|
|
|
|
|
|
L |
1698
|
|
|
|
|
|
|
|
1699
|
|
|
|
|
|
|
=head1 Machine-Readable Change Log |
1700
|
|
|
|
|
|
|
|
1701
|
|
|
|
|
|
|
The file Changes was converted into Changelog.ini by L. |
1702
|
|
|
|
|
|
|
|
1703
|
|
|
|
|
|
|
=head1 Version Numbers |
1704
|
|
|
|
|
|
|
|
1705
|
|
|
|
|
|
|
Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. |
1706
|
|
|
|
|
|
|
|
1707
|
|
|
|
|
|
|
=head1 Repository |
1708
|
|
|
|
|
|
|
|
1709
|
|
|
|
|
|
|
L |
1710
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
=head1 Support |
1712
|
|
|
|
|
|
|
|
1713
|
|
|
|
|
|
|
Bugs should be reported via the CPAN bug tracker at |
1714
|
|
|
|
|
|
|
|
1715
|
|
|
|
|
|
|
L |
1716
|
|
|
|
|
|
|
|
1717
|
|
|
|
|
|
|
=head1 Author |
1718
|
|
|
|
|
|
|
|
1719
|
|
|
|
|
|
|
L was written by Ron Savage Iron@savage.net.auE> in 2015. |
1720
|
|
|
|
|
|
|
|
1721
|
|
|
|
|
|
|
My homepage: L |
1722
|
|
|
|
|
|
|
|
1723
|
|
|
|
|
|
|
=head1 Copyright |
1724
|
|
|
|
|
|
|
|
1725
|
|
|
|
|
|
|
Australian copyright (c) 2015, Ron Savage. |
1726
|
|
|
|
|
|
|
|
1727
|
|
|
|
|
|
|
All Programs of mine are 'OSI Certified Open Source Software'; |
1728
|
|
|
|
|
|
|
you can redistribute them and/or modify them under the terms of |
1729
|
|
|
|
|
|
|
The Perl License, a copy of which is available at: |
1730
|
|
|
|
|
|
|
http://dev.perl.org/licenses/ |
1731
|
|
|
|
|
|
|
|
1732
|
|
|
|
|
|
|
=cut |