Class: Archimate::Svg::Entity::ServiceEntity

Inherits:
BaseEntity
  • Object
show all
Includes:
Rect
Defined in:
lib/archimate/svg/entity/service_entity.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, #layer_background_class, #optional_link, #shape_style, #text_lines, #text_style, #to_svg

Constructor Details

#initialize(child, bounds_offset) ⇒ ServiceEntity

Returns a new instance of ServiceEntity.



9
10
11
12
13
14
15
16
17
18
# File 'lib/archimate/svg/entity/service_entity.rb', line 9

def initialize(child, bounds_offset)
  super
  bounds = child.bounds
  @text_bounds = DataModel::Bounds.new(
    x: bounds.left + 7,
    y: bounds.top + 5,
    width: bounds.width - 14,
    height: bounds.height - 10
  )
end

Instance Method Details

#entity_shape(xml, bounds) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/archimate/svg/entity/service_entity.rb', line 20

def entity_shape(xml, bounds)
  case child.child_type
  when 1
    @badge_bounds = DataModel::Bounds.new(
      x: bounds.right - 25,
      y: bounds.top + 5,
      width: 20,
      height: 20
    )
    @badge = "#archimate-service-badge"
    rect_path(xml, bounds)
  else
    service_path(xml, bounds)
  end
end

#service_path(xml, bounds) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/archimate/svg/entity/service_entity.rb', line 36

def service_path(xml, bounds)
  xml.rect(
    x: bounds.left,
    y: bounds.top,
    width: bounds.width,
    height: bounds.height,
    rx: bounds.height / 2.0,
    ry: bounds.height / 2.0,
    class: background_class,
    style: shape_style
  )
end