| 1 | package Chart::Clicker::Axis; | ||||||||||||||||||||||||||||
| 2 | 11 | $Chart::Clicker::Axis::VERSION = '2.90'; | |||||||||||||||||||||||||||
| 3 | 11 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Moose::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 11 | extends 'Chart::Clicker::Container'; | |||||||||||||||||||||||||||
| 7 | 11 | with 'Chart::Clicker::Positioned'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: An X or Y Axis | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use Class::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Chart::Clicker::Data::Range; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use Graphics::Color::RGB; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 11 | ▶ | use Graphics::Primitive::Font; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 11 | ▶ | use Layout::Manager::Absolute; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 11 | ▶ | use Math::Trig ':pi'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 11 | has 'tick_label_angle' => ( | |||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||
| 28 | isa => 'Num' | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 11 | has 'tick_division_type' => ( is => 'rw', isa => 'Str', default => 'Exact' ); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # The above tick division type is loaded on the first call to divvy() | ||||||||||||||||||||||||||||
| 35 | 11 | has '_tick_division_type_loaded' => ( is => 'ro', isa => 'Bool', lazy_build => 1 ); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 11 | has 'baseline' => ( | |||||||||||||||||||||||||||
| 39 | is => 'rw', | ||||||||||||||||||||||||||||
| 40 | isa => 'Num', | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | has 'brush' => ( | ||||||||||||||||||||||||||||
| 45 | is => 'rw', | ||||||||||||||||||||||||||||
| 46 | isa => 'Graphics::Primitive::Brush', | ||||||||||||||||||||||||||||
| 47 | 27 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 27 | Graphics::Primitive::Brush->new( | |||||||||||||||||||||||||||
| 49 | color => Graphics::Color::RGB->new( | ||||||||||||||||||||||||||||
| 50 | red => 1, green => 0, blue => 1, alpha => 1 | ||||||||||||||||||||||||||||
| 51 | ), | ||||||||||||||||||||||||||||
| 52 | width => 1 | ||||||||||||||||||||||||||||
| 53 | ) | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 11 | ); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | has '+color' => ( | ||||||||||||||||||||||||||||
| 59 | 27 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 27 | Graphics::Color::RGB->new({ | |||||||||||||||||||||||||||
| 61 | red => 0, green => 0, blue => 0, alpha => 1 | ||||||||||||||||||||||||||||
| 62 | }) | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 11 | ); | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 11 | has 'format' => ( is => 'rw', isa => 'Str|CodeRef', default => '%s' ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 11 | has 'fudge_amount' => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 11 | has 'hidden' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 11 | has 'label' => ( is => 'rw', isa => 'Str' ); | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | has 'label_color' => ( | ||||||||||||||||||||||||||||
| 80 | is => 'rw', | ||||||||||||||||||||||||||||
| 81 | isa => 'Graphics::Color', | ||||||||||||||||||||||||||||
| 82 | 27 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 83 | 27 | Graphics::Color::RGB->new({ | |||||||||||||||||||||||||||
| 84 | red => 0, green => 0, blue => 0, alpha => 1 | ||||||||||||||||||||||||||||
| 85 | }) | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 11 | ); | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | has 'label_font' => ( | ||||||||||||||||||||||||||||
| 91 | is => 'rw', | ||||||||||||||||||||||||||||
| 92 | isa => 'Graphics::Primitive::Font', | ||||||||||||||||||||||||||||
| 93 | 27 | ▶ | default => sub { Graphics::Primitive::Font->new } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 94 | 11 | ); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 27 | ▶ | has '+layout_manager' => ( default => sub { Layout::Manager::Absolute->new }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 11 | has '+orientation' => ( | |||||||||||||||||||||||||||
| 101 | required => 1 | ||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 11 | has '+position' => ( | |||||||||||||||||||||||||||
| 106 | required => 1 | ||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | has 'range' => ( | ||||||||||||||||||||||||||||
| 111 | is => 'rw', | ||||||||||||||||||||||||||||
| 112 | isa => 'Chart::Clicker::Data::Range', | ||||||||||||||||||||||||||||
| 113 | 27 | ▶ | default => sub { Chart::Clicker::Data::Range->new } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 114 | 11 | ); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 11 | has 'show_ticks' => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 11 | has 'staggered' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 11 | has 'skip_range' => ( | |||||||||||||||||||||||||||
| 124 | is => 'rw', | ||||||||||||||||||||||||||||
| 125 | isa => 'Chart::Clicker::Data::Range', | ||||||||||||||||||||||||||||
| 126 | predicate => 'has_skip_range' | ||||||||||||||||||||||||||||
| 127 | ); | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | has 'tick_font' => ( | ||||||||||||||||||||||||||||
| 131 | is => 'rw', | ||||||||||||||||||||||||||||
| 132 | isa => 'Graphics::Primitive::Font', | ||||||||||||||||||||||||||||
| 133 | 27 | ▶ | default => sub { Graphics::Primitive::Font->new } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 134 | 11 | ); | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | has 'tick_label_color' => ( | ||||||||||||||||||||||||||||
| 138 | is => 'rw', | ||||||||||||||||||||||||||||
| 139 | isa => 'Graphics::Color', | ||||||||||||||||||||||||||||
| 140 | 27 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 141 | 27 | Graphics::Color::RGB->new({ | |||||||||||||||||||||||||||
| 142 | red => 0, green => 0, blue => 0, alpha => 1 | ||||||||||||||||||||||||||||
| 143 | }) | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 11 | ); | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 11 | has 'tick_labels' => ( | |||||||||||||||||||||||||||
| 149 | is => 'rw', | ||||||||||||||||||||||||||||
| 150 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | has 'tick_values' => ( | ||||||||||||||||||||||||||||
| 155 | traits => [ 'Array' ], | ||||||||||||||||||||||||||||
| 156 | is => 'rw', | ||||||||||||||||||||||||||||
| 157 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||
| 158 | 27 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 159 | 11 | handles => { | |||||||||||||||||||||||||||
| 160 | 'add_to_tick_values' => 'push', | ||||||||||||||||||||||||||||
| 161 | 'clear_tick_values' => 'clear', | ||||||||||||||||||||||||||||
| 162 | 'tick_value_count' => 'count' | ||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 11 | has 'ticks' => ( is => 'rw', isa => 'Int', default => 6 ); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 27 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 27 | $self->padding(3); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 5 | ▶ | sub _build__tick_division_type_loaded { | ||||||||||||||||||||||||||
|
Subroutine
_build__tick_division_type_loaded: called CC=3 SCAR=11.5
| |||||||||||||||||||||||||||||
| 176 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | # User modules are prefixed with a +. | ||||||||||||||||||||||||||||
| 179 | 5 | my $divisionTypeModule; | |||||||||||||||||||||||||||
| 180 | 5 | my $extensionOf = 'Chart::Clicker::Axis::DivisionType'; | |||||||||||||||||||||||||||
| 181 | 5 | ▶ | if ( $self->tick_division_type =~ m/^\+(.*)$/xmisg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 0 | $divisionTypeModule = $1; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||
| 185 | 5 | $divisionTypeModule = sprintf( '%s::%s', $extensionOf, $self->tick_division_type ); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | # Try to load the DivisionType module. An error is thrown when the class is | ||||||||||||||||||||||||||||
| 189 | # not available or cannot be loaded | ||||||||||||||||||||||||||||
| 190 | 5 | Class::Load::load_class($divisionTypeModule); | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | # Apply the newly loaded role to this class. | ||||||||||||||||||||||||||||
| 193 | 5 | Moose::Util::apply_all_roles( $self => $divisionTypeModule ); | |||||||||||||||||||||||||||
| 194 | 5 | ▶ | if ( not $self->does($extensionOf) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | die("Module $divisionTypeModule does not extend $extensionOf"); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 5 | return 1; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | override('prepare', sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=27 SCAR=66.3
| |||||||||||||||||||||||||||||
| 202 | 0 | my ($self, $driver) = @_; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | $self->clear_components; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | # The BUILD method above establishes a 5px padding at instantiation time. | ||||||||||||||||||||||||||||
| 207 | # That saves us setting it elsewhere, but if 'hidden' feature is used, | ||||||||||||||||||||||||||||
| 208 | # then we have to unset the padding. hidden (as explained below) is | ||||||||||||||||||||||||||||
| 209 | # basically a hack as far as G:P is concerned to render an empty Axis. | ||||||||||||||||||||||||||||
| 210 | # We want it to render because we need it prepared for other elements | ||||||||||||||||||||||||||||
| 211 | # of the chart to work. | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if($self->hidden) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 0 | $self->padding(0); | |||||||||||||||||||||||||||
| 214 | # Hide the border too, jic | ||||||||||||||||||||||||||||
| 215 | 0 | $self->border->width(0); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | super; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if($self->range->span == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | die('This axis has a span of 0, that\'s fatal!'); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if(defined($self->baseline)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if($self->range->lower > $self->baseline) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | $self->range->lower($self->baseline); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | } else { | ||||||||||||||||||||||||||||
| 229 | 0 | $self->baseline($self->range->lower); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if($self->fudge_amount) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 0 | my $span = $self->range->span; | |||||||||||||||||||||||||||
| 234 | 0 | my $lower = $self->range->lower; | |||||||||||||||||||||||||||
| 235 | 0 | $self->range->lower($lower - abs($span * $self->fudge_amount)); | |||||||||||||||||||||||||||
| 236 | 0 | my $upper = $self->range->upper; | |||||||||||||||||||||||||||
| 237 | 0 | $self->range->upper($upper + ($span * $self->fudge_amount)); | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if($self->show_ticks && !scalar(@{ $self->tick_values })) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->show_ticks and not scalar @{$self->tick_values;}
MC/DC0%0/2
$self->show_ticks and not scalar @{$self->tick_values;}
$self->show_ticks
not scalar @{$self->tick_values;}
Truth table0%0/3
A and not(B)
A= $self->show_ticksB= not scalar @{$self->tick_values;}
| |||||||||||||||||||||||||||||
| 241 | 0 | $self->tick_values($self->divvy); | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # Return now without setting a min height or width and allow | ||||||||||||||||||||||||||||
| 245 | # Layout::Manager to to set it for us, this is how we 'hide' | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return if $self->hidden; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | my $tfont = $self->tick_font; | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | my $bheight = 0; | |||||||||||||||||||||||||||
| 251 | 0 | my $bwidth = 0; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | # Determine all this once... much faster. | ||||||||||||||||||||||||||||
| 254 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 255 | 0 | foreach my $val (@{ $self->tick_values }) { | |||||||||||||||||||||||||||
| 256 | 0 | ▶ | if($self->has_skip_range && $self->skip_range->contains($val)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->has_skip_range and $self->skip_range->contains($val)
MC/DC0%0/2
$self->has_skip_range and $self->skip_range->contains($val)
$self->has_skip_range
$self->skip_range->contains($val)
Truth table0%0/3
A and B
A= $self->has_skip_rangeB= $self->skip_range->contains($val)
| |||||||||||||||||||||||||||||
| 257 | # If the label falls in inside the skip range, it's not to be | ||||||||||||||||||||||||||||
| 258 | # used at all. | ||||||||||||||||||||||||||||
| 259 | 0 | next; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | my $label = $val; | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | if(defined($self->tick_labels)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if (defined $self->tick_labels->[$i]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | $label = $self->tick_labels->[$i]; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | else { | ||||||||||||||||||||||||||||
| 268 | 0 | $label = ""; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | } else { | ||||||||||||||||||||||||||||
| 271 | 0 | $label = $self->format_value($val); | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | my $tlabel = Graphics::Primitive::TextBox->new( | |||||||||||||||||||||||||||
| 275 | text => $label, | ||||||||||||||||||||||||||||
| 276 | font => $tfont, | ||||||||||||||||||||||||||||
| 277 | color => $self->tick_label_color, | ||||||||||||||||||||||||||||
| 278 | ); | ||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if($self->tick_label_angle) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 0 | $tlabel->angle($self->tick_label_angle); | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | 0 | my $lay = $driver->get_textbox_layout($tlabel); | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | $tlabel->prepare($driver); | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 0 | $tlabel->width($lay->width); | |||||||||||||||||||||||||||
| 287 | 0 | $tlabel->height($lay->height); | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $bwidth = $tlabel->width if($tlabel->width > $bwidth); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 0 | ▶ | $bheight = $tlabel->height if($tlabel->height > $bheight); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | $self->add_component($tlabel); | |||||||||||||||||||||||||||
| 293 | 0 | $i++; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | my $big = $bheight; | |||||||||||||||||||||||||||
| 297 | 0 | ▶ | if($self->is_vertical) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 0 | $big = $bwidth; | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | my $label_width = 0; | |||||||||||||||||||||||||||
| 302 | 0 | my $label_height = 0; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($self->label) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 0 | my $label = Graphics::Primitive::TextBox->new( | |||||||||||||||||||||||||||
| 306 | # angle => $angle, | ||||||||||||||||||||||||||||
| 307 | color => $self->label_color, | ||||||||||||||||||||||||||||
| 308 | name => 'label', | ||||||||||||||||||||||||||||
| 309 | font => $self->label_font, | ||||||||||||||||||||||||||||
| 310 | text => $self->label, | ||||||||||||||||||||||||||||
| 311 | width => $self->height, | ||||||||||||||||||||||||||||
| 312 | horizontal_align => 'center' | ||||||||||||||||||||||||||||
| 313 | ); | ||||||||||||||||||||||||||||
| 314 | 0 | $label->name('label'); | |||||||||||||||||||||||||||
| 315 | 0 | $label->border->color(Graphics::Color::RGB->new(r => 0, g => 0, b => 0)); | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if($self->is_vertical) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ($self->is_left) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 0 | $label->angle(-&pip2); | |||||||||||||||||||||||||||
| 321 | } else { | ||||||||||||||||||||||||||||
| 322 | 0 | $label->angle(&pip2) | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 0 | $label->prepare($driver); | |||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | $label->width($label->minimum_width); | |||||||||||||||||||||||||||
| 330 | 0 | $label->height($label->minimum_height); | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | $label_width = $label->width; | |||||||||||||||||||||||||||
| 333 | 0 | $label_height = $label->height; | |||||||||||||||||||||||||||
| 334 | 0 | $self->add_component($label); | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if($self->is_vertical) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 338 | 0 | my $new_min_width = $self->outside_width + $big + $label_width; | |||||||||||||||||||||||||||
| 339 | 0 | ▶ | $self->minimum_width($new_min_width) if $new_min_width > $self->minimum_width; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | 0 | my $new_min_height = $self->outside_height + $big; | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | $self->minimum_height($new_min_height) if $new_min_height > $self->minimum_height; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||
| 343 | 0 | my $new_min_height = $self->outside_height + $big + $label_height; | |||||||||||||||||||||||||||
| 344 | 0 | my $new_min_width = $self->outside_width + $big; | |||||||||||||||||||||||||||
| 345 | 0 | ▶ | $self->minimum_height($new_min_height) if $new_min_height > $self->minimum_height; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $self->minimum_width($new_min_width) if $new_min_width > $self->minimum_width; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if($self->staggered) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | 0 | $self->minimum_height($self->minimum_height * 2); | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 0 | return 1; | |||||||||||||||||||||||||||
| 353 | 11 | }); | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub mark { | ||||||||||||||||||||||||||
|
Subroutine
mark: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 357 | 0 | my ($self, $span, $value) = @_; | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 0 | ▶ | return undef if not defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if($self->has_skip_range) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | # We must completely ignore values that fall inside the skip range, | ||||||||||||||||||||||||||||
| 362 | # so we return an undef. | ||||||||||||||||||||||||||||
| 363 | 0 | ▶ | return undef if $self->skip_range->contains($value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if($value > $self->skip_range->upper) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | # If the value was outside the range, but above it then we must | ||||||||||||||||||||||||||||
| 366 | # be sure and substract the range we are skipping so that the | ||||||||||||||||||||||||||||
| 367 | # value will still fall on the chart. | ||||||||||||||||||||||||||||
| 368 | 0 | $value = $value - $self->skip_range->span; | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | # 'caching' this here speeds things up. Calling after changing the | ||||||||||||||||||||||||||||
| 373 | # range would result in a messed up chart anyway... | ||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if(!defined($self->{LOWER})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | $self->{LOWER} = $self->range->lower; | |||||||||||||||||||||||||||
| 376 | 0 | ▶ | if($self->has_skip_range) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | # If we have a skip range then the RSPAN is less the skip range's | ||||||||||||||||||||||||||||
| 378 | # span. | ||||||||||||||||||||||||||||
| 379 | 0 | $self->{RSPAN} = $self->range->span - $self->skip_range->span; | |||||||||||||||||||||||||||
| 380 | } else { | ||||||||||||||||||||||||||||
| 381 | 0 | $self->{RSPAN} = $self->range->span; | |||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | return ($span / $self->{RSPAN}) * ($value - $self->{LOWER} || 0); | ||||||||||||||||||||||||||
|
Condition0%0/2
$value - $self->{'LOWER'} || 0
MC/DC0%0/1
$value - $self->{'LOWER'} || 0
$value - $self->{'LOWER'}
Truth table0%0/2
A
A= $value - $self->{'LOWER'}
| |||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | override('finalize', sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=22 SCAR=62.3
| |||||||||||||||||||||||||||||
| 389 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if($self->hidden) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | # Call the callback, just in case it matters. | ||||||||||||||||||||||||||||
| 393 | 0 | super; | |||||||||||||||||||||||||||
| 394 | 0 | return; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | my $x = 0; | |||||||||||||||||||||||||||
| 398 | 0 | my $y = 0; | |||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | my $width = $self->width; | |||||||||||||||||||||||||||
| 401 | 0 | my $height = $self->height; | |||||||||||||||||||||||||||
| 402 | 0 | my $ibb = $self->inside_bounding_box; | |||||||||||||||||||||||||||
| 403 | 0 | my $iox = $ibb->origin->x; | |||||||||||||||||||||||||||
| 404 | 0 | my $ioy = $ibb->origin->y; | |||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 0 | my $iwidth = $ibb->width; | |||||||||||||||||||||||||||
| 407 | 0 | my $iheight = $ibb->height; | |||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if($self->is_left) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 410 | 0 | $x += $width; | |||||||||||||||||||||||||||
| 411 | } elsif($self->is_right) { | ||||||||||||||||||||||||||||
| 412 | # nuffin | ||||||||||||||||||||||||||||
| 413 | } elsif($self->is_top) { | ||||||||||||||||||||||||||||
| 414 | 0 | $y += $height; | |||||||||||||||||||||||||||
| 415 | } else { | ||||||||||||||||||||||||||||
| 416 | # nuffin | ||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | my $lower = $self->range->lower; | |||||||||||||||||||||||||||
| 420 | 0 | my $upper = $self->range->upper; | |||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | 0 | my @values = @{ $self->tick_values }; | |||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if($self->is_vertical) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 0 | my $comp_count = 0; | |||||||||||||||||||||||||||
| 427 | 0 | for(0..$#values) { | |||||||||||||||||||||||||||
| 428 | 0 | my $val = $values[$_]; | |||||||||||||||||||||||||||
| 429 | 0 | my $mark = $self->mark($height, $val); | |||||||||||||||||||||||||||
| 430 | 0 | ▶ | next unless defined($mark); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 431 | 0 | my $iy = $height - $mark; | |||||||||||||||||||||||||||
| 432 | 0 | my $label = $self->get_component($comp_count); | |||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | # Adjust text on the Y axis to fit when it is | ||||||||||||||||||||||||||||
| 435 | # too close to the edges | ||||||||||||||||||||||||||||
| 436 | 0 | my $standardYOrigin = $iy - ($label->height / 2); | |||||||||||||||||||||||||||
| 437 | #my $lowerYOrigin = $iy - $label->height; | ||||||||||||||||||||||||||||
| 438 | 0 | my $lowerYOrigin = $ioy + $iheight - $label->height; | |||||||||||||||||||||||||||
| 439 | 0 | my $upperYOrigin = $ioy; | |||||||||||||||||||||||||||
| 440 | 0 | ▶ | if($standardYOrigin >= $lowerYOrigin) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 441 | # The first label (being at the bottom) needs to be | ||||||||||||||||||||||||||||
| 442 | # skooched up a bit to fit. | ||||||||||||||||||||||||||||
| 443 | 0 | $label->origin->y($lowerYOrigin); | |||||||||||||||||||||||||||
| 444 | } elsif($standardYOrigin <= $upperYOrigin) { | ||||||||||||||||||||||||||||
| 445 | # The last label (being at the top) can be positioned | ||||||||||||||||||||||||||||
| 446 | # exactly at the mark. | ||||||||||||||||||||||||||||
| 447 | 0 | $label->origin->y($upperYOrigin); | |||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||
| 449 | 0 | $label->origin->y($standardYOrigin); | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if($self->is_left) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | 0 | $label->origin->x($iox + $iwidth - $label->width); | |||||||||||||||||||||||||||
| 454 | } else { | ||||||||||||||||||||||||||||
| 455 | 0 | $label->origin->x($iox); | |||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||
| 457 | # Keep track of how many components we've actually grabbed, since | ||||||||||||||||||||||||||||
| 458 | # we could be skipping any that are in a skip range. | ||||||||||||||||||||||||||||
| 459 | 0 | $comp_count++; | |||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | # Draw the label | ||||||||||||||||||||||||||||
| 463 | # FIXME Not working, rotated text labels... | ||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if($self->label) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 465 | 0 | my $label = $self->get_component($self->find_component('label')); | |||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if($self->is_left) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 0 | $label->origin->x($iox); | |||||||||||||||||||||||||||
| 470 | 0 | $label->origin->y(($height - $label->height) / 2); | |||||||||||||||||||||||||||
| 471 | } else { | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | $label->origin->x($iox + $iwidth - $label->width); | |||||||||||||||||||||||||||
| 474 | 0 | $label->origin->y(($height - $label->height) / 2); | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | } else { | ||||||||||||||||||||||||||||
| 478 | # Draw a tick for each value. | ||||||||||||||||||||||||||||
| 479 | 0 | my $comp_count = 0; | |||||||||||||||||||||||||||
| 480 | 0 | for(0..$#values) { | |||||||||||||||||||||||||||
| 481 | 0 | my $val = $values[$_]; | |||||||||||||||||||||||||||
| 482 | 0 | my $ix = $self->mark($width, $val); | |||||||||||||||||||||||||||
| 483 | 0 | ▶ | next unless defined($ix); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 0 | my $label = $self->get_component($comp_count); | |||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | 0 | my $bump = 0; | |||||||||||||||||||||||||||
| 488 | 0 | ▶ | if($self->staggered) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if($_ % 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 490 | 0 | $bump = $iheight / 2; | |||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | # Adjust the X-origin value to ensure it is within the graph | ||||||||||||||||||||||||||||
| 495 | # and does not get snipped when too close to the edge. | ||||||||||||||||||||||||||||
| 496 | 0 | my $standardXOrigin = $ix - ($label->width / 1.8); | |||||||||||||||||||||||||||
| 497 | 0 | my $lowerXOrigin = $iox; | |||||||||||||||||||||||||||
| 498 | 0 | my $upperXOrigin = $iox + $iwidth - $label->width; | |||||||||||||||||||||||||||
| 499 | 0 | ▶ | if($standardXOrigin <= $lowerXOrigin) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 500 | 0 | $label->origin->x($lowerXOrigin); | |||||||||||||||||||||||||||
| 501 | } elsif($standardXOrigin >= $upperXOrigin) { | ||||||||||||||||||||||||||||
| 502 | 0 | $label->origin->x($upperXOrigin); | |||||||||||||||||||||||||||
| 503 | } else { | ||||||||||||||||||||||||||||
| 504 | 0 | $label->origin->x($standardXOrigin); | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if($self->is_top) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 508 | 0 | $label->origin->y($ioy + $iheight - $label->height - $bump); | |||||||||||||||||||||||||||
| 509 | } else { | ||||||||||||||||||||||||||||
| 510 | 0 | $label->origin->y($ioy + $bump); | |||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | # Keep track of how many components we've actually grabbed, since | ||||||||||||||||||||||||||||
| 513 | # we could be skipping any that are in a skip range. | ||||||||||||||||||||||||||||
| 514 | 0 | $comp_count++; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | # Draw the label | ||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if($self->label) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | my $label = $self->get_component($self->find_component('label')); | |||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | 0 | my $ext = $self->{'label_extents_cache'}; | |||||||||||||||||||||||||||
| 522 | 0 | ▶ | if ($self->is_bottom) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 0 | $label->origin->x(($width - $label->width) / 2); | |||||||||||||||||||||||||||
| 524 | 0 | $label->origin->y($height - $label->height | |||||||||||||||||||||||||||
| 525 | - ($self->padding->bottom + $self->margins->bottom | ||||||||||||||||||||||||||||
| 526 | + $self->border->top->width | ||||||||||||||||||||||||||||
| 527 | ) | ||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||
| 529 | } else { | ||||||||||||||||||||||||||||
| 530 | 0 | $label->origin->x(($width - $label->width) / 2); | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 0 | super; | |||||||||||||||||||||||||||
| 536 | 11 | }); | |||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 1 | ▶ | sub format_value { | ||||||||||||||||||||||||||
|
Subroutine
format_value: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||
| 540 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 541 | 1 | my $value = shift; | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 1 | my $format = $self->format; | |||||||||||||||||||||||||||
| 544 | 1 | ▶ | if($format) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 545 | 1 | ▶ | if(ref($format) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 546 | 0 | return &$format($value); | |||||||||||||||||||||||||||
| 547 | } else { | ||||||||||||||||||||||||||||
| 548 | 1 | return sprintf($format, $value); | |||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | 5 | ▶ | sub divvy { | ||||||||||||||||||||||||||
|
Subroutine
divvy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 556 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | # Loads the divvy module once and only once | ||||||||||||||||||||||||||||
| 559 | # which implements _real_divvy() | ||||||||||||||||||||||||||||
| 560 | 5 | $self->_tick_division_type_loaded; | |||||||||||||||||||||||||||
| 561 | 5 | return $self->_real_divvy(); | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 11 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | 11 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 11 | 1; | |||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | __END__ | ||||||||||||||||||||||||||||