Class: Archimate::Svg::Entity::ApplicationComponent

Inherits:
RectEntity show all
Defined in:
lib/archimate/svg/entity/application_component.rb

Instance Attribute Summary

Attributes inherited from BaseEntity

#background_class, #badge, #badge_bounds, #bounds_offset, #child, #entity, #text_bounds

Instance Method Summary collapse

Methods included from Rect

#rect_path

Methods inherited from BaseEntity

#entity_badge, #entity_label, #group_attrs, #optional_link, #shape_style, #text_lines, #text_style, #to_svg

Constructor Details

#initialize(child, bounds_offset) ⇒ ApplicationComponent

Returns a new instance of ApplicationComponent.



7
8
9
10
# File 'lib/archimate/svg/entity/application_component.rb', line 7

def initialize(child, bounds_offset)
  super
  @badge = "#archimate-app-component-badge"
end

Instance Method Details

#component_decoration(xml, left, top) ⇒ Object



31
32
33
34
# File 'lib/archimate/svg/entity/application_component.rb', line 31

def component_decoration(xml, left, top)
  xml.rect(x: left, y: top, width: "21", height: "13", class: background_class, style: shape_style)
  xml.rect(x: left, y: top, width: "21", height: "13", class: "archimate-decoration")
end

#component_path(xml, bounds) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/archimate/svg/entity/application_component.rb', line 22

def component_path(xml, bounds)
  main_box_x = bounds.left + 21.0 / 2
  main_box_width = bounds.width - 21 / 2
  set_text_bounds(bounds, main_box_x)
  xml.rect(x: main_box_x, y: bounds.top, width: main_box_width, height: bounds.height, class: background_class, style: shape_style)
  component_decoration(xml, bounds.left, bounds.top + 10)
  component_decoration(xml, bounds.left, bounds.top + 30)
end

#entity_shape(xml, bounds) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/archimate/svg/entity/application_component.rb', line 12

def entity_shape(xml, bounds)
  case child.child_type
  when "1"
    super
  else
    component_path(xml, bounds)
    @badge = nil
  end
end

#set_text_bounds(bounds, main_box_x) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/archimate/svg/entity/application_component.rb', line 36

def set_text_bounds(bounds, main_box_x)
  @text_bounds = DataModel::Bounds.new(
    x: main_box_x + 21 / 2,
    y: bounds.top + 1,
    width: bounds.width - 22,
    height: bounds.height - 2
  )
end