1Ace::Graphics::Glyph(3)User Contributed Perl DocumentatioAnce::Graphics::Glyph(3)
2
3
4

NAME

6       Ace::Graphics::Glyph - Base class for Ace::Graphics::Glyph objects
7

SYNOPSIS

9       See Ace::Graphics::Panel.
10

DESCRIPTION

12       Ace::Graphics::Glyph is the base class for all glyph objects.  Each
13       glyph is a wrapper around an Ace::Sequence::Feature object, knows how
14       to render itself on an Ace::Graphics::Panel, and has a variety of
15       configuration variables.
16
17       End developers will not ordinarily work directly with
18       Ace::Graphics::Glyph, but may want to subclass it for customized
19       displays.
20

METHODS

22       This section describes the class and object methods for
23       Ace::Graphics::Glyph.
24
25   CONSTRUCTORS
26       Ace::Graphics::Glyph objects are constructed automatically by an
27       Ace::Graphics::GlyphFactory, and are not usually created by end-
28       developer code.
29
30       $glyph =
31       Ace::Graphics::Glyph->new(-feature=>$feature,-factory=>$factory)
32           Given a sequence feature, creates an Ace::Graphics::Glyph object to
33           display it.  The -feature argument points to the
34           Ace::Sequence::Feature object to display.  -factory indicates an
35           Ace::Graphics::GlyphFactory object from which the glyph will fetch
36           all its run-time configuration information.
37
38           A standard set of options are recognized.  See OPTIONS.
39
40   OBJECT METHODS
41       Once a glyph is created, it responds to a large number of methods.  In
42       this section, these methods are grouped into related categories.
43
44       Retrieving glyph context:
45
46       $factory = $glyph->factory
47           Get the Ace::Graphics::GlyphFactory associated with this object.
48           This cannot be changed once it is set.
49
50       $feature = $glyph->feature
51           Get the sequence feature associated with this object.  This cannot
52           be changed once it is set.
53
54       Retrieving glyph options:
55
56       $fgcolor = $glyph->fgcolor
57       $bgcolor = $glyph->bgcolor
58       $fontcolor = $glyph->fontcolor
59       $fillcolor = $glyph->fillcolor
60           These methods return the configured foreground, background, font
61           and fill colors for the glyph in the form of a GD::Image color
62           index.
63
64       $width = $glyph->width
65           Return the maximum width allowed for the glyph.  Most glyphs will
66           be smaller than this.
67
68       $font = $glyph->font
69           Return the font for the glyph.
70
71       $option = $glyph->option($option)
72           Return the value of the indicated option.
73
74       $index = $glyph->color($color)
75           Given a symbolic or #RRGGBB-form color name, returns its GD index.
76
77       Retrieving information about the sequence:
78
79       $start = $glyph->start
80       $end   = $glyph->end
81           These methods return the start and end of the glyph in base pair
82           units.
83
84       $offset = $glyph->offset
85           Returns the offset of the segment (the base pair at the far left of
86           the image).
87
88       $length = $glyph->length
89           Returns the length of the sequence segment.
90
91       Retrieving formatting information:
92
93       $top = $glyph->top
94       $left = $glyph->left
95       $bottom = $glyph->bottom
96       $right = $glyph->right
97           These methods return the top, left, bottom and right of the glyph
98           in pixel coordinates.
99
100       $height = $glyph->height
101           Returns the height of the glyph.  This may be somewhat larger or
102           smaller than the height suggested by the GlyphFactory, depending on
103           the type of the glyph.
104
105       $scale = $glyph->scale
106           Get the scale for the glyph in pixels/bp.
107
108       $height = $glyph->labelheight
109           Return the height of the label, if any.
110
111       $label = $glyph->label
112           Return a human-readable label for the glyph.
113
114       These methods are called by Ace::Graphics::Track during the layout
115       process:
116
117       $glyph->move($dx,$dy)
118           Move the glyph in pixel coordinates by the indicated delta-x and
119           delta-y values.
120
121       ($x1,$y1,$x2,$y2) = $glyph->box
122           Return the current position of the glyph.
123
124       These methods are intended to be overridden in subclasses:
125
126       $glyph->calculate_height
127           Calculate the height of the glyph.
128
129       $glyph->calculate_left
130           Calculate the left side of the glyph.
131
132       $glyph->calculate_right
133           Calculate the right side of the glyph.
134
135       $glyph->draw($gd,$left,$top)
136           Optionally offset the glyph by the indicated amount and draw it
137           onto the GD::Image object.
138
139       $glyph->draw_label($gd,$left,$top)
140           Draw the label for the glyph onto the provided GD::Image object,
141           optionally offsetting by the amounts indicated in $left and $right.
142
143       These methods are useful utility routines:
144
145       $pixels = $glyph->map_pt($bases);
146           Map the indicated base position, given in base pair units, into
147           pixels, using the current scale and glyph position.
148
149       $glyph->filled_box($gd,$x1,$y1,$x2,$y2)
150           Draw a filled rectangle with the appropriate foreground and fill
151           colors, and pen width onto the GD::Image object given by $gd, using
152           the provided rectangle coordinates.
153
154       $glyph->filled_oval($gd,$x1,$y1,$x2,$y2)
155           As above, but draws an oval inscribed on the rectangle.
156
157   OPTIONS
158       The following options are standard among all Glyphs.  See individual
159       glyph pages for more options.
160
161         Option      Description               Default
162         ------      -----------               -------
163
164         -fgcolor    Foreground color          black
165
166         -outlinecolor                         black
167                     Synonym for -fgcolor
168
169         -bgcolor    Background color          white
170
171         -fillcolor  Interior color of filled  turquoise
172                     images
173
174         -linewidth  Width of lines drawn by   1
175                           glyph
176
177         -height     Height of glyph           10
178
179         -font       Glyph font                gdSmallFont
180
181         -label      Whether to draw a label   false
182
183       You may pass an anonymous subroutine to -label, in which case the
184       subroutine will be invoked with the feature as its single argument.
185       The subroutine must return a string to render as the label.
186

SUBCLASSING Ace::Graphics::Glyph

188       By convention, subclasses are all lower-case.  Begin each subclass with
189       a preamble like this one:
190
191        package Ace::Graphics::Glyph::crossbox;
192
193        use strict;
194        use vars '@ISA';
195        @ISA = 'Ace::Graphics::Glyph';
196
197       Then override the methods you need to.  Typically, just the draw()
198       method will need to be overridden.  However, if you need additional
199       room in the glyph, you may override calculate_height(),
200       calculate_left() and calculate_right().  Do not directly override
201       height(), left() and right(), as their purpose is to cache the values
202       returned by their calculating cousins in order to avoid time-consuming
203       recalculation.
204
205       A simple draw() method looks like this:
206
207        sub draw {
208         my $self = shift;
209         $self->SUPER::draw(@_);
210         my $gd = shift;
211
212         # and draw a cross through the box
213         my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
214         my $fg = $self->fgcolor;
215         $gd->line($x1,$y1,$x2,$y2,$fg);
216         $gd->line($x1,$y2,$x2,$y1,$fg);
217        }
218
219       This subclass draws a simple box with two lines criss-crossed through
220       it.  We first call our inherited draw() method to generate the filled
221       box and label.  We then call calculate_boundaries() to return the
222       coordinates of the glyph, disregarding any extra space taken by labels.
223       We call fgcolor() to return the desired foreground color, and then call
224       $gd->line() twice to generate the criss-cross.
225
226       For more complex draw() methods, see Ace::Graphics::Glyph::transcript
227       and Ace::Graphics::Glyph::segments.
228

BUGS

230       Please report them.
231

SEE ALSO

233       Ace::Sequence, Ace::Sequence::Feature, Ace::Graphics::Panel,
234       Ace::Graphics::Track, Ace::Graphics::Glyph::anchored_arrow,
235       Ace::Graphics::Glyph::arrow, Ace::Graphics::Glyph::box,
236       Ace::Graphics::Glyph::primers, Ace::Graphics::Glyph::segments,
237       Ace::Graphics::Glyph::toomany, Ace::Graphics::Glyph::transcript,
238

AUTHOR

240       Lincoln Stein <lstein@cshl.org>.
241
242       Copyright (c) 2001 Cold Spring Harbor Laboratory
243
244       This library is free software; you can redistribute it and/or modify it
245       under the same terms as Perl itself.  See DISCLAIMER.txt for
246       disclaimers of warranty.
247
248
249
250perl v5.36.0                      2023-01-19           Ace::Graphics::Glyph(3)
Impressum