Class: Ea::Svg::EaEmitter::Label::EndLabel
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::Label::EndLabel
- Defined in:
- lib/ea/svg/ea_emitter/label/end_label.rb
Overview
Renders the role + «property» + multiplicity cluster at one endpoint of a UML association connector.
EA encodes end-labels in two geometry boxes per endpoint:
LLT/LRT - "label text" position (role name slot)
LLB/LRB - "label box" position (multiplicity slot)
Each box carries OX/OY offsets from the connector anchor. The «property» stereotype renders one line below the role name. EA records qualified role names ("pkg::role") for cross-package associations but suppresses label rendering for those — only simple role names render.
Constant Summary collapse
- PROPERTY_STEREOTYPE =
"«property»"
Instance Attribute Summary collapse
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#font_family ⇒ Object
readonly
Returns the value of attribute font_family.
-
#font_size ⇒ Object
readonly
Returns the value of attribute font_size.
-
#font_unit ⇒ Object
readonly
Returns the value of attribute font_unit.
-
#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(canvas:, model_index:, document:, theme:, font_family:, font_size:, font_unit:) ⇒ EndLabel
constructor
A new instance of EndLabel.
-
#texts(text_box:, mult_box:, anchor:, connector:, end_kind:) ⇒ Object
Returns an Array of
<text>SVG strings for one endpoint.
Constructor Details
#initialize(canvas:, model_index:, document:, theme:, font_family:, font_size:, font_unit:) ⇒ EndLabel
Returns a new instance of EndLabel.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 26 def initialize(canvas:, model_index:, document:, theme:, font_family:, font_size:, font_unit:) @canvas = canvas @model_index = model_index @document = document @theme = theme @font_family = font_family @font_size = font_size @font_unit = font_unit end |
Instance Attribute Details
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def canvas @canvas end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def document @document end |
#font_family ⇒ Object (readonly)
Returns the value of attribute font_family.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def font_family @font_family end |
#font_size ⇒ Object (readonly)
Returns the value of attribute font_size.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def font_size @font_size end |
#font_unit ⇒ Object (readonly)
Returns the value of attribute font_unit.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def font_unit @font_unit end |
#model_index ⇒ Object (readonly)
Returns the value of attribute model_index.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def model_index @model_index end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
23 24 25 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 23 def theme @theme end |
Instance Method Details
#texts(text_box:, mult_box:, anchor:, connector:, end_kind:) ⇒ Object
Returns an Array of <text> SVG strings for one endpoint.
text_box - LLT or LRT box geometry (role position)
mult_box - LLB or LRB box geometry (mult position)
anchor - [x, y] of the connector endpoint
connector - the DiagramConnector (for relationship lookup)
end_kind - :source or :target
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ea/svg/ea_emitter/label/end_label.rb', line 44 def texts(text_box:, mult_box:, anchor:, connector:, end_kind:) from_property, role, mult = role_and_multiplicity(connector, end_kind) if role_empty?(role) && mult_empty?(mult) other_from_prop, other_role, other_mult = role_and_multiplicity(connector, opposite(end_kind)) role = other_role if role_empty?(role) mult ||= other_mult from_property ||= other_from_prop end agg = aggregation_kind_for(connector, end_kind) standalone = standalone_multiplicity(role, mult, aggregation: agg) return [] if role_empty?(role) && (standalone.nil? || standalone.empty?) text_pos = position_at(text_box, anchor) mult_pos = position_at(mult_box, anchor) || text_pos show_property = property_label?(connector) build_texts(role:, mult:, standalone:, text_pos:, mult_pos:, show_property:) end |