archimate 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -0
  4. data/README.md +10 -55
  5. data/Rakefile +19 -1
  6. data/archimate.gemspec +16 -14
  7. data/bin/archimate +12 -0
  8. data/lib/archimate/cli/archi.rb +38 -19
  9. data/lib/archimate/cli/cleanup.rb +41 -25
  10. data/lib/archimate/cli/duper.rb +0 -1
  11. data/lib/archimate/cli/mapper.rb +53 -40
  12. data/lib/archimate/cli/svger.rb +33 -4
  13. data/lib/archimate/core_refinements.rb +41 -0
  14. data/lib/archimate/data_model/bounds.rb +14 -4
  15. data/lib/archimate/data_model/comparison.rb +3 -27
  16. data/lib/archimate/data_model/connection.rb +26 -11
  17. data/lib/archimate/data_model/diagram.rb +17 -10
  18. data/lib/archimate/data_model/element.rb +21 -9
  19. data/lib/archimate/data_model/elements.rb +24 -18
  20. data/lib/archimate/data_model/lang_string.rb +34 -10
  21. data/lib/archimate/data_model/layer.rb +6 -0
  22. data/lib/archimate/data_model/location.rb +10 -13
  23. data/lib/archimate/data_model/model.rb +55 -43
  24. data/lib/archimate/data_model/organization.rb +21 -5
  25. data/lib/archimate/data_model/property.rb +0 -6
  26. data/lib/archimate/data_model/referenceable.rb +29 -3
  27. data/lib/archimate/data_model/referenceable_list.rb +34 -14
  28. data/lib/archimate/data_model/relationship.rb +29 -8
  29. data/lib/archimate/data_model/relationship_references.rb +115 -6
  30. data/lib/archimate/data_model/relationships.rb +15 -0
  31. data/lib/archimate/data_model/view_node.rb +20 -13
  32. data/lib/archimate/data_model/viewpoint.rb +13 -1
  33. data/lib/archimate/data_model/viewpoints.rb +416 -0
  34. data/lib/archimate/data_model.rb +7 -1
  35. data/lib/archimate/derived_relations.rb +2 -11
  36. data/lib/archimate/export/cypher.rb +6 -5
  37. data/lib/archimate/file_format.rb +1 -0
  38. data/lib/archimate/file_formats/archi_file_reader.rb +11 -1
  39. data/lib/archimate/file_formats/archi_file_writer.rb +15 -46
  40. data/lib/archimate/file_formats/archi_file_writer_4.rb +14 -0
  41. data/lib/archimate/file_formats/model_exchange_file_reader.rb +2 -1
  42. data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +1 -0
  43. data/lib/archimate/file_formats/sax/archi/diagram.rb +53 -13
  44. data/lib/archimate/file_formats/sax/archi/location.rb +1 -3
  45. data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +13 -2
  46. data/lib/archimate/file_formats/sax.rb +1 -0
  47. data/lib/archimate/file_formats/serializer/archi/archi_file_writer.rb +63 -0
  48. data/lib/archimate/file_formats/serializer/archi/archi_file_writer_3.rb +18 -0
  49. data/lib/archimate/file_formats/serializer/archi/archi_file_writer_4.rb +18 -0
  50. data/lib/archimate/file_formats/serializer/archi/bounds.rb +2 -2
  51. data/lib/archimate/file_formats/serializer/archi/connection.rb +24 -13
  52. data/lib/archimate/file_formats/serializer/archi/diagram.rb +3 -3
  53. data/lib/archimate/file_formats/serializer/archi/element.rb +2 -2
  54. data/lib/archimate/file_formats/serializer/archi/organization.rb +1 -1
  55. data/lib/archimate/file_formats/serializer/archi/property.rb +1 -1
  56. data/lib/archimate/file_formats/serializer/archi/relationship.rb +2 -2
  57. data/lib/archimate/file_formats/serializer/archi/view_node.rb +20 -22
  58. data/lib/archimate/file_formats/serializer/archi/viewpoint3.rb +43 -0
  59. data/lib/archimate/file_formats/serializer/archi/viewpoint4.rb +41 -0
  60. data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +3 -7
  61. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +3 -3
  62. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +9 -2
  63. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +1 -1
  64. data/lib/archimate/file_formats/serializer/model_exchange_file/v21/viewpoint.rb +23 -0
  65. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +3 -3
  66. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +5 -7
  67. data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +3 -3
  68. data/lib/archimate/file_formats/serializer/writer.rb +0 -5
  69. data/lib/archimate/file_formats/serializer.rb +6 -2
  70. data/lib/archimate/lint/duplicate_entities.rb +5 -5
  71. data/lib/archimate/lint/linter.rb +4 -4
  72. data/lib/archimate/maybe_io.rb +3 -2
  73. data/lib/archimate/svg/archimate.css +19 -21
  74. data/lib/archimate/svg/connection.rb +1 -1
  75. data/lib/archimate/svg/diagram.rb +1 -6
  76. data/lib/archimate/svg/entity/application_component.rb +9 -3
  77. data/lib/archimate/svg/entity/constraint.rb +0 -1
  78. data/lib/archimate/svg/entity/contract.rb +9 -0
  79. data/lib/archimate/svg/entity/data_entity.rb +1 -1
  80. data/lib/archimate/svg/entity/device.rb +1 -1
  81. data/lib/archimate/svg/entity/event_entity.rb +24 -7
  82. data/lib/archimate/svg/entity/group.rb +23 -4
  83. data/lib/archimate/svg/entity/grouping.rb +37 -0
  84. data/lib/archimate/svg/entity/interface_entity.rb +1 -1
  85. data/lib/archimate/svg/entity/node.rb +1 -1
  86. data/lib/archimate/svg/entity/outcome.rb +0 -1
  87. data/lib/archimate/svg/entity/principle.rb +0 -1
  88. data/lib/archimate/svg/entity/process_entity.rb +1 -1
  89. data/lib/archimate/svg/entity/requirement.rb +0 -1
  90. data/lib/archimate/svg/entity/service_entity.rb +6 -13
  91. data/lib/archimate/svg/entity.rb +1 -0
  92. data/lib/archimate/svg/entity_factory.rb +9 -5
  93. data/lib/archimate/svg/path.rb +57 -46
  94. data/lib/archimate/svg/point.rb +4 -0
  95. data/lib/archimate/svg/segment.rb +30 -0
  96. data/lib/archimate/svg/svg_template.svg.erb +11 -3
  97. data/lib/archimate/svg/view_node.rb +22 -0
  98. data/lib/archimate/version.rb +1 -1
  99. data/lib/archimate.rb +3 -2
  100. metadata +54 -54
  101. data/exe/archidiff +0 -7
  102. data/exe/archidiff-summary +0 -7
  103. data/exe/archimerge +0 -7
  104. data/exe/fmtxml +0 -7
  105. data/lib/archimate/data_model/viewpoint_type.rb +0 -389
  106. data/lib/archimate/file_formats/serializer/archi/location.rb +0 -26
  107. data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +0 -45
  108. data/lib/archimate/svg/child.rb +0 -29
@@ -25,13 +25,11 @@ module Archimate
25
25
  end
26
26
 
27
27
  def model_attrs(model)
28
- remove_nil_values(
29
- model.namespaces.merge(
30
- "xsi:schemaLocation" => model.schema_locations.join(" "),
31
- "identifier" => identifier(model.id),
32
- "version" => model.version
33
- )
34
- )
28
+ model.namespaces.merge(
29
+ "xsi:schemaLocation" => model.schema_locations.join(" "),
30
+ "identifier" => identifier(model.id),
31
+ "version" => model.version
32
+ ).compact
35
33
  end
36
34
  end
37
35
  end
@@ -22,8 +22,8 @@ module Archimate
22
22
  identifier: identifier(view_node.id),
23
23
  elementRef: nil,
24
24
  "xsi:type" => view_node.type,
25
- "x" => view_node.bounds ? (view_node.bounds&.x + x_offset).round : nil,
26
- "y" => view_node.bounds ? (view_node.bounds&.y + y_offset).round : nil,
25
+ "x" => view_node.bounds ? ((view_node.bounds&.x || 0) + x_offset).round : nil,
26
+ "y" => view_node.bounds ? ((view_node.bounds&.y || 0) + y_offset).round : nil,
27
27
  "w" => view_node.bounds&.width&.round,
28
28
  "h" => view_node.bounds&.height&.round
29
29
  }
@@ -35,7 +35,7 @@ module Archimate
35
35
  attrs[:elementRef] = view_node.view_refs
36
36
  attrs[:type] = "model"
37
37
  end
38
- remove_nil_values(attrs)
38
+ attrs.compact
39
39
  end
40
40
  end
41
41
  end
@@ -45,11 +45,6 @@ module Archimate
45
45
  end
46
46
  end
47
47
  end
48
-
49
- def remove_nil_values(h)
50
- h.delete_if { |_k, v| v.nil? }
51
- h
52
- end
53
48
  end
54
49
  end
55
50
  end
@@ -9,18 +9,21 @@ module Archimate
9
9
  autoload :XmlMetadata, 'archimate/file_formats/serializer/xml_metadata'
10
10
  autoload :XmlPropertyDefs, 'archimate/file_formats/serializer/xml_property_defs'
11
11
  module Archi
12
+ autoload :ArchiFileWriter, 'archimate/file_formats/serializer/archi/archi_file_writer'
13
+ autoload :ArchiFileWriter3, 'archimate/file_formats/serializer/archi/archi_file_writer_3'
14
+ autoload :ArchiFileWriter4, 'archimate/file_formats/serializer/archi/archi_file_writer_4'
12
15
  autoload :Bounds, 'archimate/file_formats/serializer/archi/bounds'
13
16
  autoload :Connection, 'archimate/file_formats/serializer/archi/connection'
14
17
  autoload :Diagram, 'archimate/file_formats/serializer/archi/diagram'
15
18
  autoload :Documentation, 'archimate/file_formats/serializer/archi/documentation'
16
19
  autoload :Element, 'archimate/file_formats/serializer/archi/element'
17
- autoload :Location, 'archimate/file_formats/serializer/archi/location'
18
20
  autoload :Model, 'archimate/file_formats/serializer/archi/model'
19
21
  autoload :Organization, 'archimate/file_formats/serializer/archi/organization'
20
22
  autoload :Property, 'archimate/file_formats/serializer/archi/property'
21
23
  autoload :Relationship, 'archimate/file_formats/serializer/archi/relationship'
22
24
  autoload :ViewNode, 'archimate/file_formats/serializer/archi/view_node'
23
- autoload :ViewpointType, 'archimate/file_formats/serializer/archi/viewpoint_type'
25
+ autoload :Viewpoint3, 'archimate/file_formats/serializer/archi/viewpoint3'
26
+ autoload :Viewpoint4, 'archimate/file_formats/serializer/archi/viewpoint4'
24
27
  end
25
28
  module ModelExchangeFile
26
29
  autoload :Element, 'archimate/file_formats/serializer/model_exchange_file/element'
@@ -39,6 +42,7 @@ module Archimate
39
42
  autoload :OrganizationBody, 'archimate/file_formats/serializer/model_exchange_file/v21/organization_body'
40
43
  autoload :Property, 'archimate/file_formats/serializer/model_exchange_file/v21/property'
41
44
  autoload :ViewNode, 'archimate/file_formats/serializer/model_exchange_file/v21/view_node'
45
+ autoload :Viewpoint, 'archimate/file_formats/serializer/model_exchange_file/v21/viewpoint'
42
46
  end
43
47
  module V30
44
48
  autoload :Connection, 'archimate/file_formats/serializer/model_exchange_file/v30/connection'
@@ -6,7 +6,7 @@ module Archimate
6
6
  a able about above according accordingly across actually after afterwards again against all allow allows
7
7
  almost alone along already also although always am among amongst amoungst amount an and another any anybody
8
8
  anyhow anyone anything anyway anyways anywhere apart appear appreciate appropriate are around as aside ask
9
- asking associated at available away awfully back be became because become becomes becoming been before
9
+ asking associated at available away awfully be became because become becomes becoming been before
10
10
  beforehand behind being believe below beside besides best better between beyond bill both bottom brief but
11
11
  by call came can can't cannot cant cause causes certain certainly changes clearly co com come comes computer
12
12
  con concerning consequently consider considering contain containing contains corresponding could couldn't
@@ -14,7 +14,7 @@ module Archimate
14
14
  does doesn't doing don't done down downwards due during each edu eg eight either eleven else elsewhere empty
15
15
  enough entirely especially et etc even ever every everybody everyone everything everywhere ex exactly example
16
16
  except far few fifteen fifth fify fill find fire first five followed following follows for former formerly
17
- forth forty found four from front full further furthermore get gets getting give given gives go goes going
17
+ forth forty found four from full further furthermore get gets getting give given gives go goes going
18
18
  gone got gotten greetings had hadn't happens hardly has hasn't hasnt have haven't having he he's hello help
19
19
  hence her here here's hereafter hereby herein hereupon hers herself hi him himself his hither hopefully how
20
20
  howbeit however hundred i i'd i'll i'm i've ie if ignored immediate in inasmuch inc indeed indicate indicated
@@ -85,13 +85,13 @@ module Archimate
85
85
  hash[tag] = hash.fetch(tag, []) << entity
86
86
  end
87
87
  @dupes.delete_if { |_tag, entities| entities.size <= 1 }
88
- # @word_count.sort_by(&:last).reverse.each { |ak, av| puts "#{ak}: #{av}" }
89
88
  @dupes
90
89
  end
91
90
 
92
91
  def entity_hash_name(entity)
93
- layer = entity.layer
94
- layer_sort_order = layer ? DataModel::Layers.find_index(layer) : 9
92
+ layer = entity.respond_to?(:layer) ? entity.layer : nil
93
+ layer ||= DataModel::Layers::None
94
+ layer_sort_order = DataModel::Layers.find_index(layer) # layer ? DataModel::Layers.find_index(layer) : 9
95
95
  [
96
96
  entity.class.name, # Taking advantage of Element being before Relationship
97
97
  layer_sort_order.to_s,
@@ -89,13 +89,13 @@ module Archimate
89
89
  def invalid_for_viewpoint
90
90
  model.diagrams.each_with_object([]) do |diagram, errors|
91
91
  next if diagram.total_viewpoint?
92
- valid_entity_types = DataModel::ViewpointType::VIEWPOINTS[diagram.viewpoint_type][:entities]
93
- valid_relation_types = DataModel::ViewpointType::VIEWPOINTS[diagram.viewpoint_type][:relations]
92
+ valid_entity_types = diagram.viewpoint&.allowed_element_types || DataModel::Elements.classes
93
+ valid_relation_types = diagram.viewpoint&.allowed_relationship_types || DataModel::Relationships.classes
94
94
  invalid_elements = diagram.all_nodes.reject do |child|
95
- child.element&.type.nil? || valid_entity_types.include?(child.element&.type)
95
+ child.element.nil? || valid_entity_types.include?(child.element.class)
96
96
  end
97
97
  invalid_relations = diagram.connections.reject do |sc|
98
- sc.element&.type.nil? || valid_relation_types.include?(sc.element&.type)
98
+ sc.element.nil? || valid_relation_types.include?(sc.element.class)
99
99
  end
100
100
  next unless !invalid_elements.empty? || !invalid_relations.empty?
101
101
  errors << format(
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
- ## This class passes an IO (or a fake IO) to the given block based on passing
3
- # either a filename to permit ouput into or nil for a fake IO.
2
+
3
+ # This class passes an IO (or a fake IO) to the given block based on passing
4
+ # either a filename to permit output into or nil for a fake IO.
4
5
  #
5
6
  module Archimate
6
7
  class MaybeIO
@@ -56,7 +56,6 @@ table.properties>caption {
56
56
  float: right;
57
57
  height: 20px;
58
58
  width: 20px;
59
- /*border: 1px solid red;*/
60
59
  }
61
60
 
62
61
  .archimate-icon {
@@ -115,8 +114,8 @@ table.properties>caption {
115
114
  }
116
115
 
117
116
  .archimate-motivation-background {
118
- fill: #fecdfe;
119
- stroke: #b18fb1;
117
+ fill: #cccdfd;
118
+ stroke: #8e8fb1;
120
119
  }
121
120
 
122
121
  .archimate-motivation2-background {
@@ -149,6 +148,12 @@ table.properties>caption {
149
148
  stroke: #939696;
150
149
  }
151
150
 
151
+ .archimate-grouping-background {
152
+ fill: #ffffff;
153
+ stroke: #b2b2b2;
154
+ stroke-dasharray: 8,4;
155
+ }
156
+
152
157
  .archimate-sticky-background {
153
158
  fill: #fffeb9;
154
159
  stroke: #b2b181;
@@ -185,58 +190,51 @@ table.properties>caption {
185
190
  font-size: 9px;
186
191
  }
187
192
 
188
- .archimate-assignment-relationship {
193
+ .archimate-assignment {
189
194
  marker-end: url(#archimate-filled-arrow);
190
195
  marker-start: url(#archimate-dot-marker);
191
196
  }
192
197
 
193
- .archimate-composition-relationship {
198
+ .archimate-composition {
194
199
  marker-start: url(#archimate-filled-diamond);
195
200
  }
196
201
 
197
- .archimate-used-by-relationship {
202
+ .archimate-used-by {
198
203
  marker-end: url(#archimate-used-by-arrow);
199
204
  }
200
205
 
201
- .archimate-serving-relationship {
206
+ .archimate-serving {
202
207
  marker-end: url(#archimate-used-by-arrow);
203
208
  }
204
209
 
205
- .archimate-aggregation-relationship {
210
+ .archimate-aggregation {
206
211
  marker-start: url(#archimate-hollow-diamond);
207
212
  }
208
213
 
209
- .archimate-access-relationship {
214
+ .archimate-access {
210
215
  marker-end: url(#archimate-open-arrow);
211
216
  stroke-dasharray: 2, 3;
212
217
  }
213
218
 
214
- .archimate-realisation-relationship {
219
+ .archimate-realization {
215
220
  marker-end: url(#archimate-hollow-arrow);
216
221
  stroke-dasharray: 5, 3;
217
222
  }
218
223
 
219
- .archimate-specialisation-relationship {
224
+ .archimate-specialization {
220
225
  marker-end: url(#archimate-hollow-arrow);
221
226
  }
222
227
 
223
- .archimate-influence-relationship {
228
+ .archimate-influence {
224
229
  marker-end: url(#archimate-open-arrow);
225
230
  stroke-dasharray: 5, 3;
226
231
  }
227
232
 
228
- /*, .archimate-association-relationship {
229
- }
230
- */
231
- .archimate-triggering-relationship {
233
+ .archimate-triggering {
232
234
  marker-end: url(#archimate-filled-arrow);
233
235
  }
234
236
 
235
- .archimate-flow-relationship {
237
+ .archimate-flow {
236
238
  marker-end: url(#archimate-filled-arrow);
237
239
  stroke-dasharray: 3, 3;
238
240
  }
239
-
240
- /*.archimate-default-connection {
241
- }
242
- */
@@ -51,7 +51,7 @@ module Archimate
51
51
  end
52
52
 
53
53
  def text_position
54
- case connection.style
54
+ case connection.style&.text_position
55
55
  when 0
56
56
  0.1 # "10%"
57
57
  when 1
@@ -66,15 +66,10 @@ module Archimate
66
66
  )
67
67
  end
68
68
 
69
- def attr_to_i(node, attr)
70
- ival = node.attr(attr)
71
- ival.to_i unless ival.nil? || ival.strip.empty?
72
- end
73
-
74
69
  def render_elements(svg_node)
75
70
  diagram
76
71
  .nodes
77
- .reduce(svg_node) { |svg, child| Child.new(child).render_elements(svg) }
72
+ .reduce(svg_node) { |svg, view_node| ViewNode.new(view_node).render_elements(svg) }
78
73
  end
79
74
 
80
75
  def render_connections(svg_node)
@@ -3,14 +3,20 @@
3
3
  module Archimate
4
4
  module Svg
5
5
  module Entity
6
- # TODO: support alternate appearance
7
- class ApplicationComponent < BaseEntity
6
+ class ApplicationComponent < RectEntity
8
7
  def initialize(child, bounds_offset)
9
8
  super
9
+ @badge = "#archimate-app-component-badge"
10
10
  end
11
11
 
12
12
  def entity_shape(xml, bounds)
13
- component_path(xml, bounds)
13
+ case child.child_type
14
+ when "1"
15
+ super
16
+ else
17
+ component_path(xml, bounds)
18
+ @badge = nil
19
+ end
14
20
  end
15
21
 
16
22
  def component_path(xml, bounds)
@@ -6,7 +6,6 @@ module Archimate
6
6
  class Constraint < MotivationEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @background_class = "archimate-motivation2-background"
10
9
  @badge = "#archimate-constraint-badge"
11
10
  end
12
11
  end
@@ -7,6 +7,15 @@ module Archimate
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
9
  end
10
+
11
+ def entity_shape(xml, bounds)
12
+ calc_text_bounds(bounds)
13
+ xml.g(class: background_class) do
14
+ xml.rect(x: bounds.left, y: bounds.top, width: bounds.width, height: bounds.height, class: background_class, style: shape_style)
15
+ xml.rect(x: bounds.left, y: bounds.top, width: bounds.width, height: @margin, class: "archimate-decoration")
16
+ xml.rect(x: bounds.left, y: bounds.top + bounds.height - @margin, width: bounds.width, height: @margin, class: "archimate-decoration")
17
+ end
18
+ end
10
19
  end
11
20
  end
12
21
  end
@@ -6,7 +6,7 @@ module Archimate
6
6
  class DataEntity < BaseEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @margin = 10
9
+ @margin = 8
10
10
  end
11
11
 
12
12
  def calc_text_bounds(_bounds)
@@ -12,7 +12,7 @@ module Archimate
12
12
 
13
13
  def entity_shape(xml, bounds)
14
14
  case child.child_type
15
- when 1
15
+ when "1"
16
16
  @badge = "#archimate-device-badge"
17
17
  node_path(xml, bounds)
18
18
  else
@@ -3,13 +3,28 @@
3
3
  module Archimate
4
4
  module Svg
5
5
  module Entity
6
- class EventEntity < BaseEntity
6
+ class EventEntity < RoundedRectEntity
7
+ def initialize(child, bounds_offset)
8
+ super
9
+ @badge = "#archimate-event-badge"
10
+ end
11
+
7
12
  def entity_shape(xml, bounds)
13
+ case child.child_type
14
+ when "1"
15
+ @badge = nil
16
+ event_path(xml, bounds)
17
+ else
18
+ super
19
+ end
20
+ end
21
+
22
+ def event_path(xml, bounds)
8
23
  notch_x = 18
9
24
  notch_height = bounds.height / 2.0
10
25
  event_width = bounds.width * 0.85
11
26
  rx = 17
12
- calc_text_bounds(notch_x)
27
+ calc_event_text_bounds(notch_x)
13
28
  xml.path(
14
29
  d: [
15
30
  "M", bounds.left, bounds.top,
@@ -23,12 +38,14 @@ module Archimate
23
38
  )
24
39
  end
25
40
 
26
- def calc_text_bounds(notch_x)
41
+ def calc_event_text_bounds(notch_x)
27
42
  bounds = @text_bounds
28
- @text_bounds = DataModel::Bounds.new(bounds.to_h.merge(
29
- x: bounds.left + notch_x * 0.80,
30
- width: bounds.width - notch_x
31
- ))
43
+ @text_bounds = DataModel::Bounds.new(
44
+ bounds.to_h.merge(
45
+ x: bounds.left + notch_x * 0.80,
46
+ width: bounds.width - notch_x
47
+ )
48
+ )
32
49
  end
33
50
  end
34
51
  end
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module Archimate
@@ -12,9 +11,29 @@ module Archimate
12
11
 
13
12
  def entity_shape(xml, bounds)
14
13
  group_header_height = 21
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
- xml.rect(x: bounds.left, y: bounds.top, width: bounds.width / 2.0, height: group_header_height, class: background_class, style: shape_style)
17
- xml.rect(x: bounds.left, y: bounds.top, width: bounds.width / 2.0, height: group_header_height, class: "archimate-decoration")
14
+ xml.rect(
15
+ x: bounds.left,
16
+ y: bounds.top + group_header_height,
17
+ width: bounds.width,
18
+ height: bounds.height - group_header_height,
19
+ class: background_class,
20
+ style: shape_style
21
+ )
22
+ xml.rect(
23
+ x: bounds.left,
24
+ y: bounds.top,
25
+ width: bounds.width / 2.0,
26
+ height: group_header_height,
27
+ class: background_class,
28
+ style: shape_style
29
+ )
30
+ xml.rect(
31
+ x: bounds.left,
32
+ y: bounds.top,
33
+ width: bounds.width / 2.0,
34
+ height: group_header_height,
35
+ class: "archimate-decoration"
36
+ )
18
37
  @text_bounds = DataModel::Bounds.new(bounds.to_h.merge(height: group_header_height))
19
38
  @text_align = "left"
20
39
  end
@@ -0,0 +1,37 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ module Archimate
5
+ module Svg
6
+ module Entity
7
+ class Grouping < BaseEntity
8
+ def initialize(child, bounds_offset)
9
+ super
10
+ @background_class = "archimate-grouping-background"
11
+ end
12
+
13
+ def entity_shape(xml, bounds)
14
+ group_header_height = 21
15
+ xml.rect(
16
+ x: bounds.left,
17
+ y: bounds.top + group_header_height,
18
+ width: bounds.width,
19
+ height: bounds.height - group_header_height,
20
+ class: background_class,
21
+ style: shape_style
22
+ )
23
+ xml.path(
24
+ d: ["M", bounds.left, bounds.top + group_header_height - 1,
25
+ "v", -(group_header_height - 1),
26
+ "h", bounds.width / 2,
27
+ "v", group_header_height - 1].map(&:to_s).join(" "),
28
+ class: background_class,
29
+ style: shape_style
30
+ )
31
+ @text_bounds = DataModel::Bounds.new(bounds.to_h.merge(height: group_header_height))
32
+ @text_align = "left"
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -11,7 +11,7 @@ module Archimate
11
11
 
12
12
  def entity_shape(xml, bounds)
13
13
  case child.child_type
14
- when 1
14
+ when "1"
15
15
  @badge = nil
16
16
  elipse_path(xml, bounds)
17
17
  else
@@ -14,7 +14,7 @@ module Archimate
14
14
 
15
15
  def entity_shape(xml, bounds)
16
16
  case child.child_type
17
- when 1
17
+ when "1"
18
18
  @badge_bounds = DataModel::Bounds.new(
19
19
  x: bounds.right - 25,
20
20
  y: bounds.top + 5,
@@ -6,7 +6,6 @@ module Archimate
6
6
  class Outcome < MotivationEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @background_class = "archimate-motivation2-background"
10
9
  @badge = "#archimate-outcome-badge"
11
10
  end
12
11
  end
@@ -6,7 +6,6 @@ module Archimate
6
6
  class Principle < MotivationEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @background_class = "archimate-motivation2-background"
10
9
  @badge = "#archimate-principle-badge"
11
10
  end
12
11
  end
@@ -11,7 +11,7 @@ module Archimate
11
11
 
12
12
  def entity_shape(xml, bounds)
13
13
  case child.child_type
14
- when 1
14
+ when "1"
15
15
  @badge = nil
16
16
  process_path(xml, bounds)
17
17
  else
@@ -6,7 +6,6 @@ module Archimate
6
6
  class Requirement < MotivationEntity
7
7
  def initialize(child, bounds_offset)
8
8
  super
9
- @background_class = "archimate-motivation2-background"
10
9
  @badge = "#archimate-requirement-badge"
11
10
  end
12
11
  end
@@ -3,12 +3,11 @@
3
3
  module Archimate
4
4
  module Svg
5
5
  module Entity
6
- class ServiceEntity < BaseEntity
7
- include Rect
8
-
6
+ class ServiceEntity < RoundedRectEntity
9
7
  def initialize(child, bounds_offset)
10
8
  super
11
9
  bounds = child.bounds
10
+ @badge = "#archimate-service-badge"
12
11
  @text_bounds = DataModel::Bounds.new(
13
12
  x: bounds.left + 7,
14
13
  y: bounds.top + 5,
@@ -19,17 +18,11 @@ module Archimate
19
18
 
20
19
  def entity_shape(xml, bounds)
21
20
  case child.child_type
22
- when 1
23
- @badge_bounds = DataModel::Bounds.new(
24
- x: bounds.right - 25,
25
- y: bounds.top + 5,
26
- width: 20,
27
- height: 20
28
- )
29
- @badge = "#archimate-service-badge"
30
- rect_path(xml, bounds)
31
- else
21
+ when "1"
32
22
  service_path(xml, bounds)
23
+ @badge = nil
24
+ else
25
+ super
33
26
  end
34
27
  end
35
28
 
@@ -46,6 +46,7 @@ module Archimate
46
46
  autoload :Gap, 'archimate/svg/entity/gap'
47
47
  autoload :Goal, 'archimate/svg/entity/goal'
48
48
  autoload :Group, 'archimate/svg/entity/group'
49
+ autoload :Grouping, 'archimate/svg/entity/grouping'
49
50
  autoload :ImplementationEvent, 'archimate/svg/entity/implementation_event'
50
51
  autoload :InfrastructureEvent, 'archimate/svg/entity/infrastructure_event'
51
52
  autoload :InfrastructureFunction, 'archimate/svg/entity/infrastructure_function'
@@ -3,13 +3,17 @@
3
3
  module Archimate
4
4
  module Svg
5
5
  module EntityFactory
6
+ # @todo this is wrong because it depends on `type` attribute
6
7
  def make_entity(child, bounds_offset)
7
- entity = child.element || child
8
- klass_name = entity.type.sub('archimate:', '')
9
- klass = Archimate::Svg::Entity.const_get(klass_name)
10
- klass.new(child, bounds_offset)
8
+ if child.element
9
+ klass_name = child.element.class.name.split("::").last
10
+ else
11
+ klass_name = child.type.sub('archimate:', '')
12
+ end
13
+ Entity.const_get(klass_name).new(child, bounds_offset)
11
14
  rescue NameError
12
- puts "Unsupported entity type #{klass_name}"
15
+ Logging.logger.fatal "Unsupported entity type #{klass_name}"
16
+ raise
13
17
  end
14
18
  module_function :make_entity
15
19
  end