<commit_before>=head1 LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut

package EnsEMBL::Draw::Renderer;
use EnsEMBL::Draw::Glyph::Poly;
use EnsEMBL::Draw::Glyph::Rect;
use strict;
use Time::HiRes qw(time);

our $patterns = {
  # south-west - north-east thin line
  'hatch_ne' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 3, 3, 0 ]
    ]
  },
  # south-east - north-west thin line
  'hatch_nw' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 3, 3 ]
    ]
  },
  # vertical 1px lines
  'hatch_vert' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 0, 3 ],
      [ 2, 0, 2, 3 ]
    ]
  },
  # hotizontal 1px lines
  'hatch_hori' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 3, 0 ],
      [ 0, 2, 3, 2 ]
     ]
  },
  # sw-ne (school tie!) v-thick lines
  'hatch_thick' => {
    'size' => [ 12, 12 ],
    'polys' => [
      [ [ 0, 11], [ 5,11 ], [11, 5 ], [ 11, 0 ] ],
      [ [ 0, 0 ], [ 0, 4 ], [ 4, 0 ] ],
    ],
  },
  'hatch_really_thick' => {
    'size' => [ 24, 24 ],
    'polys' => [
      [ [ 1, 0],[23, 0],[ 0,23],[ 0, 1] ],
      [ [ 2,23],[23, 2],[23,23] ],
    ],
  },
  'hatch_thick_sw' => {
    'size' => [ 12, 12 ],
    'polys' => [
      [ [ 11, 11], [ 6, 11 ], [ 0, 5 ], [ 0, 0 ] ],
      [ [ 11, 0 ], [ 11, 4 ], [ 7, 0 ] ],
    ],
  },

  'pin_ne'   => { 'size' => [8,8], 'lines' => [[0,7,7,0]] },
  'pin_sw'   => { 'size' => [8,8], 'lines' => [[0,0,7,7]] },
  'pin_hori' => { 'size' => [8,8], 'lines' => [[0,2,7,2],[0,6,7,6]] },
  'pin_vert' => { 'size' => [8,8], 'lines' => [[2,0,2,7],[6,0,6,7]] },
  'hash'     => { 'size' => [4,4], 'lines' => [[0,2,3,2],[2,0,2,3]] },
  'check'    => { 'size' => [6,6], 'lines' => [[0,0,5,5],[0,5,5,0]] }
};

sub new {
  my ($class, $config, $extra_spacing, $glyphsets_ref, $boxes) = @_;
  
  my $self = {
    'glyphsets'     => $glyphsets_ref,
    'canvas'        => undef,
    'colourmap'     => $config->colourmap,
    'config'        => $config,
    'extra_spacing' => $extra_spacing,
    'boxes'         => $boxes || {},
    'spacing'       => $config->get_parameter('spacing') || 2,
    'margin'        => $config->get_parameter('margin') || 5,
    'sf'            => $config->get_parameter('sf') || 1
  };
  
  bless($self, $class);
  
  $self->render;
  
  return $self;
}

sub config {
  my ($self, $config) = @_;
  $self->{'config'} = $config if $config;
  return $self->{'config'};
}

sub render {
  my $self = shift;
  
  my $config = $self->{'config'};
  
  # now set all our labels up with scaled negative coords and while we're looping, tot up the image height
  my $spacing   = $self->{'spacing'};
  my $im_height = $self->{'margin'} * 2 - $spacing;
  
  for my $glyphset (@{$self->{'glyphsets'}}) {
    next if scalar @{$glyphset->{'glyphs'}} == 0 || 
            scalar @{$glyphset->{'glyphs'}} == 1 && ref($glyphset->{'glyphs'}[0]) =~ /Diagnostic/;
    
    my $fntheight = defined $glyphset->label ? $config->texthelper->height($glyphset->label->font) : 0;
    my $gstheight = $glyphset->height; + $glyphset->section_height;<commit_msg>Fix weird typo which luckily had no effect.<commit_after>=head1 LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut

package EnsEMBL::Draw::Renderer;
use EnsEMBL::Draw::Glyph::Poly;
use EnsEMBL::Draw::Glyph::Rect;
use strict;
use Time::HiRes qw(time);

our $patterns = {
  # south-west - north-east thin line
  'hatch_ne' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 3, 3, 0 ]
    ]
  },
  # south-east - north-west thin line
  'hatch_nw' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 3, 3 ]
    ]
  },
  # vertical 1px lines
  'hatch_vert' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 0, 3 ],
      [ 2, 0, 2, 3 ]
    ]
  },
  # hotizontal 1px lines
  'hatch_hori' => {
    'size' => [ 4, 4 ],
    'lines' => [
      [ 0, 0, 3, 0 ],
      [ 0, 2, 3, 2 ]
     ]
  },
  # sw-ne (school tie!) v-thick lines
  'hatch_thick' => {
    'size' => [ 12, 12 ],
    'polys' => [
      [ [ 0, 11], [ 5,11 ], [11, 5 ], [ 11, 0 ] ],
      [ [ 0, 0 ], [ 0, 4 ], [ 4, 0 ] ],
    ],
  },
  'hatch_really_thick' => {
    'size' => [ 24, 24 ],
    'polys' => [
      [ [ 1, 0],[23, 0],[ 0,23],[ 0, 1] ],
      [ [ 2,23],[23, 2],[23,23] ],
    ],
  },
  'hatch_thick_sw' => {
    'size' => [ 12, 12 ],
    'polys' => [
      [ [ 11, 11], [ 6, 11 ], [ 0, 5 ], [ 0, 0 ] ],
      [ [ 11, 0 ], [ 11, 4 ], [ 7, 0 ] ],
    ],
  },

  'pin_ne'   => { 'size' => [8,8], 'lines' => [[0,7,7,0]] },
  'pin_sw'   => { 'size' => [8,8], 'lines' => [[0,0,7,7]] },
  'pin_hori' => { 'size' => [8,8], 'lines' => [[0,2,7,2],[0,6,7,6]] },
  'pin_vert' => { 'size' => [8,8], 'lines' => [[2,0,2,7],[6,0,6,7]] },
  'hash'     => { 'size' => [4,4], 'lines' => [[0,2,3,2],[2,0,2,3]] },
  'check'    => { 'size' => [6,6], 'lines' => [[0,0,5,5],[0,5,5,0]] }
};

sub new {
  my ($class, $config, $extra_spacing, $glyphsets_ref, $boxes) = @_;
  
  my $self = {
    'glyphsets'     => $glyphsets_ref,
    'canvas'        => undef,
    'colourmap'     => $config->colourmap,
    'config'        => $config,
    'extra_spacing' => $extra_spacing,
    'boxes'         => $boxes || {},
    'spacing'       => $config->get_parameter('spacing') || 2,
    'margin'        => $config->get_parameter('margin') || 5,
    'sf'            => $config->get_parameter('sf') || 1
  };
  
  bless($self, $class);
  
  $self->render;
  
  return $self;
}

sub config {
  my ($self, $config) = @_;
  $self->{'config'} = $config if $config;
  return $self->{'config'};
}

sub render {
  my $self = shift;
  
  my $config = $self->{'config'};
  
  # now set all our labels up with scaled negative coords and while we're looping, tot up the image height
  my $spacing   = $self->{'spacing'};
  my $im_height = $self->{'margin'} * 2 - $spacing;
  
  for my $glyphset (@{$self->{'glyphsets'}}) {
    next if scalar @{$glyphset->{'glyphs'}} == 0 || 
            scalar @{$glyphset->{'glyphs'}} == 1 && ref($glyphset->{'glyphs'}[0]) =~ /Diagnostic/;
    
    my $fntheight = defined $glyphset->label ? $config->texthelper->height($glyphset->label->font) : 0;
    my $gstheight = $glyphset->height;
{'fraction_non_alphanumeric': 0.22094455852156059, 'fraction_numerical': 0.048186173853524986, 'mean_word_length': 2.6240079365079363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 140, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4114671', 'n_tokens_mistral': 3136, 'n_tokens_neox': 2801, 'n_words': 713}