blib/lib/Bio/Graphics/Glyph/pentagram.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 81 CC 8 SCAR 32.6
CC
8
Cov
0%
draw_component
56.0
pad_top
6.0
my_description
2.0
CRAP 26.1
1 package Bio::Graphics::Glyph::pentagram;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 sub my_description {
7 return <<END;
8 This
9 END
10 }
11  
12 sub pad_top
13 {
14 my ($self) = @_;
15
16 my $font = $self->option('labelfont') || $self->font;
17
18 my $pad = $font->height;
19
20 if ($self->option('text'))
21 {
22 $pad *= 2;
23 }
24 return $pad;
25 }
26  
27 sub default_text
28 {
29 return '';
30 }
31  
32 sub default_text_pad_x
33 {
34 return 0;
35 }
36  
37 sub default_text_pad_y
38 {
39 return 3;
40 }
41  
42 sub default_size
43 {
44 return 20;
45 }
46  
47 sub draw_component {
48 my $self = shift;
49 my $gd = shift;
50 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
51
52 my $fg = $self->fgcolor;
53 my $bg = $self->bgcolor;
54
55 my $size = defined $self->option('size') ? $self->option('size') : $self->default_size();
56  
57 my $poly_pkg = $self->polygon_package;
58
59 my $polygon = $poly_pkg->new();
60  
61 if ($self->option('inverted') == 1)
62 {
63 $polygon->addPt($x1,$y2);
64 $polygon->addPt($x1+$size/2,$y2-$size/2);
65 $polygon->addPt($x1,$y2-$size);
66 $polygon->addPt($x1+$size, $y2-$size);
67 $polygon->addPt($x1+$size, $y2);
68 }
69 else
70 {
71 $polygon->addPt($x1,$y2);
72 $polygon->addPt($x1,$y2-$size);
73 $polygon->addPt($x1+$size/2,$y2-$size);
74 $polygon->addPt($x1+$size, $y2-$size/2);
75 $polygon->addPt($x1+$size/2, $y2);
76 }
77
78 $gd->filledPolygon($polygon, $bg);
79 $gd->polygon($polygon,$fg);
80  
81 my $text = defined $self->option('text') ? $self->option('text') : $self->default_text();
82  
83 if ($text)
84 {
85 my $text_pad_x = defined $self->option('text_pad_x') ? $self->option('text_pad_x') : $self->default_text_pad_x();
86 my $text_pad_y = defined $self->option('text_pad_y') ? $self->option('text_pad_y') : $self->default_text_pad_y();
87 my $font = $self->option('labelfont') || $self->font;
88 $gd->string($font, $x1+$text_pad_x, $y2-$size-$text_pad_y-$font->height, $text, $fg);
89
90 }
91
92 }
93  
94  
95 1;
96  
97 __END__