Bio::Graphics::Glyph
Factory
Package variables
Privates (from "my" definitions)
%LOADED_GLYPHS = ()
%GENERIC_OPTIONS = ( bgcolor => 'turquoise', fgcolor => 'black', fontcolor => 'black', font2color => 'turquoise', height => 8, font => gdSmallFont, bump => +1, )
Included modules
Carp qw ( :DEFAULT cluck )
GD
Synopsis
No synopsis!
Description
No description!
Methods
| new | No description | Code |
| clone | No description | Code |
| stylesheet | No description | Code |
| glyph_map | No description | Code |
| option_map | No description | Code |
| global_opts | No description | Code |
| panel | No description | Code |
| scale | No description | Code |
| font | No description | Code |
| map_pt | No description | Code |
| translate_color | No description | Code |
| make_glyph | No description | Code |
| feature_to_glyph | No description | Code |
| set_option | No description | Code |
| option | No description | Code |
| options | No description | Code |
Methods description
None available.
Methods code
sub new
{ my $class = shift;
my $panel = shift;
my %args = @_;
my $stylesheet = $args{-stylesheet}; my $map = $args{-map}; my $options = $args{-options}; return bless {
stylesheet => $stylesheet,
glyph_map => $map,
options => $options,
panel => $panel,
},$class;} |
sub clone
{ my $self = shift;
my %new = %$self;
my $new = bless\% new,ref($self);
$new; } |
sub stylesheet
{ shift->{stylesheet}} |
sub glyph_map
{ shift->{glyph_map}} |
sub option_map
{ shift->{options}} |
sub global_opts
{shift->{global_opts}} |
sub panel
{ shift->{panel}} |
sub scale
{ shift->{panel}->scale} |
sub font
{ my $self = shift;
my $glyph = shift;
$self->option($glyph,'font') || $self->{font};} |
sub map_pt
{ my $self = shift;
my @result = $self->panel->map_pt(@_);
return wantarray ? @result : $result[0]; } |
sub translate_color
{ my $self = shift;
my $color_name = shift;
$self->panel->translate_color($color_name); } |
sub make_glyph
{ my $self = shift;
my @result;
my $panel = $self->panel;
my ($leftmost,$rightmost) = ($panel->left,$panel->right);
for my $f (@_) {
my $type = $self->feature_to_glyph($f);
my $glyphclass = 'Bio::Graphics::Glyph';
$type ||= 'generic';
$glyphclass .= "\:\:\L$type";
unless ($LOADED_GLYPHS{$glyphclass}++) {
carp("the requested glyph class, ``$type'' is not available: $@")
unless (eval "require $glyphclass");
}
my $glyph = $glyphclass->new(-feature => $f,
-factory => $self);
push @result,$glyph if $type eq 'track'
|| ($glyph->{left} + $glyph->{width} > $leftmost && $glyph->{left} < $rightmost);
}
return wantarray ? @result : $result[0];} |
sub feature_to_glyph
{ my $self = shift;
my $feature = shift;
return scalar $self->{stylesheet}->glyph($feature) if $self->{stylesheet};
my $map = $self->glyph_map or return 'generic';
return $map->($feature) || 'generic' if ref($map) eq 'CODE';
return $map->{$feature->primary_tag} || 'generic';} |
sub set_option
{ my $self = shift;
my ($option_name,$option_value) = @_;
$self->{overriding_options}{lc $option_name} = $option_value;} |
sub option
{ my $self = shift;
my ($glyph,$option_name,$partno,$total_parts) = @_;
return unless defined $option_name;
$option_name = lc $option_name;
return $self->{overriding_options}{$option_name}
if exists $self->{overriding_options} && exists $self->{overriding_options}{$option_name};
if (my $map = $self->option_map) {
if (defined(my $value = $map->{$option_name})) {
my $feature = $glyph->feature;
return $value unless ref $value eq 'CODE';
return unless $feature->isa('Bio::SeqFeatureI');
my $val = $value->($feature,$option_name,$partno,$total_parts);
return defined $val && $val eq '*default*' ? $GENERIC_OPTIONS{$option_name} : $val;
}
}
if (my $ss = $self->stylesheet) {
my($glyph,%options) = $ss->glyph($glyph->feature);
my $value = $options{$option_name};
return $value if defined $value;
}
return $GENERIC_OPTIONS{$option_name}; } |
sub options
{ my $self = shift;
my %options;
if (my $map = $self->option_map) {
$options{lc($_)}++ foreach keys %$map;
}
$options{lc($_)}++ foreach keys %GENERIC_OPTIONS;
return keys %options;} |
General documentation
No general documentation available.