1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
package Chart::Clicker::Decoration::MarkerOverlay;
$Chart::Clicker::Decoration::MarkerOverlay::VERSION = '2.90';
use Moose;
extends 'Chart::Clicker::Decoration';
# ABSTRACT: Component for drawing markers
use Graphics::Primitive::Operation::Stroke;
use Graphics::Primitive::Operation::Fill;
use Graphics::Primitive::Paint::Solid;
override('finalize', sub {
my ($self) = @_;
my $width = $self->width;
my $height = $self->height;
my $clicker = $self->clicker;
foreach my $cname ($clicker->context_names) {
my $ctx = $clicker->get_context($cname);
foreach my $marker (@{ $ctx->markers }) {
my $key = $marker->key;
my $value = $marker->value;
if(not defined($value)) {
my $key2 = $marker->key2;
my $domain = $ctx->domain_axis;
my $x = $domain->mark($self->width, $key);
my $x2;
if($key2) {
$x2 = $domain->mark($self->width, $key2);
$self->move_to($x, 0);
$self->rectangle(($x2 - $x), $height);
my $fillop = Graphics::Primitive::Operation::Fill->new(
paint => Graphics::Primitive::Paint::Solid->new(
color => $marker->inside_color
),
);
$self->do($fillop);
}
$self->move_to($x, 0);
$self->rel_line_to(0, $height);
if($x2) {
$self->move_to($x2, 0);
$self->rel_line_to(0, $height);
}
my $op = Graphics::Primitive::Operation::Stroke->new;
$op->brush($marker->brush);
$op->brush->color($marker->color);
$self->do($op);
} elsif(not defined($key)) {
my $value2 = $marker->value2;
my $range = $ctx->range_axis;
#
my $y = $height - $range->mark($height, $value);
my $y2;
if($value2) {
$y2 = $height - $range->mark($self->height, $value2);
$self->move_to(0, $y);
$self->rectangle($width, ($y2 - $y));
my $fillop = Graphics::Primitive::Operation::Fill->new(
paint => Graphics::Primitive::Paint::Solid->new(
color => $marker->inside_color
),
);
$self->do($fillop);
}
$self->move_to(0, $y);
$self->rel_line_to($width, 0);
if($y2) {
$self->move_to(0, $y2);
$self->rel_line_to($width, 0);
}
my $op = Graphics::Primitive::Operation::Stroke->new;
$op->brush($marker->brush);
$op->brush->color($marker->color);
$self->do($op);
}
}
}
});
__PACKAGE__->meta->make_immutable;
no Moose;
1;
__END__
=pod
=head1 NAME
Chart::Clicker::Decoration::MarkerOverlay - Component for drawing markers
=head1 VERSION
version 2.90
=head1 DESCRIPTION
A Component that handles the rendering of Markers.
=head1 AUTHOR
Cory G Watson <gphat@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Cory G Watson.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|