Class: Lutaml::Xsd::Spa::Svg::Renderers::GroupRenderer

Inherits:
ComponentRenderer show all
Defined in:
lib/lutaml/xsd/spa/svg/renderers/group_renderer.rb

Overview

Renders model group components (sequence, choice, all)

Instance Attribute Summary

Attributes inherited from ComponentRenderer

#config, #schema_name

Instance Method Summary collapse

Methods inherited from ComponentRenderer

#initialize

Constructor Details

This class inherits a constructor from Lutaml::Xsd::Spa::Svg::ComponentRenderer

Instance Method Details

#render(component_data, box) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lutaml/xsd/spa/svg/renderers/group_renderer.rb', line 12

def render(component_data, box)
  type = component_data["type"] || component_data["kind"]

  parts = []

  # Box
  fill = if config.effects.gradient_enabled?
           "url(#groupGradient)"
         else
           config.colors.group.base
         end

  parts << create_box(
    box,
    fill,
    stroke: config.colors.ui.border,
    stroke_width: 1,
  )

  # Text
  parts << Utils::SvgBuilder.text(
    box.center.x,
    box.y + config.dimensions.text_offset_y,
    type,
    {
      fill: config.colors.ui.text,
      "font-size" => 12,
      "font-weight" => "bold",
      "text-anchor" => "middle",
    },
  )

  Utils::SvgBuilder.group({ class: "group-box" }) { parts.join("\n") }
end