Skip to content

Commit

Permalink
Deprecate xyplot "histogram" subtype and default to "boxes".
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Jun 9, 2011
1 parent 5c0c59d commit 61746dd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Bio::Graphics. Revision history for Perl extension Bio::Graphics.


2.25
- Deprecate xyplot "histogram" subtype and default to "boxes".

2.24 2.24
- In feature file configuration sections, allow a tag to contain ":". - In feature file configuration sections, allow a tag to contain ":".


Expand Down
1 change: 1 addition & 0 deletions lib/Bio/Graphics/Glyph.pm
Expand Up @@ -1012,6 +1012,7 @@ sub optimized_layout {
$part->move(0,$offset); $part->move(0,$offset);
$overbumped = $offset if $bump_limit > 0 && $offset >= $bump_limit * $rect->[2]; $overbumped = $offset if $bump_limit > 0 && $offset >= $bump_limit * $rect->[2];
} }

return $overbumped && $overbumped < $layout->totalHeight ? $overbumped : $layout->totalHeight; return $overbumped && $overbumped < $layout->totalHeight ? $overbumped : $layout->totalHeight;
} }


Expand Down
79 changes: 40 additions & 39 deletions lib/Bio/Graphics/Glyph/xyplot.pm
Expand Up @@ -41,10 +41,11 @@ sub my_options {
'range to be clipped.' 'range to be clipped.'
], ],
graph_type => [ graph_type => [
['histogram','boxes','line','points','linepoints'], ['boxes','line','points','linepoints'],
'histogram', 'boxes',
'Type of graph to generate. Options are "histogram", "boxes",', 'Type of graph to generate. Options are "boxes",',
'"line","points", or "linepoints".' '"line","points", or "linepoints".',
'The deprecated "histogram" subtype is equivalent to "boxes".'
], ],
point_symbol => [ point_symbol => [
'string', 'string',
Expand Down Expand Up @@ -216,7 +217,7 @@ sub lookup_draw_method {
my $self = shift; my $self = shift;
my $type = shift; my $type = shift;


return '_draw_histogram' if $type eq 'histogram'; return '_draw_boxes' if $type eq 'histogram'; # same thing
return '_draw_boxes' if $type eq 'boxes'; return '_draw_boxes' if $type eq 'boxes';
return qw(_draw_line _draw_points) if $type eq 'linepoints'; return qw(_draw_line _draw_points) if $type eq 'linepoints';
return '_draw_line' if $type eq 'line'; return '_draw_line' if $type eq 'line';
Expand Down Expand Up @@ -279,40 +280,40 @@ sub min10 {
return $l*int($a/$l); return $l*int($a/$l);
} }


sub _draw_histogram { # sub _draw_histogram {
my $self = shift; # my $self = shift;
my ($gd,$left,$top,$bottom) = @_; # my ($gd,$left,$top,$bottom) = @_;


my @parts = $self->parts; # my @parts = $self->parts;
my $fgcolor = $self->fgcolor; # my $fgcolor = $self->fgcolor;


# draw each of the component lines of the histogram surface # # draw each of the component lines of the histogram surface
for (my $i = 0; $i < @parts; $i++) { # for (my $i = 0; $i < @parts; $i++) {
my $part = $parts[$i]; # my $part = $parts[$i];
my $next = $parts[$i+1]; # my $next = $parts[$i+1];
my ($x1,$y1,$x2,$y2) = $part->calculate_boundaries($left,$top); # my ($x1,$y1,$x2,$y2) = $part->calculate_boundaries($left,$top);
next unless defined $part->{_y_position}; # next unless defined $part->{_y_position};
$gd->line($x1,$part->{_y_position},$x2,$part->{_y_position},$fgcolor); # $gd->line($x1,$part->{_y_position},$x2,$part->{_y_position},$fgcolor);
next unless $next; # next unless $next;
my ($x3,$y3,$x4,$y4) = $next->calculate_boundaries($left,$top); # my ($x3,$y3,$x4,$y4) = $next->calculate_boundaries($left,$top);
if ($x2 == $x3) {# connect vertically to next level # if ($x2 == $x3) {# connect vertically to next level
$gd->line($x2,$part->{_y_position},$x2,$next->{_y_position},$fgcolor); # $gd->line($x2,$part->{_y_position},$x2,$next->{_y_position},$fgcolor);
} else { # } else {
$gd->line($x2,$part->{_y_position},$x2,$bottom,$fgcolor); # to bottom # $gd->line($x2,$part->{_y_position},$x2,$bottom,$fgcolor); # to bottom
$gd->line($x2,$bottom,$x3,$bottom,$fgcolor); # to right # $gd->line($x2,$bottom,$x3,$bottom,$fgcolor); # to right
$gd->line($x3,$bottom,$x3,$next->{_y_position},$fgcolor); # up # $gd->line($x3,$bottom,$x3,$next->{_y_position},$fgcolor); # up
} # }
} # }


# end points: from bottom to first # # end points: from bottom to first
my ($x1,$y1,$x2,$y2) = $parts[0]->calculate_boundaries($left,$top); # my ($x1,$y1,$x2,$y2) = $parts[0]->calculate_boundaries($left,$top);
$gd->line($x1,$bottom,$x1,$parts[0]->{_y_position},$fgcolor); # $gd->line($x1,$bottom,$x1,$parts[0]->{_y_position},$fgcolor);
# from last to bottom # # from last to bottom
my ($x3,$y3,$x4,$y4) = $parts[-1]->calculate_boundaries($left,$top); # my ($x3,$y3,$x4,$y4) = $parts[-1]->calculate_boundaries($left,$top);
$gd->line($x4,$parts[-1]->{_y_position},$x4,$bottom,$fgcolor); # $gd->line($x4,$parts[-1]->{_y_position},$x4,$bottom,$fgcolor);


# That's it. Not too hard. # # That's it. Not too hard.
} # }


sub _draw_boxes { sub _draw_boxes {
my $self = shift; my $self = shift;
Expand Down

0 comments on commit 61746dd

Please sign in to comment.