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 con‐
15       figuration variables.
16
17       End developers will not ordinarily work directly with Ace::Graph‐
18       ics::Glyph, but may want to subclass it for customized displays.
19

METHODS

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

SUBCLASSING Ace::Graphics::Glyph

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

BUGS

232       Please report them.
233

SEE ALSO

235       Ace::Sequence, Ace::Sequence::Feature, Ace::Graphics::Panel,
236       Ace::Graphics::Track, Ace::Graphics::Glyph::anchored_arrow, Ace::Graph‐
237       ics::Glyph::arrow, Ace::Graphics::Glyph::box, Ace::Graph‐
238       ics::Glyph::primers, Ace::Graphics::Glyph::segments, Ace::Graph‐
239       ics::Glyph::toomany, Ace::Graphics::Glyph::transcript,
240

AUTHOR

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