Module: Archimate::FileFormats::Serializer::Archi::ViewNode

Included in:
ArchiFileWriter
Defined in:
lib/archimate/file_formats/serializer/archi/view_node.rb

Instance Method Summary collapse

Instance Method Details

#archi_style_hash(style) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/archimate/file_formats/serializer/archi/view_node.rb', line 37

def archi_style_hash(style)
  {
    "fillColor" => style&.fill_color&.to_rgba,
    "font" => style&.font&.to_archi_font,
    "fontColor" => style&.font_color&.to_rgba,
    "lineColor" => style&.line_color&.to_rgba,
    "lineWidth" => style&.line_width&.to_s,
    "textAlignment" => style&.text_alignment&.to_s,
    "textPosition" => style&.text_position
  }
end

#serialize_view_node(xml, child) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/archimate/file_formats/serializer/archi/view_node.rb', line 8

def serialize_view_node(xml, child)
  style_hash = archi_style_hash(child.style)
  fill_color = style_hash.delete("fillColor")
  xml.child(
    remove_nil_values(
      {
        "xsi:type" => child.type,
        "id" => child.id,
        "name" => child.name
      }.merge(
        style_hash.merge(
          "targetConnections" => child.target_connections.empty? ? nil : child.target_connections.join(" "),
          "fillColor" => fill_color,
          "model" => child.view_refs&.id,
          "archimateElement" => child.element&.id,
          "type" => child.child_type
        )
      )
    )
  ) do
    serialize_bounds(xml, child.bounds)
    serialize(xml, child.connections)
    xml.content { xml.text child.content } if child.content
    serialize(xml, child.nodes)
    serialize_documentation(xml, child.documentation)
    serialize(xml, child.properties)
  end
end