Class: Lutaml::Xsd::Spa::Svg::Layouts::TreeLayout
- Inherits:
-
Lutaml::Xsd::Spa::Svg::LayoutEngine
- Object
- Lutaml::Xsd::Spa::Svg::LayoutEngine
- Lutaml::Xsd::Spa::Svg::Layouts::TreeLayout
- Defined in:
- lib/lutaml/xsd/spa/svg/layouts/tree_layout.rb
Overview
Tree-based layout - organizes components hierarchically
Instance Attribute Summary
Attributes inherited from Lutaml::Xsd::Spa::Svg::LayoutEngine
Instance Method Summary collapse
Methods inherited from Lutaml::Xsd::Spa::Svg::LayoutEngine
Constructor Details
This class inherits a constructor from Lutaml::Xsd::Spa::Svg::LayoutEngine
Instance Method Details
#calculate(component_data, component_type) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lutaml/xsd/spa/svg/layouts/tree_layout.rb', line 12 def calculate(component_data, component_type) nodes = [] connections = [] start_x = 20 start_y = 20 # Build tree structure tree = build_tree(component_data, component_type) # Calculate positions position_tree(tree, start_x, start_y, nodes, connections) # Calculate dimensions max_x = nodes.map { |n| n.box.x + n.box.width }.max || 200 max_y = nodes.map { |n| n.box.y + n.box.height }.max || 100 LayoutResult.new( nodes, connections, Geometry::Box.new(0, 0, max_x + 20, max_y + 20), ) end |