lib/Graphics/Primitive/Driver.pm

filter: Statementstmt 84.4% 38 / 45 Branchbran 63.3% 19 / 30 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 5 / 5 Podpod 100% 3 / 3 totaltotal 70.1% 68 / 97 CC 22 SCAR 25.8
CC
22
Cov
71%
draw
22.6
prepare
7.1
finalize
6.9
CRAP 13.1
« blib/lib/Graphics/Primitive/TextBox.pm ↑ Summary blib/lib/Graphics/Primitive/Font.pm »
1 package Graphics::Primitive::Driver;
2 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 requires qw(
5 _draw_arc _draw_bezier _draw_canvas _draw_circle _draw_component
6 _draw_ellipse _draw_line _draw_path _draw_polygon _draw_rectangle
7 _draw_textbox _do_fill _do_stroke _finish_page _resize data
8 get_textbox_layout reset write
9 );
10  
11 2 has 'height' => (
12 is => 'rw',
13 isa => 'Num'
14 );
15 2 has 'width' => (
16 is => 'rw',
17 isa => 'Num'
18 );
19  
20 2 ▶sub draw {
Subroutine draw: called CC=11 SCAR=31.2
Pod documented
21 2 my ($self, $comp) = @_;
22  
23 2 ▶ if($comp->page) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->page) 0 2 2
24 # FIRST_PAGE is a little protection to ensure that we don't call
25 # show page on the first page, as that would mean we'd have an
26 # empty first page all the time.
27 0 ▶ if($self->{FIRST_PAGE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'FIRST_PAGE'}) { } 0 0 0
28 0 $self->_finish_page;
29 } else {
30 0 $self->{FIRST_PAGE} = 1;
31 }
32 0 $self->_resize($comp->width, $comp->height);
33 }
34  
35 2 ▶ die('Components must be objects.') unless ref($comp);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $comp 0 2 2
36 # The order of this is important, since isa will return true for any
37 # superclass...
38 # TODO Check::ISA
39 2 ▶ if($comp->isa('Graphics::Primitive::Canvas')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($comp->isa('Graphics::Primitive::Canvas')) { } 0 2 2
elsif ($comp->isa('Graphics::Primitive::Image')) { } 0 2 2
elsif ($comp->isa('Graphics::Primitive::TextBox')) { } 0 2 2
elsif ($comp->isa('Graphics::Primitive::Component')) { } 2 0 2
40 0 $self->_draw_canvas($comp);
41 } elsif($comp->isa('Graphics::Primitive::Image')) {
42 0 $self->_draw_image($comp);
43 } elsif($comp->isa('Graphics::Primitive::TextBox')) {
44 0 $self->_draw_textbox($comp);
45 } elsif($comp->isa('Graphics::Primitive::Component')) {
46 2 $self->_draw_component($comp);
47 }
48  
49 2 ▶ if($comp->isa('Graphics::Primitive::Container')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->isa("Graphics::Primitive::Container")) 1 1 2
50 1 ▶ if($comp->can('components')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->can("components")) 1 0 1
51 1 foreach my $subcomp (@{ $comp->components }) {
52 1 $self->draw($subcomp);
53 }
54 }
55 }
56 }
57  
58 4 ▶sub finalize {
Subroutine finalize: called CC=6 SCAR=19.3
Pod documented
59 4 my ($self, $comp) = @_;
60  
61 4 $comp->finalize($self);
62  
63 4 ▶ if($comp->isa('Graphics::Primitive::Container')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->isa("Graphics::Primitive::Container")) 2 2 4
64 2 foreach my $c (@{ $comp->components }) {
65 2 ▶ next unless defined($c) && defined($c)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c and defined $c and $c->visible 0 2 2
Condition33%2/6
defined $c and defined $c and $c->visible
!ll&&!rl&&r
002
defined $c and defined $c
!ll&&!rl&&r
002
MC/DC0%0/3
defined $c and defined $c and $c->visible
defined $c defined $c $c->visible
Truth table25%1/4
A and B and C
A= defined $cB= defined $cC= $c->visible
ABCresult
0XX0
10X0
1100
1111
66 && $c->visible;
67 2 $self->finalize($c);
68 }
69 }
70 }
71  
72 4 ▶sub prepare {
Subroutine prepare: called CC=7 SCAR=19.6
Pod documented
73 4 my ($self, $comp) = @_;
74  
75 4 ▶ unless(defined($self->width)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->width) 2 2 4
76 2 $self->width($comp->width);
77 }
78 4 ▶ unless(defined($self->height)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->height) 2 2 4
79 2 $self->height($comp->height);
80 }
81  
82 4 $comp->prepare($self);
83  
84 # TODO Check::ISA
85 4 ▶ if($comp->isa('Graphics::Primitive::Container')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->isa("Graphics::Primitive::Container")) 2 2 4
86 2 foreach my $c (@{ $comp->components }) {
87 2 ▶ next unless defined($c) && $c->visible;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $c and $c->visible 0 2 2
Condition33%1/3
defined $c and $c->visible
!ll&&!rl&&r
002
MC/DC0%0/2
defined $c and $c->visible
defined $c $c->visible
Truth table33%1/3
A and B
A= defined $cB= $c->visible
ABresult
0X0
100
111
88 2 $self->prepare($c);
89 }
90 }
91 }
92  
93 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 2 1;
95 __END__
« blib/lib/Graphics/Primitive/TextBox.pm ↑ Summary blib/lib/Graphics/Primitive/Font.pm »