Clicker/Decoration/Grid.pm

filter: Statementstmt 42.8% 24 / 56 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 6 / 8 Podpod 100% 1 / 1 totaltotal 37.8% 31 / 82 CC 10 SCAR 31.8
CC
10
Cov
34%
draw_lines
42.0
__ANON__
30.0
BEGIN
1.0
CRAP 24.0
« Clicker/Renderer/Point.pm ↑ Summary Clicker/Renderer/Pie.pm »
1 package Chart::Clicker::Decoration::Grid;
2 9 $Chart::Clicker::Decoration::Grid::VERSION = '2.89';
3 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 extends 'Graphics::Primitive::Canvas';
6  
7 9 with 'Graphics::Primitive::Oriented';
8  
9 # ABSTRACT: Under-data grid
10  
11 9 ▶use Graphics::Color::RGB;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 has '+background_color' => (
15 default => sub {
16 8 ▶ Graphics::Color::RGB->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
17 red => 0.9, green => 0.9, blue => 0.9, alpha => 1
18 )
19 }
20 9 );
21  
22  
23 9 has 'clicker' => ( is => 'rw', isa => 'Chart::Clicker' );
24  
25  
26 has 'domain_brush' => (
27 is => 'rw',
28 isa => 'Graphics::Primitive::Brush',
29 default => sub {
30 8 ▶ Graphics::Primitive::Brush->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
31 color => Graphics::Color::RGB->new(
32 red => .75, green => .75, blue => .75, alpha => 1
33 ),
34 width => 1
35 )
36 }
37 9 );
38  
39  
40 has 'range_brush' => (
41 is => 'rw',
42 isa => 'Graphics::Primitive::Brush',
43 default => sub {
44 8 ▶ Graphics::Primitive::Brush->new(
Subroutine __ANON__: called CC=1 SCAR=0.0
45 color => Graphics::Color::RGB->new(
46 red => .75, green => .75, blue => .75, alpha => 1
47 ),
48 width => 1
49 )
50 }
51 9 );
52  
53  
54 9 has 'show_domain' => (
55 is => 'rw',
56 isa => 'Bool',
57 default => 1
58 );
59  
60  
61 9 has 'show_range' => (
62 is => 'rw',
63 isa => 'Bool',
64 default => 1
65 );
66  
67  
68 override('finalize', sub {
69 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=5 SCAR=34.0
70  
71 0 ▶ return unless ($self->show_domain || $self->show_range);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->show_domain or $self->show_range 0 0 0
Condition0%0/3
$self->show_domain or $self->show_range
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->show_domain or $self->show_range
$self->show_domain $self->show_range
Truth table0%0/3
A or B
A= $self->show_domainB= $self->show_range
ABresult
1X1
011
000
72  
73 0 my $clicker = $self->clicker;
74  
75 0 my $dflt = $clicker->get_context('default');
76 0 my $daxis = $dflt->domain_axis;
77 0 my $raxis = $dflt->range_axis;
78  
79 0 ▶ if($self->show_domain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->show_domain) 0 0 0
80 0 $self->draw_lines($daxis);
81 0 my $dop = Graphics::Primitive::Operation::Stroke->new;
82 0 $dop->brush($self->domain_brush);
83 0 $self->do($dop);
84 }
85  
86 0 ▶ if($self->show_range) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->show_range) 0 0 0
87 0 $self->draw_lines($raxis);
88 0 my $rop = Graphics::Primitive::Operation::Stroke->new;
89 0 $rop->brush($self->range_brush);
90 0 $self->do($rop);
91 }
92 9 });
93  
94  
95 sub draw_lines {
96 0 ▶ my ($self, $axis) = @_;
Subroutine draw_lines: not called CC=6 SCAR=37.4
Pod documented
97  
98 0 my $height = $self->height;
99 0 my $width = $self->width;
100  
101 0 ▶ if($axis->is_horizontal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($axis->is_horizontal) { } 0 0 0
102  
103 0 foreach my $val (@{ $axis->tick_values }) {
104 0 my $mark = $axis->mark($width, $val);
105 # Don't try and draw a mark if the Axis wouldn't give us a value,
106 # it might be skipping...
107 0 ▶ next unless defined($mark);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mark 0 0 0
108 0 $self->move_to($mark, 0);
109 0 $self->rel_line_to(0, $height);
110 }
111 } else {
112  
113 0 foreach my $val (@{ $axis->tick_values }) {
114 0 my $mark = $axis->mark($height, $val);
115 # Don't try and draw a mark if the Axis wouldn't give us a value,
116 # it might be skipping...
117 0 ▶ next unless defined($mark);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mark 0 0 0
118 0 $self->move_to(0, $height - $mark);
119 0 $self->rel_line_to($width, 0);
120 }
121 }
122 }
123  
124 9 __PACKAGE__->meta->make_immutable;
125  
126 9 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 9 1;
129  
130 __END__
131  
132 =pod
133  
134 =head1 NAME
135  
136 Chart::Clicker::Decoration::Grid - Under-data grid
137  
138 =head1 VERSION
139  
140 version 2.89
141  
142 =head1 DESCRIPTION
143  
144 Generates a collection of Markers for use as a background.
145  
146 =head1 ATTRIBUTES
147  
148 =head2 background_color
149  
150 Set/Get the background L<color|Graphics::Color::RGB> for this Grid.
151  
152 =head2 border
153  
154 Set/Get the L<border|Graphics::Primitive::Border> for this Grid.
155  
156 =head2 color
157  
158 Set/Get the L<color|Graphics::Color::RGB> for this Grid.
159  
160 =head2 domain_brush
161  
162 Set/Get the L<brush|Graphics::Primitive::Brush> for inking the domain markers.
163  
164 =head2 range_brush
165  
166 Set/Get the L<brush|Graphics::Primitive::Brush> for inking the range markers.
167  
168 =head2 show_domain
169  
170 Flag to show or not show the domain lines.
171  
172 =head2 show_range
173  
174 Flag to show or not show the range lines.
175  
176 =head2 stroke
177  
178 Set/Get the Stroke for this Grid.
179  
180 =head1 METHODS
181  
182 =head2 draw_lines
183  
184 Called by pack, draws the lines for a given axis.
185  
186 =head1 AUTHOR
187  
188 Cory G Watson <gphat@cpan.org>
189  
190 =head1 COPYRIGHT AND LICENSE
191  
192 This software is copyright (c) 2016 by Cory G Watson.
193  
194 This is free software; you can redistribute it and/or modify it under
195 the same terms as the Perl 5 programming language system itself.
196  
197 =cut
« Clicker/Renderer/Point.pm ↑ Summary Clicker/Renderer/Pie.pm »