Skip to content

Commit

Permalink
refactor special-case code for width 0 feature into base glyph
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Mar 23, 2012
1 parent 19b0145 commit e61a3ad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -59,6 +59,7 @@ lib/Bio/Graphics/Glyph/pairplot.pm
lib/Bio/Graphics/Glyph/pentagram.pm
lib/Bio/Graphics/Glyph/phylo_align.pm
lib/Bio/Graphics/Glyph/pinsertion.pm
lib/Bio/Graphics/Glyph/point_glyph.pm
lib/Bio/Graphics/Glyph/primers.pm
lib/Bio/Graphics/Glyph/processed_transcript.pm
lib/Bio/Graphics/Glyph/protein.pm
Expand Down
12 changes: 1 addition & 11 deletions lib/Bio/Graphics/Glyph/diamond.pm
Expand Up @@ -2,7 +2,7 @@ package Bio::Graphics::Glyph::diamond;
# DAS-compatible package to use for drawing a colored diamond

use strict;
use base qw(Bio::Graphics::Glyph::generic);
use base qw(Bio::Graphics::Glyph::point_glyph);

sub my_description {
return <<END;
Expand Down Expand Up @@ -70,16 +70,6 @@ sub draw_component {
}
}

sub box {
my $self = shift;
my @result = $self->SUPER::box();
return @result unless $self->option('point');
my $h = $self->option('height')/2;
my $mid = int(($result[2]+$result[0])/2);
$result[0] = $mid-$h-1; # fudge a little to make it easier to click on
$result[2] = $mid+$h+1;
return @result;
}

1;

Expand Down
17 changes: 17 additions & 0 deletions lib/Bio/Graphics/Glyph/point_glyph.pm
@@ -0,0 +1,17 @@
package Bio::Graphics::Glyph::point_glyph;

use strict;
use base qw(Bio::Graphics::Glyph::generic);

sub box {
my $self = shift;
my @result = $self->SUPER::box();
return @result unless $self->option('point') && $result[2]-$result[0] < 3;
my $h = $self->option('height')/2;
my $mid = int(($result[2]+$result[0])/2);
$result[0] = $mid-$h-1; # fudge a little to make it easier to click on
$result[2] = $mid+$h+1;
return @result;
}

1;
2 changes: 1 addition & 1 deletion lib/Bio/Graphics/Glyph/triangle.pm
Expand Up @@ -2,7 +2,7 @@ package Bio::Graphics::Glyph::triangle;
# DAS-compatible package to use for drawing a triangle

use strict;
use base qw(Bio::Graphics::Glyph::generic);
use base qw(Bio::Graphics::Glyph::point_glyph);

sub pad_left {
my $self = shift;
Expand Down

0 comments on commit e61a3ad

Please sign in to comment.