Class: Ea::Svg::EaEmitter::Element::StereotypeIconRenderer
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::Element::StereotypeIconRenderer
- Defined in:
- lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb
Overview
Emits stereotype decorator icons inside an element's body. EA renders a small symbolic polygon (typically a diamond or chevron) when a stereotype provides a custom icon via ShapeScript.
Currently provides hardcoded fallback polygons for the most common GML stereotypes (FeatureType, Type) since the source ShapeScript definitions live in EA's encrypted InternalTechnologies (TODO.diagrams/87). Future enhancement: read shapescript from MDG files when available.
Constant Summary collapse
- FALLBACK_ICONS =
Hardcoded fallback icons keyed by stereotype name. Each entry is [fill, stroke, points_array].
{ "FeatureType" => ["#FAF1EC", "#69738C", [[0, -5], [5, 0], [0, 5], [-5, 0]]], "Type" => ["#FAF1EC", "#69738C", [[0, -5], [5, 0], [0, 5], [-5, 0]]] }.freeze
- OFFSET_X =
Default position offset from element's center
0- OFFSET_Y =
0
Instance Attribute Summary collapse
-
#bounds ⇒ Object
readonly
Returns the value of attribute bounds.
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#classifier ⇒ Object
readonly
Returns the value of attribute classifier.
-
#mdg_registry ⇒ Object
readonly
Returns the value of attribute mdg_registry.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(classifier:, bounds:, canvas: nil, mdg_registry: nil) ⇒ StereotypeIconRenderer
constructor
A new instance of StereotypeIconRenderer.
-
#to_svg ⇒ String
SVG fragment, or "" if no icon applies.
Constructor Details
#initialize(classifier:, bounds:, canvas: nil, mdg_registry: nil) ⇒ StereotypeIconRenderer
Returns a new instance of StereotypeIconRenderer.
38 39 40 41 42 43 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 38 def initialize(classifier:, bounds:, canvas: nil, mdg_registry: nil) @classifier = classifier @bounds = bounds @canvas = canvas @mdg_registry = mdg_registry end |
Instance Attribute Details
#bounds ⇒ Object (readonly)
Returns the value of attribute bounds.
31 32 33 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 31 def bounds @bounds end |
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
31 32 33 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 31 def canvas @canvas end |
#classifier ⇒ Object (readonly)
Returns the value of attribute classifier.
31 32 33 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 31 def classifier @classifier end |
#mdg_registry ⇒ Object (readonly)
Returns the value of attribute mdg_registry.
31 32 33 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 31 def mdg_registry @mdg_registry end |
Class Method Details
.render(classifier:, bounds:, canvas: nil, **opts) ⇒ Object
45 46 47 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 45 def self.render(classifier:, bounds:, canvas: nil, **opts) new(classifier: classifier, bounds: bounds, canvas: canvas, **opts).to_svg end |
Instance Method Details
#to_svg ⇒ String
Returns SVG fragment, or "" if no icon applies.
50 51 52 53 54 55 |
# File 'lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb', line 50 def to_svg return "" unless classifier && bounds return "" unless stereotype_name shapescript_svg || fallback_svg end |