Class: Ea::Svg::EaEmitter::Elements

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

Overview

Emits the elements layer. Orchestrates per-element rendering by delegating to specialized compartment renderers (shape, header, divider, attribute). Frame-element filtering and stereotype-color fallback also live in dedicated collaborators.

Defined Under Namespace

Classes: PackageContentRow

Constant Summary collapse

DEFAULT_FILL =
"#FFFFFF"
DEFAULT_STROKE =
"#000000"
DEFAULT_STROKE_WIDTH =
2
DEFAULT_TEXT_COLOR =
"#000000"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagram, model_index:, canvas: nil, document: nil) ⇒ Elements

Returns a new instance of Elements.



19
20
21
22
23
24
# File 'lib/ea/svg/ea_emitter/elements.rb', line 19

def initialize(diagram, model_index:, canvas: nil, document: nil)
  @diagram = diagram
  @model_index = model_index
  @canvas = canvas
  @document = document
end

Instance Attribute Details

#canvasObject (readonly)

Returns the value of attribute canvas.



17
18
19
# File 'lib/ea/svg/ea_emitter/elements.rb', line 17

def canvas
  @canvas
end

#diagramObject (readonly)

Returns the value of attribute diagram.



17
18
19
# File 'lib/ea/svg/ea_emitter/elements.rb', line 17

def diagram
  @diagram
end

#documentObject (readonly)

Returns the value of attribute document.



17
18
19
# File 'lib/ea/svg/ea_emitter/elements.rb', line 17

def document
  @document
end

#model_indexObject (readonly)

Returns the value of attribute model_index.



17
18
19
# File 'lib/ea/svg/ea_emitter/elements.rb', line 17

def model_index
  @model_index
end

Instance Method Details

#groupsObject

Returns an Array of per-entity <g>...</g> strings. Each element contributes up to 4 groups (shape, header, divider, attrs) in EA's per-entity layer order.



33
34
35
# File 'lib/ea/svg/ea_emitter/elements.rb', line 33

def groups
  ordered_elements.flat_map { |e| groups_for(e) }
end

#renderObject



26
27
28
# File 'lib/ea/svg/ea_emitter/elements.rb', line 26

def render
  groups.join("\n")
end