comparison variant_effect_predictor/Bio/Graphics/Glyph/diamond.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 package Bio::Graphics::Glyph::diamond;
2 # DAS-compatible package to use for drawing a colored diamond
3
4 use strict;
5 use vars '@ISA';
6 use Bio::Graphics::Glyph::generic;
7 @ISA = 'Bio::Graphics::Glyph::generic';
8
9 sub draw_component {
10 my $self = shift;
11 my $gd = shift;
12 my $fg = $self->fgcolor;
13
14 # find the center and vertices
15 my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
16 my $xmid = ($x1+$x2)/2;
17 my $ymid = ($y1+$y2)/2;
18
19 my $h = $self->option('height')/2;
20 $y1 = $ymid - $h;
21 $y2 = $ymid + $h;
22
23 # if it's a point-like feature, then draw symmetrically
24 # around the midpoing
25 if ($self->option('point') || $x2 - $x1 < $h*2) {
26 $x1 = $xmid - $h;
27 $x2 = $xmid + $h;
28 }
29
30 elsif ($self->option('fallback_to_rectangle')) {
31 return $self->SUPER::draw_component($gd,@_);
32 }
33
34 $gd->line($x1,$ymid,$xmid,$y1,$fg);
35 $gd->line($xmid,$y1,$x2,$ymid,$fg);
36 $gd->line($x2,$ymid,$xmid,$y2,$fg);
37 $gd->line($xmid,$y2,$x1,$ymid,$fg);
38
39 if (my $c = $self->bgcolor) {
40 $gd->fillToBorder($xmid,$ymid,$fg,$c);
41 }
42 }
43
44 1;
45
46 __END__
47
48 =head1 NAME
49
50 Bio::Graphics::Glyph::diamond - The "diamond" glyph
51
52 =head1 SYNOPSIS
53
54 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
55
56 =head1 DESCRIPTION
57
58 This glyph draws a diamond of fixed size, positioned in the center of
59 the feature. The height and width of the diamond are set by the
60 "height" option.
61
62 =head2 OPTIONS
63
64 The following options are standard among all Glyphs. See
65 L<Bio::Graphics::Glyph> for a full explanation.
66
67 Option Description Default
68 ------ ----------- -------
69
70 -fgcolor Foreground color black
71
72 -outlinecolor Synonym for -fgcolor
73
74 -bgcolor Background color turquoise
75
76 -fillcolor Synonym for -bgcolor
77
78 -linewidth Line width 1
79
80 -height Height of glyph 10
81
82 -font Glyph font gdSmallFont
83
84 -connector Connector type 0 (false)
85
86 -connector_color
87 Connector color black
88
89 -label Whether to draw a label 0 (false)
90
91 -description Whether to draw a description 0 (false)
92
93 =head1 BUGS
94
95 If the feature is wider than a point, then the label and description
96 are placed where the feature's boundary is, and not where the diamond
97 is drawn.
98
99 =head1 SEE ALSO
100
101 L<Bio::Graphics::Panel>,
102 L<Bio::Graphics::Glyph>,
103 L<Bio::Graphics::Glyph::arrow>,
104 L<Bio::Graphics::Glyph::cds>,
105 L<Bio::Graphics::Glyph::crossbox>,
106 L<Bio::Graphics::Glyph::diamond>,
107 L<Bio::Graphics::Glyph::dna>,
108 L<Bio::Graphics::Glyph::dot>,
109 L<Bio::Graphics::Glyph::ellipse>,
110 L<Bio::Graphics::Glyph::extending_arrow>,
111 L<Bio::Graphics::Glyph::generic>,
112 L<Bio::Graphics::Glyph::graded_segments>,
113 L<Bio::Graphics::Glyph::heterogeneous_segments>,
114 L<Bio::Graphics::Glyph::line>,
115 L<Bio::Graphics::Glyph::pinsertion>,
116 L<Bio::Graphics::Glyph::primers>,
117 L<Bio::Graphics::Glyph::rndrect>,
118 L<Bio::Graphics::Glyph::segments>,
119 L<Bio::Graphics::Glyph::ruler_arrow>,
120 L<Bio::Graphics::Glyph::toomany>,
121 L<Bio::Graphics::Glyph::transcript>,
122 L<Bio::Graphics::Glyph::transcript2>,
123 L<Bio::Graphics::Glyph::translation>,
124 L<Bio::Graphics::Glyph::triangle>,
125 L<Bio::DB::GFF>,
126 L<Bio::SeqI>,
127 L<Bio::SeqFeatureI>,
128 L<Bio::Das>,
129 L<GD>
130
131 =head1 AUTHOR
132
133 Lincoln Stein E<lt>lstein@cshl.orgE<gt>
134
135 Copyright (c) 2001 Cold Spring Harbor Laboratory
136
137 This library is free software; you can redistribute it and/or modify
138 it under the same terms as Perl itself. See DISCLAIMER.txt for
139 disclaimers of warranty.
140
141 =cut