# File lib/bio/graphics/feature.rb, line 115
  def draw(panel_destination)
    # First we want to set some parameters of Track at draw-time instead of
    # at initialization time
    @glyph = @glyph.nil? ? @track.glyph : @glyph
    
    @colour = @colour.nil? ? @track.colour : @colour
    @colour = @colour.respond_to?(:call) ? @colour.call(self) : @colour
    
    feature_context = Cairo::Context.new(panel_destination)

    # Move the feature drawing down based on track it's in and the number
    # of times is has to be bumped
    row = self.find_row

    @vertical_offset = self.track.vertical_offset + Bio::Graphics::TRACK_HEADER_HEIGHT + Bio::Graphics::FEATURE_V_DISTANCE
    @vertical_offset += (Bio::Graphics::FEATURE_HEIGHT+Bio::Graphics::FEATURE_V_DISTANCE)*row
    
    feature_context.translate(0, @vertical_offset)

    # Let the subfeatures do the drawing.
    @subfeatures.each do |subfeature|
      subfeature.draw(feature_context)
    end

    @left_pixel_of_feature = @left_pixel_of_subfeatures.min
    @right_pixel_of_feature = @right_pixel_of_subfeatures.max
    
    # Add the label for the feature
    if @track.show_label
      pango_layout = feature_context.create_pango_layout
      pango_layout.text = @label
      fdesc = Pango::FontDescription.new('Sans Serif')
      fdesc.set_size(8 * Pango::SCALE)
      pango_layout.font_description = fdesc

      text_range = @start.floor..(@start.floor + pango_layout.pixel_size[0]*@track.panel.rescale_factor)
      if @track.grid[row+1].nil?
        @track.grid[row+1] = Array.new
      end
      @track.grid[row].push(text_range)
      @track.grid[row+1].push(text_range)
      feature_context.move_to(@left_pixel_of_feature, Bio::Graphics::TRACK_HEADER_HEIGHT)
      feature_context.set_source_rgb(0,0,0)
      feature_context.show_pango_layout(pango_layout)
#      feature_context.set_source_rgb(@colour)
    end


    # And add the region to the image map
    # Comment: we have to add the vertical_offset and TRACK_HEADER_HEIGHT!
    @track.panel.image_map.add_element(@left_pixel_of_feature,
                                       @vertical_offset,
                                       @right_pixel_of_feature,
                                       @vertical_offset + Bio::Graphics::FEATURE_HEIGHT,
                                       @link
                                       )
  end