| 1 | package Chart::Clicker::Renderer::Point; | ||||||||||
| 2 | 7 | $Chart::Clicker::Renderer::Point::VERSION = '2.90'; | |||||||||
| 3 | 7 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: Point renderer | ||||||||||
| 6 | |||||||||||
| 7 | 7 | extends 'Chart::Clicker::Renderer'; | |||||||||
| 8 | |||||||||||
| 9 | 7 | ▶ | use Geometry::Primitive::Circle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 7 | ▶ | use Geometry::Primitive::Point; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 7 | ▶ | use Graphics::Primitive::Operation::Fill; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 7 | ▶ | use Graphics::Primitive::Paint::Solid; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | has 'shape' => ( | ||||||||||
| 16 | is => 'rw', | ||||||||||
| 17 | does => 'Geometry::Primitive::Shape', | ||||||||||
| 18 | 3 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | Geometry::Primitive::Circle->new({ | |||||||||
| 20 | radius => 3, | ||||||||||
| 21 | }); | ||||||||||
| 22 | } | ||||||||||
| 23 | 7 | ); | |||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 7 | has 'shape_brush' => ( | |||||||||
| 27 | is => 'rw', | ||||||||||
| 28 | isa => 'Graphics::Primitive::Brush', | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | override('finalize', sub { | ||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||
| 32 | 0 | my ($self) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 0 | my $clicker = $self->clicker; | |||||||||
| 35 | |||||||||||
| 36 | 0 | my $width = $self->width; | |||||||||
| 37 | 0 | my $height = $self->height; | |||||||||
| 38 | |||||||||||
| 39 | 0 | my $dses = $clicker->get_datasets_for_context($self->context); | |||||||||
| 40 | 0 | foreach my $ds (@{ $dses }) { | |||||||||
| 41 | 0 | foreach my $series (@{ $ds->series }) { | |||||||||
| 42 | |||||||||||
| 43 | # TODO if undef... | ||||||||||
| 44 | 0 | my $ctx = $clicker->get_context($ds->context); | |||||||||
| 45 | 0 | my $domain = $ctx->domain_axis; | |||||||||
| 46 | 0 | my $range = $ctx->range_axis; | |||||||||
| 47 | |||||||||||
| 48 | 0 | my $min = $range->range->lower; | |||||||||
| 49 | |||||||||||
| 50 | 0 | my @vals = @{ $series->values }; | |||||||||
| 51 | 0 | my @keys = @{ $series->keys }; | |||||||||
| 52 | 0 | for(0..($series->key_count - 1)) { | |||||||||
| 53 | 0 | my $x = $domain->mark($width, $keys[$_]); | |||||||||
| 54 | 0 | ▶ | next unless defined($x); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 0 | my $ymark = $range->mark($height, $vals[$_]); | |||||||||
| 56 | 0 | ▶ | next unless defined($ymark); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | my $y = $height - $ymark; | |||||||||
| 58 | |||||||||||
| 59 | 0 | $self->move_to($x, $y); | |||||||||
| 60 | 0 | $self->draw_point($x, $y, $series, $_); | |||||||||
| 61 | } | ||||||||||
| 62 | 0 | my $op = Graphics::Primitive::Operation::Fill->new( | |||||||||
| 63 | paint => Graphics::Primitive::Paint::Solid->new( | ||||||||||
| 64 | color => $clicker->color_allocator->next | ||||||||||
| 65 | ) | ||||||||||
| 66 | ); | ||||||||||
| 67 | 0 | ▶ | if(defined($self->shape_brush)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | $op->preserve(1); | |||||||||
| 69 | } | ||||||||||
| 70 | 0 | $self->do($op); | |||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | if(defined($self->shape_brush)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 0 | my $op3 = Graphics::Primitive::Operation::Stroke->new; | |||||||||
| 74 | 0 | $op3->brush($self->shape_brush->clone); | |||||||||
| 75 | 0 | $self->do($op3); | |||||||||
| 76 | } | ||||||||||
| 77 | } | ||||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 0 | return 1; | |||||||||
| 81 | 7 | }); | |||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | sub draw_point { | ||||||||
|
Subroutine
draw_point: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 85 | 0 | my ($self, $x, $y, $series, $count) = @_; | |||||||||
| 86 | |||||||||||
| 87 | 0 | my $shape = $self->shape->clone; | |||||||||
| 88 | 0 | $shape->origin(Geometry::Primitive::Point->new(x => $x, y => $y)); | |||||||||
| 89 | 0 | $self->path->add_primitive($shape); | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||
| 93 | |||||||||||
| 94 | 7 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 95 | |||||||||||
| 96 | 7 | 1; | |||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||