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

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 69 CC 7 SCAR 34.4
CC
7
Cov
0%
draw_component
56.0
default_weight_size
2.0
default_length
2.0
CRAP 31.1
1 package Bio::Graphics::Glyph::weighted_arrow;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 use Math::Trig;
7  
8 sub default_weight_size
9 {
10 return 8;
11 }
12  
13 sub default_length
14 {
15 return 20;
16 }
17  
18 sub default_left_alignment
19 {
20 return 1;
21 }
22  
23 sub draw_component {
24 my $self = shift;
25 my $gd = shift;
26 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
27
28 my $fg = $self->fgcolor;
29 my $bg = $self->bgcolor;
30
31 my $weight_size = defined $self->option('weight_size') ? $self->option('weight_size') : $self->default_weight_size();
32  
33 my $length = defined $self->option('length') ? $self->option('length') : $self->default_length();
34 my $left_alignment = defined $self->option('left_alignment') ? $self->option('left_alignment') : $self->default_left_alignment();
35
36 my ($w_x1, $l_x1);
37 if ($left_alignment == 1)
38 {
39 $w_x1 = $x1+1;
40 $l_x1 = $x1;
41 }
42 else
43 {
44 $w_x1 = $x2-1-$weight_size;
45 $l_x1 = $x2;
46
47 }
48
49 my $poly_pkg = $self->polygon_package;
50 my $polygon = $poly_pkg->new();
51 $polygon->addPt($w_x1,$y2);
52 $polygon->addPt($w_x1,$y2-$weight_size);
53 $polygon->addPt($w_x1+$weight_size,$y2-$weight_size);
54 $polygon->addPt($w_x1+$weight_size,$y2);
55 $gd->filledPolygon($polygon,$bg);
56  
57 my $angle = deg2rad(30);
58 my $dx = 6;
59 my $dy = 4;
60 my $midX = $x2-$dx;
61 my $midY = $y1+$dy;
62
63 $gd->line($l_x1, $y2, $l_x1, $y1+$dy, $fg);
64  
65 return unless $left_alignment == 1;
66
67 return if ($x2-$x1 <= $weight_size);
68
69 $x2 = $x1+$weight_size+1+$length;
70 $gd->line($l_x1, $midY, $x2, $midY, $fg);
71 $gd->line($x2, $midY, $x2-$dx, $y1, $fg);
72 $gd->line($x2, $midY, $x2-$dx, $y1+2*$dy, $fg);
73
74 }
75  
76  
77 1;
78  
79 __END__