line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#_{ Encoding and name |
2
|
|
|
|
|
|
|
=encoding utf8 |
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
Grid::Layout::Track |
5
|
|
|
|
|
|
|
=cut |
6
|
|
|
|
|
|
|
#_} |
7
|
|
|
|
|
|
|
package Grid::Layout::Track; |
8
|
|
|
|
|
|
|
#_{ use … |
9
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
10
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
37
|
|
11
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
31
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1120
|
|
14
|
|
|
|
|
|
|
#_} |
15
|
|
|
|
|
|
|
our $VERSION = 0.01; |
16
|
|
|
|
|
|
|
#_{ Synopsis |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
#_} |
21
|
|
|
|
|
|
|
#_{ Description |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
a C<< Grid::Layout::Track >> is the space between to adjacent L<< Grid::Layout::Line >>s. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Usually, a horizontal track is referred to as a row, a vertical track as a column. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
#_} |
31
|
|
|
|
|
|
|
#_{ Methods |
32
|
|
|
|
|
|
|
#_{ POD |
33
|
|
|
|
|
|
|
=head1 METHODS |
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
#_} |
36
|
|
|
|
|
|
|
sub new { #_{ |
37
|
|
|
|
|
|
|
#_{ POD |
38
|
|
|
|
|
|
|
=head2 new |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Creates a C<< Grid::Layout::Track >>. Should not be called by the user. |
41
|
|
|
|
|
|
|
The constructor is called by L<< Grid::Layout/add_track >> instead. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
#_} |
45
|
|
|
|
|
|
|
|
46
|
18
|
|
|
18
|
0
|
29
|
my $class = shift; |
47
|
18
|
|
|
|
|
23
|
my $grid_layout = shift; |
48
|
18
|
|
|
|
|
22
|
my $V_or_H = shift; |
49
|
18
|
|
|
|
|
25
|
my $position = shift; |
50
|
|
|
|
|
|
|
|
51
|
18
|
50
|
|
|
|
50
|
croak 'Grid::Layout expected' unless $grid_layout->isa('Grid::Layout'); |
52
|
18
|
50
|
66
|
|
|
66
|
croak 'V or H expected' unless $V_or_H eq 'V' or $V_or_H eq 'H'; |
53
|
18
|
50
|
|
|
|
77
|
croak 'position not a number' unless $position =~ /^\d+$/; |
54
|
|
|
|
|
|
|
|
55
|
18
|
|
|
|
|
32
|
my $self = {}; |
56
|
|
|
|
|
|
|
|
57
|
18
|
|
|
|
|
36
|
$self -> {grid_layout} = $grid_layout; |
58
|
18
|
|
|
|
|
35
|
$self -> {V_or_H } = $V_or_H; |
59
|
18
|
|
|
|
|
28
|
$self -> {position } = $position; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
18
|
|
|
|
|
26
|
bless $self, $class; |
63
|
18
|
|
|
|
|
43
|
return $self; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} #_} |
66
|
|
|
|
|
|
|
#_{ line_left/right/above/beneath |
67
|
|
|
|
|
|
|
sub line_left { #_{ |
68
|
|
|
|
|
|
|
#_{ POD |
69
|
|
|
|
|
|
|
=head2 line_left |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns the line to the left of the track. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Only applicable if the track is vertical (C<< $self->{V_or_H} eq 'V' >>). |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
#_} |
77
|
|
|
|
|
|
|
|
78
|
2
|
|
|
2
|
0
|
10
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
2
|
50
|
|
|
|
7
|
croak 'Type of track is not vertical' unless $self->{V_or_H} eq 'V'; |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
6
|
return $self->{grid_layout}->line_x($self->{position}); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} #_} |
85
|
|
|
|
|
|
|
sub line_right { #_{ |
86
|
|
|
|
|
|
|
#_{ POD |
87
|
|
|
|
|
|
|
=head2 line_right |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returns the line to the right of the track. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Only applicable if the track is vertical (C<< $self->{V_or_H} eq 'V' >>). |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
#_} |
95
|
|
|
|
|
|
|
|
96
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
1
|
50
|
|
|
|
4
|
croak 'Type of track is not vertical' unless $self->{V_or_H} eq 'V'; |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
6
|
return $self->{grid_layout}->line_x($self->{position} + 1); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
} #_} |
103
|
|
|
|
|
|
|
sub line_above { #_{ |
104
|
|
|
|
|
|
|
#_{ POD |
105
|
|
|
|
|
|
|
=head2 line_left |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the line above the track. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Only applicable if the track is vertical (C<< $self->{V_or_H} eq 'H' >>). |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
#_} |
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
2
|
0
|
14
|
my $self = shift; |
115
|
|
|
|
|
|
|
|
116
|
2
|
50
|
|
|
|
10
|
croak 'Type of track is not horizontal' unless $self->{V_or_H} eq 'H'; |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
8
|
return $self->{grid_layout}->line_y($self->{position}); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} #_} |
121
|
|
|
|
|
|
|
sub line_beneath { #_{ |
122
|
|
|
|
|
|
|
#_{ POD |
123
|
|
|
|
|
|
|
=head2 line_beneath |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns the line beneath the track. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Only applicable if the track is vertical (C<< $self->{V_or_H} eq 'H' >>). |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
#_} |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
1
|
0
|
438
|
my $self = shift; |
133
|
|
|
|
|
|
|
|
134
|
1
|
50
|
|
|
|
8
|
croak 'Type of track is not horizontal' unless $self->{V_or_H} eq 'H'; |
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
11
|
return $self->{grid_layout}->line_y($self->{position} + 1); |
137
|
|
|
|
|
|
|
} #_} |
138
|
|
|
|
|
|
|
#_} |
139
|
|
|
|
|
|
|
sub cells { #_{ |
140
|
|
|
|
|
|
|
#_{ POD |
141
|
|
|
|
|
|
|
=head2 cells |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my @cells = $track->cells(); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Return an array of the L<< cells|Grid::Layout::Cell >> in the track. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
#_} |
149
|
|
|
|
|
|
|
|
150
|
12
|
|
|
12
|
0
|
452
|
my $self = shift; |
151
|
|
|
|
|
|
|
|
152
|
12
|
|
|
|
|
24
|
my @ret=(); |
153
|
12
|
|
|
|
|
50
|
for my $p (0 .. $self->{grid_layout}->_size(Grid::Layout::VH_opposite($self->{V_or_H}))-1) { |
154
|
98
|
100
|
|
|
|
170
|
if ($self->{V_or_H} eq 'V') { |
155
|
10
|
|
|
|
|
28
|
push @ret, $self->{grid_layout}->cell($self->{position}, $p); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
88
|
|
|
|
|
175
|
push @ret, $self->{grid_layout}->cell($p, $self->{position}); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
12
|
|
|
|
|
40
|
return @ret; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
} #_} |
165
|
|
|
|
|
|
|
sub area { #_{ |
166
|
|
|
|
|
|
|
#_{ POD |
167
|
|
|
|
|
|
|
=head2 area |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
#_} |
171
|
|
|
|
|
|
|
|
172
|
2
|
|
|
2
|
0
|
10
|
my $self = shift; |
173
|
2
|
|
|
|
|
4
|
my $track_from = shift; |
174
|
2
|
|
|
|
|
3
|
my $track_to = shift; |
175
|
|
|
|
|
|
|
|
176
|
2
|
50
|
|
|
|
8
|
croak '$track_from must be a Grid::Layout::Track' unless $track_from->isa('Grid::Layout::Track'); |
177
|
2
|
50
|
|
|
|
7
|
croak '$track_to must be a Grid::Layout::Track' unless $track_to ->isa('Grid::Layout::Track'); |
178
|
|
|
|
|
|
|
|
179
|
2
|
50
|
|
|
|
8
|
croak '$track_from must be other direction' unless $track_from->{V_or_H} eq Grid::Layout::VH_opposite($self->{V_or_H}); |
180
|
2
|
50
|
|
|
|
6
|
croak '$track_from must be other direction' unless $track_to ->{V_or_H} eq Grid::Layout::VH_opposite($self->{V_or_H}); |
181
|
|
|
|
|
|
|
|
182
|
2
|
100
|
|
|
|
6
|
if ($self->{V_or_H} eq 'V') { |
183
|
1
|
|
|
|
|
3
|
return $self->{grid_layout}->area($self, $track_from, $self, $track_to); |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
else { |
186
|
1
|
|
|
|
|
4
|
return $self->{grid_layout}->area($track_from, $self, $track_to, $self); |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
} #_} |
191
|
|
|
|
|
|
|
#_} |
192
|
|
|
|
|
|
|
#_{ POD: Copyright |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 Copyright |
195
|
|
|
|
|
|
|
Copyright © 2017 René Nyffenegger, Switzerland. All rights reserved. |
196
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
197
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
198
|
|
|
|
|
|
|
copy of the full license at: L |
199
|
|
|
|
|
|
|
=cut |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
#_} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
'tq84'; |