Class: Ea::Svg::EaEmitter::Labels

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

Overview

Emits connector labels (role names, multiplicities) at the EA-recorded offset from the connector endpoints. Each label box has its own position decoded from the EA LLB/LLT/LRT/LRB geometry slots.

Constant Summary collapse

DEFAULT_FAMILY =
"Calibri"
DEFAULT_SIZE =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagram) ⇒ Labels

Returns a new instance of Labels.



16
17
18
# File 'lib/ea/svg/ea_emitter/labels.rb', line 16

def initialize(diagram)
  @diagram = diagram
end

Instance Attribute Details

#diagramObject (readonly)

Returns the value of attribute diagram.



14
15
16
# File 'lib/ea/svg/ea_emitter/labels.rb', line 14

def diagram
  @diagram
end

Instance Method Details

#renderObject



20
21
22
23
24
25
26
# File 'lib/ea/svg/ea_emitter/labels.rb', line 20

def render
  texts = visible_connectors.filter_map { |c| texts_for(c) }
  return "" if texts.empty?

  blocks = texts.flatten
  %(<g style="stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel; fill:#000000;fill-opacity:1.00; stroke:#000000; stroke-opacity:0.00">\n#{blocks.join("\n")}\n</g>)
end