line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Chart::Clicker::Data::Range; |
2
|
|
|
|
|
|
|
$Chart::Clicker::Data::Range::VERSION = '2.90'; |
3
|
16
|
|
|
16
|
|
57284
|
use Moose; |
|
16
|
|
|
|
|
356544
|
|
|
16
|
|
|
|
|
124
|
|
4
|
16
|
|
|
16
|
|
102355
|
use Moose::Util::TypeConstraints; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
188
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
31729
|
use constant EPSILON => 0.0001; |
|
16
|
|
|
|
|
32
|
|
|
16
|
|
|
|
|
16700
|
|
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
|
|
|
|
33
|
unless(defined($self->min)) { |
113
|
7
|
100
|
100
|
|
|
65
|
if(!defined($self->lower) || ($range->lower < $self->lower)) { |
114
|
5
|
|
|
|
|
56
|
$self->lower($range->lower); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
8
|
100
|
|
|
|
70
|
unless(defined($self->max)) { |
119
|
7
|
100
|
100
|
|
|
61
|
if(!defined($self->upper) || ($range->upper > $self->upper)) { |
120
|
6
|
|
|
|
|
109
|
$self->upper($range->upper); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
8
|
|
|
|
|
55
|
return 1; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub contains { |
129
|
4
|
|
|
4
|
1
|
7
|
my ($self, $value) = @_; |
130
|
|
|
|
|
|
|
|
131
|
4
|
100
|
66
|
|
|
11
|
return 1 if $value >= $self->lower && $value <= $self->upper; |
132
|
1
|
|
|
|
|
10
|
return 0; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub span { |
137
|
52
|
|
|
52
|
1
|
1022
|
my ($self) = @_; |
138
|
|
|
|
|
|
|
|
139
|
52
|
|
|
|
|
217
|
my $span = $self->upper - $self->lower; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#we still want to be able to see flat lines! |
142
|
52
|
50
|
|
|
|
487
|
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
|
|
|
|
|
294
|
return $span; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
151
|
|
|
|
|
|
|
|
152
|
16
|
|
|
16
|
|
191
|
no Moose; |
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
113
|
|
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.90 |
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) 2016 by Cory G Watson. |
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 |