Class: Bio::Graphics::Glyph::DirectedSpliced

Inherits:
Common
  • Object
show all
Defined in:
lib/bio/graphics/glyphs/directed_spliced.rb

Instance Attribute Summary

Attributes inherited from Common

#feature_context, #subfeature

Instance Method Summary collapse

Methods inherited from Common

#initialize, #left_pixel, #right_pixel

Constructor Details

This class inherits a constructor from Bio::Graphics::Glyph::Common

Instance Method Details

#drawObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bio/graphics/glyphs/directed_spliced.rb', line 11

def draw
  gap_starts = Array.new
  gap_stops = Array.new

  #   Start with the one with the arrow
  pixel_ranges = @subfeature.pixel_range_collection.sort_by{|pr| pr.lend}
  range_with_arrow = nil
  if @subfeature.strand == -1 # reverse strand => box with arrow is first one
    range_with_arrow = pixel_ranges.shift
    @feature_context.rectangle((range_with_arrow.lend)+Bio::Graphics::FEATURE_ARROW_LENGTH, 0, range_with_arrow.rend - range_with_arrow.lend - Bio::Graphics::FEATURE_ARROW_LENGTH, Bio::Graphics::FEATURE_HEIGHT).fill
    arrow(@feature_context,:left,range_with_arrow.lend+Bio::Graphics::FEATURE_ARROW_LENGTH, 0,Bio::Graphics::FEATURE_ARROW_LENGTH)
    @feature_context.close_path.fill
  else # forward strand => box with arrow is last one
    range_with_arrow = pixel_ranges.pop
    @feature_context.rectangle(range_with_arrow.lend, 0, range_with_arrow.rend - range_with_arrow.lend - Bio::Graphics::FEATURE_ARROW_LENGTH, Bio::Graphics::FEATURE_HEIGHT).fill
    arrow(@feature_context,:right,range_with_arrow.rend-Bio::Graphics::FEATURE_ARROW_LENGTH, 0,Bio::Graphics::FEATURE_ARROW_LENGTH)
    @feature_context.close_path.fill
  end
  gap_starts.push(range_with_arrow.rend)
  gap_stops.push(range_with_arrow.lend)

  #   And then add the others
  draw_spliced(@feature_context, pixel_ranges, gap_starts, gap_stops)

end