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

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 52 CC 4 SCAR 23.0
CC
4
Cov
0%
draw
20.0
box
2.0
insertion_width
2.0
CRAP 10.0
1 package Bio::Graphics::Glyph::pinsertion;
2 # package to use for drawing P insertion as a triangle
3 # p insertion is a point (one base).
4  
5 use strict;
6 use GD;
7 use base qw(Bio::Graphics::Glyph::generic);
8  
9 sub box {
10 my $self = shift;
11 my $half = $self->insertion_width/2;
12 return ($self->left-$half,$self->top,$self->right+$half,$self->bottom);
13 }
14  
15 sub insertion_width {
16 my $self = shift;
17 return $self->option('insertion_width') || 6;
18 }
19  
20 # override draw method
21 sub draw {
22 my $self = shift;
23  
24 my $gd = shift;
25 my ($left,$top) = @_;
26  
27 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
28  
29 my $height = $self->height;
30  
31 my $half = $self->insertion_width/2;
32 my $fill = $self->bgcolor;
33 my $border = $self->fgcolor;
34  
35 my $poly_pkg = $self->polygon_package;
36 my $poly = $poly_pkg->new();
37 if ($self->feature->strand > 0) { #plus strand
38 $poly->addPt($x1 - $half, $y1);
39 $poly->addPt($x1 + ($half), $y1);
40 $poly->addPt($x1, $y2); #pointer down
41 } else {
42 $poly->addPt($x1, $y1); #pointer up
43 $poly->addPt($x1 - $half, $y2);
44 $poly->addPt($x1 + ($half), $y2);
45 }
46 $gd->filledPolygon($poly,$fill);
47 $gd->polygon($poly,$border);
48  
49 # add a label if requested
50 $self->draw_label($gd,$left,$top) if $self->option('label');
51 $self->draw_description($gd,$left,$top) if $self->option('description');
52 }
53  
54  
55 1;
56  
57 =head1 NAME
58  
59 Bio::Graphics::Glyph::pinsertion - The "Drosophila P-element Insertion" glyph
60  
61 =head1 SYNOPSIS
62  
63 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
64  
65 =head1 DESCRIPTION
66  
67 This glyph was designed to show P-element insertions in the Drosophila
68 genome, but in fact is suitable for any type of zero-width feature.
69 Also see the triangle glyph.
70  
71 =head2 OPTIONS
72  
73 In addition to the generic options, this glyph recognizes:
74  
75 Option Name Description Default
76 ----------- ----------- -------
77  
78 -insertion_width Width of glyph in pixels 3
79  
80 =head1 BUGS
81  
82 Please report them.
83  
84 =head1 SEE ALSO
85  
86 L<Bio::Graphics::Panel>,
87 L<Bio::Graphics::Glyph>,
88 L<Bio::Graphics::Glyph::arrow>,
89 L<Bio::Graphics::Glyph::cds>,
90 L<Bio::Graphics::Glyph::crossbox>,
91 L<Bio::Graphics::Glyph::diamond>,
92 L<Bio::Graphics::Glyph::dna>,
93 L<Bio::Graphics::Glyph::dot>,
94 L<Bio::Graphics::Glyph::ellipse>,
95 L<Bio::Graphics::Glyph::extending_arrow>,
96 L<Bio::Graphics::Glyph::generic>,
97 L<Bio::Graphics::Glyph::graded_segments>,
98 L<Bio::Graphics::Glyph::heterogeneous_segments>,
99 L<Bio::Graphics::Glyph::line>,
100 L<Bio::Graphics::Glyph::pinsertion>,
101 L<Bio::Graphics::Glyph::primers>,
102 L<Bio::Graphics::Glyph::rndrect>,
103 L<Bio::Graphics::Glyph::segments>,
104 L<Bio::Graphics::Glyph::ruler_arrow>,
105 L<Bio::Graphics::Glyph::toomany>,
106 L<Bio::Graphics::Glyph::transcript>,
107 L<Bio::Graphics::Glyph::transcript2>,
108 L<Bio::Graphics::Glyph::translation>,
109 L<Bio::Graphics::Glyph::triangle>,
110 L<Bio::DB::GFF>,
111 L<Bio::SeqI>,
112 L<Bio::SeqFeatureI>,
113 L<Bio::Das>,
114 L<GD>
115  
116 =head1 AUTHOR
117  
118 Allen Day E<lt>day@cshl.orgE<gt>, Shengqiang Shu E<lt>sshu@bdgp.lbl.govE<gt>
119  
120 Copyright (c) 2001 Cold Spring Harbor Laboratory, BDGP
121  
122 This library is free software; you can redistribute it and/or modify
123 it under the same terms as Perl itself. See DISCLAIMER.txt for
124 disclaimers of warranty.
125  
126 =cut