~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/Graphics/Glyph/text_in_box.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Bio::Graphics::Glyph::text_in_box;
 
2
 
 
3
use strict;
 
4
use base qw(Bio::Graphics::Glyph::generic);
 
5
 
 
6
sub default_text
 
7
{
 
8
  return "3'";  
 
9
}
 
10
 
 
11
sub default_text_pad
 
12
{
 
13
  return 3;  
 
14
}
 
15
 
 
16
sub draw_component {
 
17
  my $self = shift;
 
18
  my $gd = shift;
 
19
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
 
20
  
 
21
  my $fg = $self->fgcolor;
 
22
  
 
23
  my $font = $self->option('labelfont') || $self->font;
 
24
  
 
25
  my $text = defined $self->option('text') ? $self->option('text') : $self->default_text();
 
26
  my $text_pad = defined $self->option('text_pad') ? $self->option('text_pad') : $self->default_text_pad();
 
27
  
 
28
  my $width = $font->width * length $text;
 
29
  my $height = $font->height;
 
30
 
 
31
  my $midY = ($y2+$y1) / 2;
 
32
 
 
33
  my $poly_pkg = $self->polygon_package;
 
34
  
 
35
  my $polygon   = $poly_pkg->new();
 
36
  $polygon->addPt($x1,$midY-$height/2-$text_pad);
 
37
  $polygon->addPt($x1+$width+2*$text_pad,$midY-$height/2-$text_pad);
 
38
  $polygon->addPt($x1+$width+2*$text_pad,$midY+$height/2+$text_pad);
 
39
  $polygon->addPt($x1, $midY+$height/2+$text_pad);
 
40
 
 
41
  if (defined (my $bgcolor = $self->option('text_bgcolor')))
 
42
  {
 
43
    $gd->filledPolygon($polygon,$self->factory->translate_color($bgcolor));
 
44
  }
 
45
 
 
46
  $gd->polygon($polygon,$fg);
 
47
      
 
48
  $gd->string($font, $x1+$text_pad, $midY-$height/2, $text, $self->fontcolor);
 
49
}
 
50
 
 
51
 
 
52
1;
 
53
 
 
54
__END__
 
55
 
 
56
=head1 NAME
 
57
 
 
58
Bio::Graphics::Glyph::text_in_box - The "text in box" glyph
 
59
 
 
60
=head1 SYNOPSIS
 
61
 
 
62
  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
 
63
 
 
64
=head1 DESCRIPTION
 
65
 
 
66
This glyph draws the specified text in a rectangular box.
 
67
 
 
68
=head2 OPTIONS
 
69
 
 
70
In addition to the common options, the following glyph-specific
 
71
options are recognized:
 
72
 
 
73
  Option      Description                  Default
 
74
  ------      -----------                  -------
 
75
 
 
76
  -text       The text to draw in the box    3'
 
77
 
 
78
  -text_pad   The number of pixels to offset 3
 
79
              the box
 
80
 
 
81
  -text_bgcolor                             none
 
82
              The background color of the box
 
83
 
 
84
=head1 BUGS
 
85
 
 
86
Please report them.
 
87
 
 
88
=head1 SEE ALSO
 
89
 
 
90
L<Bio::Graphics::Panel>,
 
91
L<Bio::Graphics::Glyph>,
 
92
L<Bio::Graphics::Glyph::arrow>,
 
93
L<Bio::Graphics::Glyph::cds>,
 
94
L<Bio::Graphics::Glyph::crossbox>,
 
95
L<Bio::Graphics::Glyph::diamond>,
 
96
L<Bio::Graphics::Glyph::dna>,
 
97
L<Bio::Graphics::Glyph::dot>,
 
98
L<Bio::Graphics::Glyph::ellipse>,
 
99
L<Bio::Graphics::Glyph::extending_arrow>,
 
100
L<Bio::Graphics::Glyph::generic>,
 
101
L<Bio::Graphics::Glyph::graded_segments>,
 
102
L<Bio::Graphics::Glyph::heterogeneous_segments>,
 
103
L<Bio::Graphics::Glyph::line>,
 
104
L<Bio::Graphics::Glyph::pinsertion>,
 
105
L<Bio::Graphics::Glyph::primers>,
 
106
L<Bio::Graphics::Glyph::rndrect>,
 
107
L<Bio::Graphics::Glyph::segments>,
 
108
L<Bio::Graphics::Glyph::ruler_arrow>,
 
109
L<Bio::Graphics::Glyph::toomany>,
 
110
L<Bio::Graphics::Glyph::transcript>,
 
111
L<Bio::Graphics::Glyph::transcript2>,
 
112
L<Bio::Graphics::Glyph::translation>,
 
113
L<Bio::Graphics::Glyph::triangle>,
 
114
L<Bio::DB::GFF>,
 
115
L<Bio::SeqI>,
 
116
L<Bio::SeqFeatureI>,
 
117
L<Bio::Das>,
 
118
L<GD>
 
119
 
 
120
=head1 AUTHOR
 
121
 
 
122
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
 
123
 
 
124
Copyright (c) 2004 Cold Spring Harbor Laboratory
 
125
 
 
126
This library is free software; you can redistribute it and/or modify
 
127
it under the same terms as Perl itself.  See DISCLAIMER.txt for
 
128
disclaimers of warranty.
 
129
 
 
130
=cut