blib/lib/Bio/Graphics/Glyph/ragged_ends.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 4 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 50 CC 4 SCAR 26.4
CC
4
Cov
0%
draw_component
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 14.0
1 package Bio::Graphics::Glyph::ragged_ends;
2  
3 use strict;
4 use base qw(Bio::Graphics::Glyph::generic);
5  
6 sub draw_component {
7 my $self = shift;
8 my $gd = shift;
9 my $fg = $self->fgcolor;
10 my $bg = $self->option('bgcolor');
11 my ($left,$top) = @_;
12 my($x1,$y1,$x2,$y2) = $self->bounds(@_);
13  
14 my $zig = $self->option('zig') || 4;
15 my $zag = $self->option('zag') || 4;
16  
17 my $polygon = GD::Polygon->new;
18  
19 $polygon->addPt($x1, $y1);
20 my $yoff = $y1 + $zig;
21 my $i = 1;
22 if ($self->option("ragged_left")) {
23 while ($yoff <= $y2) {
24 $polygon->addPt( $x1 + ($i * $zag),
25 $yoff );
26 $i = !$i;
27 $yoff += $zig;
28 }
29 }
30 $polygon->addPt($x1, $y2);
31  
32 $polygon->addPt($x2, $y2);
33 $yoff = $y2 - $zig;
34 $i = 1;
35 if ($self->option("ragged_right")) {
36 while ($yoff >= $y1) {
37 $polygon->addPt( $x2 - ($i * $zag),
38 $yoff );
39 $i = !$i;
40 $yoff -= $zig;
41 }
42 }
43 $polygon->addPt($x2, $y1);
44  
45 $polygon->addPt($x1, $y1); # close the polygon
46  
47 $gd->polygon($polygon, $fg);
48 $gd->filledPolygon($polygon, $bg) if $bg;
49 }
50  
51 1;
52  
53 =head1 NAME
54  
55 Bio::Graphics::Glyph::ragged_ends - The "ragged ends" glyph
56  
57 =head1 SYNOPSIS
58  
59 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
60  
61 =head1 DESCRIPTION
62  
63 This is identical to the "box" glyph except that it will draw the
64 subparts of features that contain subfeatures. The subparts are not
65 connected -- use the "segments" glyph for that. "Generic" is the
66 default glyph used when not otherwise specified.
67  
68 =head2 OPTIONS
69  
70 This glyph provides two extra options to control whether the right
71 and/or left ends of the drawn box are to be drawn "raggedly" with
72 zigzags instead of vertical lines.
73  
74 Option Values Default
75 -raggedleft 0 | 1 1
76 -raggedright 0 | 1 1
77 -zig > 3 4
78 -zag > 3 4
79  
80 The following options are standard among all Glyphs. See
81 L<Bio::Graphics::Glyph> for a full explanation.
82  
83 Option Description Default
84 ------ ----------- -------
85  
86 -fgcolor Foreground color black
87  
88 -outlinecolor Synonym for -fgcolor
89  
90 -bgcolor Background color turquoise
91  
92 -fillcolor Synonym for -bgcolor
93  
94 -linewidth Line width 1
95  
96 -height Height of glyph 10
97  
98 -font Glyph font gdSmallFont
99  
100 -connector Connector type 0 (false)
101  
102 -connector_color
103 Connector color black
104  
105 -pad_top Top padding 0
106  
107 -pad_bottom Bottom padding 0
108  
109 -label Whether to draw a label 0 (false)
110  
111 -description Whether to draw a description 0 (false)
112  
113 -strand_arrow Whether to indicate 0 (false)
114 strandedness
115  
116 -hilite Highlight color undef (no color)
117  
118 -pad_top and -pad_bottom allow you to insert some blank space between
119 the glyph's boundary and its contents. This is useful if you are
120 changing the glyph's height dynamically based on its feature's score.
121  
122 =head1 BUGS
123  
124 Please report them.
125  
126 =head1 SEE ALSO
127  
128 L<Bio::Graphics::Panel>,
129 L<Bio::Graphics::Glyph>,
130 L<Bio::Graphics::Glyph::arrow>,
131 L<Bio::Graphics::Glyph::cds>,
132 L<Bio::Graphics::Glyph::crossbox>,
133 L<Bio::Graphics::Glyph::diamond>,
134 L<Bio::Graphics::Glyph::dna>,
135 L<Bio::Graphics::Glyph::dot>,
136 L<Bio::Graphics::Glyph::ellipse>,
137 L<Bio::Graphics::Glyph::extending_arrow>,
138 L<Bio::Graphics::Glyph::generic>,
139 L<Bio::Graphics::Glyph::graded_segments>,
140 L<Bio::Graphics::Glyph::heterogeneous_segments>,
141 L<Bio::Graphics::Glyph::line>,
142 L<Bio::Graphics::Glyph::pinsertion>,
143 L<Bio::Graphics::Glyph::primers>,
144 L<Bio::Graphics::Glyph::rndrect>,
145 L<Bio::Graphics::Glyph::segments>,
146 L<Bio::Graphics::Glyph::ruler_arrow>,
147 L<Bio::Graphics::Glyph::toomany>,
148 L<Bio::Graphics::Glyph::transcript>,
149 L<Bio::Graphics::Glyph::transcript2>,
150 L<Bio::Graphics::Glyph::translation>,
151 L<Bio::Graphics::Glyph::triangle>,
152 L<Bio::Graphics::Glyph::xyplot>,
153 L<Bio::DB::GFF>,
154 L<Bio::SeqI>,
155 L<Bio::SeqFeatureI>,
156 L<Bio::Das>,
157 L<GD>
158  
159 =head1 AUTHOR
160  
161 Aaron J Mackey E<lt>amackey@pcbi.upenn.eduE<gt>.
162  
163 This library is free software; you can redistribute it and/or modify
164 it under the same terms as Perl itself. See DISCLAIMER.txt for
165 disclaimers of warranty.
166  
167 =cut