archimate 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/README.md +10 -55
- data/Rakefile +19 -1
- data/archimate.gemspec +16 -14
- data/bin/archimate +12 -0
- data/lib/archimate/cli/archi.rb +38 -19
- data/lib/archimate/cli/cleanup.rb +41 -25
- data/lib/archimate/cli/duper.rb +0 -1
- data/lib/archimate/cli/mapper.rb +53 -40
- data/lib/archimate/cli/svger.rb +33 -4
- data/lib/archimate/core_refinements.rb +41 -0
- data/lib/archimate/data_model/bounds.rb +14 -4
- data/lib/archimate/data_model/comparison.rb +3 -27
- data/lib/archimate/data_model/connection.rb +26 -11
- data/lib/archimate/data_model/diagram.rb +17 -10
- data/lib/archimate/data_model/element.rb +21 -9
- data/lib/archimate/data_model/elements.rb +24 -18
- data/lib/archimate/data_model/lang_string.rb +34 -10
- data/lib/archimate/data_model/layer.rb +6 -0
- data/lib/archimate/data_model/location.rb +10 -13
- data/lib/archimate/data_model/model.rb +55 -43
- data/lib/archimate/data_model/organization.rb +21 -5
- data/lib/archimate/data_model/property.rb +0 -6
- data/lib/archimate/data_model/referenceable.rb +29 -3
- data/lib/archimate/data_model/referenceable_list.rb +34 -14
- data/lib/archimate/data_model/relationship.rb +29 -8
- data/lib/archimate/data_model/relationship_references.rb +115 -6
- data/lib/archimate/data_model/relationships.rb +15 -0
- data/lib/archimate/data_model/view_node.rb +20 -13
- data/lib/archimate/data_model/viewpoint.rb +13 -1
- data/lib/archimate/data_model/viewpoints.rb +416 -0
- data/lib/archimate/data_model.rb +7 -1
- data/lib/archimate/derived_relations.rb +2 -11
- data/lib/archimate/export/cypher.rb +6 -5
- data/lib/archimate/file_format.rb +1 -0
- data/lib/archimate/file_formats/archi_file_reader.rb +11 -1
- data/lib/archimate/file_formats/archi_file_writer.rb +15 -46
- data/lib/archimate/file_formats/archi_file_writer_4.rb +14 -0
- data/lib/archimate/file_formats/model_exchange_file_reader.rb +2 -1
- data/lib/archimate/file_formats/model_exchange_file_writer_21.rb +1 -0
- data/lib/archimate/file_formats/sax/archi/diagram.rb +53 -13
- data/lib/archimate/file_formats/sax/archi/location.rb +1 -3
- data/lib/archimate/file_formats/sax/model_exchange_file/diagram.rb +13 -2
- data/lib/archimate/file_formats/sax.rb +1 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer.rb +63 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer_3.rb +18 -0
- data/lib/archimate/file_formats/serializer/archi/archi_file_writer_4.rb +18 -0
- data/lib/archimate/file_formats/serializer/archi/bounds.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/connection.rb +24 -13
- data/lib/archimate/file_formats/serializer/archi/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/archi/element.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/organization.rb +1 -1
- data/lib/archimate/file_formats/serializer/archi/property.rb +1 -1
- data/lib/archimate/file_formats/serializer/archi/relationship.rb +2 -2
- data/lib/archimate/file_formats/serializer/archi/view_node.rb +20 -22
- data/lib/archimate/file_formats/serializer/archi/viewpoint3.rb +43 -0
- data/lib/archimate/file_formats/serializer/archi/viewpoint4.rb +41 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/style.rb +3 -7
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/model.rb +9 -2
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/view_node.rb +1 -1
- data/lib/archimate/file_formats/serializer/model_exchange_file/v21/viewpoint.rb +23 -0
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/diagram.rb +3 -3
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/model.rb +5 -7
- data/lib/archimate/file_formats/serializer/model_exchange_file/v30/view_node.rb +3 -3
- data/lib/archimate/file_formats/serializer/writer.rb +0 -5
- data/lib/archimate/file_formats/serializer.rb +6 -2
- data/lib/archimate/lint/duplicate_entities.rb +5 -5
- data/lib/archimate/lint/linter.rb +4 -4
- data/lib/archimate/maybe_io.rb +3 -2
- data/lib/archimate/svg/archimate.css +19 -21
- data/lib/archimate/svg/connection.rb +1 -1
- data/lib/archimate/svg/diagram.rb +1 -6
- data/lib/archimate/svg/entity/application_component.rb +9 -3
- data/lib/archimate/svg/entity/constraint.rb +0 -1
- data/lib/archimate/svg/entity/contract.rb +9 -0
- data/lib/archimate/svg/entity/data_entity.rb +1 -1
- data/lib/archimate/svg/entity/device.rb +1 -1
- data/lib/archimate/svg/entity/event_entity.rb +24 -7
- data/lib/archimate/svg/entity/group.rb +23 -4
- data/lib/archimate/svg/entity/grouping.rb +37 -0
- data/lib/archimate/svg/entity/interface_entity.rb +1 -1
- data/lib/archimate/svg/entity/node.rb +1 -1
- data/lib/archimate/svg/entity/outcome.rb +0 -1
- data/lib/archimate/svg/entity/principle.rb +0 -1
- data/lib/archimate/svg/entity/process_entity.rb +1 -1
- data/lib/archimate/svg/entity/requirement.rb +0 -1
- data/lib/archimate/svg/entity/service_entity.rb +6 -13
- data/lib/archimate/svg/entity.rb +1 -0
- data/lib/archimate/svg/entity_factory.rb +9 -5
- data/lib/archimate/svg/path.rb +57 -46
- data/lib/archimate/svg/point.rb +4 -0
- data/lib/archimate/svg/segment.rb +30 -0
- data/lib/archimate/svg/svg_template.svg.erb +11 -3
- data/lib/archimate/svg/view_node.rb +22 -0
- data/lib/archimate/version.rb +1 -1
- data/lib/archimate.rb +3 -2
- metadata +54 -54
- data/exe/archidiff +0 -7
- data/exe/archidiff-summary +0 -7
- data/exe/archimerge +0 -7
- data/exe/fmtxml +0 -7
- data/lib/archimate/data_model/viewpoint_type.rb +0 -389
- data/lib/archimate/file_formats/serializer/archi/location.rb +0 -26
- data/lib/archimate/file_formats/serializer/archi/viewpoint_type.rb +0 -45
- data/lib/archimate/svg/child.rb +0 -29
data/lib/archimate/svg/path.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
using Archimate::CoreRefinements
|
4
|
+
|
3
5
|
module Archimate
|
4
6
|
module Svg
|
5
7
|
class Path
|
8
|
+
LINE_CURVE_RADIUS = 5
|
9
|
+
|
6
10
|
attr_reader :connection
|
7
11
|
|
8
12
|
def initialize(connection)
|
@@ -23,28 +27,42 @@ module Archimate
|
|
23
27
|
# @return Point at the given percent along line between start and end
|
24
28
|
def point(fraction)
|
25
29
|
length_from_start = length * fraction
|
26
|
-
segments.each do |
|
27
|
-
|
28
|
-
|
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
|
30
|
+
segments.each do |segment|
|
31
|
+
return segment.from_start(length_from_start) if segment.length >= length_from_start
|
32
|
+
length_from_start -= segment.length
|
37
33
|
end
|
38
34
|
Point.new(0.0, 0.0)
|
39
35
|
end
|
40
36
|
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
37
|
+
# New implementation of SVG d method for a set of points
|
38
|
+
# making smooth curves at each bendpoint
|
39
|
+
#
|
40
|
+
# Given three points: a, b, c
|
41
|
+
# The result should be:
|
42
|
+
# (a is already part of the path -> first point is a move_to command)
|
43
|
+
# line_to(segment(a-b) - curve_radius (from end))
|
44
|
+
# q_curve(b, segment(b-c) - curve_radius (from start))
|
45
|
+
#
|
46
|
+
# For cases with more bendpoints (with values d, e, ...)
|
47
|
+
# repeat the above section with c as the new a value (so then [c, d, e], [d, e, f], etc.)
|
46
48
|
def d
|
47
|
-
[move_to(points.first)]
|
49
|
+
[move_to(points.first)]
|
50
|
+
.concat(
|
51
|
+
points
|
52
|
+
.each_cons(3)
|
53
|
+
.flat_map { |a, b, c| curve_segment(a, b, c) }
|
54
|
+
)
|
55
|
+
.concat([line_to(points.last)])
|
56
|
+
.join(" ")
|
57
|
+
end
|
58
|
+
|
59
|
+
def curve_segment(a, b, c)
|
60
|
+
pt1 = Segment.new(a, b).from_end(LINE_CURVE_RADIUS)
|
61
|
+
pt2 = Segment.new(b, c).from_start(LINE_CURVE_RADIUS)
|
62
|
+
[
|
63
|
+
line_to(pt1),
|
64
|
+
q_curve(b, pt2)
|
65
|
+
]
|
48
66
|
end
|
49
67
|
|
50
68
|
def points
|
@@ -52,37 +70,29 @@ module Archimate
|
|
52
70
|
end
|
53
71
|
|
54
72
|
def segments
|
55
|
-
(0..points.length - 2).map { |i|
|
73
|
+
(0..points.length - 2).map { |i| Segment.new(points[i], points[i + 1]) }
|
56
74
|
end
|
57
75
|
|
58
76
|
# Returns the lengths of each segment of the line
|
59
77
|
def segment_lengths
|
60
|
-
segments.map
|
78
|
+
segments.map(&:length)
|
61
79
|
end
|
62
80
|
|
63
81
|
private
|
64
82
|
|
65
83
|
def source_bounds
|
66
|
-
@source_bounds ||= connection.
|
84
|
+
@source_bounds ||= connection.source_bounds || DataModel::Bounds.zero
|
67
85
|
end
|
68
86
|
|
69
87
|
def target_bounds
|
70
|
-
@target_bounds ||= connection.
|
88
|
+
@target_bounds ||= connection.target_bounds || DataModel::Bounds.zero
|
71
89
|
end
|
72
90
|
|
73
91
|
def normalized_bend_points
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
92
|
+
connection
|
93
|
+
.bendpoints
|
94
|
+
.reject { |bendpoint| [source_bounds, target_bounds].any? { |bounds| bendpoint.inside?(bounds) } }
|
95
|
+
.map { |bendpoint| DataModel::Bounds.from_location(bendpoint) }
|
86
96
|
end
|
87
97
|
|
88
98
|
def calc_points
|
@@ -98,17 +108,21 @@ module Archimate
|
|
98
108
|
points.uniq
|
99
109
|
end
|
100
110
|
|
101
|
-
#
|
102
|
-
# b
|
111
|
+
# Takes the bounds of two objects and returns the optimal points
|
112
|
+
# between from the edge of `a` to the edge of `b`
|
113
|
+
# if left/right range of both overlap, use centerpoint of overlap range as x val
|
114
|
+
# if top/bottom range of both overlap, use centerpoint of overlap range as y val
|
115
|
+
# @param a [Bounds]
|
116
|
+
# @param b [Bounds]
|
103
117
|
def bounds_to_points(a, b)
|
104
118
|
ax_range = a.x_range
|
105
119
|
bx_range = b.x_range
|
106
120
|
|
107
|
-
overlap_x_center =
|
121
|
+
overlap_x_center = ax_range.overlap_midpoint(bx_range)
|
108
122
|
|
109
123
|
if overlap_x_center
|
110
124
|
ax = bx = overlap_x_center
|
111
|
-
elsif b.
|
125
|
+
elsif b.right_of?(a)
|
112
126
|
ax = a.right
|
113
127
|
bx = b.left
|
114
128
|
else
|
@@ -119,11 +133,11 @@ module Archimate
|
|
119
133
|
ay_range = a.y_range
|
120
134
|
by_range = b.y_range
|
121
135
|
|
122
|
-
overlap_y_center =
|
136
|
+
overlap_y_center = ay_range.overlap_midpoint(by_range)
|
123
137
|
|
124
138
|
if overlap_y_center
|
125
139
|
ay = by = overlap_y_center
|
126
|
-
elsif b.
|
140
|
+
elsif b.above?(a)
|
127
141
|
ay = a.top
|
128
142
|
by = b.bottom
|
129
143
|
else
|
@@ -135,18 +149,15 @@ module Archimate
|
|
135
149
|
end
|
136
150
|
|
137
151
|
def move_to(point)
|
138
|
-
"M #{point
|
152
|
+
"M #{point}"
|
139
153
|
end
|
140
154
|
|
141
155
|
def line_to(point)
|
142
|
-
"L #{point
|
156
|
+
"L #{point}"
|
143
157
|
end
|
144
158
|
|
145
|
-
def
|
146
|
-
|
147
|
-
end_min = [r1, r2].map(&:end).min
|
148
|
-
return nil if begin_max > end_min
|
149
|
-
(begin_max + end_min) / 2.0
|
159
|
+
def q_curve(cp, pt)
|
160
|
+
"Q #{cp} #{pt}"
|
150
161
|
end
|
151
162
|
end
|
152
163
|
end
|
data/lib/archimate/svg/point.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module Svg
|
5
|
+
Segment = Struct.new(:a, :b) do
|
6
|
+
def length
|
7
|
+
b - a
|
8
|
+
end
|
9
|
+
|
10
|
+
def from_end(dist)
|
11
|
+
length = b - a
|
12
|
+
from_start(length - dist)
|
13
|
+
end
|
14
|
+
|
15
|
+
def from_start(dist)
|
16
|
+
length = b - a
|
17
|
+
return a if dist.negative?
|
18
|
+
return b if length < dist
|
19
|
+
point_at_percent(dist / length)
|
20
|
+
end
|
21
|
+
|
22
|
+
def point_at_percent(pct)
|
23
|
+
Point.new(
|
24
|
+
a.x + ((b.x - a.x) * pct),
|
25
|
+
a.y + ((b.y - a.y) * pct)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -80,8 +80,8 @@
|
|
80
80
|
<symbol id="archimate-collaboration-badge" class="archimate-badge" viewBox="0 0 20 15" preserveAspectRatio="xMaxYMin meet">
|
81
81
|
<path d="m7.5 14 a 6.5 6.5 0 0 1 0 -13 a 6.5 6.5 0 0 1 0 13 m 5 0 a 6.5 6.5 0 0 1 0 -13 a 6.5 6.5 0 0 1 0 13" style="fill:inherit;stroke:inherit"/>
|
82
82
|
</symbol>
|
83
|
-
<symbol id="archimate-communication-badge" class="archimate-badge" viewBox="0 0 20 15">
|
84
|
-
<path d="m7.5 -1 l -6.5 6.5 l 6.5 6.5 m 5 -13 l 6.5 6.5 l -6.5 6.5 m -7 -6.5 h
|
83
|
+
<symbol id="archimate-communication-path-badge" class="archimate-badge" viewBox="0 0 20 15">
|
84
|
+
<path d="m7.5 -1 l -6.5 6.5 l 6.5 6.5 m 5 -13 l 6.5 6.5 l -6.5 6.5 m -7 -6.5 h 2 m 1.5 0 h 2 m 1.5 0 h 2" style="fill:inherit;stroke:inherit"/>
|
85
85
|
</symbol>
|
86
86
|
<symbol id="archimate-constraint-badge" class="archimate-badge" viewBox="0 0 20 15">
|
87
87
|
<path d="m6 -1 h 13 l -5 10 h -13 z m 4 0 l -5 10" style="fill:inherit;stroke:inherit"/>
|
@@ -93,6 +93,9 @@
|
|
93
93
|
<symbol id="archimate-driver-badge" class="archimate-badge" viewBox="0 0 20 15">
|
94
94
|
<path d="m17.5 6.5 a 6.5 6.5 0 0 0 -13 0 a 6.5 6.5 0 0 0 13 0 m 2 0 h -17 m 8.5 -8.5 v 17 m -6.01 -2.49 l 12.02 -12.02 m 0 12.02 l -12.02 -12.02" style="fill:inherit;stroke:inherit"/>
|
95
95
|
</symbol>
|
96
|
+
<symbol id="archimate-event-badge" class="archimate-badge" viewBox="0 0 20 20">
|
97
|
+
<path d="m1 1 a 8 6.5 0 0 1 0 12 h 12 a 6 5.5 0 0 0 0 -12 z" style="fill:inherit;stroke:inherit"/>
|
98
|
+
</symbol>
|
96
99
|
<symbol id="archimate-function-badge" class="archimate-badge" viewBox="0 0 20 20" preserveAspectRatio="xMaxYMin meet">
|
97
100
|
<path d="m7 15 l 0 -9 l 6 -5 l 6 5 l 0 9 l -6 -6 z" style="fill:none;stroke:inherit"/>
|
98
101
|
</symbol>
|
@@ -117,6 +120,11 @@
|
|
117
120
|
<symbol id="archimate-network-badge" class="archimate-badge" viewBox="0 0 20 15">
|
118
121
|
<path d="m9 9.5 a 2.5 2.5 0 0 0 -5 0 a 2.5 2.5 0 0 0 5 0 m -2 -2.5 l 1 -3 m 0.5 0 a 2.5 2.5 0 0 0 0 -5 a 2.5 2.5 0 0 0 0 5 m 2 -2.5 h 3.5 a 2.5 2.5 0 0 0 5 0 a 2.5 2.5 0 0 0 -5 0 m 2 2.5 l -1 3 m -0.5 0 a 2.5 2.5 0 0 0 0 5 a 2.5 2.5 0 0 0 0 -5 m -2 2.5 h -3.5" style="fill:inherit;stroke:inherit"/>
|
119
122
|
</symbol>
|
123
|
+
<symbol id="archimate-app-component-badge" class="archimate-badge" viewBox="0 0 20 20">
|
124
|
+
<path d="m6 4 v -3 h 12 v 17 h -12 v -3 m 0 -4 v -3" style="fill:inherit;stroke:inherit;"/>
|
125
|
+
<rect x="1" y="4" width="9" height="4" style="fill:inherit;stroke:inherit;"/>
|
126
|
+
<rect x="1" y="11" width="9" height="4" style="fill:inherit;stroke:inherit;"/>
|
127
|
+
</symbol>
|
120
128
|
<symbol id="archimate-node-badge" class="archimate-badge" viewBox="0 0 20 20">
|
121
129
|
<path d="M1 19 v -15 l 3 -3 h 15 v 15 l -3 3 z M 16 19 v -15 l 3 -3 m -3 3 h -15" style="fill:none;stroke:inherit;stroke-linejoin:miter;"/>
|
122
130
|
</symbol>
|
@@ -143,7 +151,7 @@
|
|
143
151
|
</symbol>
|
144
152
|
|
145
153
|
<!-- Line Markers -->
|
146
|
-
<marker id="archimate-dot-marker" viewBox="0 0 10 10" refX="
|
154
|
+
<marker id="archimate-dot-marker" viewBox="0 0 10 10" refX="4" refY="4" markerUnits="strokeWidth" markerWidth="10" markerHeight="10">
|
147
155
|
<circle cx="4" cy="4" r="3" fill="black" stroke="black" />
|
148
156
|
</marker>
|
149
157
|
<marker id="archimate-used-by-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="8" orient="auto">
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Archimate
|
4
|
+
module Svg
|
5
|
+
class ViewNode
|
6
|
+
attr_reader :view_node
|
7
|
+
|
8
|
+
def initialize(view_node)
|
9
|
+
@view_node = view_node
|
10
|
+
end
|
11
|
+
|
12
|
+
# The info needed to render is contained in the view node with the exception of
|
13
|
+
# any offset needed. So this will need to be included in the recursive drawing of children
|
14
|
+
def render_elements(svg)
|
15
|
+
Nokogiri::XML::Builder.with(svg) do |xml|
|
16
|
+
EntityFactory.make_entity(view_node, nil).to_svg(xml)
|
17
|
+
end
|
18
|
+
svg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/archimate/version.rb
CHANGED
data/lib/archimate.rb
CHANGED
@@ -35,7 +35,6 @@ module Archimate
|
|
35
35
|
end
|
36
36
|
|
37
37
|
module FileFormats
|
38
|
-
autoload :ArchiFileFormat, 'archimate/file_formats/archi_file_format'
|
39
38
|
autoload :ArchiFileReader, 'archimate/file_formats/archi_file_reader'
|
40
39
|
autoload :ArchiFileWriter, 'archimate/file_formats/archi_file_writer'
|
41
40
|
autoload :ModelExchangeFileReader, 'archimate/file_formats/model_exchange_file_reader'
|
@@ -51,7 +50,6 @@ module Archimate
|
|
51
50
|
end
|
52
51
|
|
53
52
|
module Svg
|
54
|
-
autoload :Child, 'archimate/svg/child'
|
55
53
|
autoload :CssStyle, 'archimate/svg/css_style'
|
56
54
|
autoload :Connection, 'archimate/svg/connection'
|
57
55
|
autoload :Diagram, 'archimate/svg/diagram'
|
@@ -60,7 +58,9 @@ module Archimate
|
|
60
58
|
autoload :Extents, 'archimate/svg/extents'
|
61
59
|
autoload :Path, 'archimate/svg/path'
|
62
60
|
autoload :Point, 'archimate/svg/point'
|
61
|
+
autoload :Segment, 'archimate/svg/segment'
|
63
62
|
autoload :SvgTemplate, 'archimate/svg/svg_template'
|
63
|
+
autoload :ViewNode, 'archimate/svg/view_node'
|
64
64
|
end
|
65
65
|
|
66
66
|
autoload :FileFormat, 'archimate/file_format'
|
@@ -69,6 +69,7 @@ module Archimate
|
|
69
69
|
autoload :DerivedRelations, 'archimate/derived_relations'
|
70
70
|
|
71
71
|
require "archimate/version"
|
72
|
+
require "archimate/core_refinements"
|
72
73
|
require "archimate/config"
|
73
74
|
require "archimate/logging"
|
74
75
|
require "archimate/color"
|