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

« back to all changes in this revision

Viewing changes to Bio/Graphics/Glyph/dashed_line.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::dashed_line;
2
 
 
3
 
use strict;
4
 
use base qw(Bio::Graphics::Glyph::generic);
5
 
 
6
 
sub default_linewidth
7
 
{
8
 
  return 1;  
9
 
}
10
 
 
11
 
sub default_dash_size
12
 
{
13
 
  return 6;  
14
 
}
15
 
 
16
 
sub default_space_size
17
 
{
18
 
  return 3;  
19
 
}
20
 
 
21
 
sub draw_component {
22
 
  my $self = shift;
23
 
  my $gd = shift;
24
 
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
25
 
 
26
 
  my $fg = $self->fgcolor;
27
 
  
28
 
  my $midY = ($y1+$y2) / 2;
29
 
  
30
 
  my $linewidth = defined $self->option('linewidth') ? $self->option('linewidth')  : $self->default_linewidth();
31
 
  my $dash_size = defined $self->option('dash_size') ? $self->option('dash_size') : $self->default_dash_size();
32
 
  my $space_size = defined $self->option('space_size') ? $self->option('space_size') : $self->default_space_size();
33
 
  my $space_color = $self->option('space_color');
34
 
  my $shear = $self->option('shear') || "";
35
 
  $space_color = $self->factory->translate_color($space_color) if $space_color;
36
 
  
37
 
  my ($x, $_y1, $_y2);
38
 
  $x = $x1;
39
 
  while ($x<$x2)
40
 
  {
41
 
    my $newX = $x+$dash_size;
42
 
    $newX = $x2 if $newX > $x2;
43
 
    if ($shear == 1)
44
 
    {
45
 
      $_y1 = $midY-$linewidth;
46
 
      $_y2 = $midY;
47
 
    }
48
 
    else
49
 
    {
50
 
      $_y1 = $midY - $linewidth/2;  
51
 
      $_y2 = $midY + $linewidth/2;  
52
 
    }
53
 
    $self->filled_box($gd,$x,$_y1,$newX,$_y2,$fg,$fg);
54
 
    last if $newX >= $x2;
55
 
    
56
 
    $x = $newX;
57
 
    $newX = $x+$space_size;
58
 
    $newX = $x2 if $newX > $x2;
59
 
    if ($space_color)
60
 
    {
61
 
      if ($shear == 1)
62
 
      {
63
 
        $_y1 = $midY;
64
 
        $_y2 = $midY+$linewidth;
65
 
      }
66
 
      else
67
 
      {
68
 
        $_y1 = $midY - $linewidth/2;  
69
 
        $_y2 = $midY + $linewidth/2;  
70
 
      }
71
 
      $self->filled_box($gd, $x,$_y1,$newX,$_y2,$space_color,$space_color);
72
 
    }
73
 
    $x = $newX;
74
 
  }
75
 
}
76
 
 
77
 
1;
78
 
 
79
 
__END__
80
 
 
81
 
=head1 NAME
82
 
 
83
 
Bio::Graphics::Glyph::dashed_line - The "dashed line" glyph
84
 
 
85
 
=head1 SYNOPSIS
86
 
 
87
 
  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
88
 
 
89
 
=head1 DESCRIPTION
90
 
 
91
 
This glyph draws a dashed line. The lengths of the dash and the space are configurable.
92
 
The space can be filled with a different color, thus making a two-colored line.
93
 
Also, the two colors can be "sheared".
94
 
 
95
 
=head2 OPTIONS
96
 
 
97
 
In addition to the common options, the following glyph-specific
98
 
options are recognized:
99
 
 
100
 
  Option      Description                  Default
101
 
  ------      -----------                  -------
102
 
 
103
 
  -dash_size  Width of one dash              6
104
 
 
105
 
  -space_size Width of one space             3
106
 
              between dashes       
107
 
 
108
 
  -space_color Color of the space            none 
109
 
              between dashes       
110
 
 
111
 
  -shear      Whether to use shearing       0
112
 
              (1 or 0)
113
 
 
114
 
  -linewidth  Standard option, but          1
115
 
              important here
116
 
 
117
 
=head1 BUGS
118
 
 
119
 
Please report them.
120
 
 
121
 
=head1 SEE ALSO
122
 
 
123
 
L<Bio::Graphics::Panel>,
124
 
L<Bio::Graphics::Glyph>,
125
 
L<Bio::Graphics::Glyph::arrow>,
126
 
L<Bio::Graphics::Glyph::cds>,
127
 
L<Bio::Graphics::Glyph::crossbox>,
128
 
L<Bio::Graphics::Glyph::diamond>,
129
 
L<Bio::Graphics::Glyph::dna>,
130
 
L<Bio::Graphics::Glyph::dot>,
131
 
L<Bio::Graphics::Glyph::ellipse>,
132
 
L<Bio::Graphics::Glyph::extending_arrow>,
133
 
L<Bio::Graphics::Glyph::generic>,
134
 
L<Bio::Graphics::Glyph::graded_segments>,
135
 
L<Bio::Graphics::Glyph::heterogeneous_segments>,
136
 
L<Bio::Graphics::Glyph::line>,
137
 
L<Bio::Graphics::Glyph::pinsertion>,
138
 
L<Bio::Graphics::Glyph::primers>,
139
 
L<Bio::Graphics::Glyph::rndrect>,
140
 
L<Bio::Graphics::Glyph::segments>,
141
 
L<Bio::Graphics::Glyph::ruler_arrow>,
142
 
L<Bio::Graphics::Glyph::toomany>,
143
 
L<Bio::Graphics::Glyph::transcript>,
144
 
L<Bio::Graphics::Glyph::transcript2>,
145
 
L<Bio::Graphics::Glyph::translation>,
146
 
L<Bio::Graphics::Glyph::triangle>,
147
 
L<Bio::DB::GFF>,
148
 
L<Bio::SeqI>,
149
 
L<Bio::SeqFeatureI>,
150
 
L<Bio::Das>,
151
 
L<GD>
152
 
 
153
 
=head1 AUTHOR
154
 
 
155
 
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
156
 
 
157
 
Copyright (c) 2004 Cold Spring Harbor Laboratory
158
 
 
159
 
This library is free software; you can redistribute it and/or modify
160
 
it under the same terms as Perl itself.  See DISCLAIMER.txt for
161
 
disclaimers of warranty.
162
 
 
163
 
=cut