ea 0.6.138 → 0.6.140

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ea/fonts/metrics.rb +22 -2
  3. data/lib/ea/model/note.rb +2 -0
  4. data/lib/ea/sources/qea/diagram_builder/routing.rb +140 -2
  5. data/lib/ea/sources/qea/diagram_builder.rb +10 -0
  6. data/lib/ea/sources/qea/note_builder.rb +7 -1
  7. data/lib/ea/sources/xmi/diagram_builder/element_borders.rb +27 -0
  8. data/lib/ea/sources/xmi/diagram_builder.rb +40 -11
  9. data/lib/ea/sources/xmi/note_builder.rb +2 -1
  10. data/lib/ea/sources/xmi/stored_route/reversed_routes.rb +94 -0
  11. data/lib/ea/sources/xmi/stored_route.rb +121 -8
  12. data/lib/ea/svg/ea_emitter/bottom_margin.rb +100 -0
  13. data/lib/ea/svg/ea_emitter/bounds_calculator.rb +3 -1
  14. data/lib/ea/svg/ea_emitter/canvas.rb +37 -9
  15. data/lib/ea/svg/ea_emitter/canvas_anchor.rb +124 -0
  16. data/lib/ea/svg/ea_emitter/compartment/note_body.rb +5 -1
  17. data/lib/ea/svg/ea_emitter/compartment/package_from_parent.rb +23 -4
  18. data/lib/ea/svg/ea_emitter/compartment/shape.rb +17 -5
  19. data/lib/ea/svg/ea_emitter/connector_bridges.rb +113 -41
  20. data/lib/ea/svg/ea_emitter/connectors.rb +67 -17
  21. data/lib/ea/svg/ea_emitter/content_extent.rb +95 -0
  22. data/lib/ea/svg/ea_emitter/document.rb +56 -27
  23. data/lib/ea/svg/ea_emitter/element/legend_renderer.rb +14 -6
  24. data/lib/ea/svg/ea_emitter/element/note_shape_renderer.rb +64 -32
  25. data/lib/ea/svg/ea_emitter/elements.rb +21 -4
  26. data/lib/ea/svg/ea_emitter/label/end_label.rb +64 -6
  27. data/lib/ea/svg/ea_emitter/labels.rb +6 -0
  28. data/lib/ea/svg/ea_emitter/layer_sequencer.rb +40 -26
  29. data/lib/ea/svg/ea_emitter/markers.rb +22 -10
  30. data/lib/ea/svg/ea_emitter/paint_order.rb +29 -0
  31. data/lib/ea/svg/ea_emitter/render_context.rb +14 -3
  32. data/lib/ea/svg/ea_emitter/segment_geometry.rb +123 -0
  33. data/lib/ea/svg/ea_emitter.rb +6 -0
  34. data/lib/ea/version.rb +1 -1
  35. metadata +8 -1
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module Svg
5
+ module EaEmitter
6
+ # Segment arithmetic for connector bridges: where two segments cross at
7
+ # any slope, and where the arc chord sits on the carrier segment.
8
+ module SegmentGeometry
9
+ EPSILON = 1e-9
10
+
11
+ module_function
12
+
13
+ def distance(point, other)
14
+ Math.hypot(point[0] - other[0], point[1] - other[1])
15
+ end
16
+
17
+ # 0 for a horizontal segment, 1 for a vertical one, nil otherwise.
18
+ def axis_for(first, last)
19
+ return 0 if first[1] == last[1] && first[0] != last[0]
20
+ return 1 if first[0] == last[0] && first[1] != last[1]
21
+
22
+ nil
23
+ end
24
+
25
+ # A proper crossing of two segments; parallel and collinear segments
26
+ # never cross. Each span must leave `radius` of room either side.
27
+ def crossing(first, last, start, finish, radius)
28
+ point = axis_crossing(first, last, start, finish) ||
29
+ slanted_crossing(first, last, start, finish)
30
+ return unless point && room?(point, first, last, radius) && room?(point, start, finish, radius)
31
+ return unless chord_fits?(first, last, point, radius)
32
+
33
+ point
34
+ end
35
+
36
+ # The arc chord, one radius either side of the crossing along the
37
+ # carrier's dominant axis. A horizontal/vertical carrier keeps the
38
+ # exact crossing. On a slanted carrier EA seats the centre on the
39
+ # integer grid at floor(crossing) and offsets it by the half-chord
40
+ # (radius, truncated radius * slope), signed with the line direction.
41
+ def chord(first, last, crossing, radius)
42
+ major = dominant_axis(first, last)
43
+ step = last[major] > first[major] ? radius : -radius
44
+ return axis_chord(first, crossing, major, step) if first[1 - major] == last[1 - major]
45
+
46
+ slanted_chord(first, last, crossing, major, step)
47
+ end
48
+
49
+ def slanted_chord(first, last, crossing, major, step)
50
+ centre = crossing.map { |value| (value + EPSILON).floor }
51
+ half = half_chord(first, last, major, step)
52
+ [-1, 1].map { |sign| centre.zip(half).map { |c, h| c + sign * h } }
53
+ end
54
+
55
+ def half_chord(first, last, major, step)
56
+ minor = 1 - major
57
+ slope = (last[minor] - first[minor]).fdiv(last[major] - first[major])
58
+ major.zero? ? [step, (step * slope).truncate] : [(step * slope).truncate, step]
59
+ end
60
+
61
+ def axis_chord(first, crossing, major, step)
62
+ start = crossing.dup
63
+ finish = crossing.dup
64
+ start[1 - major] = finish[1 - major] = first[1 - major]
65
+ start[major] -= step
66
+ finish[major] += step
67
+ [start, finish]
68
+ end
69
+
70
+ # Integer seating must not extend the decorated carrier past an end.
71
+ def chord_fits?(first, last, point, radius)
72
+ chord(first, last, point, radius).all? do |seat|
73
+ [0, 1].all? { |axis| within?(seat[axis], first[axis], last[axis]) }
74
+ end
75
+ end
76
+
77
+ def dominant_axis(first, last)
78
+ (last[0] - first[0]).abs >= (last[1] - first[1]).abs ? 0 : 1
79
+ end
80
+
81
+ def axis_crossing(first, last, start, finish)
82
+ axis = axis_for(first, last)
83
+ return unless axis && axis_for(start, finish) == 1 - axis
84
+
85
+ axis.zero? ? [start[0], first[1]] : [first[0], start[1]]
86
+ end
87
+
88
+ def slanted_crossing(first, last, start, finish)
89
+ return if axis_for(first, last) && axis_for(start, finish)
90
+
91
+ direction = delta(first, last)
92
+ other = delta(start, finish)
93
+ denominator = cross(direction, other)
94
+ return if denominator.zero?
95
+
96
+ advance(first, direction, cross(delta(first, start), other).fdiv(denominator))
97
+ end
98
+
99
+ def advance(origin, direction, fraction)
100
+ [origin[0] + fraction * direction[0], origin[1] + fraction * direction[1]]
101
+ end
102
+
103
+ def delta(from, to)
104
+ [to[0] - from[0], to[1] - from[1]]
105
+ end
106
+
107
+ def cross(one, other)
108
+ one[0] * other[1] - one[1] * other[0]
109
+ end
110
+
111
+ def room?(point, first, last, radius)
112
+ distance(point, first) >= radius && distance(point, last) >= radius &&
113
+ [0, 1].all? { |axis| within?(point[axis], first[axis], last[axis]) }
114
+ end
115
+
116
+ def within?(value, from, to)
117
+ minimum, maximum = [from, to].minmax
118
+ value >= minimum - EPSILON && value <= maximum + EPSILON
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
@@ -26,13 +26,19 @@ module Ea
26
26
  #
27
27
  module EaEmitter
28
28
  autoload :Canvas, "ea/svg/ea_emitter/canvas"
29
+ autoload :CanvasAnchor, "ea/svg/ea_emitter/canvas_anchor"
30
+ autoload :BottomMargin, "ea/svg/ea_emitter/bottom_margin"
31
+ autoload :ContentExtent, "ea/svg/ea_emitter/content_extent"
29
32
  autoload :Background, "ea/svg/ea_emitter/background"
30
33
  autoload :BoundsCalculator, "ea/svg/ea_emitter/bounds_calculator"
31
34
  autoload :Style, "ea/svg/ea_emitter/style"
32
35
  autoload :Elements, "ea/svg/ea_emitter/elements"
36
+ autoload :PaintOrder, "ea/svg/ea_emitter/paint_order"
33
37
  autoload :Connectors, "ea/svg/ea_emitter/connectors"
34
38
  autoload :ConnectorBridges, "ea/svg/ea_emitter/connector_bridges"
35
39
  private_constant :ConnectorBridges
40
+ autoload :SegmentGeometry, "ea/svg/ea_emitter/segment_geometry"
41
+ private_constant :SegmentGeometry
36
42
  autoload :Markers, "ea/svg/ea_emitter/markers"
37
43
  autoload :Labels, "ea/svg/ea_emitter/labels"
38
44
  autoload :GhostLabels, "ea/svg/ea_emitter/ghost_labels"
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.138"
7
+ VERSION = "0.6.140"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.138
4
+ version: 0.6.140
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -854,6 +854,7 @@ files:
854
854
  - lib/ea/sources/xmi/diagram_builder.rb
855
855
  - lib/ea/sources/xmi/diagram_builder/association_class_metadata.rb
856
856
  - lib/ea/sources/xmi/diagram_builder/connector_metadata.rb
857
+ - lib/ea/sources/xmi/diagram_builder/element_borders.rb
857
858
  - lib/ea/sources/xmi/diagram_builder/font_settings.rb
858
859
  - lib/ea/sources/xmi/diagram_builder/stereotype_profiles.rb
859
860
  - lib/ea/sources/xmi/diagram_builder/umldi_edges.rb
@@ -875,6 +876,7 @@ files:
875
876
  - lib/ea/sources/xmi/relationship_type_map.rb
876
877
  - lib/ea/sources/xmi/stereotype_builder.rb
877
878
  - lib/ea/sources/xmi/stored_route.rb
879
+ - lib/ea/sources/xmi/stored_route/reversed_routes.rb
878
880
  - lib/ea/sources/xmi/tag_builder.rb
879
881
  - lib/ea/sources/xmi/type_classifier_map.rb
880
882
  - lib/ea/sources/xmi/umldi_keyword_extractor.rb
@@ -898,8 +900,10 @@ files:
898
900
  - lib/ea/svg/connector_router.rb
899
901
  - lib/ea/svg/ea_emitter.rb
900
902
  - lib/ea/svg/ea_emitter/background.rb
903
+ - lib/ea/svg/ea_emitter/bottom_margin.rb
901
904
  - lib/ea/svg/ea_emitter/bounds_calculator.rb
902
905
  - lib/ea/svg/ea_emitter/canvas.rb
906
+ - lib/ea/svg/ea_emitter/canvas_anchor.rb
903
907
  - lib/ea/svg/ea_emitter/color_resolver.rb
904
908
  - lib/ea/svg/ea_emitter/compartment.rb
905
909
  - lib/ea/svg/ea_emitter/compartment/attributes.rb
@@ -922,6 +926,7 @@ files:
922
926
  - lib/ea/svg/ea_emitter/connector_bridges.rb
923
927
  - lib/ea/svg/ea_emitter/connector_redock.rb
924
928
  - lib/ea/svg/ea_emitter/connectors.rb
929
+ - lib/ea/svg/ea_emitter/content_extent.rb
925
930
  - lib/ea/svg/ea_emitter/diagram_frame.rb
926
931
  - lib/ea/svg/ea_emitter/document.rb
927
932
  - lib/ea/svg/ea_emitter/element.rb
@@ -976,7 +981,9 @@ files:
976
981
  - lib/ea/svg/ea_emitter/marker/registry.rb
977
982
  - lib/ea/svg/ea_emitter/markers.rb
978
983
  - lib/ea/svg/ea_emitter/orthogonal_ray.rb
984
+ - lib/ea/svg/ea_emitter/paint_order.rb
979
985
  - lib/ea/svg/ea_emitter/render_context.rb
986
+ - lib/ea/svg/ea_emitter/segment_geometry.rb
980
987
  - lib/ea/svg/ea_emitter/style.rb
981
988
  - lib/ea/svg/ea_emitter/text_renderer.rb
982
989
  - lib/ea/svg/ea_emitter/visibility_symbol.rb