~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to Bio/Graphics/Glyph/triangle.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::triangle;
2
 
# DAS-compatible package to use for drawing a triangle
3
 
 
4
 
use strict;
5
 
use base qw(Bio::Graphics::Glyph::generic);
6
 
 
7
 
sub pad_left {
8
 
  my $self = shift;
9
 
  my $left = $self->SUPER::pad_left;
10
 
  return $left unless $self->option('point');
11
 
  my $extra = $self->option('height')/3;
12
 
  return $extra > $left ? $extra : $left;
13
 
}
14
 
 
15
 
sub pad_right {
16
 
  my $self = shift;
17
 
  my $right = $self->SUPER::pad_right;
18
 
  return $right unless $self->option('point');
19
 
  my $extra = $self->option('height')/3;
20
 
  return $extra > $right ? $extra : $right;
21
 
}
22
 
 
23
 
sub draw_component {
24
 
  my $self = shift;
25
 
  my $gd = shift;
26
 
  my $fg = $self->fgcolor;
27
 
  my $orient = $self->option('orient') || 'S';
28
 
 
29
 
  # find the center and vertices
30
 
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
31
 
  my $xmid = ($x1+$x2)/2;
32
 
  my $ymid = ($y1+$y2)/2;
33
 
 
34
 
  my ($vx1,$vy1,$vx2,$vy2,$vx3,$vy3);
35
 
 
36
 
  #make an equilateral
37
 
  my ($p,$q) = ($self->option('height'),($x2-$x1)/2);
38
 
  if ($self->option('point')){
39
 
    $q = $p/sqrt(3); #2;
40
 
    $x1 = $xmid - $q; $x2 = $xmid + $q;
41
 
    $y1 = $ymid - $q; $y2 = $ymid + $q;
42
 
  }
43
 
 
44
 
  if   ($orient eq 'S'){$vx1=$x1;$vy1=$y1;$vx2=$x2;$vy2=$y1;$vx3=$xmid;$vy3=$y2;}
45
 
  elsif($orient eq 'N'){$vx1=$x1;$vy1=$y2;$vx2=$x2;$vy2=$y2;$vx3=$xmid;$vy3=$y1;}
46
 
  elsif($orient eq 'W'){$vx1=$x2;$vy1=$y1;$vx2=$x2;$vy2=$y2;$vx3=$x2-$q*2;$vy3=$ymid;}
47
 
  elsif($orient eq 'E'){$vx1=$x1;$vy1=$y1;$vx2=$x1;$vy2=$y2;$vx3=$x1+$q*2;$vy3=$ymid;}
48
 
 
49
 
  # now draw the triangle
50
 
  my $poly_pkg = $self->polygon_package;
51
 
  my $poly     = $poly_pkg->new();
52
 
  $poly->addPt($vx1,$vy1);
53
 
  $poly->addPt($vx2,$vy2);
54
 
  $poly->addPt($vx3,$vy3);
55
 
 
56
 
  if (my $c = $self->bgcolor){
57
 
    $gd->filledPolygon($poly,$c);
58
 
  }
59
 
  $gd->polygon($poly,$fg);
60
 
}
61
 
 
62
 
1;
63
 
 
64
 
__END__
65
 
 
66
 
=head1 NAME
67
 
 
68
 
Bio::Graphics::Glyph::triangle - The "triangle" glyph
69
 
 
70
 
=head1 SYNOPSIS
71
 
 
72
 
  See L<Bio::Graphics::Panel> and L<Bio::Graphics::Glyph>.
73
 
 
74
 
=head1 DESCRIPTION
75
 
 
76
 
This glyph draws an equilateral triangle when -point is defined.
77
 
It draws an isoceles triangle otherwise.  It is possible to draw
78
 
the triangle with the base on the N, S, E, or W side.
79
 
 
80
 
=head2 OPTIONS
81
 
 
82
 
In addition to the common options, the following glyph-specific
83
 
options are recognized:
84
 
 
85
 
  Option      Description                  Default
86
 
  ------      -----------                  -------
87
 
 
88
 
  -point      If true, the triangle         0
89
 
              will drawn at the center
90
 
              of the range, and not scaled
91
 
              to the feature width.
92
 
 
93
 
  -orient     On which side shall the       S
94
 
              base be? (NSEW)
95
 
 
96
 
=head1 BUGS
97
 
 
98
 
Please report them.
99
 
 
100
 
=head1 SEE ALSO
101
 
 
102
 
L<Bio::Graphics::Panel>,
103
 
L<Bio::Graphics::Glyph>,
104
 
L<Bio::Graphics::Glyph::arrow>,
105
 
L<Bio::Graphics::Glyph::cds>,
106
 
L<Bio::Graphics::Glyph::crossbox>,
107
 
L<Bio::Graphics::Glyph::diamond>,
108
 
L<Bio::Graphics::Glyph::dna>,
109
 
L<Bio::Graphics::Glyph::dot>,
110
 
L<Bio::Graphics::Glyph::ellipse>,
111
 
L<Bio::Graphics::Glyph::extending_arrow>,
112
 
L<Bio::Graphics::Glyph::generic>,
113
 
L<Bio::Graphics::Glyph::graded_segments>,
114
 
L<Bio::Graphics::Glyph::heterogeneous_segments>,
115
 
L<Bio::Graphics::Glyph::line>,
116
 
L<Bio::Graphics::Glyph::pinsertion>,
117
 
L<Bio::Graphics::Glyph::primers>,
118
 
L<Bio::Graphics::Glyph::rndrect>,
119
 
L<Bio::Graphics::Glyph::segments>,
120
 
L<Bio::Graphics::Glyph::ruler_arrow>,
121
 
L<Bio::Graphics::Glyph::toomany>,
122
 
L<Bio::Graphics::Glyph::transcript>,
123
 
L<Bio::Graphics::Glyph::transcript2>,
124
 
L<Bio::Graphics::Glyph::translation>,
125
 
L<Bio::Graphics::Glyph::triangle>,
126
 
L<Bio::DB::GFF>,
127
 
L<Bio::SeqI>,
128
 
L<Bio::SeqFeatureI>,
129
 
L<Bio::Das>,
130
 
L<GD>
131
 
 
132
 
=head1 AUTHOR
133
 
 
134
 
Allen Day E<lt>day@cshl.orgE<gt>.
135
 
 
136
 
Copyright (c) 2001 Cold Spring Harbor Laboratory
137
 
 
138
 
This library is free software; you can redistribute it and/or modify
139
 
it under the same terms as Perl itself.  See DISCLAIMER.txt for
140
 
disclaimers of warranty.
141
 
 
142
 
=cut