Merge pull request #5 from solgenomics/topic/fix_il_maps
[cview.git] / lib / CXGN / Cview / Label / RangeLabel.pm
blobb1fd8179461cfc1197afddab5b4f7a3ba7b268bd
2 use strict;
4 use CXGN::Cview::Label;
6 package CXGN::Cview::Label::RangeLabel;
8 use base qw / CXGN::Cview::Label /;
11 =head2 function new()
13 Synopsis:
14 Arguments:
15 Returns:
16 Side effects:
17 Description:
19 =cut
21 sub new {
22 my $class = shift;
23 my $self = $class->SUPER::new(@_);
25 # set some interesting defaults
27 $self->set_align_side("left");
28 $self->set_label_spacer(20);
29 $self->set_vertical_stacking_spacing(0);
31 return $self;
35 =head2 function render_line()
37 Synopsis:
38 Arguments:
39 Returns:
40 Side effects:
41 Description:
43 =cut
45 sub render_line {
46 my $self = shift;
47 my $image = shift;
49 my $line_color = $image->colorResolve($self->get_line_color());
51 $image -> setAntiAliased($line_color);
52 my $width = 0;
54 # calculate the point that the line should connect to
55 # on the label
57 my ($x, $y, $a, $b) = $self->get_enclosing_rect();
58 my ($connection_x, $connection_y) = (0, 0);
60 if ($self->get_align_side() eq "right") {
62 $connection_x = $a;
63 $connection_y = $y + CXGN::Cview::ImageObject::round(($b - $y ) /2);
65 my $horizontal = ($self->get_reference_point())[0]-$self->get_stacking_level()*$self->get_stacking_height();
67 $image->line($connection_x, $connection_y,
68 $horizontal, ($self->get_reference_point())[1],
69 $line_color
70 #$image->colorResolve(255,0,0)
73 # draw the lines for the northern range
75 $image->line($horizontal, $self->get_north_position(),
76 $horizontal, $self->get_south_position(), $line_color);
78 # northern tick
80 $image->line($horizontal, $self->get_north_position(), $horizontal+$self->get_stacking_level()* $self->get_stacking_height(), $self->get_north_position(), $line_color);
82 # draw the line for the southern range tick
84 $image->line($horizontal, $self->get_south_position(), $horizontal + $self->get_stacking_level()*$self->get_stacking_height(), $self->get_south_position(), $line_color);
87 if ($self->get_align_side() eq "left") {
89 $connection_x = $x;
90 $connection_y = $y + CXGN::Cview::ImageObject::round(($b - $y)/2);
92 my $horizontal = ($self->get_reference_point())[0]+$self->get_stacking_level()*$self->get_stacking_height();
94 # draw the line from the text box to the chromosome
96 $image->line($connection_x, $connection_y,
97 $horizontal, ($self->get_reference_point())[1], $line_color );
99 # draw the line of the region
101 $image->line($horizontal, $self->get_north_position(), $horizontal, $self->get_south_position(), $line_color);
103 # draw the lines for the northern range
105 $image->line($horizontal, $self->get_north_position(), $horizontal-$self->get_stacking_level()*$self->get_stacking_height(), $self->get_north_position(), $line_color);
107 # draw the line for the southern range
109 $image->line($horizontal, $self->get_south_position(), $horizontal-$self->get_stacking_level()*$self->get_stacking_height(), $self->get_south_position(), $line_color);
111 #$image->rectangle($self->get_enclosing_rect(), $line_color);
114 =head2 function get_stacking_height
116 Synopsis:
117 Arguments:
118 Returns:
119 Side effects:
120 Description:
122 =cut
124 sub get_stacking_height {
125 my $self=shift;
126 return $self->{stacking_height} || 3;
129 =head2 function set_stacking_height
131 Synopsis:
132 Arguments:
133 Returns:
134 Side effects:
135 Description:
137 =cut
139 sub set_stacking_height {
140 my $self=shift;
141 $self->{stacking_height}=shift;