<commit_before>package Bio::EnsEMBL::Renderer::imagemap;
use strict;
use Bio::EnsEMBL::Renderer;
use vars qw(@ISA);
@ISA = qw(Bio::EnsEMBL::Renderer);

#########
# imagemaps are basically strings, so initialise the canvas with ""
# imagemaps also aren't too fussed about width & height boundaries
#
sub init_canvas {
    my ($self, $config, $im_width, $im_height) = @_;
    $self->canvas("");
    $self->{'show_zmenus'} = defined( $config->get("_settings","opt_zmenus") ) ? $config->get("_settings","opt_zmenus") : 1;
 #   print STDERR "XX: $self->{'show_zmenus'}\n";
}

sub add_canvas_frame {
    my ($self, $config, $im_width, $im_height) = @_;
	return(); # no-op!	
}

sub render_Rect {
    my ($self, $glyph) = @_;
    my $href = $self->_getHref($glyph);
	return unless(defined $href);

    my $x1 = int( $glyph->pixelx() );
    my $x2 = int( $glyph->pixelx() + $glyph->pixelwidth() );
    my $y1 = int( $glyph->pixely() );
    my $y2 = int( $glyph->pixely() + $glyph->pixelheight() );

    $x1 = 0 if($x1<0);
    $x2 = 0 if($x2<0);
    $y1 = 0 if($y1<0);
    $y2 = 0 if($y2<0);

    $y2 += 1;
    $x2 += 1;

    $self->{'canvas'} = qq(<area coords="$x1 $y1 $x2 $y2"$href>\n).$self->{'canvas'} if(defined $href);

}

sub render_Text {
    my ($self, $glyph) = @_;
	$self->render_Rect($glyph);
}

sub render_Circle {
}

sub render_Ellipse {
}

sub render_Intron {
}

sub render_Poly {
    my ($self, $glyph) = @_;
	my $href = $self->_getHref( $glyph );
	return unless(defined $href);
    my $pointslist = join ' ',map { int } @{$glyph->pixelpoints()};
    $self->{'canvas'} = qq(<area shape="poly" coords="$pointslist"$href>\n).$self->{'canvas'} ; 
}

sub render_Space {
    my ($self, $glyph) = @_;
    return $self->render_Rect($glyph);
}

sub render_Composite {
    my ($self, $glyph) = @_;
    $self->render_Rect($glyph);
    $self->SUPER::render_Composite($glyph);
}

sub render_Line {
}

sub _getHref {
    my ($self, $glyph) = @_;
	my $onmouseover = $glyph->onmouseover();
       $onmouseover = (defined $onmouseover) ? qq( onmouseover="$onmouseover") : "";
    my $onmouseout = $glyph->onmouseout();
       $onmouseout = (defined $onmouseout) ? qq( onmouseout="$onmouseout") : "";
    my $href = $glyph->href();
       $href = qq( href="$href") if(defined $href);
    my $alt = $glyph->id();
       $alt = (defined $alt) ? qq( alt="$alt")  : "";

    ######### zmenus will override existing href, alt, onmouseover & onmouseout attributes
    if($self->{'show_zmenus'}==1) {<commit_msg>no longer bubbles down zmenu<commit_after>package Bio::EnsEMBL::Renderer::imagemap;
use strict;
use Bio::EnsEMBL::Renderer;
use vars qw(@ISA);
@ISA = qw(Bio::EnsEMBL::Renderer);

#########
# imagemaps are basically strings, so initialise the canvas with ""
# imagemaps also aren't too fussed about width & height boundaries
#
sub init_canvas {
    my ($self, $config, $im_width, $im_height) = @_;
    $self->canvas("");
    $self->{'show_zmenus'} = defined( $config->get("_settings","opt_zmenus") ) ? $config->get("_settings","opt_zmenus") : 1;
 #   print STDERR "XX: $self->{'show_zmenus'}\n";
}

sub add_canvas_frame {
    my ($self, $config, $im_width, $im_height) = @_;
	return(); # no-op!	
}

sub render_Rect {
    my ($self, $glyph) = @_;
    my $href = $self->_getHref($glyph);
	return unless(defined $href);

    my $x1 = int( $glyph->pixelx() );
    my $x2 = int( $glyph->pixelx() + $glyph->pixelwidth() );
    my $y1 = int( $glyph->pixely() );
    my $y2 = int( $glyph->pixely() + $glyph->pixelheight() );

    $x1 = 0 if($x1<0);
    $x2 = 0 if($x2<0);
    $y1 = 0 if($y1<0);
    $y2 = 0 if($y2<0);

    $y2 += 1;
    $x2 += 1;

    $self->{'canvas'} = qq(<area coords="$x1 $y1 $x2 $y2"$href>\n).$self->{'canvas'} if(defined $href);

}

sub render_Text {
    my ($self, $glyph) = @_;
	$self->render_Rect($glyph);
}

sub render_Circle {
}

sub render_Ellipse {
}

sub render_Intron {
}

sub render_Poly {
    my ($self, $glyph) = @_;
	my $href = $self->_getHref( $glyph );
	return unless(defined $href);
    my $pointslist = join ' ',map { int } @{$glyph->pixelpoints()};
    $self->{'canvas'} = qq(<area shape="poly" coords="$pointslist"$href>\n).$self->{'canvas'} ; 
}

sub render_Space {
    my ($self, $glyph) = @_;
    return $self->render_Rect($glyph);
}

sub render_Composite {
    my ($self, $glyph) = @_;
    $self->render_Rect($glyph);
#    $self->SUPER::render_Composite($glyph);
}

sub render_Line {
}

sub _getHref {
    my ($self, $glyph) = @_;
	my $onmouseover = $glyph->onmouseover();
       $onmouseover = (defined $onmouseover) ? qq( onmouseover="$onmouseover") : "";
    my $onmouseout = $glyph->onmouseout();
       $onmouseout = (defined $onmouseout) ? qq( onmouseout="$onmouseout") : "";
    my $href = $glyph->href();
       $href = qq( href="$href") if(defined $href);
    my $alt = $glyph->id();
       $alt = (defined $alt) ? qq( alt="$alt")  : "";

    ######### zmenus will override existing href, alt, onmouseover & onmouseout attributes
    if($self->{'show_zmenus'}==1) {
{'fraction_non_alphanumeric': 0.21594087095485417, 'fraction_numerical': 0.011985617259288853, 'mean_word_length': 3.7822349570200573, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139561', 'n_tokens_mistral': 2012, 'n_tokens_neox': 1914, 'n_words': 414}