~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package Bio::Graphics::Glyph::wave;
2
 
 
3
 
use strict;
4
 
use base qw(Bio::Graphics::Glyph::generic);
5
 
 
6
 
sub default_spread
7
 
{
8
 
  return 0.3;  
9
 
}
10
 
 
11
 
sub default_radius
12
 
{
13
 
  return 5;  
14
 
}
15
 
 
16
 
sub draw_component {
17
 
  my $self = shift;
18
 
  my $gd = shift;
19
 
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
20
 
  
21
 
  my $spread = defined $self->option('spread') ? $self->option('spread') : $self->default_spread();
22
 
  
23
 
  my $fg = $self->fgcolor;
24
 
 
25
 
  my $height = ($y2-$y1)/2;
26
 
  my $midY = $y1 + $height;
27
 
  
28
 
  if ($self->option('circle') == 1)
29
 
  {
30
 
    my $radius = defined $self->option('radius') ? $self->option('radius') : $self->default_radius();
31
 
    $gd->ellipse($x1+$radius,$midY,2*$radius,2*$radius,$fg);
32
 
    $x1 = $x1+2*$radius;
33
 
  }
34
 
  
35
 
  if ($self->option('line') == 1)
36
 
  {
37
 
    if ($x1 < $x2)
38
 
    {
39
 
      $gd->line($x1,$midY,$x2,$midY,$fg);
40
 
    }
41
 
    return;
42
 
  }
43
 
    
44
 
  my ($oldX, $oldY);
45
 
  foreach my $x ($x1..$x2)
46
 
  {
47
 
    my $y = -$height * sin ($spread * ($x-$x1))+$midY;
48
 
    if ($x>$x1)
49
 
    {
50
 
      $gd->line($oldX,$oldY,$x,$y,$fg);
51
 
    }
52
 
    $oldX=$x;
53
 
    $oldY=$y;
54
 
  }
55
 
}
56
 
 
57
 
 
58
 
1;
59
 
 
60
 
__END__
61
 
 
62
 
=head1 NAME
63
 
 
64
 
Bio::Graphics::Glyph::wave - The "wave" glyph
65
 
 
66
 
=head1 SYNOPSIS
67
 
 
68
 
  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
69
 
 
70
 
=head1 DESCRIPTION
71
 
 
72
 
This glyph draws a sine wave with an optional circle in the beginning.
73
 
The wave can also become a straight line.
74
 
 
75
 
=head2 OPTIONS
76
 
 
77
 
In addition to the common options, the following glyph-specific
78
 
options are recognized:
79
 
 
80
 
  Option      Description                  Default
81
 
  ------      -----------                  -------
82
 
 
83
 
  -spread     The "spread" of the sine curve 0.3
84
 
              Values from 0.1 to 0.5 look best
85
 
 
86
 
  -line       Whether  to draw a line         0
87
 
              instead of a wave (1 or 0)
88
 
 
89
 
  -circle     Whether to draw a circle        0
90
 
              in the left corner (1 or 0)
91
 
 
92
 
  -radius     The radius of the circle        5
93
 
              if present
94
 
 
95
 
=head1 BUGS
96
 
 
97
 
Please report them.
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
 
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
134
 
 
135
 
Copyright (c) 2004 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