1
package Bio::Graphics::Glyph::text_in_box;
4
use base qw(Bio::Graphics::Glyph::generic);
19
my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
21
my $fg = $self->fgcolor;
23
my $font = $self->option('labelfont') || $self->font;
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();
28
my $width = $font->width * length $text;
29
my $height = $font->height;
31
my $midY = ($y2+$y1) / 2;
33
my $poly_pkg = $self->polygon_package;
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);
41
if (defined (my $bgcolor = $self->option('text_bgcolor')))
43
$gd->filledPolygon($polygon,$self->factory->translate_color($bgcolor));
46
$gd->polygon($polygon,$fg);
48
$gd->string($font, $x1+$text_pad, $midY-$height/2, $text, $self->fontcolor);
58
Bio::Graphics::Glyph::text_in_box - The "text in box" glyph
62
See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
66
This glyph draws the specified text in a rectangular box.
70
In addition to the common options, the following glyph-specific
71
options are recognized:
73
Option Description Default
74
------ ----------- -------
76
-text The text to draw in the box 3'
78
-text_pad The number of pixels to offset 3
82
The background color of the box
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>,
122
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
124
Copyright (c) 2004 Cold Spring Harbor Laboratory
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.