| 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__ |