Bio-Graphics

 view release on metacpan or  search on metacpan

lib/Bio/Graphics/Glyph/Factory.pm  view on Meta::CPAN

=head2 map_pt

  Title    : map_pt
  Usage    : @pixel_positions = $f->map_pt(@bp_positions)
  Function : map bp positions to pixel positions
  Returns  : a list of pixel positions
  Args     : a list of bp positions
  Status   : Internal to Bio::Graphics

The real work is done by the panel, but factory subclasses can
override if desired.

=cut

sub map_pt {
  my $self = shift;
  my @result = $self->panel->map_pt(@_);
  return wantarray ? @result : $result[0];
}

=head2 map_no_trunc

  Title    : map_no_trunc
  Usage    : @pixel_positions = $f->map_no_trunc(@bp_positions)
  Function : map bp positions to pixel positions
  Returns  : a list of pixel positions
  Args     : a list of bp positions
  Status   : Internal to Bio::Graphics

Same as map_pt(), but it will NOT clip pixel positions to be within
the drawing frame.

=cut

sub map_no_trunc {
  my $self = shift;
  my @result = $self->panel->map_no_trunc(@_);
  return wantarray ? @result : $result[0];
}

=head2 translate_color

  Title    : translate_color
  Usage    : $index = $f->translate_color($color_name)
  Function : translate symbolic color names into GD indexes
  Returns  : an integer
  Args     : a color name in format "green" or "#00FF00"
  Status   : Internal to Bio::Graphics

The real work is done by the panel, but factory subclasses can
override if desired.

=cut

sub translate_color {
  my $self = shift;
  my $color_name = shift;
  $self->panel->translate_color($color_name);
}

=head2 transparent_color

  Title    : transparent_color
  Usage    : $index = $f->transparent_color($opacity,$color_name)
  Function : translate symbolic color names into GD indexes, with
                an opacity value taken into account
  Returns  : an integer
  Args     : an opacity value from 0-1.0, plus a color name in format "green" or "#00FF00"
  Status   : Internal to Bio::Graphics

The real work is done by the panel, but factory subclasses can
override if desired.

=cut

sub transparent_color {
  my $self = shift;
  $self->panel->transparent_color(@_);
}

=head2 make_glyph

  Title    : make_glyph
  Usage    : @glyphs = $f->glyph($level,[$type,]$feature1,$feature2...)
  Function : transform features into glyphs.
  Returns  : a list of Bio::Graphics::Glyph objects
  Args     : a feature "level", followed by a list of FeatureI objects.
  Status   : Internal to Bio::Graphics

The level is used to track the level of nesting of features that have
subfeatures. The option $type argument can be used to force the glyph type

=cut

# create a glyph
sub make_glyph {
  my $self  = shift;
  my $level = shift;
  my $forced_type  = shift unless ref($_[0]);

  my @result;
  my $panel = $self->panel;
  my $flip  = $panel->flip;

  for my $f (@_) {
    my $type = $forced_type || $self->feature_to_glyph($f);

    my $glyphclass = 'Bio::Graphics::Glyph';
    $type ||= 'generic';
    $glyphclass .= "\:\:\L$type";

    unless ($LOADED_GLYPHS{$glyphclass}++) {
      $self->throw("The requested glyph class, ``$type'' is not available: $@")
        unless (eval "require $glyphclass");
    }

    my $glyph = $glyphclass->new(-feature  => $f,
				 -factory  => $self,
				 -flip     => $flip,
				 -level    => $level);

    push @result,$glyph;

  }
  return wantarray ? @result : $result[0];
}


=head2 feature_to_glyph

  Title    : feature_to_glyph
  Usage    : $glyph_name = $f->feature_to_glyph($feature)
  Function : choose the glyph name given a feature
  Returns  : a glyph name
  Args     : a Bio::Seq::FeatureI object
  Status   : Internal to Bio::Graphics

=cut



( run in 0.623 second using v1.01-cache-2.11-cpan-39bf76dae61 )