AcePerl
view release on metacpan or search on metacpan
Ace/Graphics/Glyph/group.pm view on Meta::CPAN
# should have done a formal container/contained relationship
# in order to accomodate groups
sub bump {
my $self = shift;
my @glyphs = $self->members;
my %occupied;
for my $g (sort { $a->left <=> $b->left} @glyphs) {
my $pos = 0;
for my $y (sort {$a <=> $b} keys %occupied) {
my $previous = $occupied{$y};
last if $previous->right + 2 < $g->left; # no collision at this position
$pos += $previous->height + 2; # collision, so bump
}
$occupied{$pos} = $g; # remember where we are
$g->move(0,$pos);
}
return sort { $a->top <=> $b->top } @glyphs;
}
# override draw method - draw individual subparts
sub draw {
my $self = shift;
my $gd = shift;
my ($left,$top) = @_;
# bail out if this isn't the right kind of feature
my @parts = $self->members;
# three pixels of black, three pixels of transparent
my $black = 1;
my ($x1,$y1,$x2,$y2) = $parts[0]->calculate_boundaries($left,$top);
my $center1 = ($y2 + $y1)/2;
$gd->setStyle($black,$black,gdTransparent,gdTransparent,);
for (my $i=0;$i<@parts-1;$i++) {
my ($x1,$y1,$x2,$y2) = $parts[$i]->calculate_boundaries($left,$top);
my ($x3,$y3,$x4,$y4) = $parts[$i+1]->calculate_boundaries($left,$top);
next unless ($x3 - $x1) >= 3;
$gd->line($x2+1,($y1+$y2)/2,$x3-1,($y3+$y4)/2,gdStyled);
}
}
1;
=head1 NAME
Ace::Graphics::Glyph::group - The group glyph
=head1 SYNOPSIS
none
=head1 DESCRIPTION
This is an internal glyph type, used by Ace::Graphics::Track for
moving sets of glyphs around as a group. This glyph is created
automatically when processing a set of features passed to
Ace::Graphics::Panel->new as an array ref.
=head2 OPTIONS
In addition to the common options, the following glyph-specific
options are recognized:
Option Description Default
------ ----------- -------
-connect Whether to connect members false
of the group by a dashed
line.
=head1 BUGS
Please report them.
=head1 SEE ALSO
L<Ace::Sequence>, L<Ace::Sequence::Feature>, L<Ace::Graphics::Panel>,
L<Ace::Graphics::Track>, L<Ace::Graphics::Glyph::anchored_arrow>,
L<Ace::Graphics::Glyph::arrow>,
L<Ace::Graphics::Glyph::box>,
L<Ace::Graphics::Glyph::primers>,
L<Ace::Graphics::Glyph::segments>,
L<Ace::Graphics::Glyph::toomany>,
L<Ace::Graphics::Glyph::transcript>,
=head1 AUTHOR
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2001 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. See DISCLAIMER.txt for
disclaimers of warranty.
=cut
( run in 0.518 second using v1.01-cache-2.11-cpan-39bf76dae61 )