Class: Ea::Svg::EaEmitter::Labels
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::Labels
- Defined in:
- lib/ea/svg/ea_emitter/labels.rb
Overview
Emits the labels layer: connector role/multiplicity end labels plus midpoint stereotype labels for non-association connectors.
This class is the orchestrator. The actual label-shaping
logic lives in dedicated, MECE collaborators under
Ea::Svg::EaEmitter::Label:
Label::EndLabel - role + «property» + mult at LLT/LRT
Label::MidpointLabel - «stereotype» at connector midpoint
Label::Registry - dispatch by relationship kind (OCP)
Theme is read once and threaded to collaborators so the rendering rules (font family/size, fill color) live in one place.
Constant Summary collapse
- DEFAULT_FAMILY =
"Yu Gothic UI"- DEFAULT_SIZE =
13
Instance Attribute Summary collapse
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#diagram ⇒ Object
readonly
Returns the value of attribute diagram.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#model_index ⇒ Object
readonly
Returns the value of attribute model_index.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(diagram, canvas: nil, model_index: nil, theme: nil, document: nil) ⇒ Labels
constructor
A new instance of Labels.
- #render ⇒ Object
Constructor Details
#initialize(diagram, canvas: nil, model_index: nil, theme: nil, document: nil) ⇒ Labels
Returns a new instance of Labels.
27 28 29 30 31 32 33 34 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 27 def initialize(diagram, canvas: nil, model_index: nil, theme: nil, document: nil) @diagram = diagram @canvas = canvas @model_index = model_index @theme = theme || Ea::Theme::Registry.default @document = document end |
Instance Attribute Details
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
25 26 27 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 25 def canvas @canvas end |
#diagram ⇒ Object (readonly)
Returns the value of attribute diagram.
25 26 27 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 25 def diagram @diagram end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
25 26 27 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 25 def document @document end |
#model_index ⇒ Object (readonly)
Returns the value of attribute model_index.
25 26 27 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 25 def model_index @model_index end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
25 26 27 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 25 def theme @theme end |
Instance Method Details
#render ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ea/svg/ea_emitter/labels.rb', line 36 def render texts = visible_connectors.flat_map { |c| texts_for(c) } return "" if texts.empty? %(<g style="stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel; fill:#000000;fill-opacity:1.00; stroke:#000000; stroke-opacity:0.00">\n#{texts.join("\n")}\n</g>) end |