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

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 47 CC 4 SCAR 24.0
CC
4
Cov
0%
draw_component
20.0
default_text
2.0
default_text_pad
2.0
CRAP 11.0
1 package Bio::Graphics::Glyph::text_in_box;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 sub default_text
7 {
8 return "3'";
9 }
10  
11 sub default_text_pad
12 {
13 return 3;
14 }
15  
16 sub draw_component {
17 my $self = shift;
18 my $gd = shift;
19 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
20
21 my $fg = $self->fgcolor;
22
23 my $font = $self->option('labelfont') || $self->font;
24
25 my $text = defined $self->option('text') ? $self->option('text') : $self->default_text();
26 my $text_pad = defined $self->option('text_pad') ? $self->option('text_pad') : $self->default_text_pad();
27
28 my $width = $self->string_width($text);
29 my $height = $self->font_height;
30  
31 my $midY = ($y2+$y1) / 2;
32  
33 my $poly_pkg = $self->polygon_package;
34
35 my $polygon = $poly_pkg->new();
36 $polygon->addPt($x1,$midY-$height/2-$text_pad);
37 $polygon->addPt($x1+$width+2*$text_pad,$midY-$height/2-$text_pad);
38 $polygon->addPt($x1+$width+2*$text_pad,$midY+$height/2+$text_pad);
39 $polygon->addPt($x1, $midY+$height/2+$text_pad);
40  
41 if (defined (my $bgcolor = $self->option('text_bgcolor')))
42 {
43 $gd->filledPolygon($polygon,$self->factory->translate_color($bgcolor));
44 }
45  
46 $gd->polygon($polygon,$fg);
47
48 $gd->string($font, $x1+$text_pad, $midY-$height/2, $text, $self->fontcolor);
49 }
50  
51  
52 1;
53  
54 __END__