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

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 36 CC 4 SCAR 25.1
CC
4
Cov
0%
draw_component
20.0
my_description
2.0
BEGIN
2.0
CRAP 12.3
1 package Bio::Graphics::Glyph::ex;
2  
3 # Non object-oriented utilities used here-and-there in Bio::Graphics modules
4  
5 =head1 NAME
6  
7 Bio::Graphics::Glyph::ex - the "ex", or "crossed box" glyph
8  
9 =cut
10  
11 use strict;
12 use base 'Bio::Graphics::Glyph::generic';
13  
14 sub my_description {
15 return <<END;
16 This is a box with an 'X' inside glyph.
17 END
18 }
19  
20 # override draw_component to draw a crossed box rather than empty
21 sub draw_component {
22 my $self = shift;
23 my $gd = shift;
24 my $fg = $self->fgcolor;
25 my ($left,$top) = @_;
26 my($x1,$y1,$x2,$y2) = $self->bounds(@_);
27  
28 #if widthless
29 if($self->option('point')){
30 my $arm = int($self->height/2);
31 my $minx = $x2 > $x1 ? $x1 : $x2;
32 my $centerx = abs($x2 - $x1) + $minx;
33 my $miny = $y2 > $y1 ? $y1 : $y2;
34 my $centery = abs($y2 - $y1) + $miny;
35 $gd->line($centerx-$arm, $centery-$arm, $centerx+$arm, $centery+$arm, $fg);
36 $gd->line($centerx-$arm, $centery+$arm, $centerx+$arm, $centery-$arm, $fg);
37 return;
38 } else {
39 $gd->line($x1,$y1,$x2,$y2,$fg);
40 $gd->line($x1,$y2,$x2,$y1,$fg);
41 }
42 }
43  
44  
45 1;
46  
47 __END__