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

« back to all changes in this revision

Viewing changes to Bio/Graphics/Glyph/pentagram.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::pentagram;
2
 
 
3
 
use strict;
4
 
use base qw(Bio::Graphics::Glyph::generic);
5
 
 
6
 
sub pad_top
7
 
{
8
 
  my ($self) = @_;
9
 
  
10
 
  my $font = $self->option('labelfont') || $self->font;
11
 
  
12
 
  my $pad = $font->height;
13
 
  
14
 
  if ($self->option('text'))
15
 
  {
16
 
    $pad *= 2;
17
 
  }
18
 
  return $pad;
19
 
}
20
 
 
21
 
sub default_text
22
 
{
23
 
  return '';  
24
 
}
25
 
 
26
 
sub default_text_pad_x
27
 
{
28
 
  return 0;  
29
 
}
30
 
 
31
 
sub default_text_pad_y
32
 
{
33
 
  return 3;  
34
 
}
35
 
 
36
 
sub default_size
37
 
{
38
 
  return 20;  
39
 
}
40
 
 
41
 
sub draw_component {
42
 
  my $self = shift;
43
 
  my $gd = shift;
44
 
  my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
45
 
  
46
 
  my $fg = $self->fgcolor;
47
 
  my $bg = $self->bgcolor;
48
 
  
49
 
  my $size = defined $self->option('size') ? $self->option('size') : $self->default_size();
50
 
 
51
 
  my $poly_pkg = $self->polygon_package;
52
 
  
53
 
  my $polygon   = $poly_pkg->new();
54
 
 
55
 
  if ($self->option('inverted') == 1)
56
 
  {
57
 
    $polygon->addPt($x1,$y2);
58
 
    $polygon->addPt($x1+$size/2,$y2-$size/2);
59
 
    $polygon->addPt($x1,$y2-$size);
60
 
    $polygon->addPt($x1+$size, $y2-$size);
61
 
    $polygon->addPt($x1+$size, $y2);      
62
 
  }
63
 
  else
64
 
  {
65
 
    $polygon->addPt($x1,$y2);
66
 
    $polygon->addPt($x1,$y2-$size);
67
 
    $polygon->addPt($x1+$size/2,$y2-$size);
68
 
    $polygon->addPt($x1+$size, $y2-$size/2);
69
 
    $polygon->addPt($x1+$size/2, $y2);      
70
 
  }
71
 
  
72
 
  $gd->filledPolygon($polygon, $bg);
73
 
  $gd->polygon($polygon,$fg);
74
 
 
75
 
  my $text = defined $self->option('text') ? $self->option('text') : $self->default_text();
76
 
 
77
 
  if ($text)
78
 
  {
79
 
    my $text_pad_x = defined $self->option('text_pad_x') ? $self->option('text_pad_x') : $self->default_text_pad_x();
80
 
    my $text_pad_y = defined $self->option('text_pad_y') ? $self->option('text_pad_y') : $self->default_text_pad_y();
81
 
    my $font = $self->option('labelfont') || $self->font;
82
 
    $gd->string($font, $x1+$text_pad_x, $y2-$size-$text_pad_y-$font->height, $text, $fg);
83
 
    
84
 
  }
85
 
  
86
 
}
87
 
 
88
 
 
89
 
1;
90
 
 
91
 
__END__
92
 
 
93
 
=head1 NAME
94
 
 
95
 
Bio::Graphics::Glyph::pentagram - The "pentagram" 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 draws a pentagram with the sharp angle pointing right
104
 
or,if the 'inverted' option is set to 1, an "inverted" pentagram
105
 
(with the sharp angle pointing inwards, not outwards).
106
 
There may be an optional text above the glyph.
107
 
 
108
 
=head2 OPTIONS
109
 
 
110
 
In addition to the common options, the following glyph-specific
111
 
options are recognized:
112
 
 
113
 
  Option      Description                  Default
114
 
  ------      -----------                  -------
115
 
 
116
 
  -size       Width and height of the       20
117
 
              glyph
118
 
 
119
 
  -text       Text to show                  none
120
 
 
121
 
  -text_pad_x Number of pixels between        0
122
 
              the left edge of the glyph
123
 
              and the start of text
124
 
 
125
 
  -text_pad_x Number of pixels between        3
126
 
              the pentagram
127
 
              and the text
128
 
 
129
 
=head1 BUGS
130
 
 
131
 
Please report them.
132
 
 
133
 
=head1 SEE ALSO
134
 
 
135
 
L<Bio::Graphics::Panel>,
136
 
L<Bio::Graphics::Glyph>,
137
 
L<Bio::Graphics::Glyph::arrow>,
138
 
L<Bio::Graphics::Glyph::cds>,
139
 
L<Bio::Graphics::Glyph::crossbox>,
140
 
L<Bio::Graphics::Glyph::diamond>,
141
 
L<Bio::Graphics::Glyph::dna>,
142
 
L<Bio::Graphics::Glyph::dot>,
143
 
L<Bio::Graphics::Glyph::ellipse>,
144
 
L<Bio::Graphics::Glyph::extending_arrow>,
145
 
L<Bio::Graphics::Glyph::generic>,
146
 
L<Bio::Graphics::Glyph::graded_segments>,
147
 
L<Bio::Graphics::Glyph::heterogeneous_segments>,
148
 
L<Bio::Graphics::Glyph::line>,
149
 
L<Bio::Graphics::Glyph::pinsertion>,
150
 
L<Bio::Graphics::Glyph::primers>,
151
 
L<Bio::Graphics::Glyph::rndrect>,
152
 
L<Bio::Graphics::Glyph::segments>,
153
 
L<Bio::Graphics::Glyph::ruler_arrow>,
154
 
L<Bio::Graphics::Glyph::toomany>,
155
 
L<Bio::Graphics::Glyph::transcript>,
156
 
L<Bio::Graphics::Glyph::transcript2>,
157
 
L<Bio::Graphics::Glyph::translation>,
158
 
L<Bio::Graphics::Glyph::triangle>,
159
 
L<Bio::DB::GFF>,
160
 
L<Bio::SeqI>,
161
 
L<Bio::SeqFeatureI>,
162
 
L<Bio::Das>,
163
 
L<GD>
164
 
 
165
 
=head1 AUTHOR
166
 
 
167
 
Vsevolod (Simon) Ilyushchenko E<lt>simonf@cshl.eduE<gt>.
168
 
 
169
 
Copyright (c) 2004 Cold Spring Harbor Laboratory
170
 
 
171
 
This library is free software; you can redistribute it and/or modify
172
 
it under the same terms as Perl itself.  See DISCLAIMER.txt for
173
 
disclaimers of warranty.
174
 
 
175
 
=cut