Class: Ea::Svg::ConnectorRouter

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/svg/connector_router.rb

Constant Summary collapse

EDGE_TOP_OFFSET =

Empirically determined offset EA adds to top-edge attachment points: connector starts ~9 px below the element's logical top edge (matches header height).

9

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_bounds:, target_bounds:, edge_code: nil, source_delta: [0, 0], target_delta: [0, 0], bend_path: nil) ⇒ ConnectorRouter

Returns a new instance of ConnectorRouter.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ea/svg/connector_router.rb', line 14

def initialize(source_bounds:, target_bounds:,
               edge_code: nil,
               source_delta: [0, 0], target_delta: [0, 0],
               bend_path: nil)
  @source_bounds = source_bounds
  @target_bounds = target_bounds
  @edge_code = edge_code
  @source_delta = source_delta
  @target_delta = target_delta
  @bend_path = bend_path || []
end

Instance Attribute Details

#bend_pathObject (readonly)

Returns the value of attribute bend_path.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def bend_path
  @bend_path
end

#edge_codeObject (readonly)

Returns the value of attribute edge_code.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def edge_code
  @edge_code
end

#source_boundsObject (readonly)

Returns the value of attribute source_bounds.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def source_bounds
  @source_bounds
end

#source_deltaObject (readonly)

Returns the value of attribute source_delta.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def source_delta
  @source_delta
end

#target_boundsObject (readonly)

Returns the value of attribute target_bounds.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def target_bounds
  @target_bounds
end

#target_deltaObject (readonly)

Returns the value of attribute target_delta.



11
12
13
# File 'lib/ea/svg/connector_router.rb', line 11

def target_delta
  @target_delta
end

Instance Method Details

#waypointsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ea/svg/connector_router.rb', line 26

def waypoints
  src_pt = source_point
  tgt_pt = target_point
  return [] unless src_pt && tgt_pt

  # Path= values from EA are ABSOLUTE pixel positions on the
  # diagram canvas (verified against reference SVGs). Use them
  # as-is — do not offset by src_pt.
  return [src_pt, *bend_path, tgt_pt] if bend_path.any?

  points = [src_pt]
  bend = bend_point(src_pt, tgt_pt)
  points << bend if bend
  points << tgt_pt
  points
end