GeniusTrader/Graphics/Object/Polygon.pm untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 71 CC 3 SCAR 15.5
CC
3
Cov
0%
init
12.0
display
2.0
BEGIN
2.0
CRAP 4.7
1 package Finance::GeniusTrader::Graphics::Object::Polygon;
2  
3 # Copyright 2003 Oliver Bossert
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8 use vars qw(@ISA);
9 @ISA = qw(Finance::GeniusTrader::Graphics::Object);
10  
11 use Finance::GeniusTrader::Prices;
12 use Finance::GeniusTrader::Graphics::Object;
13 use Finance::GeniusTrader::Graphics::Driver;
14 use Finance::GeniusTrader::Graphics::Tools qw(:color);
15 use Finance::GeniusTrader::Conf;
16  
17 Finance::GeniusTrader::Conf::default("Graphic::Polygon::Color", "red");
18  
19 =head1 Finance::GeniusTrader::Graphics::Object::Text
20  
21 This graphical object displays a block of text.
22  
23 =cut
24  
25 sub init {
26 my $self = shift;
27 #my $calc = shift;
28 my $pts = shift;
29 my @points = @{$pts};
30 print STDERR join("#", @points) . "\n";
31 my @realpoints = ();
32 for (my $i=0; $i<=$#points; $i++) {
33 my ($day, $val) = split /\//, $points[$i];
34 if ( $day =~ /....-..-../ ) {
35 if ($self->{'source'}->prices->has_date($day)) {
36 $day = $self->{'source'}->prices->date($day);
37 } else {
38 $day = $self->{'source'}->prices->date($self->{'source'}->prices->find_nearest_date($day));
39 }
40 }
41 push @realpoints, [$day, $val];
42 print STDERR $day . " - " . $val . "\n";
43 }
44 push @realpoints, [$realpoints[0][0], $realpoints[0][1]];
45 $self->{'points'} = \@realpoints;
46 $self->{'fg_color'} = get_color(Finance::GeniusTrader::Conf::get("Graphic::Polygon::Color"));
47 }
48  
49 sub display {
50 my ($self, $driver, $picture) = @_;
51 my $zone = $self->{'zone'};
52 my $scale = $self->get_scale();
53  
54 my @points = @{$self->{'points'}};
55 for (my $i=0; $i<=$#points; $i++) {
56 ($points[$i][0], $points[$i][1]) = $zone->absolute_coordinate($scale->convert_to_x_coordinate($points[$i][0]),
57 $scale->convert_to_y_coordinate($points[$i][1]));
58 }
59  
60 $driver->polygon($picture, $self->{'fg_color'}, @points);
61 }
62  
63 1;