~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/Graphics/Glyph/two_bolts.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Bio::Graphics::Glyph::two_bolts;
 
2
 
 
3
use strict;
 
4
use base qw(Bio::Graphics::Glyph::generic);
 
5
 
 
6
sub default_bolt_height
 
7
{
 
8
  return 10;  
 
9
}
 
10
 
 
11
sub default_bolt_length
 
12
{
 
13
  return 20;  
 
14
}
 
15
 
 
16
sub default_remainder_length
 
17
{
 
18
  return 10;  
 
19
}
 
20
 
 
21
sub default_bolt_color
 
22
{
 
23
  return 'red';  
 
24
}
 
25
 
 
26
sub draw_component {
 
27
  my $self = shift;
 
28
  my $gd = shift;
 
29
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
 
30
 
 
31
  my $fg = $self->fgcolor;
 
32
  
 
33
  my $midY1 = $y1+($y2-$y1) / 3;
 
34
  my $midY2 = $y1 + 2*($y2-$y1) / 3;
 
35
    
 
36
  my $bolt_color = defined $self->option('bolt_color') ? $self->option('bolt_color')  : $self->default_bolt_color();
 
37
  $bolt_color = $self->factory->translate_color($bolt_color);
 
38
 
 
39
  my $bolt_height = defined $self->option('bolt_height') ? $self->option('bolt_height')  : $self->default_bolt_height();  
 
40
  my $bolt_length = defined $self->option('bolt_length') ? $self->option('bolt_length')  : $self->default_bolt_length();  
 
41
  my $remainder_length = defined $self->option('remainder_length') ? $self->option('remaindert_length')  : $self->default_remainder_length();  
 
42
 
 
43
  if ($x2-$x1 < $bolt_length+$remainder_length)
 
44
  {
 
45
    $gd->line($x1, $y1, $x2, $y2, $bolt_color);
 
46
    return;
 
47
  }
 
48
  
 
49
  my $bolt_start = $x2-$bolt_length-$remainder_length;
 
50
  my $step = $bolt_length / 8;
 
51
  my $shift = $bolt_height/2;
 
52
  $gd->line($x1, $midY1, $bolt_start, $midY1, $fg);
 
53
  $self->draw_bolt($gd, $bolt_start, $step, $midY1, $shift, $bolt_color);
 
54
  $gd->line($x2-$remainder_length, $midY1, $x2, $midY1, $fg);
 
55
 
 
56
  $bolt_start = $x1+$remainder_length;
 
57
  $gd->line($x1, $midY2, $bolt_start, $midY2, $fg);
 
58
  $self->draw_bolt($gd, $bolt_start, $step, $midY2, $shift, $bolt_color);
 
59
  $gd->line($x1+$bolt_length+$remainder_length, $midY2, $x2, $midY2, $fg);
 
60
  
 
61
  
 
62
}
 
63
 
 
64
sub draw_bolt
 
65
{
 
66
  my ($self, $gd, $bolt_start, $step, $y, $shift, $bolt_color) = @_;
 
67
  $gd->line($bolt_start, $y, $bolt_start+$step, $y-$shift, $bolt_color);
 
68
  $gd->line($bolt_start+$step, $y-$shift, $bolt_start+3*$step, $y+$shift, $bolt_color);
 
69
  $gd->line($bolt_start+3*$step, $y+$shift, $bolt_start+5*$step, $y-$shift, $bolt_color);
 
70
  $gd->line($bolt_start+5*$step, $y-$shift, $bolt_start+7*$step, $y+$shift, $bolt_color);
 
71
  $gd->line($bolt_start+7*$step, $y+$shift, $bolt_start+8*$step, $y, $bolt_color);
 
72
  
 
73
}
 
74
 
 
75
1;
 
76
 
 
77
__END__
 
78
 
 
79
=head1 NAME
 
80
 
 
81
Bio::Graphics::Glyph::two_bolts - The "two bolts" glyph
 
82
 
 
83
=head1 SYNOPSIS
 
84
 
 
85
  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
 
86
 
 
87
=head1 DESCRIPTION
 
88
 
 
89
This glyph draws two "bolts" on a line. They look like this;
 
90
 
 
91
--------/\/\/\--
 
92
--/\/\/\--------
 
93
 
 
94
=head2 OPTIONS
 
95
 
 
96
In addition to the common options, the following glyph-specific
 
97
options are recognized:
 
98
 
 
99
  Option      Description                  Default
 
100
  ------      -----------                  -------
 
101
 
 
102
  -bolt_height  Height of the bolt          10
 
103
 
 
104
  -bolt_length  Length of the bolt          20
 
105
 
 
106
  -bolt_color   Color of the bolt           red
 
107
 
 
108
  -remainder_length
 
109
                Length of the short line    10
 
110
 
 
111
=head1 BUGS
 
112
 
 
113
Please report them.
 
114
 
 
115
=head1 SEE ALSO
 
116
 
 
117
L<Bio::Graphics::Panel>,
 
118
L<Bio::Graphics::Glyph>,
 
119
L<Bio::Graphics::Glyph::arrow>,
 
120
L<Bio::Graphics::Glyph::cds>,
 
121
L<Bio::Graphics::Glyph::crossbox>,
 
122
L<Bio::Graphics::Glyph::diamond>,
 
123
L<Bio::Graphics::Glyph::dna>,
 
124
L<Bio::Graphics::Glyph::dot>,
 
125
L<Bio::Graphics::Glyph::ellipse>,
 
126
L<Bio::Graphics::Glyph::extending_arrow>,
 
127
L<Bio::Graphics::Glyph::generic>,
 
128
L<Bio::Graphics::Glyph::graded_segments>,
 
129
L<Bio::Graphics::Glyph::heterogeneous_segments>,
 
130
L<Bio::Graphics::Glyph::line>,
 
131
L<Bio::Graphics::Glyph::pinsertion>,
 
132
L<Bio::Graphics::Glyph::primers>,
 
133
L<Bio::Graphics::Glyph::rndrect>,
 
134
L<Bio::Graphics::Glyph::segments>,
 
135
L<Bio::Graphics::Glyph::ruler_arrow>,
 
136
L<Bio::Graphics::Glyph::toomany>,
 
137
L<Bio::Graphics::Glyph::transcript>,
 
138
L<Bio::Graphics::Glyph::transcript2>,
 
139
L<Bio::Graphics::Glyph::translation>,
 
140
L<Bio::Graphics::Glyph::triangle>,
 
141
L<Bio::DB::GFF>,
 
142
L<Bio::SeqI>,
 
143
L<Bio::SeqFeatureI>,
 
144
L<Bio::Das>,
 
145
L<GD>
 
146
 
 
147
=head1 AUTHOR
 
148
 
 
149
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
 
150
 
 
151
Copyright (c) 2004 Cold Spring Harbor Laboratory
 
152
 
 
153
This library is free software; you can redistribute it and/or modify
 
154
it under the same terms as Perl itself.  See DISCLAIMER.txt for
 
155
disclaimers of warranty.
 
156
 
 
157
=cut