Class: Lutaml::Ea::Diagram::PathBuilder

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/lutaml/ea/diagram/path_builder.rb

Overview

Path builder for connector rendering

This class calculates SVG path data for connectors between diagram elements, supporting various connector types and routing algorithms.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#parse_ea_geometry, #parse_geometry_offsets

Constructor Details

#initialize(connector, source_element = nil, target_element = nil) ⇒ PathBuilder

Returns a new instance of PathBuilder.



18
19
20
21
22
# File 'lib/lutaml/ea/diagram/path_builder.rb', line 18

def initialize(connector, source_element = nil, target_element = nil)
  @connector = connector
  @source_element = source_element
  @target_element = target_element
end

Instance Attribute Details

#connectorObject (readonly)

Returns the value of attribute connector.



16
17
18
# File 'lib/lutaml/ea/diagram/path_builder.rb', line 16

def connector
  @connector
end

#source_elementObject (readonly)

Returns the value of attribute source_element.



16
17
18
# File 'lib/lutaml/ea/diagram/path_builder.rb', line 16

def source_element
  @source_element
end

#target_elementObject (readonly)

Returns the value of attribute target_element.



16
17
18
# File 'lib/lutaml/ea/diagram/path_builder.rb', line 16

def target_element
  @target_element
end

Instance Method Details

#build_pathString

Build SVG path data for the connector

Returns:

  • (String)

    SVG path data



26
27
28
29
30
31
32
33
34
35
# File 'lib/lutaml/ea/diagram/path_builder.rb', line 26

def build_path
  return straight_path if simple_connector?
  return waypoint_path if geometry_has_waypoints?

  case connector[:routing_type]
  when "orthogonal" then orthogonal_path
  when "bezier" then bezier_path
  else manhattan_path
  end
end