4 CXGN::Cview::Marker::Physical - a class to draw markers representing physical associations to maps, such as BACs or contigs.
8 CXGN::Cview::Marker::Physical inherits from L<CXGN::Cview::Marker>.
10 my $m = CXGN::Cview::Marker::Physical->new();
15 Lukas Mueller (lam87@cornell.edu)
19 This class implements the following functions:
24 use CXGN
::Cview
::Marker
;
25 use CXGN
::Cview
::Label
::Physical
;
27 package CXGN
::Cview
::Marker
::Physical
;
29 use base qw
/ CXGN::Cview::Marker::RangeMarker /;
34 Arguments: A CXGN::Cview::Chromosome object (or subclassed object)
35 to which this marker belongs.
41 my $chromosome = shift;
42 my $self = $class -> SUPER
::new
($chromosome);
44 my $bac_label = CXGN
::Cview
::Label
::Physical
->new();
46 $self->set_label($bac_label);
47 $self->set_label_side("right");
48 $self->set_hilite_chr_region(0);
49 $self->set_region_hilite_color(100, 100, 150);
50 $self->set_north_range(1);
51 $self->set_south_range(1);
59 # calculate the pos in pixels of the northern range limit
61 my $north_pixels = $self->get_chromosome()->mapunits2pixels($self->get_offset()) + $self->get_chromosome()->get_vertical_offset() - $self->get_chromosome()->mapunits2pixels($self->get_north_range());
63 # determine the pixels of the southern limit
65 my $south_pixels = $self->get_chromosome()->mapunits2pixels($self->get_offset()) + $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_south_range());
66 # print STDERR "cM = ".$self->get_north_range().", pixels= $north_pixels\n";
67 # print STDERR "cM = ".$self->get_south_range().", pixels= $south_pixels\n";
69 $self->get_label()->set_north_position($north_pixels);
70 $self->get_label()->set_south_position($south_pixels);
72 #if ($self->get_url()) { $self->get_label()->set_url($self->get_url()); }
74 my $stacking = $self->get_label()->get_stacking_height() * $self->get_label()->get_stacking_level();
77 if ($self->is_visible()) {
78 if ($self->get_label_side() eq "right") {
79 my $x = $self->get_chromosome()->get_horizontal_offset()
80 +int($self->get_chromosome()->get_width()/2)
83 my $label_horizontal_position = $x + 50;
84 if ($stacking > 200) {
85 $label_horizontal_position=$x-100;
86 $self->get_label()->align_right();
88 $self->get_label()->set_horizontal_offset($label_horizontal_position);
89 $self->get_label()->set_reference_point($x, int($north_pixels+$south_pixels)/2);
92 elsif ($self->get_label_side() eq "left") {
93 my $x = $self->get_chromosome()->get_horizontal_offset()-int($self->get_chromosome()->get_width()/2) - $self->get_label()->get_stacking_height()*($self->get_label()->get_stacking_level());
95 $self->get_label()->set_horizontal_offset($x-50);
96 $self->get_label()->set_reference_point($x, int($north_pixels+$south_pixels)/2);
100 die "[RangeMarker.pm] label_side can either be right or left. Sorry.";
102 if ($self->is_label_visible()) {
103 $self->get_label()->render($image);
106 if ($self->get_hilite_chr_region()) {
107 $self->hilite_chr_region($image);
109 $self->draw_tick($image);
115 =head2 accessors set_region_hilite_color(), get_region_hilite_color()
126 sub get_region_hilite_color
{
128 return @
{$self->{region_hilite_color
}};
131 sub set_region_hilite_color
{
133 @
{$self->{region_hilite_color
}}= (shift, shift, shift);
136 =head2 accessors set_hilite_chr_region(), get_hilite_chr_region()
147 sub get_hilite_chr_region
{
149 return $self->{hilite_chr_region
};
152 sub set_hilite_chr_region
{
154 $self->{hilite_chr_region
}=shift;
160 my $color = $image -> colorResolve
($self->get_color());
162 my ($x, $north_y, $y, $south_y) = $self->get_enclosing_rect();
164 if ($self->get_show_tick()) {
165 $image -> rectangle
($x, $north_y, $y, $south_y, $color);
171 my $coords = join ",", ($self->get_enclosing_rect());
174 my $s= '<area shape="rect" coords="'.$coords.'" href="'.$self->get_url().'" alt="'.$self->get_marker_name().'" title="'.$self->get_tooltip().'" />';
175 #print STDERR "Imagemap = $s\n";
180 sub get_enclosing_rect
{
182 my $halfwidth = int($self->get_chromosome->get_width/2);
183 my $north_y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset()-$self->get_north_range());
185 my $south_y = $self->get_chromosome()->get_vertical_offset() + $self->get_chromosome()->mapunits2pixels($self->get_offset()+$self->get_south_range());
187 my $x = $self->get_chromosome()->get_horizontal_offset()+$halfwidth+$self->get_label()->get_stacking_height()*$self->get_label()->get_stacking_level();
188 return ($x-1, $north_y, $x+1, $south_y);