line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::TagCloud::Extended::Factor; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
6
|
use HTML::TagCloud::Extended::Exception; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
271
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
7
|
0
|
|
|
|
|
|
my $self = bless { |
8
|
|
|
|
|
|
|
min => 0, |
9
|
|
|
|
|
|
|
max => 0, |
10
|
|
|
|
|
|
|
range => 0, |
11
|
|
|
|
|
|
|
_factor => 0, |
12
|
|
|
|
|
|
|
}, $class; |
13
|
0
|
|
|
|
|
|
$self->_init(@_); |
14
|
0
|
|
|
|
|
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _init { |
18
|
0
|
|
|
0
|
|
|
my($self, %args) = @_; |
19
|
0
|
|
|
|
|
|
foreach my $key ( qw/min max range/ ) { |
20
|
0
|
0
|
|
|
|
|
if ( exists $args{$key} ) { |
21
|
0
|
|
|
|
|
|
$self->{$key} = $args{$key}; |
22
|
|
|
|
|
|
|
} else { |
23
|
0
|
|
|
|
|
|
HTML::TagCloud::Extended::Exception->throw(qq/ |
24
|
|
|
|
|
|
|
"$key" isn't found. |
25
|
|
|
|
|
|
|
/); |
26
|
|
|
|
|
|
|
} |
27
|
0
|
|
|
|
|
|
my $range = $args{range}; |
28
|
0
|
|
|
|
|
|
my $min = sqrt($args{min}); |
29
|
0
|
|
|
|
|
|
my $max = sqrt($args{max}); |
30
|
0
|
0
|
|
|
|
|
$min -= $range if ($min == $max); |
31
|
0
|
|
|
|
|
|
$self->{_factor} = $range / ($max - $min); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get_level { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $number) = @_; |
37
|
0
|
|
|
|
|
|
return int( ( sqrt($number + 0) - sqrt($self->{min}) ) * $self->{_factor} ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |