Class: Ea::Svg::EaEmitter::DiagramFrame

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

Overview

Emits the diagram frame: outer border + name tab. EA renders every diagram with a 1px black border forming a rectangle inset 6px from the canvas edge, plus a "tab" polygon in the upper-left containing the diagram type + name text.

Layout:

┌───┐
│tab│──────────────────┐
└───┘                  │
                     │
(diagram contents)     │
                     │
┌──────────────────────┘

Format observed in EA reference SVGs:

<g style="...stroke-width:1;stroke-linecap:square;
         stroke-linejoin:miter; fill:#000000;
         fill-opacity:0.00; stroke:#000000;
         stroke-opacity:1.00">
<path d="M 6 6 L 6 H-6 W-6 W-6 6 L 6 6"/>
</g>
<g style="...fill:#FFFFFF;...">
<polygon points="6 26 X 26 X+13 12 X+13 6 6 6 6 26"/>
</g>
<g style="...">
<text x="11" y="19" ...>class DiagramName</text>
</g>

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(canvas:, theme: nil) ⇒ DiagramFrame

Returns a new instance of DiagramFrame.



36
37
38
39
# File 'lib/ea/svg/ea_emitter/diagram_frame.rb', line 36

def initialize(canvas:, theme: nil)
  @canvas = canvas
  @theme = theme || Ea::Theme::Registry.default
end

Instance Attribute Details

#canvasObject (readonly)

Returns the value of attribute canvas.



34
35
36
# File 'lib/ea/svg/ea_emitter/diagram_frame.rb', line 34

def canvas
  @canvas
end

#themeObject (readonly)

Returns the value of attribute theme.



34
35
36
# File 'lib/ea/svg/ea_emitter/diagram_frame.rb', line 34

def theme
  @theme
end

Instance Method Details

#layers(diagram) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/ea/svg/ea_emitter/diagram_frame.rb', line 41

def layers(diagram)
  return [] if canvas.nil?

  [
    border_layer(canvas),
    tab_layer(canvas, diagram),
    tab_label_layer(canvas, diagram)
  ].compact
end