| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Chart::Clicker::Data::Range; |
|
2
|
|
|
|
|
|
|
$Chart::Clicker::Data::Range::VERSION = '2.88'; |
|
3
|
16
|
|
|
16
|
|
26838
|
use Moose; |
|
|
16
|
|
|
|
|
601691
|
|
|
|
16
|
|
|
|
|
126
|
|
|
4
|
16
|
|
|
16
|
|
121357
|
use Moose::Util::TypeConstraints; |
|
|
16
|
|
|
|
|
41
|
|
|
|
16
|
|
|
|
|
204
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
39543
|
use constant EPSILON => 0.0001; |
|
|
16
|
|
|
|
|
37
|
|
|
|
16
|
|
|
|
|
17059
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: A range of Data |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
subtype 'Lower' |
|
12
|
|
|
|
|
|
|
=> as 'Num|Undef' |
|
13
|
|
|
|
|
|
|
=> where { defined($_) }; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
coerce 'Lower' |
|
16
|
|
|
|
|
|
|
=> from 'Undef' |
|
17
|
|
|
|
|
|
|
=> via { - EPSILON }; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'lower' => ( is => 'rw', isa => 'Lower', coerce => 1); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'max' => ( is => 'rw', isa => 'Num' ); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'min' => ( is => 'rw', isa => 'Num' ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
subtype 'Upper' |
|
29
|
|
|
|
|
|
|
=> as 'Num|Undef' |
|
30
|
|
|
|
|
|
|
=> where { defined($_) }; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
coerce 'Upper' |
|
33
|
|
|
|
|
|
|
=> from 'Num|Undef' |
|
34
|
|
|
|
|
|
|
=> via { EPSILON }; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'upper' => ( is => 'rw', isa => 'Upper', coerce => 1); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has 'ticks' => ( is => 'rw', isa => 'Int', default => 5 ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
after 'lower' => sub { |
|
44
|
|
|
|
|
|
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if(defined($self->{'min'})) { |
|
47
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'min'}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'min'} unless (defined($self->{'lower'})); |
|
51
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'max'} unless (defined($self->{'upper'})); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if(defined($self->{'lower'}) && defined($self->{'upper'}) && $self->{'lower'} == $self->{'upper'}) { |
|
54
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'lower'} - EPSILON; |
|
55
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'lower'} + EPSILON; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
}; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
after 'upper' => sub { |
|
61
|
|
|
|
|
|
|
my $self = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if(defined($self->{'max'})) { |
|
64
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'max'}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'min'} unless (defined($self->{'lower'})); |
|
68
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'max'} unless (defined($self->{'upper'})); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if(defined($self->{'lower'}) && defined($self->{'upper'}) && $self->{'lower'} == $self->{'upper'}) { |
|
71
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'upper'} - EPSILON; |
|
72
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'upper'} + EPSILON; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
after 'min' => sub { |
|
78
|
|
|
|
|
|
|
my $self = shift; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
if(defined($self->{'min'})) { |
|
81
|
|
|
|
|
|
|
$self->{'lower'} = $self->{'min'}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
after 'max' => sub { |
|
86
|
|
|
|
|
|
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if(defined($self->{'max'})) { |
|
89
|
|
|
|
|
|
|
$self->{'upper'} = $self->{'max'}; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub add { |
|
95
|
0
|
|
|
0
|
1
|
0
|
my ($self, $range) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
0
|
if(defined($self->upper)) { |
|
98
|
0
|
|
|
|
|
0
|
$self->upper($self->upper + $range->upper); |
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
0
|
|
|
|
|
0
|
$self->upper($range->upper); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
0
|
0
|
|
|
0
|
if(!defined($self->lower) || ($range->lower < $self->lower)) { |
|
104
|
0
|
|
|
|
|
0
|
$self->lower($range->lower); |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub combine { |
|
110
|
8
|
|
|
8
|
1
|
16
|
my ($self, $range) = @_; |
|
111
|
|
|
|
|
|
|
|
|
112
|
8
|
100
|
|
|
|
32
|
unless(defined($self->min)) { |
|
113
|
7
|
100
|
100
|
|
|
67
|
if(!defined($self->lower) || ($range->lower < $self->lower)) { |
|
114
|
5
|
|
|
|
|
53
|
$self->lower($range->lower); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
8
|
100
|
|
|
|
71
|
unless(defined($self->max)) { |
|
119
|
7
|
100
|
100
|
|
|
70
|
if(!defined($self->upper) || ($range->upper > $self->upper)) { |
|
120
|
6
|
|
|
|
|
72
|
$self->upper($range->upper); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
8
|
|
|
|
|
64
|
return 1; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub contains { |
|
129
|
4
|
|
|
4
|
1
|
7
|
my ($self, $value) = @_; |
|
130
|
|
|
|
|
|
|
|
|
131
|
4
|
100
|
66
|
|
|
12
|
return 1 if $value >= $self->lower && $value <= $self->upper; |
|
132
|
1
|
|
|
|
|
11
|
return 0; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub span { |
|
137
|
52
|
|
|
52
|
1
|
1118
|
my ($self) = @_; |
|
138
|
|
|
|
|
|
|
|
|
139
|
52
|
|
|
|
|
152
|
my $span = $self->upper - $self->lower; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#we still want to be able to see flat lines! |
|
142
|
52
|
50
|
|
|
|
429
|
if ($span <= EPSILON) { |
|
143
|
0
|
|
|
|
|
0
|
$self->upper($self->upper() + EPSILON); |
|
144
|
0
|
|
|
|
|
0
|
$self->lower($self->lower() - EPSILON); |
|
145
|
0
|
|
|
|
|
0
|
$span = $self->upper - $self->lower; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
52
|
|
|
|
|
251
|
return $span; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
151
|
|
|
|
|
|
|
|
|
152
|
16
|
|
|
16
|
|
166
|
no Moose; |
|
|
16
|
|
|
|
|
36
|
|
|
|
16
|
|
|
|
|
100
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__END__ |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=pod |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 NAME |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Chart::Clicker::Data::Range - A range of Data |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 VERSION |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
version 2.88 |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
use Chart::Clicker::Data::Range; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $range = Chart::Clicker::Data::Range->new({ |
|
173
|
|
|
|
|
|
|
lower => 1, |
|
174
|
|
|
|
|
|
|
upper => 10 |
|
175
|
|
|
|
|
|
|
}); |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Chart::Clicker::Data::Range implements a range of values. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 lower |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Set/Get the lower bound for this Range |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 max |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Set/Get the maximum value allowed for this Range. This value should only be |
|
190
|
|
|
|
|
|
|
set if you want to EXPLICITLY set the upper value. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 min |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Set/Get the minimum value allowed for this Range. This value should only be |
|
195
|
|
|
|
|
|
|
set if you want to EXPLICITLY set the lower value. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 upper |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Set/Get the upper bound for this Range |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 ticks |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
The number of ticks to be displayed for this range. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 METHODS |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 add |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Adds the specified range to this one. The lower is reduced to that of the |
|
210
|
|
|
|
|
|
|
provided one if it is lower, and the upper is ADDED to this range's upper. |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 combine |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Combine this range with the specified so that this range encompasses the |
|
215
|
|
|
|
|
|
|
values specified. For example, adding a range with an upper-lower of 1-10 |
|
216
|
|
|
|
|
|
|
with one of 5-20 will result in a combined range of 1-20. |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head2 contains ($value) |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Returns true if supplied value falls within this range (inclusive). Otherwise |
|
221
|
|
|
|
|
|
|
returns false. |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 span |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Returns the span of this range, or UPPER - LOWER. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 AUTHOR |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Cold Hard Code, LLC. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
236
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |