Class: Sankey::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/generator.rb

Constant Summary collapse

ProcessWidth =
40
ProcessLayerStep =
100
ProcessSideStep =
50
Margin =
5
InputReagentsStep =
20
OutputReagentsStep =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGenerator

Returns a new instance of Generator.



16
17
18
# File 'lib/generator.rb', line 16

def initialize
  @processes = []
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/generator.rb', line 7

def data
  @data
end

#processesObject (readonly)

Returns the value of attribute processes.



7
8
9
# File 'lib/generator.rb', line 7

def processes
  @processes
end

Instance Method Details

#go!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generator.rb', line 20

def go!
  @processes_vertices = {}
  @drawn_reagents = []
  @vertices = []
  @input_reagent_offset = Margin
  @below_next_process_offset = {}
  @process_input_offset = {}
  @process_output_left_offset = {}
  @process_output_right_offset = {}
  get_max_distances_to_processes
  to_be_drawn = []
  input_reagents.each { |r| to_be_drawn.push r }
  until to_be_drawn.empty? do
    STDERR.puts "to draw"
    to_be_drawn.each { |r| STDERR.puts "  " + r.to_s + " " + r.name }
    not_drawn = []
    to_be_drawn.each { |r| not_drawn += recursively_draw r }
    to_be_drawn = not_drawn.uniq
  end
  make_coordinates_positive
  w, h = get_size
  @data = ImageData.new @vertices, w, h
end