| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | if($comp->can('components')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | foreach my $c (@{ $comp->components }) { | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | next unless defined($c) && defined($c) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $c and defined $c and $c->visible
defined $c and defined $c
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | $self->width($comp->width); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | unless(defined($self->height)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 2 | foreach my $c (@{ $comp->components }) { | |||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | next unless defined($c) && $c->visible; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $c and $c->visible
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||