0
|
1 package Bio::Graphics::Glyph::redgreen_box;
|
|
2 #$Id: redgreen_box.pm,v 1.4.2.1 2003/07/05 00:32:04 lstein Exp $
|
|
3
|
|
4 use strict;
|
|
5 use Bio::Graphics::Glyph::generic;
|
|
6 use vars '@ISA';
|
|
7 @ISA = 'Bio::Graphics::Glyph::generic';
|
|
8
|
|
9 sub bgcolor {
|
|
10 my $self = shift;
|
|
11 $self->{force_bgcolor};
|
|
12 }
|
|
13
|
|
14 sub fgcolor {
|
|
15 my $self = shift;
|
|
16 return $self->option('border') ? $self->SUPER::fgcolor : $self->{force_bgcolor};
|
|
17 }
|
|
18
|
|
19 sub draw {
|
|
20 my $self = shift;
|
|
21 my $val = $self->feature->score;
|
|
22
|
|
23 # we're going to force all our parts to share the same colors
|
|
24 # since the
|
|
25 my @parts = $self->parts;
|
|
26 @parts = $self if !@parts && $self->level == 0;
|
|
27 my @rgb = map {int($_)} HSVtoRGB(120*(1-$val),1,255);
|
|
28 my $color = $self->panel->translate_color(@rgb);
|
|
29 $_->{force_bgcolor} = $color foreach @parts;
|
|
30
|
|
31 $self->SUPER::draw(@_);
|
|
32 }
|
|
33
|
|
34 sub HSVtoRGB ($$$) {
|
|
35 my ($h,$s,$v)=@_;
|
|
36 my ($r,$g,$b,$i,$f,$p,$q,$t);
|
|
37
|
|
38 if( $s == 0 ) {
|
|
39 ## achromatic (grey)
|
|
40 return ($v,$v,$v);
|
|
41 }
|
|
42
|
|
43 $h /= 60; ## sector 0 to 5
|
|
44 $i = int($h);
|
|
45 $f = $h - $i; ## factorial part of h
|
|
46 $p = $v * ( 1 - $s );
|
|
47 $q = $v * ( 1 - $s * $f );
|
|
48 $t = $v * ( 1 - $s * ( 1 - $f ) );
|
|
49
|
|
50 if($i<1) {
|
|
51 $r = $v;
|
|
52 $g = $t;
|
|
53 $b = $p;
|
|
54 } elsif($i<2){
|
|
55 $r = $q;
|
|
56 $g = $v;
|
|
57 $b = $p;
|
|
58 } elsif($i<3){
|
|
59 $r = $p;
|
|
60 $g = $v;
|
|
61 $b = $t;
|
|
62 } elsif($i<4){
|
|
63 $r = $p;
|
|
64 $g = $q;
|
|
65 $b = $v;
|
|
66 } elsif($i<5){
|
|
67 $r = $t;
|
|
68 $g = $p;
|
|
69 $b = $v;
|
|
70 } else {
|
|
71 $r = $v;
|
|
72 $g = $p;
|
|
73 $b = $q;
|
|
74 }
|
|
75 return ($r,$g,$b);
|
|
76 }
|
|
77
|
|
78 sub mMin {
|
|
79 my $n=10000000000000;
|
|
80 map { $n=($n>$_) ? $_ : $n } @_;
|
|
81 return($n);
|
|
82 }
|
|
83
|
|
84 sub mMax {
|
|
85 my $n=0;
|
|
86 map { $n=($n<$_) ? $_ : $n } @_;
|
|
87 return($n);
|
|
88 }
|
|
89
|
|
90
|
|
91 1;
|
|
92
|
|
93 =head1 NAME
|
|
94
|
|
95 Bio::Graphics::Glyph::redgreen_box - The "redgreen_box" glyph
|
|
96
|
|
97 =head1 SYNOPSIS
|
|
98
|
|
99 See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
|
|
100
|
|
101 =head1 DESCRIPTION
|
|
102
|
|
103 This glyph is similar to the graded_segments glyph except that it
|
|
104 generates a green-E<gt>red gradient suitable for use with microarray data.
|
|
105 A feature score of 0 is full green; a feature score of 1.0 is full
|
|
106 red; intermediate scores are shades of yellow.
|
|
107
|
|
108 =head2 OPTIONS
|
|
109
|
|
110 The following options are standard among all Glyphs. See
|
|
111 L<Bio::Graphics::Glyph> for a full explanation.
|
|
112
|
|
113 Option Description Default
|
|
114 ------ ----------- -------
|
|
115
|
|
116 -fgcolor Foreground color black
|
|
117
|
|
118 -outlinecolor Synonym for -fgcolor
|
|
119
|
|
120 -bgcolor Background color turquoise
|
|
121
|
|
122 -fillcolor Synonym for -bgcolor
|
|
123
|
|
124 -linewidth Line width 1
|
|
125
|
|
126 -height Height of glyph 10
|
|
127
|
|
128 -font Glyph font gdSmallFont
|
|
129
|
|
130 -connector Connector type 0 (false)
|
|
131
|
|
132 -connector_color
|
|
133 Connector color black
|
|
134
|
|
135 -label Whether to draw a label 0 (false)
|
|
136
|
|
137 -description Whether to draw a description 0 (false)
|
|
138
|
|
139 The following glyph-specific option is recognized:
|
|
140
|
|
141 -border Draw a fgcolor border around 0 (false)
|
|
142 the box
|
|
143
|
|
144
|
|
145 =head1 BUGS
|
|
146
|
|
147 Please report them.
|
|
148
|
|
149 =head1 SEE ALSO
|
|
150
|
|
151 L<Bio::Graphics::Panel>,
|
|
152 L<Bio::Graphics::Glyph>,
|
|
153 L<Bio::Graphics::Glyph::arrow>,
|
|
154 L<Bio::Graphics::Glyph::cds>,
|
|
155 L<Bio::Graphics::Glyph::crossbox>,
|
|
156 L<Bio::Graphics::Glyph::diamond>,
|
|
157 L<Bio::Graphics::Glyph::dna>,
|
|
158 L<Bio::Graphics::Glyph::dot>,
|
|
159 L<Bio::Graphics::Glyph::ellipse>,
|
|
160 L<Bio::Graphics::Glyph::extending_arrow>,
|
|
161 L<Bio::Graphics::Glyph::generic>,
|
|
162 L<Bio::Graphics::Glyph::graded_segments>,
|
|
163 L<Bio::Graphics::Glyph::heterogeneous_segments>,
|
|
164 L<Bio::Graphics::Glyph::line>,
|
|
165 L<Bio::Graphics::Glyph::pinsertion>,
|
|
166 L<Bio::Graphics::Glyph::primers>,
|
|
167 L<Bio::Graphics::Glyph::rndrect>,
|
|
168 L<Bio::Graphics::Glyph::segments>,
|
|
169 L<Bio::Graphics::Glyph::ruler_arrow>,
|
|
170 L<Bio::Graphics::Glyph::toomany>,
|
|
171 L<Bio::Graphics::Glyph::transcript>,
|
|
172 L<Bio::Graphics::Glyph::transcript2>,
|
|
173 L<Bio::Graphics::Glyph::translation>,
|
|
174 L<Bio::Graphics::Glyph::triangle>,
|
|
175 L<Bio::DB::GFF>,
|
|
176 L<Bio::SeqI>,
|
|
177 L<Bio::SeqFeatureI>,
|
|
178 L<Bio::Das>,
|
|
179 L<GD>
|
|
180
|
|
181 =head1 AUTHOR
|
|
182
|
|
183 Lincoln Stein E<lt>lstein@cshl.orgE<gt>
|
|
184
|
|
185 Copyright (c) 2001 Cold Spring Harbor Laboratory
|
|
186
|
|
187 This library is free software; you can redistribute it and/or modify
|
|
188 it under the same terms as Perl itself. See DISCLAIMER.txt for
|
|
189 disclaimers of warranty.
|
|
190
|
|
191 =cut
|