Method: Rubyvis::Layout::Tree#first_walk

Defined in:
lib/rubyvis/layout/tree.rb

#first_walk(v) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rubyvis/layout/tree.rb', line 70

def first_walk(v)
  l,r,a=nil,nil,nil
  if (!v.first_child)
    l= v.previous_sibling
    v.prelim = l.prelim + distance(v.depth, true)  if l
  else    
    l = v.first_child
    r = v.last_child
    a = l # default ancestor
    v.each_child {|c| 
      first_walk(c)
      a = apportion(c, a)
    }
    execute_shifts(v)
    midpoint = 0.5 * (l.prelim + r.prelim)
    l = v.previous_sibling
    if l
      v.prelim = l.prelim + distance(v.depth, true)
      v.mod = v.prelim - midpoint
    else
      v.prelim = midpoint
    end
  end
end