Bio::Graphics::Glyph::two_bolts - The "two bolts" glyph


Bio-Graphics documentation Contained in the Bio-Graphics distribution.

Index


Code Index:

NAME

Top

Bio::Graphics::Glyph::two_bolts - The "two bolts" glyph

SYNOPSIS

Top

  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.

DESCRIPTION

Top

This glyph draws two "bolts" on a line. They look like this;

--------/\/\/\-- --/\/\/\--------

OPTIONS

In addition to the common options, the following glyph-specific options are recognized:

  Option      Description                  Default
  ------      -----------                  -------

  -bolt_height  Height of the bolt          10

  -bolt_length  Length of the bolt          20

  -bolt_color   Color of the bolt           red

  -remainder_length
                Length of the short line    10

BUGS

Top

Please report them.

SEE ALSO

Top

Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::triangle, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD

AUTHOR

Top

Vsevolod (Simon) Ilyushchenko <simonf@cshl.edu>.

Copyright (c) 2004 Cold Spring Harbor Laboratory

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.


Bio-Graphics documentation Contained in the Bio-Graphics distribution.

package Bio::Graphics::Glyph::two_bolts;

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

sub default_bolt_height
{
  return 10;  
}

sub default_bolt_length
{
  return 20;  
}

sub default_remainder_length
{
  return 10;  
}

sub default_bolt_color
{
  return 'red';  
}

sub draw_component {
  my $self = shift;
  my $gd = shift;
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);

  my $fg = $self->fgcolor;
  
  my $midY1 = $y1+($y2-$y1) / 3;
  my $midY2 = $y1 + 2*($y2-$y1) / 3;
    
  my $bolt_color = defined $self->option('bolt_color') ? $self->option('bolt_color')  : $self->default_bolt_color();
  $bolt_color = $self->factory->translate_color($bolt_color);

  my $bolt_height = defined $self->option('bolt_height') ? $self->option('bolt_height')  : $self->default_bolt_height();  
  my $bolt_length = defined $self->option('bolt_length') ? $self->option('bolt_length')  : $self->default_bolt_length();  
  my $remainder_length = defined $self->option('remainder_length') ? $self->option('remaindert_length')  : $self->default_remainder_length();  

  if ($x2-$x1 < $bolt_length+$remainder_length)
  {
    $gd->line($x1, $y1, $x2, $y2, $bolt_color);
    return;
  }
  
  my $bolt_start = $x2-$bolt_length-$remainder_length;
  my $step = $bolt_length / 8;
  my $shift = $bolt_height/2;
  $gd->line($x1, $midY1, $bolt_start, $midY1, $fg);
  $self->draw_bolt($gd, $bolt_start, $step, $midY1, $shift, $bolt_color);
  $gd->line($x2-$remainder_length, $midY1, $x2, $midY1, $fg);

  $bolt_start = $x1+$remainder_length;
  $gd->line($x1, $midY2, $bolt_start, $midY2, $fg);
  $self->draw_bolt($gd, $bolt_start, $step, $midY2, $shift, $bolt_color);
  $gd->line($x1+$bolt_length+$remainder_length, $midY2, $x2, $midY2, $fg);
  
  
}

sub draw_bolt
{
  my ($self, $gd, $bolt_start, $step, $y, $shift, $bolt_color) = @_;
  $gd->line($bolt_start, $y, $bolt_start+$step, $y-$shift, $bolt_color);
  $gd->line($bolt_start+$step, $y-$shift, $bolt_start+3*$step, $y+$shift, $bolt_color);
  $gd->line($bolt_start+3*$step, $y+$shift, $bolt_start+5*$step, $y-$shift, $bolt_color);
  $gd->line($bolt_start+5*$step, $y-$shift, $bolt_start+7*$step, $y+$shift, $bolt_color);
  $gd->line($bolt_start+7*$step, $y+$shift, $bolt_start+8*$step, $y, $bolt_color);
  
}

1;

__END__