Class: DrawioDsl::LayoutEngine

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

Overview

The layout engine is responsible for laying out the elements on the page.

The layout engine can automatically place elements on the page.

It will keep track of layout boundaries, current position and flow direction. Elements will be placed on the page in the order they are added. Row/column flow objects will hold information about horizontal and vertical element padding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ LayoutEngine

Returns a new instance of LayoutEngine.



17
18
19
# File 'lib/drawio_dsl/layout_engine.rb', line 17

def initialize(page)
  @page = page
end

Instance Attribute Details

#current_layoutObject (readonly)

Returns the value of attribute current_layout.



15
16
17
# File 'lib/drawio_dsl/layout_engine.rb', line 15

def current_layout
  @current_layout
end

#current_pageObject (readonly)

Returns the value of attribute current_page.



14
15
16
# File 'lib/drawio_dsl/layout_engine.rb', line 14

def current_page
  @current_page
end

#pageObject (readonly)

Returns the value of attribute page.



12
13
14
# File 'lib/drawio_dsl/layout_engine.rb', line 12

def page
  @page
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
# File 'lib/drawio_dsl/layout_engine.rb', line 21

def call
  page.position_x = page.margin_left
  page.position_y = page.margin_top

  page.nodes.all.each do |node|
    traverse_node(node)
  end
end