@api-client/ui 0.2.2 → 0.2.3

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 (170) hide show
  1. package/package.json +7 -2
  2. package/test/env.ts +15 -0
  3. package/test/tsconfig.json +1 -7
  4. package/web-test-runner.config.js +5 -1
  5. package/build/src/visualization/elements/VizAssociationElement.d.ts +0 -4
  6. package/build/src/visualization/elements/VizAssociationElement.d.ts.map +0 -1
  7. package/build/src/visualization/elements/VizAssociationElement.js +0 -4
  8. package/build/src/visualization/elements/VizAssociationElement.js.map +0 -1
  9. package/build/src/visualization/elements/VizWorkspaceElement.d.ts +0 -110
  10. package/build/src/visualization/elements/VizWorkspaceElement.d.ts.map +0 -1
  11. package/build/src/visualization/elements/VizWorkspaceElement.js +0 -321
  12. package/build/src/visualization/elements/VizWorkspaceElement.js.map +0 -1
  13. package/build/src/visualization/elements/WorkspaceStyles.d.ts +0 -3
  14. package/build/src/visualization/elements/WorkspaceStyles.d.ts.map +0 -1
  15. package/build/src/visualization/elements/WorkspaceStyles.js +0 -168
  16. package/build/src/visualization/elements/WorkspaceStyles.js.map +0 -1
  17. package/build/src/visualization/lib/AnchorFinder.d.ts +0 -64
  18. package/build/src/visualization/lib/AnchorFinder.d.ts.map +0 -1
  19. package/build/src/visualization/lib/AnchorFinder.js +0 -107
  20. package/build/src/visualization/lib/AnchorFinder.js.map +0 -1
  21. package/build/src/visualization/lib/AnchorUtils.d.ts +0 -10
  22. package/build/src/visualization/lib/AnchorUtils.d.ts.map +0 -1
  23. package/build/src/visualization/lib/AnchorUtils.js +0 -44
  24. package/build/src/visualization/lib/AnchorUtils.js.map +0 -1
  25. package/build/src/visualization/lib/AssociationAnchors.d.ts +0 -134
  26. package/build/src/visualization/lib/AssociationAnchors.d.ts.map +0 -1
  27. package/build/src/visualization/lib/AssociationAnchors.js +0 -351
  28. package/build/src/visualization/lib/AssociationAnchors.js.map +0 -1
  29. package/build/src/visualization/lib/LabelSketch.d.ts +0 -16
  30. package/build/src/visualization/lib/LabelSketch.d.ts.map +0 -1
  31. package/build/src/visualization/lib/LabelSketch.js +0 -53
  32. package/build/src/visualization/lib/LabelSketch.js.map +0 -1
  33. package/build/src/visualization/lib/LineSketch.d.ts +0 -26
  34. package/build/src/visualization/lib/LineSketch.d.ts.map +0 -1
  35. package/build/src/visualization/lib/LineSketch.js +0 -55
  36. package/build/src/visualization/lib/LineSketch.js.map +0 -1
  37. package/build/src/visualization/lib/Point.d.ts +0 -74
  38. package/build/src/visualization/lib/Point.d.ts.map +0 -1
  39. package/build/src/visualization/lib/Point.js +0 -121
  40. package/build/src/visualization/lib/Point.js.map +0 -1
  41. package/build/src/visualization/lib/PositionUtils.d.ts +0 -65
  42. package/build/src/visualization/lib/PositionUtils.d.ts.map +0 -1
  43. package/build/src/visualization/lib/PositionUtils.js +0 -205
  44. package/build/src/visualization/lib/PositionUtils.js.map +0 -1
  45. package/build/src/visualization/lib/SelectionManager.d.ts +0 -183
  46. package/build/src/visualization/lib/SelectionManager.d.ts.map +0 -1
  47. package/build/src/visualization/lib/SelectionManager.js +0 -481
  48. package/build/src/visualization/lib/SelectionManager.js.map +0 -1
  49. package/build/src/visualization/lib/ShapeArtist.d.ts +0 -45
  50. package/build/src/visualization/lib/ShapeArtist.d.ts.map +0 -1
  51. package/build/src/visualization/lib/ShapeArtist.js +0 -209
  52. package/build/src/visualization/lib/ShapeArtist.js.map +0 -1
  53. package/build/src/visualization/lib/SvgMarkers.d.ts +0 -14
  54. package/build/src/visualization/lib/SvgMarkers.d.ts.map +0 -1
  55. package/build/src/visualization/lib/SvgMarkers.js +0 -77
  56. package/build/src/visualization/lib/SvgMarkers.js.map +0 -1
  57. package/build/src/visualization/lib/TipSketch.d.ts +0 -26
  58. package/build/src/visualization/lib/TipSketch.d.ts.map +0 -1
  59. package/build/src/visualization/lib/TipSketch.js +0 -77
  60. package/build/src/visualization/lib/TipSketch.js.map +0 -1
  61. package/build/src/visualization/lib/TouchSupport.d.ts +0 -14
  62. package/build/src/visualization/lib/TouchSupport.d.ts.map +0 -1
  63. package/build/src/visualization/lib/TouchSupport.js +0 -55
  64. package/build/src/visualization/lib/TouchSupport.js.map +0 -1
  65. package/build/src/visualization/lib/Utils.d.ts +0 -25
  66. package/build/src/visualization/lib/Utils.d.ts.map +0 -1
  67. package/build/src/visualization/lib/Utils.js +0 -59
  68. package/build/src/visualization/lib/Utils.js.map +0 -1
  69. package/build/src/visualization/lib/VisualizationTypes.d.ts +0 -216
  70. package/build/src/visualization/lib/VisualizationTypes.d.ts.map +0 -1
  71. package/build/src/visualization/lib/VisualizationTypes.js +0 -3
  72. package/build/src/visualization/lib/VisualizationTypes.js.map +0 -1
  73. package/build/src/visualization/lib/WorkspaceAlignment.d.ts +0 -51
  74. package/build/src/visualization/lib/WorkspaceAlignment.d.ts.map +0 -1
  75. package/build/src/visualization/lib/WorkspaceAlignment.js +0 -243
  76. package/build/src/visualization/lib/WorkspaceAlignment.js.map +0 -1
  77. package/build/src/visualization/lib/WorkspaceDebugging.d.ts +0 -104
  78. package/build/src/visualization/lib/WorkspaceDebugging.d.ts.map +0 -1
  79. package/build/src/visualization/lib/WorkspaceDebugging.js +0 -286
  80. package/build/src/visualization/lib/WorkspaceDebugging.js.map +0 -1
  81. package/build/src/visualization/lib/WorkspaceEdges.d.ts +0 -293
  82. package/build/src/visualization/lib/WorkspaceEdges.d.ts.map +0 -1
  83. package/build/src/visualization/lib/WorkspaceEdges.js +0 -1073
  84. package/build/src/visualization/lib/WorkspaceEdges.js.map +0 -1
  85. package/build/src/visualization/lib/WorkspaceGestures.d.ts +0 -119
  86. package/build/src/visualization/lib/WorkspaceGestures.d.ts.map +0 -1
  87. package/build/src/visualization/lib/WorkspaceGestures.js +0 -376
  88. package/build/src/visualization/lib/WorkspaceGestures.js.map +0 -1
  89. package/build/src/visualization/lib/WorkspaceSizing.d.ts +0 -66
  90. package/build/src/visualization/lib/WorkspaceSizing.d.ts.map +0 -1
  91. package/build/src/visualization/lib/WorkspaceSizing.js +0 -168
  92. package/build/src/visualization/lib/WorkspaceSizing.js.map +0 -1
  93. package/build/src/visualization/lib/lines/RectilinearLine.d.ts +0 -114
  94. package/build/src/visualization/lib/lines/RectilinearLine.d.ts.map +0 -1
  95. package/build/src/visualization/lib/lines/RectilinearLine.js +0 -605
  96. package/build/src/visualization/lib/lines/RectilinearLine.js.map +0 -1
  97. package/build/src/visualization/lib/tips/RectilinearTip.d.ts +0 -26
  98. package/build/src/visualization/lib/tips/RectilinearTip.d.ts.map +0 -1
  99. package/build/src/visualization/lib/tips/RectilinearTip.js +0 -149
  100. package/build/src/visualization/lib/tips/RectilinearTip.js.map +0 -1
  101. package/build/src/visualization/lib/tips/TipArtist.d.ts +0 -22
  102. package/build/src/visualization/lib/tips/TipArtist.d.ts.map +0 -1
  103. package/build/src/visualization/lib/tips/TipArtist.js +0 -31
  104. package/build/src/visualization/lib/tips/TipArtist.js.map +0 -1
  105. package/build/src/visualization/lib/types.d.ts +0 -164
  106. package/build/src/visualization/lib/types.d.ts.map +0 -1
  107. package/build/src/visualization/lib/types.js +0 -2
  108. package/build/src/visualization/lib/types.js.map +0 -1
  109. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts +0 -126
  110. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts.map +0 -1
  111. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js +0 -260
  112. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js.map +0 -1
  113. package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts +0 -93
  114. package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts.map +0 -1
  115. package/build/src/visualization/plugin/group-selection/GroupSelection.js +0 -250
  116. package/build/src/visualization/plugin/group-selection/GroupSelection.js.map +0 -1
  117. package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts +0 -10
  118. package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts.map +0 -1
  119. package/build/src/visualization/plugin/positioning/DataModelLayout.js +0 -105
  120. package/build/src/visualization/plugin/positioning/DataModelLayout.js.map +0 -1
  121. package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts +0 -93
  122. package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts.map +0 -1
  123. package/build/src/visualization/plugin/positioning/WorkspaceLayout.js +0 -96
  124. package/build/src/visualization/plugin/positioning/WorkspaceLayout.js.map +0 -1
  125. package/build/src/visualization/viz-association.d.ts +0 -7
  126. package/build/src/visualization/viz-association.d.ts.map +0 -1
  127. package/build/src/visualization/viz-association.js +0 -3
  128. package/build/src/visualization/viz-association.js.map +0 -1
  129. package/build/src/visualization/viz-workspace.d.ts +0 -7
  130. package/build/src/visualization/viz-workspace.d.ts.map +0 -1
  131. package/build/src/visualization/viz-workspace.js +0 -3
  132. package/build/src/visualization/viz-workspace.js.map +0 -1
  133. package/src/visualization/elements/VizAssociationElement.ts +0 -3
  134. package/src/visualization/elements/VizWorkspaceElement.ts +0 -302
  135. package/src/visualization/elements/WorkspaceStyles.ts +0 -168
  136. package/src/visualization/lib/AnchorFinder.ts +0 -112
  137. package/src/visualization/lib/AnchorUtils.ts +0 -53
  138. package/src/visualization/lib/AssociationAnchors.ts +0 -418
  139. package/src/visualization/lib/LabelSketch.ts +0 -67
  140. package/src/visualization/lib/LineSketch.ts +0 -62
  141. package/src/visualization/lib/Point.ts +0 -134
  142. package/src/visualization/lib/PositionUtils.ts +0 -218
  143. package/src/visualization/lib/SelectionManager.ts +0 -513
  144. package/src/visualization/lib/ShapeArtist.ts +0 -222
  145. package/src/visualization/lib/SvgMarkers.ts +0 -80
  146. package/src/visualization/lib/TipSketch.ts +0 -91
  147. package/src/visualization/lib/TouchSupport.ts +0 -72
  148. package/src/visualization/lib/Utils.ts +0 -63
  149. package/src/visualization/lib/VisualizationTypes.ts +0 -232
  150. package/src/visualization/lib/WorkspaceAlignment.ts +0 -261
  151. package/src/visualization/lib/WorkspaceDebugging.ts +0 -313
  152. package/src/visualization/lib/WorkspaceEdges.ts +0 -1153
  153. package/src/visualization/lib/WorkspaceGestures.ts +0 -400
  154. package/src/visualization/lib/WorkspaceSizing.ts +0 -181
  155. package/src/visualization/lib/lines/RectilinearLine.ts +0 -589
  156. package/src/visualization/lib/tips/RectilinearTip.ts +0 -156
  157. package/src/visualization/lib/tips/TipArtist.ts +0 -34
  158. package/src/visualization/lib/types.ts +0 -173
  159. package/src/visualization/plugin/dnd/DragAndDropPlugin.ts +0 -294
  160. package/src/visualization/plugin/group-selection/GroupSelection.ts +0 -271
  161. package/src/visualization/plugin/positioning/DataModelLayout.ts +0 -114
  162. package/src/visualization/plugin/positioning/WorkspaceLayout.ts +0 -149
  163. package/src/visualization/viz-association.ts +0 -9
  164. package/src/visualization/viz-workspace.ts +0 -9
  165. package/test/env.d.ts +0 -9
  166. package/test/env.js +0 -7
  167. package/test/visualization/lib/AnchorFinder.test.ts +0 -313
  168. package/test/visualization/lib/AnchorUtils.test.ts +0 -178
  169. package/test/visualization/lib/PositionUtils.test.ts +0 -406
  170. package/test/visualization/lib/test-styles.css +0 -80
@@ -1,605 +0,0 @@
1
- import { findDirection } from '../PositionUtils.js';
2
- import { Point } from '../Point.js';
3
- export const startWest = Symbol('startWest');
4
- export const startEast = Symbol('startEast');
5
- export const startSouth = Symbol('startSouth');
6
- export const startNorth = Symbol('startNorth');
7
- export const sketchEastEast = Symbol('sketchEastEast');
8
- export const sketchEastWest = Symbol('sketchEastWest');
9
- export const sketchEastSouth = Symbol('sketchEastSouth');
10
- export const sketchEastNorth = Symbol('sketchEastNorth');
11
- export const sketchNorthWest = Symbol('sketchNorthWest');
12
- export const sketchNorthEast = Symbol('sketchNorthEast');
13
- export const sketchNorthSouth = Symbol('sketchNorthSouth');
14
- export const sketchNorthNorth = Symbol('sketchNorthNorth');
15
- export const sketchWestSouth = Symbol('sketchWestSouth');
16
- export const sketchWestWest = Symbol('sketchWestWest');
17
- export const sketchWestEast = Symbol('sketchWestEast');
18
- export const sketchWestNorth = Symbol('sketchWestNorth');
19
- export const sketchSouthNorth = Symbol('sketchSouthNorth');
20
- export const sketchSouthWest = Symbol('sketchSouthWest');
21
- export const sketchSouthSouth = Symbol('sketchSouthSouth');
22
- export const sketchSouthEast = Symbol('sketchSouthEast');
23
- export const ElbowThreshold = 24;
24
- /**
25
- * A class that draws a rectilinear line
26
- */
27
- export class RectilinearLine {
28
- ep;
29
- sp;
30
- source;
31
- target;
32
- others;
33
- /**
34
- * The default padding to use when computing distance between the line and an object.
35
- */
36
- overlapPadding = 20;
37
- /**
38
- * The list of all points (start + end + control points)
39
- */
40
- coordinates;
41
- /**
42
- * The list of all control points.
43
- */
44
- controlPoints = [];
45
- transformOrigin;
46
- /**
47
- * The delta between Y coordinates
48
- */
49
- dx;
50
- /**
51
- * The delta between Y coordinates
52
- */
53
- dy;
54
- /**
55
- * Half distance between start.x and end.x
56
- */
57
- halfX;
58
- /**
59
- * Half distance between start.y and end.y
60
- */
61
- halfY;
62
- constructor(config) {
63
- const { endPoint, target, startPoint, source, others } = config;
64
- this.ep = endPoint;
65
- this.sp = startPoint;
66
- this.source = source;
67
- this.target = target;
68
- this.others = others;
69
- this.coordinates = [startPoint];
70
- this.transformOrigin = `${startPoint.x}px ${endPoint.y}px`;
71
- this.dx = endPoint.x - startPoint.x;
72
- this.dy = endPoint.y - startPoint.y;
73
- this.halfX = Math.abs(this.dx) / 2;
74
- this.halfY = Math.abs(this.dy) / 2;
75
- }
76
- /**
77
- * Sketches a regular line.
78
- * @returns Computed model for the association.
79
- */
80
- sketch() {
81
- const { sp, ep, source, target } = this;
82
- if (!sp.validate() || !ep.validate()) {
83
- return null;
84
- }
85
- const directions = findDirection(sp, ep, source, target);
86
- const { start, end } = directions;
87
- // console.log(start, end);
88
- if (start === 'west') {
89
- this[startWest](end);
90
- }
91
- else if (start === 'south') {
92
- this[startSouth](end);
93
- }
94
- else if (start === 'east') {
95
- this[startEast](end);
96
- }
97
- else {
98
- this[startNorth](end);
99
- }
100
- const { coordinates, controlPoints, transformOrigin } = this;
101
- coordinates.push(this.ep);
102
- const path = coordinates.map((item) => `${item.x},${item.y}`).join(' ');
103
- const result = {
104
- controlPoints,
105
- transformOrigin,
106
- type: 'rectilinear',
107
- coordinates,
108
- rotate: 0,
109
- path,
110
- startPoint: sp,
111
- endPoint: ep,
112
- };
113
- return result;
114
- }
115
- /**
116
- * Adds a control point to the list of points.
117
- */
118
- addCP(x = 0, y = 0) {
119
- const cp = new Point(x, y);
120
- this.coordinates.push(cp);
121
- this.controlPoints.push(cp);
122
- return cp;
123
- }
124
- /**
125
- * Computes the line that starts on the west side of the source object
126
- * and end in the `end`
127
- * @param end The direction where the line ends.
128
- */
129
- [startWest](end) {
130
- if (end === 'west') {
131
- this[sketchWestWest]();
132
- }
133
- else if (end === 'south') {
134
- this[sketchWestSouth]();
135
- }
136
- else if (end === 'east') {
137
- this[sketchWestEast]();
138
- }
139
- else {
140
- this[sketchWestNorth]();
141
- }
142
- }
143
- [sketchWestSouth]() {
144
- const { target, sp, ep, overlapPadding, dx, dy } = this;
145
- if (dx >= 0) {
146
- if (dy < 0) {
147
- // go around the source to the right
148
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
149
- const cp2 = this.addCP(cp1.x, target.bottom + overlapPadding);
150
- this.addCP(ep.x, cp2.y);
151
- }
152
- else {
153
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
154
- const cp2 = this.addCP(cp1.x, target.bottom + overlapPadding);
155
- this.addCP(ep.x, cp2.y);
156
- }
157
- }
158
- else if (dy < 0) {
159
- this.addCP(ep.x, sp.y);
160
- }
161
- else {
162
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
163
- const cp2 = this.addCP(cp1.x, target.bottom + overlapPadding);
164
- this.addCP(ep.x, cp2.y);
165
- }
166
- }
167
- [sketchWestWest]() {
168
- const { source, target, sp, ep, overlapPadding, halfX, dy } = this;
169
- const overlap = source.left < target.right;
170
- if (overlap) {
171
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
172
- const cp2 = this.addCP(cp1.x, source.top - overlapPadding);
173
- const cp3 = this.addCP(Math.max(target.right, source.right) + overlapPadding, cp2.y);
174
- this.addCP(cp3.x, ep.y);
175
- }
176
- else {
177
- // draw a straight line when distance between the two is below the threshold
178
- if (Math.abs(dy) > ElbowThreshold) {
179
- this.addCP(sp.x - halfX, sp.y);
180
- this.addCP(ep.x + halfX, ep.y);
181
- }
182
- }
183
- }
184
- [sketchWestEast]() {
185
- const { source, target, sp, ep, overlapPadding } = this;
186
- const overlap = source.left < target.left;
187
- if (overlap) {
188
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
189
- this.addCP(cp1.x, ep.y);
190
- }
191
- else {
192
- const cp1 = this.addCP(ep.x - overlapPadding, sp.y);
193
- this.addCP(cp1.x, ep.y);
194
- }
195
- }
196
- [sketchWestNorth]() {
197
- const { source, target, sp, ep, overlapPadding } = this;
198
- const overlap = source.left < target.right;
199
- if (overlap) {
200
- const cp1 = this.addCP(sp.x - overlapPadding, sp.y);
201
- const cp2 = this.addCP(cp1.x, ep.y - overlapPadding);
202
- this.addCP(ep.x, cp2.y);
203
- }
204
- else {
205
- this.addCP(ep.x, sp.y);
206
- }
207
- }
208
- /**
209
- * Computes the line that starts on the west side of the source object
210
- * and end in the `end`
211
- * @param end The direction where the line ends.
212
- */
213
- [startSouth](end) {
214
- if (end === 'west') {
215
- this[sketchSouthWest]();
216
- }
217
- else if (end === 'south') {
218
- this[sketchSouthSouth]();
219
- }
220
- else if (end === 'east') {
221
- this[sketchSouthEast]();
222
- }
223
- else {
224
- this[sketchSouthNorth]();
225
- }
226
- }
227
- [sketchSouthNorth]() {
228
- const { source, target, sp, ep, halfY, overlapPadding, dx } = this;
229
- const overlapping = source.bottom + overlapPadding > target.top - overlapPadding;
230
- if (overlapping) {
231
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
232
- let cp2;
233
- if (source.right < target.left) {
234
- // the target is on the right
235
- cp2 = this.addCP(target.left - overlapPadding, cp1.y);
236
- }
237
- else {
238
- // the target is on the left
239
- cp2 = this.addCP(target.right + overlapPadding, cp1.y);
240
- }
241
- const cp3 = this.addCP(cp2.x, target.top - overlapPadding);
242
- this.addCP(ep.x, cp3.y);
243
- }
244
- else {
245
- // draw a straight line instead of the elbow when the distance is below the threshold
246
- if (Math.abs(dx) > ElbowThreshold) {
247
- const cp1 = this.addCP(sp.x, sp.y + halfY);
248
- this.addCP(ep.x, cp1.y);
249
- }
250
- }
251
- }
252
- [sketchSouthWest]() {
253
- const { sp, ep, dx, dy, halfY, halfX, overlapPadding } = this;
254
- if (dx >= 0) {
255
- if (dy < 0) {
256
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
257
- const cp2 = this.addCP(ep.x + overlapPadding, cp1.y);
258
- this.addCP(cp2.x, ep.y);
259
- }
260
- else {
261
- const cp1 = this.addCP(sp.x, sp.y + halfY);
262
- const cp2 = this.addCP(ep.x + overlapPadding, cp1.y);
263
- this.addCP(cp2.x, ep.y);
264
- }
265
- }
266
- else if (dy < 0) {
267
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
268
- const cp2 = this.addCP(ep.x + halfX, cp1.y);
269
- this.addCP(cp2.x, ep.y);
270
- }
271
- else {
272
- this.addCP(sp.x, ep.y);
273
- }
274
- }
275
- [sketchSouthSouth]() {
276
- const { source, target, sp, ep, overlapPadding } = this;
277
- if (source.bottom + 2 * overlapPadding > target.bottom) {
278
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
279
- this.addCP(ep.x, cp1.y);
280
- }
281
- else {
282
- const cp1 = this.addCP(sp.x, ep.y + overlapPadding);
283
- this.addCP(ep.x, cp1.y);
284
- }
285
- }
286
- [sketchSouthEast]() {
287
- const { source, sp, ep, dx, dy, overlapPadding, halfX, halfY } = this;
288
- if (dx >= 0) {
289
- if (dy < 0) {
290
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
291
- let c2x = sp.x + halfX;
292
- if (c2x < source.right + overlapPadding) {
293
- c2x = ep.x - overlapPadding;
294
- }
295
- const cp2 = this.addCP(c2x, cp1.y);
296
- this.addCP(cp2.x, ep.y);
297
- }
298
- else {
299
- this.addCP(sp.x, ep.y);
300
- }
301
- }
302
- else if (dy < 0) {
303
- const cp1 = this.addCP(sp.x, sp.y + overlapPadding);
304
- const cp2 = this.addCP(ep.x - overlapPadding, cp1.y);
305
- this.addCP(cp2.x, ep.y);
306
- }
307
- else {
308
- const cp1 = this.addCP(sp.x, sp.y + halfY);
309
- const cp2 = this.addCP(ep.x - overlapPadding, cp1.y);
310
- this.addCP(cp2.x, ep.y);
311
- }
312
- }
313
- /**
314
- * Computes the line that starts on the west side of the source object
315
- * and end in the `end`
316
- * @param end The direction where the line ends.
317
- */
318
- [startEast](end) {
319
- if (end === 'west') {
320
- this[sketchEastWest]();
321
- }
322
- else if (end === 'east') {
323
- this[sketchEastEast]();
324
- }
325
- else if (end === 'south') {
326
- this[sketchEastSouth]();
327
- }
328
- else {
329
- this[sketchEastNorth]();
330
- }
331
- }
332
- [sketchEastEast]() {
333
- const { source, target, sp, ep, overlapPadding, halfX, dy } = this;
334
- if (sp.x + 2 * overlapPadding > target.x) {
335
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
336
- const cp2 = this.addCP(cp1.x, source.top - overlapPadding);
337
- const cp3 = this.addCP(ep.x - overlapPadding, cp2.y);
338
- this.addCP(cp3.x, ep.y);
339
- }
340
- else {
341
- // draw a straight line when distance between the two is below the threshold
342
- if (Math.abs(dy) > ElbowThreshold) {
343
- const cp1 = this.addCP(sp.x + halfX, sp.y);
344
- this.addCP(cp1.x, ep.y);
345
- }
346
- }
347
- }
348
- [sketchEastWest]() {
349
- const { source, target, sp, ep, overlapPadding, dx } = this;
350
- if (dx >= 0) {
351
- // target on the right
352
- if (sp.y > target.top - overlapPadding && sp.y < target.bottom + overlapPadding) {
353
- // line is going through the target object
354
- const targetAbove = ep.y < sp.y;
355
- const cp1 = this.addCP(target.left - overlapPadding, sp.y);
356
- const cp2 = this.addCP(cp1.x);
357
- if (targetAbove) {
358
- cp2.y = target.bottom + overlapPadding;
359
- }
360
- else {
361
- cp2.y = target.top - overlapPadding;
362
- }
363
- const cp3 = this.addCP(ep.x + overlapPadding, cp2.y);
364
- this.addCP(cp3.x, ep.y);
365
- }
366
- else {
367
- const cp1 = this.addCP(ep.x + overlapPadding, sp.y);
368
- this.addCP(cp1.x, ep.y);
369
- }
370
- }
371
- else {
372
- // target on the left
373
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
374
- if (ep.y > source.top - overlapPadding && ep.y < source.bottom + overlapPadding) {
375
- // line is going through the source object
376
- const targetAbove = ep.y < sp.y;
377
- const cp2 = this.addCP(cp1.x);
378
- if (targetAbove) {
379
- cp2.y = source.top - overlapPadding;
380
- }
381
- else {
382
- cp2.y = source.bottom + overlapPadding;
383
- }
384
- const cp3 = this.addCP(source.left - overlapPadding, cp2.y);
385
- this.addCP(cp3.x, ep.y);
386
- }
387
- else {
388
- this.addCP(cp1.x, ep.y);
389
- }
390
- }
391
- }
392
- [sketchEastSouth]() {
393
- const { source, target, sp, ep, overlapPadding } = this;
394
- const targetAround = ep.y > sp.y;
395
- const sourceAround = sp.x > ep.x;
396
- if (targetAround && sourceAround) {
397
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
398
- const cp2 = this.addCP(cp1.x, Math.max(ep.y, source.bottom) + overlapPadding);
399
- this.addCP(ep.x, cp2.y);
400
- }
401
- else if (targetAround) {
402
- const overlapping = sp.x + overlapPadding > target.left;
403
- if (overlapping) {
404
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
405
- const cp2 = this.addCP(cp1.x, target.bottom + overlapPadding);
406
- const cp3 = this.addCP(target.left - overlapPadding, cp2.y);
407
- const cp4 = this.addCP(cp3.x, ep.y - overlapPadding);
408
- this.addCP(ep.x, cp4.y);
409
- }
410
- else {
411
- const cp1 = this.addCP(target.left - overlapPadding, sp.y);
412
- const cp2 = this.addCP(cp1.x, ep.y + overlapPadding);
413
- this.addCP(ep.x, cp2.y);
414
- }
415
- }
416
- else if (sourceAround) {
417
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
418
- const cp2 = this.addCP(cp1.x, source.bottom + overlapPadding);
419
- const cp3 = this.addCP(target.right + overlapPadding, cp2.y);
420
- const cp4 = this.addCP(cp3.x, target.bottom + overlapPadding);
421
- this.addCP(ep.x, cp4.y);
422
- }
423
- else {
424
- this.addCP(ep.x, sp.y);
425
- }
426
- }
427
- [sketchEastNorth]() {
428
- const { source, target, sp, ep, overlapPadding, dx, dy } = this;
429
- if (dx >= 0) {
430
- if (dy < 0) {
431
- const cp1 = this.addCP(target.right + overlapPadding, sp.y);
432
- const cp2 = this.addCP(cp1.x, target.top - overlapPadding);
433
- this.addCP(ep.x, cp2.y);
434
- }
435
- else if (source.right > target.left - overlapPadding) {
436
- // go around the source
437
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
438
- const cp2 = this.addCP(cp1.x, source.bottom + overlapPadding);
439
- const cp3 = this.addCP(target.left - overlapPadding, cp2.y);
440
- const cp4 = this.addCP(cp3.x, target.bottom + overlapPadding);
441
- this.addCP(ep.x, cp4.y);
442
- }
443
- else {
444
- this.addCP(ep.x, sp.y);
445
- }
446
- }
447
- else if (source.bottom + 2 * overlapPadding < target.top) {
448
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
449
- const cp2 = this.addCP(cp1.x, source.bottom + overlapPadding);
450
- this.addCP(ep.x, cp2.y);
451
- }
452
- else {
453
- const cp1 = this.addCP(sp.x + overlapPadding, sp.y);
454
- const cp2 = this.addCP(cp1.x, Math.min(target.top, source.top) - overlapPadding);
455
- this.addCP(ep.x, cp2.y);
456
- }
457
- }
458
- /**
459
- * Computes the line that starts on the west side of the source object
460
- * and end in the `end`
461
- * @param end The direction where the line ends.
462
- */
463
- [startNorth](end) {
464
- if (end === 'west') {
465
- this[sketchNorthWest]();
466
- }
467
- else if (end === 'north') {
468
- this[sketchNorthNorth]();
469
- }
470
- else if (end === 'east') {
471
- this[sketchNorthEast]();
472
- }
473
- else {
474
- this[sketchNorthSouth]();
475
- }
476
- }
477
- [sketchNorthWest]() {
478
- const { source, target, sp, ep, overlapPadding, dx, dy } = this;
479
- if (dx >= 0) {
480
- if (dy < 0) {
481
- if (target.bottom + 2 * overlapPadding > sp.y) {
482
- // go above the target
483
- const cp1 = this.addCP(sp.x, target.top - overlapPadding);
484
- const cp2 = this.addCP(ep.x + overlapPadding, cp1.y);
485
- this.addCP(cp2.x, ep.y);
486
- }
487
- else {
488
- // go below the target
489
- const cp1 = this.addCP(sp.x, target.bottom + overlapPadding);
490
- const cp2 = this.addCP(ep.x + overlapPadding, cp1.y);
491
- this.addCP(cp2.x, ep.y);
492
- }
493
- }
494
- else {
495
- const cp1 = this.addCP(sp.x, Math.min(sp.y, target.top) - overlapPadding);
496
- const cp2 = this.addCP(Math.max(ep.x, source.right) + overlapPadding, cp1.y);
497
- this.addCP(cp2.x, ep.y);
498
- }
499
- }
500
- else if (dx < 0) {
501
- if (ep.y < sp.y - overlapPadding) {
502
- this.addCP(sp.x, ep.y);
503
- }
504
- else {
505
- const cp1 = this.addCP(sp.x, Math.min(sp.y, target.top) - overlapPadding);
506
- if (ep.x + 2 * overlapPadding > source.left) {
507
- const cp2 = this.addCP(source.left - overlapPadding, cp1.y);
508
- const cp3 = this.addCP(cp2.x, target.top - overlapPadding);
509
- const cp4 = this.addCP(target.right + overlapPadding, cp3.y);
510
- this.addCP(cp4.x, ep.y);
511
- }
512
- else {
513
- const cp2 = this.addCP(Math.min(ep.x, source.left) + overlapPadding, cp1.y);
514
- this.addCP(cp2.x, ep.y);
515
- }
516
- }
517
- }
518
- }
519
- [sketchNorthEast]() {
520
- const { source, target, sp, ep, overlapPadding, dx, dy } = this;
521
- const cp1 = this.addCP(sp.x, sp.y - overlapPadding);
522
- if (dx >= 0) {
523
- if (dy < 0) {
524
- this.addCP(sp.x, ep.y);
525
- }
526
- else if (source.right > target.left - overlapPadding) {
527
- const cp2 = this.addCP(source.right + overlapPadding, cp1.y);
528
- const cp3 = this.addCP(cp2.x, source.bottom + overlapPadding);
529
- const cp4 = this.addCP(ep.x - overlapPadding, cp3.y);
530
- this.addCP(cp4.x, ep.y);
531
- }
532
- else {
533
- const cp2 = this.addCP(ep.x - overlapPadding, cp1.y);
534
- this.addCP(cp2.x, ep.y);
535
- }
536
- }
537
- else {
538
- if (cp1.y > target.top - overlapPadding && cp1.y < target.bottom + overlapPadding) {
539
- const cp2 = this.addCP(target.right + overlapPadding, cp1.y);
540
- const posy = ep.y < sp.y ? target.bottom + overlapPadding : target.top - overlapPadding;
541
- const cp3 = this.addCP(cp2.x, posy);
542
- this.addCP(ep.x - overlapPadding, cp3.y);
543
- }
544
- else {
545
- const overlapping = ep.x - overlapPadding > source.left;
546
- if (overlapping) {
547
- const cp2 = this.addCP(source.left - overlapPadding, cp1.y);
548
- this.addCP(cp2.x, ep.y);
549
- }
550
- else {
551
- this.addCP(ep.x - overlapPadding, cp1.y);
552
- }
553
- }
554
- this.addCP(ep.x - overlapPadding, ep.y);
555
- }
556
- }
557
- [sketchNorthSouth]() {
558
- const { source, target, sp, ep, overlapPadding, dy, dx, halfY } = this;
559
- // (dy < 0) - the source is below target
560
- // (ep.y + 2*overlapPadding < sp.y) - there is a room to render the line between the boxes
561
- if (dy < 0 && ep.y + 2 * overlapPadding < sp.y) {
562
- // draw a straight line instead of the elbow when the distance is below the threshold
563
- if (Math.abs(dx) > ElbowThreshold) {
564
- const cp1 = this.addCP(sp.x, ep.y + halfY); // ep.y + overlapPadding
565
- this.addCP(ep.x, cp1.y);
566
- }
567
- }
568
- else {
569
- const cp1 = this.addCP(sp.x, sp.y - overlapPadding);
570
- let cp2;
571
- if (sp.x < ep.x) {
572
- // to the left
573
- cp2 = this.addCP(Math.max(target.left - overlapPadding, source.right + overlapPadding), cp1.y);
574
- }
575
- else {
576
- // to the right
577
- cp2 = this.addCP(Math.min(target.right + overlapPadding, source.left - overlapPadding), cp1.y);
578
- }
579
- const cp3 = this.addCP(cp2.x, ep.y - overlapPadding);
580
- this.addCP(ep.x, cp3.y);
581
- }
582
- }
583
- [sketchNorthNorth]() {
584
- const { source, target, sp, ep, overlapPadding, dy } = this;
585
- if (dy < 0 && ep.y + 2 * overlapPadding < sp.y) {
586
- const cp1 = this.addCP(sp.x, ep.y - overlapPadding);
587
- this.addCP(ep.x, cp1.y);
588
- }
589
- else {
590
- const cp1 = this.addCP(sp.x, sp.y - overlapPadding);
591
- let cp2;
592
- if (sp.x < ep.x) {
593
- // to the left
594
- cp2 = this.addCP(Math.max(target.left - overlapPadding, source.right + overlapPadding), cp1.y);
595
- }
596
- else {
597
- // to the right
598
- cp2 = this.addCP(Math.min(target.right + overlapPadding, source.left - overlapPadding), cp1.y);
599
- }
600
- const cp3 = this.addCP(cp2.x, ep.y - overlapPadding);
601
- this.addCP(ep.x, cp3.y);
602
- }
603
- }
604
- }
605
- //# sourceMappingURL=RectilinearLine.js.map