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

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 14 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 93 CC 11 SCAR 44.6
CC
11
Cov
0%
draw
132.0
my_description
2.0
draw_connector
2.0
CRAP 86.1
1 package Bio::Graphics::Glyph::line;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 sub my_description {
7 return <<END;
8 This glyph draws a horizontal line spanning the feature.
9 END
10 }
11  
12 sub draw {
13 my $self = shift;
14 $self->SUPER::draw(@_);
15  
16 my $gd = shift;
17  
18 my $fg = $self->fgcolor;
19 my $linewidth = $self->linewidth;
20 $fg = $self->set_pen($linewidth) if $linewidth > 1;
21  
22 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
23 my $center = ($y1+$y2)/2;
24  
25 my ($lowest,$highest);
26  
27 my @parts = $self->parts;
28 my $previous = -1;
29 for (my $i = 0;$i<@parts;$i++) {
30 my $part = $parts[$i];
31 my ($l,undef,$xx1,$yy1) = $part->calculate_boundaries(@_);
32  
33 $lowest = $l if !defined $lowest || $lowest > $l;
34 $highest = $xx1 if !defined $xx1 || $highest < $xx1;
35  
36 my $next_part = $parts[$i+1] or last;
37 my ($xx2,$yy2,undef,undef) = $next_part->calculate_boundaries(@_);
38  
39 $self->draw_connector($gd,$xx1,$xx2,$y1,$y2) if $xx1 < $xx2;
40 }
41  
42 if ($lowest && $x1 < $lowest) {
43 $self->draw_connector($gd,$x1,$lowest,$y1,$y2);
44 }
45  
46 if ($highest && $x2 > $highest) {
47 $self->draw_connector($gd,$highest,$x2,$y1,$y2);
48 }
49  
50 my $height = $self->height;
51 $height = 12 unless $height > 12;
52  
53 return unless $self->parts;
54 if ($self->feature->strand > 0) {
55 $self->arrow($gd,$x2,$x2+$height/2,$center);
56 } elsif ($self->feature->strand < 0) {
57 $self->arrow($gd,$x1,$x1-$height/2,$center);
58 }
59 }
60  
61 sub draw_connector {
62 my $self = shift;
63 my $gd = shift;
64 my ($left,$right,$high,$low) = @_;
65 my $fg = $self->fgcolor;
66 my $center = ($high+$low)/2;
67 $gd->line($left,$center,$right,$center,$fg);
68 }
69  
70 sub bump { 0 }
71  
72 sub maxdepth { return }
73  
74  
75 1;
76  
77 __END__