Class: Archimate::Svg::Entity::ProcessEntity

Inherits:
RoundedRectEntity show all
Defined in:
lib/archimate/svg/entity/process_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 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) ⇒ ProcessEntity

Returns a new instance of ProcessEntity.



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

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

Instance Method Details

#calc_text_bounds(bounds) ⇒ Object



57
58
59
# File 'lib/archimate/svg/entity/process_entity.rb', line 57

def calc_text_bounds(bounds)
  @text_bounds = bounds.reduced_by(2)
end

#entity_shape(xml, bounds) ⇒ Object



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

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

#process_path(xml, bounds) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/archimate/svg/entity/process_entity.rb', line 22

def process_path(xml, bounds)
  top = bounds.top
  shaft_top = bounds.top + bounds.height * 0.15
  middle = bounds.top + bounds.height * 0.5
  shaft_bottom = bounds.bottom - bounds.height * 0.15
  bottom = bounds.bottom

  left = bounds.left
  arrow_back = bounds.right - bounds.height * 0.5
  right = bounds.right

  calc_text_bounds(
    DataModel::Bounds.new(
      x: left,
      y: shaft_top,
      width: bounds.width - bounds.height * 0.25,
      height: shaft_bottom - shaft_top
    )
  )
  xml.path(
    d: [
      "M", left, shaft_top,
      "L", arrow_back, shaft_top,
      "L", arrow_back, top,
      "L", right, middle,
      "L", arrow_back, bottom,
      "L", arrow_back, shaft_bottom,
      "L", left, shaft_bottom,
      "z"
    ].flatten.join(" "),
    class: background_class,
    style: shape_style
  )
end