Merge pull request #5 from solgenomics/topic/fix_il_maps
[cview.git] / lib / CXGN / Cview / ChrLink.pm
blobc9206f157560526327018e9420453815a4d339aa
3 =head1 NAME
5 CXGN::Cview::ChrLink - an class for drawing chromosome relationships.
7 =head1 DESCRIPTION
9 Inherits from L<CXGN::Cview::ImageObject>.
11 =head1 SEE ALSO
13 See also the documentation in L<CXGN::Cview>.
15 =head1 AUTHOR(S)
17 Lukas Mueller (lam87@cornell.edu)
19 =head1 FUNCTIONS
22 =cut
26 use strict;
28 use CXGN::Cview::ImageObject;
30 package CXGN::Cview::ChrLink;
32 use base qw/CXGN::Cview::ImageObject/;
34 use GD;
36 sub new {
37 my $class = shift;
38 my $args = {};
39 my $self = bless $args, $class;
41 $self->{chr1}=shift;
42 $self->{cM1} = shift;
43 $self->{chr2}=shift;
44 $self->{cM2} = shift;
45 $self->{marker_name}=shift;
47 # define default color
48 $self -> set_color(100, 100, 100);
49 return $self;
52 sub set_color {
53 my $self = shift;
54 $self->{color}[0]=shift;
55 $self->{color}[1]=shift;
56 $self->{color}[2]=shift;
59 sub render {
60 my $self = shift;
61 my $image = shift;
63 # draw only of both markers are visible...
64 if ($self->{chr1}->is_visible($self->{cM1}) && $self->{chr2}->is_visible($self->{cM2})) {
65 my $sign = (($self->{chr2}->get_horizontal_offset()) <=> ($self->{chr1}->get_horizontal_offset()));
66 my $x1 = $self->{chr1}->get_horizontal_offset() + $sign*($self->{chr1}->get_width()/2);
67 my $y1 = $self->{chr1}->mapunits2pixels($self->{cM1});
68 my $x2 = $self->{chr2}->get_horizontal_offset() - $sign*($self->{chr2}-> get_width()/2);
69 my $y2 = $self->{chr2}->mapunits2pixels($self->{cM2});
71 #print STDERR "link color: $self->{color}[0], $self->{color}[1], $self->{color}[2]\n";
72 my $color = $image -> colorResolve($self->{color}[0], $self->{color}[1], $self->{color}[2]);
73 $image->setAntiAliased($color);
74 $image -> line($x1, $self->{chr1}->get_vertical_offset()+$y1, $x2, $self->{chr2}->get_vertical_offset()+$y2, gdAntiAliased);
76 else {
77 #print STDERR "Not rendering link because not visible. chr1 cM: $self->{cM1} chr2 cM: $self->{cM2}\n";
82 =head2 get_marker_name(), set_marker_name()
84 Usage:
85 Desc:
86 Ret:
87 Args:
88 Side Effects:
89 Example:
91 =cut
93 sub get_marker_name {
94 my $self=shift;
95 return $self->{marker_name};
99 sub set_marker_name {
100 my $self=shift;
101 $self->{marker_name}=shift;