archimate 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -0
  3. data/TODOs.org +219 -0
  4. data/archimate.gemspec +2 -1
  5. data/exe/archidiff +7 -0
  6. data/exe/archidiff-summary +7 -0
  7. data/exe/archimerge +7 -0
  8. data/exe/fmtxml +7 -0
  9. data/lib/archimate.rb +10 -21
  10. data/lib/archimate/cli/archi.rb +2 -1
  11. data/lib/archimate/cli/cleanup.rb +8 -9
  12. data/lib/archimate/cli/convert.rb +3 -1
  13. data/lib/archimate/cli/mapper.rb +1 -1
  14. data/lib/archimate/cli/stats.rb +1 -1
  15. data/lib/archimate/config.rb +4 -1
  16. data/lib/archimate/data_model.rb +11 -24
  17. data/lib/archimate/data_model/any_attribute.rb +18 -5
  18. data/lib/archimate/data_model/any_element.rb +30 -7
  19. data/lib/archimate/data_model/bounds.rb +34 -7
  20. data/lib/archimate/data_model/color.rb +32 -7
  21. data/lib/archimate/data_model/comparison.rb +87 -0
  22. data/lib/archimate/data_model/concern.rb +20 -7
  23. data/lib/archimate/data_model/connection.rb +71 -51
  24. data/lib/archimate/data_model/connector_type.rb +23 -0
  25. data/lib/archimate/data_model/diagram.rb +72 -10
  26. data/lib/archimate/data_model/diagram_type.rb +17 -0
  27. data/lib/archimate/data_model/differentiable.rb +142 -0
  28. data/lib/archimate/data_model/element.rb +39 -45
  29. data/lib/archimate/data_model/element_type.rb +89 -0
  30. data/lib/archimate/data_model/font.rb +30 -12
  31. data/lib/archimate/data_model/lang_string.rb +89 -16
  32. data/lib/archimate/data_model/layer.rb +55 -0
  33. data/lib/archimate/data_model/layers.rb +62 -0
  34. data/lib/archimate/data_model/location.rb +27 -11
  35. data/lib/archimate/data_model/metadata.rb +10 -3
  36. data/lib/archimate/data_model/model.rb +188 -121
  37. data/lib/archimate/data_model/modeling_note.rb +14 -3
  38. data/lib/archimate/data_model/organization.rb +44 -13
  39. data/lib/archimate/data_model/{documentation.rb → preserved_lang_string.rb} +1 -5
  40. data/lib/archimate/data_model/property.rb +17 -11
  41. data/lib/archimate/data_model/property_definition.rb +34 -4
  42. data/lib/archimate/data_model/referenceable.rb +0 -9
  43. data/lib/archimate/data_model/referenceable_collection.rb +201 -0
  44. data/lib/archimate/data_model/relationship.rb +52 -33
  45. data/lib/archimate/data_model/relationship_type.rb +43 -0
  46. data/lib/archimate/data_model/schema_info.rb +17 -6
  47. data/lib/archimate/data_model/style.rb +41 -11
  48. data/lib/archimate/data_model/view_node.rb +153 -59
  49. data/lib/archimate/data_model/viewpoint.rb +56 -80
  50. data/lib/archimate/data_model/viewpoint_type.rb +429 -0
  51. data/lib/archimate/export/csv_export.rb +2 -2
  52. data/lib/archimate/export/cypher.rb +2 -2
  53. data/lib/archimate/export/graph_ml.rb +7 -5
  54. data/lib/archimate/export/jsonl.rb +166 -0
  55. data/lib/archimate/export/n_quads.rb +8 -5
  56. data/lib/archimate/file_format.rb +4 -5
  57. data/lib/archimate/file_formats/archi_file_reader.rb +7 -240
  58. data/lib/archimate/file_formats/archi_file_writer.rb +16 -188
  59. data/lib/archimate/file_formats/model_exchange_file_reader.rb +7 -225
  60. data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +22 -114
  61. data/lib/archimate/file_formats/model_exchange_file_writer_30.rb +22 -122
  62. data/lib/archimate/file_formats/sax.rb +55 -0
  63. data/lib/archimate/file_formats/sax/any_element.rb +64 -0
  64. data/lib/archimate/file_formats/sax/archi/archi_handler_factory.rb +48 -0
  65. data/lib/archimate/file_formats/sax/archi/bounds.rb +25 -0
  66. data/lib/archimate/file_formats/sax/archi/connection.rb +47 -0
  67. data/lib/archimate/file_formats/sax/archi/content.rb +28 -0
  68. data/lib/archimate/file_formats/sax/archi/diagram.rb +66 -0
  69. data/lib/archimate/file_formats/sax/archi/element.rb +36 -0
  70. data/lib/archimate/file_formats/sax/archi/location.rb +25 -0
  71. data/lib/archimate/file_formats/sax/archi/model.rb +109 -0
  72. data/lib/archimate/file_formats/sax/archi/organization.rb +60 -0
  73. data/lib/archimate/file_formats/sax/archi/property.rb +54 -0
  74. data/lib/archimate/file_formats/sax/archi/relationship.rb +50 -0
  75. data/lib/archimate/file_formats/sax/archi/style.rb +35 -0
  76. data/lib/archimate/file_formats/sax/archi/view_node.rb +76 -0
  77. data/lib/archimate/file_formats/sax/capture_content.rb +20 -0
  78. data/lib/archimate/file_formats/sax/capture_documentation.rb +19 -0
  79. data/lib/archimate/file_formats/sax/capture_properties.rb +20 -0
  80. data/lib/archimate/file_formats/sax/content_element.rb +19 -0
  81. data/lib/archimate/file_formats/sax/document.rb +80 -0
  82. data/lib/archimate/file_formats/sax/handler.rb +54 -0
  83. data/lib/archimate/file_formats/sax/lang_string.rb +28 -0
  84. data/lib/archimate/file_formats/sax/model_exchange_file/color.rb +36 -0
  85. data/lib/archimate/file_formats/sax/model_exchange_file/connection.rb +67 -0
  86. data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +60 -0
  87. data/lib/archimate/file_formats/sax/model_exchange_file/element.rb +43 -0
  88. data/lib/archimate/file_formats/sax/model_exchange_file/font.rb +44 -0
  89. data/lib/archimate/file_formats/sax/model_exchange_file/item.rb +64 -0
  90. data/lib/archimate/file_formats/sax/model_exchange_file/location.rb +23 -0
  91. data/lib/archimate/file_formats/sax/model_exchange_file/metadata.rb +66 -0
  92. data/lib/archimate/file_formats/sax/model_exchange_file/model.rb +124 -0
  93. data/lib/archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory.rb +53 -0
  94. data/lib/archimate/file_formats/sax/model_exchange_file/property.rb +32 -0
  95. data/lib/archimate/file_formats/sax/model_exchange_file/property_definition.rb +36 -0
  96. data/lib/archimate/file_formats/sax/model_exchange_file/relationship.rb +49 -0
  97. data/lib/archimate/file_formats/sax/model_exchange_file/schema_info.rb +47 -0
  98. data/lib/archimate/file_formats/sax/model_exchange_file/style.rb +66 -0
  99. data/lib/archimate/file_formats/sax/model_exchange_file/view_node.rb +86 -0
  100. data/lib/archimate/file_formats/sax/no_op.rb +17 -0
  101. data/lib/archimate/file_formats/sax/preserved_lang_string.rb +28 -0
  102. data/lib/archimate/file_formats/serializer.rb +57 -0
  103. data/lib/archimate/file_formats/serializer/archi/bounds.rb +23 -0
  104. data/lib/archimate/file_formats/serializer/archi/connection.rb +33 -0
  105. data/lib/archimate/file_formats/serializer/archi/diagram.rb +28 -0
  106. data/lib/archimate/file_formats/serializer/archi/documentation.rb +16 -0
  107. data/lib/archimate/file_formats/serializer/archi/element.rb +24 -0
  108. data/lib/archimate/file_formats/serializer/archi/location.rb +26 -0
  109. data/lib/archimate/file_formats/serializer/archi/model.rb +25 -0
  110. data/lib/archimate/file_formats/serializer/archi/organization.rb +21 -0
  111. data/lib/archimate/file_formats/serializer/archi/property.rb +15 -0
  112. data/lib/archimate/file_formats/serializer/archi/relationship.rb +36 -0
  113. data/lib/archimate/file_formats/serializer/archi/view_node.rb +52 -0
  114. data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +45 -0
  115. data/lib/archimate/file_formats/serializer/model_exchange_file/element.rb +25 -0
  116. data/lib/archimate/file_formats/serializer/model_exchange_file/location.rb +15 -0
  117. data/lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb +32 -0
  118. data/lib/archimate/file_formats/serializer/model_exchange_file/organization.rb +23 -0
  119. data/lib/archimate/file_formats/serializer/model_exchange_file/properties.rb +15 -0
  120. data/lib/archimate/file_formats/serializer/model_exchange_file/relationship.rb +19 -0
  121. data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +48 -0
  122. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/connection.rb +25 -0
  123. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +27 -0
  124. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/item.rb +17 -0
  125. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/label.rb +17 -0
  126. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +36 -0
  127. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/organization_body.rb +25 -0
  128. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/property.rb +19 -0
  129. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +44 -0
  130. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/connection.rb +26 -0
  131. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +27 -0
  132. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/item.rb +17 -0
  133. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/label.rb +17 -0
  134. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +41 -0
  135. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/organization_body.rb +25 -0
  136. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property.rb +19 -0
  137. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/property_definitions.rb +34 -0
  138. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +45 -0
  139. data/lib/archimate/file_formats/serializer/named_collection.rb +21 -0
  140. data/lib/archimate/file_formats/serializer/writer.rb +56 -0
  141. data/lib/archimate/file_formats/serializer/xml_lang_string.rb +30 -0
  142. data/lib/archimate/file_formats/serializer/xml_metadata.rb +64 -0
  143. data/lib/archimate/file_formats/{model_exchange_file → serializer}/xml_property_defs.rb +2 -2
  144. data/lib/archimate/lint/duplicate_entities.rb +3 -3
  145. data/lib/archimate/lint/linter.rb +24 -29
  146. data/lib/archimate/svg/connection.rb +13 -103
  147. data/lib/archimate/svg/diagram.rb +1 -1
  148. data/lib/archimate/svg/entity/base_entity.rb +12 -8
  149. data/lib/archimate/svg/entity/data_entity.rb +2 -2
  150. data/lib/archimate/svg/entity/diagram_model_reference.rb +1 -1
  151. data/lib/archimate/svg/entity/event_entity.rb +2 -2
  152. data/lib/archimate/svg/entity/gap.rb +1 -1
  153. data/lib/archimate/svg/entity/group.rb +1 -1
  154. data/lib/archimate/svg/entity/motivation_entity.rb +1 -1
  155. data/lib/archimate/svg/entity/node.rb +1 -1
  156. data/lib/archimate/svg/entity/rect_entity.rb +1 -1
  157. data/lib/archimate/svg/entity/rounded_rect_entity.rb +1 -1
  158. data/lib/archimate/svg/entity/service_entity.rb +2 -2
  159. data/lib/archimate/svg/entity/value.rb +2 -2
  160. data/lib/archimate/svg/path.rb +153 -0
  161. data/lib/archimate/svg/point.rb +8 -1
  162. data/lib/archimate/version.rb +1 -1
  163. metadata +118 -36
  164. data/lib/archimate/data_model/archimate_node.rb +0 -181
  165. data/lib/archimate/data_model/concept.rb +0 -14
  166. data/lib/archimate/data_model/constants.rb +0 -82
  167. data/lib/archimate/data_model/container.rb +0 -17
  168. data/lib/archimate/data_model/diffable_array.rb +0 -213
  169. data/lib/archimate/data_model/diffable_primitive.rb +0 -83
  170. data/lib/archimate/data_model/label.rb +0 -19
  171. data/lib/archimate/data_model/named_referenceable.rb +0 -14
  172. data/lib/archimate/data_model/view.rb +0 -12
  173. data/lib/archimate/data_model/view_concept.rb +0 -18
  174. data/lib/archimate/file_formats/archi_file_format.rb +0 -151
  175. data/lib/archimate/file_formats/archimate_v2.rb +0 -461
  176. data/lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb +0 -35
  177. data/lib/archimate/file_formats/model_exchange_file/xml_metadata.rb +0 -115
  178. data/lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb +0 -28
  179. data/lib/archimate/file_formats/model_exchange_file_reader_21.rb +0 -73
  180. data/lib/archimate/file_formats/model_exchange_file_reader_30.rb +0 -134
  181. data/lib/archimate/file_formats/model_exchange_file_writer.rb +0 -157
  182. data/lib/archimate/file_formats/writer.rb +0 -56
@@ -27,7 +27,7 @@ module Archimate
27
27
 
28
28
  def set_title(svg)
29
29
  svg.at_css("title").content = diagram.name || "untitled"
30
- svg.at_css("desc").content = diagram.documentation.first&.text || ""
30
+ svg.at_css("desc").content = diagram.documentation.to_s || ""
31
31
  end
32
32
 
33
33
  # Scan the SVG and figure out min & max
@@ -24,20 +24,24 @@ module Archimate
24
24
 
25
25
  def layer_background_class
26
26
  case child.element&.layer
27
- when "Strategy"
27
+ when "Strategy", DataModel::Layers::Strategy
28
28
  "archimate-strategy-background"
29
- when "Business"
29
+ when "Business", DataModel::Layers::Business
30
30
  "archimate-business-background"
31
- when "Application"
31
+ when "Application", DataModel::Layers::Application
32
32
  "archimate-application-background"
33
- when "Technology"
33
+ when "Technology", DataModel::Layers::Technology
34
34
  "archimate-infrastructure-background"
35
- when "Physical"
35
+ when "Physical", DataModel::Layers::Physical
36
36
  "archimate-physical-background"
37
- when "Motivation"
37
+ when "Motivation", DataModel::Layers::Motivation
38
38
  "archimate-motivation-background"
39
- when "Implementation and Migration"
39
+ when "Implementation and Migration", DataModel::Layers::Implementation_and_migration
40
40
  "archimate-implementation-background"
41
+ when "Connectors", DataModel::Layers::Connectors
42
+ "archimate-connectors-background"
43
+ else
44
+ puts "Unexpected layer #{child.element&.layer.inspect}" if child.element&.layer
41
45
  end
42
46
  end
43
47
 
@@ -45,7 +49,7 @@ module Archimate
45
49
  optional_link(xml) {
46
50
  xml.g(group_attrs) do
47
51
  xml.title { xml.text @entity.name } unless @entity.name.nil? || @entity.name.empty?
48
- xml.desc { xml.text(@entity.documentation.map(&:text).join("\n\n")) } unless @entity.documentation.empty?
52
+ xml.desc { xml.text(@entity.documentation.to_s) } if @entity.documentation && !@entity.documentation.empty?
49
53
  entity_shape(xml, child.bounds)
50
54
  entity_badge(xml)
51
55
  entity_label(xml)
@@ -10,10 +10,10 @@ module Archimate
10
10
  end
11
11
 
12
12
  def calc_text_bounds(_bounds)
13
- @text_bounds = @text_bounds.with(
13
+ @text_bounds = DataModel::Bounds.new(@text_bounds.to_h.merge(
14
14
  y: @text_bounds.top + @margin,
15
15
  height: @text_bounds.height - @margin
16
- )
16
+ ))
17
17
  end
18
18
 
19
19
  def entity_shape(xml, bounds)
@@ -8,7 +8,7 @@ module Archimate
8
8
  super
9
9
  @badge = "#archimate-diagram-model-reference-badge"
10
10
  @background_class = "archimate-diagram-model-reference-background"
11
- @entity = child.model_element
11
+ @entity = child.view_refs
12
12
  end
13
13
 
14
14
  def optional_link(xml, &block)
@@ -25,10 +25,10 @@ module Archimate
25
25
 
26
26
  def calc_text_bounds(notch_x)
27
27
  bounds = @text_bounds
28
- @text_bounds = bounds.with(
28
+ @text_bounds = DataModel::Bounds.new(bounds.to_h.merge(
29
29
  x: bounds.left + notch_x * 0.80,
30
30
  width: bounds.width - notch_x
31
- )
31
+ ))
32
32
  end
33
33
  end
34
34
  end
@@ -8,7 +8,7 @@ module Archimate
8
8
  super
9
9
  @background_class = "archimate-implementation2-background"
10
10
  @badge = "#archimate-gap-badge"
11
- @badge_bounds = child.bounds.with(
11
+ @badge_bounds = DataModel::Bounds.new(
12
12
  x: child.bounds.right - 25,
13
13
  y: child.bounds.top + 5,
14
14
  width: 20,
@@ -15,7 +15,7 @@ module Archimate
15
15
  xml.rect(x: bounds.left, y: bounds.top + group_header_height, width: bounds.width, height: bounds.height - group_header_height, class: background_class, style: shape_style)
16
16
  xml.rect(x: bounds.left, y: bounds.top, width: bounds.width / 2.0, height: group_header_height, class: background_class, style: shape_style)
17
17
  xml.rect(x: bounds.left, y: bounds.top, width: bounds.width / 2.0, height: group_header_height, class: "archimate-decoration")
18
- @text_bounds = bounds.with(height: group_header_height)
18
+ @text_bounds = DataModel::Bounds.new(bounds.to_h.merge(height: group_header_height))
19
19
  @text_align = "left"
20
20
  end
21
21
  end
@@ -6,7 +6,7 @@ module Archimate
6
6
  class MotivationEntity < BaseEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @badge_bounds = child.bounds.with(
9
+ @badge_bounds = DataModel::Bounds.new(
10
10
  x: child.bounds.right - 25,
11
11
  y: child.bounds.top + 5,
12
12
  width: 20,
@@ -15,7 +15,7 @@ module Archimate
15
15
  def entity_shape(xml, bounds)
16
16
  case child.child_type
17
17
  when 1
18
- @badge_bounds = bounds.with(
18
+ @badge_bounds = DataModel::Bounds.new(
19
19
  x: bounds.right - 25,
20
20
  y: bounds.top + 5,
21
21
  width: 20,
@@ -8,7 +8,7 @@ module Archimate
8
8
 
9
9
  def initialize(child, bounds_offset)
10
10
  super
11
- @badge_bounds = child.bounds.with(
11
+ @badge_bounds = DataModel::Bounds.new(
12
12
  x: child.bounds.right - 25,
13
13
  y: child.bounds.top + 5,
14
14
  width: 20,
@@ -6,7 +6,7 @@ module Archimate
6
6
  class RoundedRectEntity < BaseEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @badge_bounds = child.bounds.with(
9
+ @badge_bounds = DataModel::Bounds.new(
10
10
  x: child.bounds.right - 25,
11
11
  y: child.bounds.top + 5,
12
12
  width: 20,
@@ -9,7 +9,7 @@ module Archimate
9
9
  def initialize(child, bounds_offset)
10
10
  super
11
11
  bounds = child.bounds
12
- @text_bounds = bounds.with(
12
+ @text_bounds = DataModel::Bounds.new(
13
13
  x: bounds.left + 7,
14
14
  y: bounds.top + 5,
15
15
  width: bounds.width - 14,
@@ -20,7 +20,7 @@ module Archimate
20
20
  def entity_shape(xml, bounds)
21
21
  case child.child_type
22
22
  when 1
23
- @badge_bounds = bounds.with(
23
+ @badge_bounds = DataModel::Bounds.new(
24
24
  x: bounds.right - 25,
25
25
  y: bounds.top + 5,
26
26
  width: 20,
@@ -14,12 +14,12 @@ module Archimate
14
14
  end
15
15
 
16
16
  def calc_text_bounds(_bounds)
17
- @text_bounds = @text_bounds.with(
17
+ @text_bounds = DataModel::Bounds.new(@text_bounds.to_h.merge(
18
18
  x: @text_bounds.left + 10,
19
19
  y: @text_bounds.top + 10,
20
20
  width: @text_bounds.width - 20,
21
21
  height: @text_bounds.height - 20
22
- )
22
+ ))
23
23
  end
24
24
  end
25
25
  end
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Archimate
4
+ module Svg
5
+ class Path
6
+ attr_reader :connection
7
+
8
+ def initialize(connection)
9
+ @connection = connection
10
+ end
11
+
12
+ # @return Float length of this path
13
+ def length
14
+ segment_lengths.reduce(0) { |total, length| total + length }
15
+ end
16
+
17
+ # @return Point mid-point on Path
18
+ def midpoint
19
+ point(0.5)
20
+ end
21
+
22
+ # @param fraction Float 0.0-1.0
23
+ # @return Point at the given percent along line between start and end
24
+ def point(fraction)
25
+ length_from_start = length * fraction
26
+ segments.each do |a, b|
27
+ seg_length = b - a
28
+ if seg_length >= length_from_start
29
+ pct = length_from_start / seg_length
30
+ return Point.new(
31
+ a.x + ((b.x - a.x) * pct),
32
+ a.y + ((b.y - a.y) * pct)
33
+ )
34
+ else
35
+ length_from_start -= seg_length
36
+ end
37
+ end
38
+ Point.new(0.0, 0.0)
39
+ end
40
+
41
+ # builds the line coordinates for the path
42
+ # rough drawing is the point at center of first element, point of each bendpoint, and center of end element
43
+ # First naive implementation
44
+ # if left/right range of both overlap, use centerpoint of overlap range as x val
45
+ # if top/bottom range of both overlap, use centerpoint of overlap range as y val
46
+ def d
47
+ [move_to(points.first)].concat(points[1..-1].map { |pt| line_to(pt) }).join(" ")
48
+ end
49
+
50
+ def points
51
+ @points ||= calc_points
52
+ end
53
+
54
+ def segments
55
+ (0..points.length - 2).map { |i| [points[i], points[i + 1]] }
56
+ end
57
+
58
+ # Returns the lengths of each segment of the line
59
+ def segment_lengths
60
+ segments.map { |a, b| b - a }
61
+ end
62
+
63
+ private
64
+
65
+ def source_bounds
66
+ @source_bounds ||= connection.source&.absolute_position || DataModel::Bounds.zero
67
+ end
68
+
69
+ def target_bounds
70
+ @target_bounds ||= connection.target&.absolute_position || DataModel::Bounds.zero
71
+ end
72
+
73
+ def normalized_bend_points
74
+ source_bounds_center = source_bounds.center
75
+ bp_bounds = connection.bendpoints.map do |bp|
76
+ DataModel::Bounds.new(
77
+ x: source_bounds_center.x + (bp.x || 0),
78
+ y: source_bounds_center.y + (bp.y || 0),
79
+ width: 0,
80
+ height: 0
81
+ )
82
+ end
83
+ bp_bounds.reject do |bounds|
84
+ bounds.inside?(source_bounds) || bounds.inside?(target_bounds)
85
+ end
86
+ end
87
+
88
+ def calc_points
89
+ bounds = [source_bounds, normalized_bend_points, target_bounds].flatten
90
+
91
+ points = []
92
+ a = bounds.shift
93
+ until bounds.empty?
94
+ b = bounds.shift
95
+ points.concat(bounds_to_points(a, b))
96
+ a = b
97
+ end
98
+ points.uniq
99
+ end
100
+
101
+ # a: Bounds
102
+ # b: Bounds
103
+ def bounds_to_points(a, b)
104
+ ax_range = a.x_range
105
+ bx_range = b.x_range
106
+
107
+ overlap_x_center = ranges_overlap(ax_range, bx_range)
108
+
109
+ if overlap_x_center
110
+ ax = bx = overlap_x_center
111
+ elsif b.is_right_of?(a)
112
+ ax = a.right
113
+ bx = b.left
114
+ else
115
+ ax = a.left
116
+ bx = b.right
117
+ end
118
+
119
+ ay_range = a.y_range
120
+ by_range = b.y_range
121
+
122
+ overlap_y_center = ranges_overlap(ay_range, by_range)
123
+
124
+ if overlap_y_center
125
+ ay = by = overlap_y_center
126
+ elsif b.is_above?(a)
127
+ ay = a.top
128
+ by = b.bottom
129
+ else
130
+ ay = a.bottom
131
+ by = b.top
132
+ end
133
+
134
+ [Point.new(ax, ay), Point.new(bx, by)]
135
+ end
136
+
137
+ def move_to(point)
138
+ "M #{point.x} #{point.y}"
139
+ end
140
+
141
+ def line_to(point)
142
+ "L #{point.x} #{point.y}"
143
+ end
144
+
145
+ def ranges_overlap(r1, r2)
146
+ begin_max = [r1, r2].map(&:begin).max
147
+ end_min = [r1, r2].map(&:end).min
148
+ return nil if begin_max > end_min
149
+ (begin_max + end_min) / 2.0
150
+ end
151
+ end
152
+ end
153
+ end
@@ -2,6 +2,13 @@
2
2
 
3
3
  module Archimate
4
4
  module Svg
5
- Point = Struct.new(:x, :y)
5
+ Point = Struct.new(:x, :y) do
6
+ def -(pt)
7
+ Math.sqrt(
8
+ ((pt.x - x) ** 2) +
9
+ ((pt.y - y) ** 2)
10
+ )
11
+ end
12
+ end
6
13
  end
7
14
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Archimate
3
- VERSION = "1.2.1"
3
+ VERSION = "2.0.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Morga
@@ -10,20 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: dry-struct
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.3.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.3.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: nokogiri
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +80,20 @@ dependencies:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '1.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-enum
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.7.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.7.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -379,7 +379,11 @@ email:
379
379
  - markmorga@gmail.com
380
380
  - mmorga@rackspace.com
381
381
  executables:
382
+ - archidiff
383
+ - archidiff-summary
382
384
  - archimate
385
+ - archimerge
386
+ - fmtxml
383
387
  extensions: []
384
388
  extra_rdoc_files: []
385
389
  files:
@@ -398,7 +402,11 @@ files:
398
402
  - bin/archimate
399
403
  - bin/console
400
404
  - bin/setup
405
+ - exe/archidiff
406
+ - exe/archidiff-summary
401
407
  - exe/archimate
408
+ - exe/archimerge
409
+ - exe/fmtxml
402
410
  - lib/archimate.rb
403
411
  - lib/archimate/cli/archi.rb
404
412
  - lib/archimate/cli/cleanup.rb
@@ -413,58 +421,131 @@ files:
413
421
  - lib/archimate/data_model.rb
414
422
  - lib/archimate/data_model/any_attribute.rb
415
423
  - lib/archimate/data_model/any_element.rb
416
- - lib/archimate/data_model/archimate_node.rb
417
424
  - lib/archimate/data_model/bounds.rb
418
425
  - lib/archimate/data_model/color.rb
419
- - lib/archimate/data_model/concept.rb
426
+ - lib/archimate/data_model/comparison.rb
420
427
  - lib/archimate/data_model/concern.rb
421
428
  - lib/archimate/data_model/connection.rb
422
- - lib/archimate/data_model/constants.rb
423
- - lib/archimate/data_model/container.rb
429
+ - lib/archimate/data_model/connector_type.rb
424
430
  - lib/archimate/data_model/diagram.rb
425
- - lib/archimate/data_model/diffable_array.rb
426
- - lib/archimate/data_model/diffable_primitive.rb
427
- - lib/archimate/data_model/documentation.rb
431
+ - lib/archimate/data_model/diagram_type.rb
432
+ - lib/archimate/data_model/differentiable.rb
428
433
  - lib/archimate/data_model/element.rb
434
+ - lib/archimate/data_model/element_type.rb
429
435
  - lib/archimate/data_model/font.rb
430
- - lib/archimate/data_model/label.rb
431
436
  - lib/archimate/data_model/lang_string.rb
437
+ - lib/archimate/data_model/layer.rb
438
+ - lib/archimate/data_model/layers.rb
432
439
  - lib/archimate/data_model/location.rb
433
440
  - lib/archimate/data_model/metadata.rb
434
441
  - lib/archimate/data_model/model.rb
435
442
  - lib/archimate/data_model/modeling_note.rb
436
- - lib/archimate/data_model/named_referenceable.rb
437
443
  - lib/archimate/data_model/organization.rb
444
+ - lib/archimate/data_model/preserved_lang_string.rb
438
445
  - lib/archimate/data_model/property.rb
439
446
  - lib/archimate/data_model/property_definition.rb
440
447
  - lib/archimate/data_model/referenceable.rb
448
+ - lib/archimate/data_model/referenceable_collection.rb
441
449
  - lib/archimate/data_model/relationship.rb
450
+ - lib/archimate/data_model/relationship_type.rb
442
451
  - lib/archimate/data_model/schema_info.rb
443
452
  - lib/archimate/data_model/style.rb
444
- - lib/archimate/data_model/view.rb
445
- - lib/archimate/data_model/view_concept.rb
446
453
  - lib/archimate/data_model/view_node.rb
447
454
  - lib/archimate/data_model/viewpoint.rb
455
+ - lib/archimate/data_model/viewpoint_type.rb
448
456
  - lib/archimate/export/csv_export.rb
449
457
  - lib/archimate/export/cypher.rb
450
458
  - lib/archimate/export/graph_ml.rb
459
+ - lib/archimate/export/jsonl.rb
451
460
  - lib/archimate/export/n_quads.rb
452
461
  - lib/archimate/file_format.rb
453
- - lib/archimate/file_formats/archi_file_format.rb
454
462
  - lib/archimate/file_formats/archi_file_reader.rb
455
463
  - lib/archimate/file_formats/archi_file_writer.rb
456
- - lib/archimate/file_formats/archimate_v2.rb
457
- - lib/archimate/file_formats/model_exchange_file/xml_lang_string.rb
458
- - lib/archimate/file_formats/model_exchange_file/xml_metadata.rb
459
- - lib/archimate/file_formats/model_exchange_file/xml_property_definitions.rb
460
- - lib/archimate/file_formats/model_exchange_file/xml_property_defs.rb
461
464
  - lib/archimate/file_formats/model_exchange_file_reader.rb
462
- - lib/archimate/file_formats/model_exchange_file_reader_21.rb
463
- - lib/archimate/file_formats/model_exchange_file_reader_30.rb
464
- - lib/archimate/file_formats/model_exchange_file_writer.rb
465
465
  - lib/archimate/file_formats/model_exchange_file_writer_21.rb
466
466
  - lib/archimate/file_formats/model_exchange_file_writer_30.rb
467
- - lib/archimate/file_formats/writer.rb
467
+ - lib/archimate/file_formats/sax.rb
468
+ - lib/archimate/file_formats/sax/any_element.rb
469
+ - lib/archimate/file_formats/sax/archi/archi_handler_factory.rb
470
+ - lib/archimate/file_formats/sax/archi/bounds.rb
471
+ - lib/archimate/file_formats/sax/archi/connection.rb
472
+ - lib/archimate/file_formats/sax/archi/content.rb
473
+ - lib/archimate/file_formats/sax/archi/diagram.rb
474
+ - lib/archimate/file_formats/sax/archi/element.rb
475
+ - lib/archimate/file_formats/sax/archi/location.rb
476
+ - lib/archimate/file_formats/sax/archi/model.rb
477
+ - lib/archimate/file_formats/sax/archi/organization.rb
478
+ - lib/archimate/file_formats/sax/archi/property.rb
479
+ - lib/archimate/file_formats/sax/archi/relationship.rb
480
+ - lib/archimate/file_formats/sax/archi/style.rb
481
+ - lib/archimate/file_formats/sax/archi/view_node.rb
482
+ - lib/archimate/file_formats/sax/capture_content.rb
483
+ - lib/archimate/file_formats/sax/capture_documentation.rb
484
+ - lib/archimate/file_formats/sax/capture_properties.rb
485
+ - lib/archimate/file_formats/sax/content_element.rb
486
+ - lib/archimate/file_formats/sax/document.rb
487
+ - lib/archimate/file_formats/sax/handler.rb
488
+ - lib/archimate/file_formats/sax/lang_string.rb
489
+ - lib/archimate/file_formats/sax/model_exchange_file/color.rb
490
+ - lib/archimate/file_formats/sax/model_exchange_file/connection.rb
491
+ - lib/archimate/file_formats/sax/model_exchange_file/diagram.rb
492
+ - lib/archimate/file_formats/sax/model_exchange_file/element.rb
493
+ - lib/archimate/file_formats/sax/model_exchange_file/font.rb
494
+ - lib/archimate/file_formats/sax/model_exchange_file/item.rb
495
+ - lib/archimate/file_formats/sax/model_exchange_file/location.rb
496
+ - lib/archimate/file_formats/sax/model_exchange_file/metadata.rb
497
+ - lib/archimate/file_formats/sax/model_exchange_file/model.rb
498
+ - lib/archimate/file_formats/sax/model_exchange_file/model_exchange_handler_factory.rb
499
+ - lib/archimate/file_formats/sax/model_exchange_file/property.rb
500
+ - lib/archimate/file_formats/sax/model_exchange_file/property_definition.rb
501
+ - lib/archimate/file_formats/sax/model_exchange_file/relationship.rb
502
+ - lib/archimate/file_formats/sax/model_exchange_file/schema_info.rb
503
+ - lib/archimate/file_formats/sax/model_exchange_file/style.rb
504
+ - lib/archimate/file_formats/sax/model_exchange_file/view_node.rb
505
+ - lib/archimate/file_formats/sax/no_op.rb
506
+ - lib/archimate/file_formats/sax/preserved_lang_string.rb
507
+ - lib/archimate/file_formats/serializer.rb
508
+ - lib/archimate/file_formats/serializer/archi/bounds.rb
509
+ - lib/archimate/file_formats/serializer/archi/connection.rb
510
+ - lib/archimate/file_formats/serializer/archi/diagram.rb
511
+ - lib/archimate/file_formats/serializer/archi/documentation.rb
512
+ - lib/archimate/file_formats/serializer/archi/element.rb
513
+ - lib/archimate/file_formats/serializer/archi/location.rb
514
+ - lib/archimate/file_formats/serializer/archi/model.rb
515
+ - lib/archimate/file_formats/serializer/archi/organization.rb
516
+ - lib/archimate/file_formats/serializer/archi/property.rb
517
+ - lib/archimate/file_formats/serializer/archi/relationship.rb
518
+ - lib/archimate/file_formats/serializer/archi/view_node.rb
519
+ - lib/archimate/file_formats/serializer/archi/viewpoint_type.rb
520
+ - lib/archimate/file_formats/serializer/model_exchange_file/element.rb
521
+ - lib/archimate/file_formats/serializer/model_exchange_file/location.rb
522
+ - lib/archimate/file_formats/serializer/model_exchange_file/model_exchange_file_writer.rb
523
+ - lib/archimate/file_formats/serializer/model_exchange_file/organization.rb
524
+ - lib/archimate/file_formats/serializer/model_exchange_file/properties.rb
525
+ - lib/archimate/file_formats/serializer/model_exchange_file/relationship.rb
526
+ - lib/archimate/file_formats/serializer/model_exchange_file/style.rb
527
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/connection.rb
528
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb
529
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/item.rb
530
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/label.rb
531
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb
532
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/organization_body.rb
533
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/property.rb
534
+ - lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb
535
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/connection.rb
536
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb
537
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/item.rb
538
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/label.rb
539
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb
540
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/organization_body.rb
541
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/property.rb
542
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/property_definitions.rb
543
+ - lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb
544
+ - lib/archimate/file_formats/serializer/named_collection.rb
545
+ - lib/archimate/file_formats/serializer/writer.rb
546
+ - lib/archimate/file_formats/serializer/xml_lang_string.rb
547
+ - lib/archimate/file_formats/serializer/xml_metadata.rb
548
+ - lib/archimate/file_formats/serializer/xml_property_defs.rb
468
549
  - lib/archimate/lint/duplicate_entities.rb
469
550
  - lib/archimate/lint/linter.rb
470
551
  - lib/archimate/logging.rb
@@ -562,6 +643,7 @@ files:
562
643
  - lib/archimate/svg/entity/work_package.rb
563
644
  - lib/archimate/svg/entity_factory.rb
564
645
  - lib/archimate/svg/extents.rb
646
+ - lib/archimate/svg/path.rb
565
647
  - lib/archimate/svg/point.rb
566
648
  - lib/archimate/svg/svg_template.rb
567
649
  - lib/archimate/svg/svg_template.svg.erb