Bio::Graphics::Glyph::fixedwidth(3) A base class fixed width glyphs

SYNOPSIS


use Bio::Graphics;
use Bio::Seq;
use Bio::SeqFeature::Generic;
my $bsg = 'Bio::SeqFeature::Generic';
my $seq = Bio::Seq->new(-length=>1000);
my $whole = $bsg->new(-display_name => 'Clone82',
-start => 1,
-end => $seq->length);
my $f1 = $bsg->new(-start => 100,
-end => 300,
-display_name => 'feature 1',
);
my $f2 = $bsg->new(-start => 500,
-end => 800,
-display_name => 'feature 2',
);
my $panel = Bio::Graphics::Panel->new(-length => $seq->length,
-width => 800,
-key_style => 'between',
-pad_left => 10,
-pad_right => 10,
);
$panel->add_track($whole,
-glyph => 'arrow',
-double => 1,
-tick => 2,
-label => 1,
);
$panel->add_track([$f1,$f2],
-glyph => 'fixedwidth',
-label => 1,
-fixed_height => 20,
-fixed_width => 20,
-key => 'fixed width');
binmode STDOUT;
print $panel->png;

DESCRIPTION

This glyph is a base class for glyphs that wish to draw a fixed width content, such as an icon, image, scatterplot, and it would be inappropriate for the content to be stretched to match the start and end point of the associated feature. Instead the glyph draws a simple box spanning the feature's start:end region, two diagonal connecting lines, and then a fixed width rectangle beneath the box.

This glyph does nothing very interesting itself. It is intended that subclasses should override the draw_contents() method to draw something interesting. See ``Subclassing'' for a simple example.

OPTIONS

The following options are standard among all Glyphs. See Bio::Graphics::Glyph for a full explanation.

  Option      Description                      Default
  ------      -----------                      -------
  -fgcolor      Foreground color               black
  -outlinecolor Synonym for -fgcolor
  -bgcolor      Background color               turquoise
  -fillcolor    Synonym for -bgcolor
  -linewidth    Line width                     1
  -height       Height of glyph                10
  -font         Glyph font                     gdSmallFont
  -connector    Connector type                 0 (false)
  -connector_color
                Connector color                black
  -label        Whether to draw a label        0 (false)
  -description  Whether to draw a description  0 (false)
  -hilite       Highlight color                undef (no color)

The following additional options are available to the ``fixedwidth'' glyph:

  Option            Description                       Default
  ------            -----------                       -------
  -fixed_width      Width of the content                 0
  -fixed_height     Height of the content                Same as -height
  -fixed_gap        Vertical gap between the box         8
                    that shows the extent of the
                    feature and the fixed-width
                    content.
                    If -fixed_gap is less than 8
                    then the diagonal connecting
                    lines are not drawn.

EXAMPLE SUBCLASS

To draw something interesting in the fixed rectangle, override the draw_contents method. It takes four arguments consisting of the GD object, and the left, top, right and bottom coordinates of the fixed rectangle. Example:

 package Bio::Graphics::Glyph::fixedexample;
 use strict;
 use base 'Bio::Graphics::Glyph::fixedwidth';
 sub draw_contents {
   my $self = shift;
   my ($gd,$left,$top,$right,$bottom) = @_;
   $self->unfilled_box($gd,$left,$top,$right,$bottom);
   $gd->line($left,$top,$right,$bottom,$self->fgcolor);
   $gd->line($left,$bottom,$right,$top,$self->fgcolor);
 }
 1;

This will draw the outline of the fixed rectangle. The rectangle will contain two diagonal lines. Not very interesting, but an example, nonetheless.

See the stackedplot glyph for a more interesting subclass.

BUGS AND LIMITATIONS

This glyph should used as the base for the image glyph, but isn't. This will be fixed.

AUTHOR

Lincoln Stein <[email protected]>

Copyright (c) 2007 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.