Module: Ea::Svg::EaEmitter::Compartment::HeaderDivider

Defined in:
lib/ea/svg/ea_emitter/compartment/header_divider.rb

Overview

Horizontal divider between header and the first content compartment (attributes / operations / literals / tagged values). Skipped when there is no content below.

Class Method Summary collapse

Class Method Details

.divider_required?(context) ⇒ Boolean

EA shows a header divider on Object diagrams when the element is large enough to hold a slot compartment (height

50). The starter Object diagram uses 90×50 boxes with no slots and no divider; richer Object diagrams use 133×53+ boxes with the divider always present. On HandDraw diagrams (Domain Model), every element shows a divider regardless of content. For other diagrams the divider is shown only when there is content below the header.

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/ea/svg/ea_emitter/compartment/header_divider.rb', line 35

def divider_required?(context)
  return true if hand_draw?(context)
  return object_element_with_slots?(context) if object_diagram?(context)

  context.content_below_header?
end

.hand_draw?(context) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ea/svg/ea_emitter/compartment/header_divider.rb', line 46

def hand_draw?(context)
  context.diagram && context.diagram.hand_draw
end

.object_diagram?(context) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ea/svg/ea_emitter/compartment/header_divider.rb', line 42

def object_diagram?(context)
  context.diagram && context.diagram.diagram_type == "Object"
end

.object_element_with_slots?(context) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ea/svg/ea_emitter/compartment/header_divider.rb', line 50

def object_element_with_slots?(context)
  context.bounds && context.bounds.height.to_i > 50
end

.render(context) ⇒ Object



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

def render(context)
  return nil unless context.geometry
  return nil unless context.geometry.divider_y
  return nil unless divider_required?(context)

  Element::DividerRenderer.render(
    context.bounds,
    y: context.geometry.divider_y,
    stroke: context.stroke,
    stroke_width: context.stroke_width
  )
end