bpmn-js 9.1.0 → 9.2.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 (73) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/assets/diagram-js.css +47 -35
  3. package/dist/bpmn-modeler.development.js +56705 -56638
  4. package/dist/bpmn-modeler.production.min.js +28 -28
  5. package/dist/bpmn-navigated-viewer.development.js +21591 -21939
  6. package/dist/bpmn-navigated-viewer.production.min.js +20 -20
  7. package/dist/bpmn-viewer.development.js +20785 -21133
  8. package/dist/bpmn-viewer.production.min.js +20 -20
  9. package/lib/BaseModeler.js +1 -1
  10. package/lib/BaseViewer.js +1 -1
  11. package/lib/Modeler.js +1 -1
  12. package/lib/NavigatedViewer.js +1 -1
  13. package/lib/Viewer.js +1 -1
  14. package/lib/draw/BpmnRenderUtil.js +3 -1
  15. package/lib/draw/BpmnRenderer.js +11 -9
  16. package/lib/features/auto-place/BpmnAutoPlaceUtil.js +10 -0
  17. package/lib/features/auto-resize/BpmnAutoResize.js +1 -1
  18. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +1 -1
  19. package/lib/features/context-pad/ContextPadProvider.js +57 -3
  20. package/lib/features/copy-paste/ModdleCopy.js +0 -2
  21. package/lib/features/drilldown/DrilldownOverlayBehavior.js +1 -1
  22. package/lib/features/editor-actions/BpmnEditorActions.js +1 -1
  23. package/lib/features/grid-snapping/behavior/LayoutConnectionBehavior.js +1 -1
  24. package/lib/features/keyboard/BpmnKeyboardBindings.js +1 -1
  25. package/lib/features/label-editing/LabelEditingProvider.js +10 -0
  26. package/lib/features/modeling/BpmnLayouter.js +1 -1
  27. package/lib/features/modeling/BpmnUpdater.js +1 -1
  28. package/lib/features/modeling/ElementFactory.js +1 -1
  29. package/lib/features/modeling/Modeling.js +1 -1
  30. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +1 -1
  31. package/lib/features/modeling/behavior/AppendBehavior.js +1 -1
  32. package/lib/features/modeling/behavior/AssociationBehavior.js +1 -1
  33. package/lib/features/modeling/behavior/AttachEventBehavior.js +1 -1
  34. package/lib/features/modeling/behavior/BoundaryEventBehavior.js +1 -1
  35. package/lib/features/modeling/behavior/CreateBehavior.js +1 -1
  36. package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +1 -1
  37. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +1 -1
  38. package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +1 -1
  39. package/lib/features/modeling/behavior/DataStoreBehavior.js +1 -1
  40. package/lib/features/modeling/behavior/DeleteLaneBehavior.js +1 -1
  41. package/lib/features/modeling/behavior/DetachEventBehavior.js +1 -1
  42. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +1 -1
  43. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.js +1 -1
  44. package/lib/features/modeling/behavior/GroupBehavior.js +1 -1
  45. package/lib/features/modeling/behavior/IsHorizontalFix.js +1 -1
  46. package/lib/features/modeling/behavior/LabelBehavior.js +1 -1
  47. package/lib/features/modeling/behavior/LayoutConnectionBehavior.js +117 -0
  48. package/lib/features/modeling/behavior/MessageFlowBehavior.js +1 -1
  49. package/lib/features/modeling/behavior/RemoveElementBehavior.js +1 -1
  50. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.js +1 -1
  51. package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +1 -1
  52. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +1 -1
  53. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +1 -1
  54. package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +1 -1
  55. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.js +1 -1
  56. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.js +1 -1
  57. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.js +1 -1
  58. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +1 -1
  59. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +1 -1
  60. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +1 -1
  61. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +1 -1
  62. package/lib/features/modeling/behavior/index.js +3 -0
  63. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.js +16 -0
  64. package/lib/features/modeling/behavior/util/GeometricUtil.js +1 -121
  65. package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +3 -192
  66. package/lib/features/modeling/behavior/util/LayoutUtil.js +230 -0
  67. package/lib/features/modeling/cmd/SetColorHandler.js +6 -2
  68. package/lib/features/ordering/BpmnOrderingProvider.js +1 -1
  69. package/lib/features/replace-preview/BpmnReplacePreview.js +1 -1
  70. package/lib/features/rules/BpmnRules.js +1 -6
  71. package/lib/features/snapping/BpmnCreateMoveSnapping.js +1 -1
  72. package/package.json +4 -4
  73. package/test/util/custom-rules/CustomRules.js +1 -1
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -1,5 +1,5 @@
1
1
 
2
- import inherits from 'inherits';
2
+ import inherits from 'inherits-browser';
3
3
 
4
4
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
5
5
 
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
4
 
@@ -17,6 +17,7 @@ import GroupBehavior from './GroupBehavior';
17
17
  import ImportDockingFix from './ImportDockingFix';
18
18
  import IsHorizontalFix from './IsHorizontalFix';
19
19
  import LabelBehavior from './LabelBehavior';
20
+ import LayoutConnectionBehavior from './LayoutConnectionBehavior';
20
21
  import MessageFlowBehavior from './MessageFlowBehavior';
21
22
  import ModelingFeedback from './ModelingFeedback';
22
23
  import RemoveEmbeddedLabelBoundsBehavior from './RemoveEmbeddedLabelBoundsBehavior';
@@ -57,6 +58,7 @@ export default {
57
58
  'importDockingFix',
58
59
  'isHorizontalFix',
59
60
  'labelBehavior',
61
+ 'layoutConnectionBehavior',
60
62
  'messageFlowBehavior',
61
63
  'modelingFeedback',
62
64
  'removeElementBehavior',
@@ -95,6 +97,7 @@ export default {
95
97
  importDockingFix: [ 'type', ImportDockingFix ],
96
98
  isHorizontalFix: [ 'type', IsHorizontalFix ],
97
99
  labelBehavior: [ 'type', LabelBehavior ],
100
+ layoutConnectionBehavior: [ 'type', LayoutConnectionBehavior ],
98
101
  messageFlowBehavior: [ 'type', MessageFlowBehavior ],
99
102
  modelingFeedback: [ 'type', ModelingFeedback ],
100
103
  removeElementBehavior: [ 'type', RemoveElementBehavior ],
@@ -0,0 +1,16 @@
1
+ import { getAnchorPointAdjustment } from './LayoutUtil';
2
+
3
+ /**
4
+ * Calculate the new point after the connection waypoints got updated.
5
+ *
6
+ * @param {djs.model.Label} label
7
+ * @param {Array<Point>} newWaypoints
8
+ * @param {Array<Point>} oldWaypoints
9
+ * @param {Object} hints
10
+ *
11
+ * @return {Point} point
12
+ */
13
+ export function getConnectionAdjustment(position, newWaypoints, oldWaypoints, hints) {
14
+ return getAnchorPointAdjustment(position, newWaypoints, oldWaypoints, hints).point;
15
+ }
16
+
@@ -1,121 +1 @@
1
- /**
2
- * Returns the length of a vector
3
- *
4
- * @param {Vector}
5
- * @return {Float}
6
- */
7
- export function vectorLength(v) {
8
- return Math.sqrt(Math.pow(v.x, 2) + Math.pow(v.y, 2));
9
- }
10
-
11
-
12
- /**
13
- * Calculates the angle between a line a the yAxis
14
- *
15
- * @param {Array}
16
- * @return {Float}
17
- */
18
- export function getAngle(line) {
19
-
20
- // return value is between 0, 180 and -180, -0
21
- // @janstuemmel: maybe replace return a/b with b/a
22
- return Math.atan((line[1].y - line[0].y) / (line[1].x - line[0].x));
23
- }
24
-
25
-
26
- /**
27
- * Rotates a vector by a given angle
28
- *
29
- * @param {Vector}
30
- * @param {Float} Angle in radians
31
- * @return {Vector}
32
- */
33
- export function rotateVector(vector, angle) {
34
- return (!angle) ? vector : {
35
- x: Math.cos(angle) * vector.x - Math.sin(angle) * vector.y,
36
- y: Math.sin(angle) * vector.x + Math.cos(angle) * vector.y
37
- };
38
- }
39
-
40
-
41
- /**
42
- * Solves a 2D equation system
43
- * a + r*b = c, where a,b,c are 2D vectors
44
- *
45
- * @param {Vector}
46
- * @param {Vector}
47
- * @param {Vector}
48
- * @return {Float}
49
- */
50
- function solveLambaSystem(a, b, c) {
51
-
52
- // the 2d system
53
- var system = [
54
- { n: a[0] - c[0], lambda: b[0] },
55
- { n: a[1] - c[1], lambda: b[1] }
56
- ];
57
-
58
- // solve
59
- var n = system[0].n * b[0] + system[1].n * b[1],
60
- l = system[0].lambda * b[0] + system[1].lambda * b[1];
61
-
62
- return -n/l;
63
- }
64
-
65
-
66
- /**
67
- * Position of perpendicular foot
68
- *
69
- * @param {Point}
70
- * @param [ {Point}, {Point} ] line defined through two points
71
- * @return {Point} the perpendicular foot position
72
- */
73
- export function perpendicularFoot(point, line) {
74
-
75
- var a = line[0], b = line[1];
76
-
77
- // relative position of b from a
78
- var bd = { x: b.x - a.x, y: b.y - a.y };
79
-
80
- // solve equation system to the parametrized vectors param real value
81
- var r = solveLambaSystem([ a.x, a.y ], [ bd.x, bd.y ], [ point.x, point.y ]);
82
-
83
- return { x: a.x + r*bd.x, y: a.y + r*bd.y };
84
- }
85
-
86
-
87
- /**
88
- * Calculates the distance between a point and a line
89
- *
90
- * @param {Point}
91
- * @param [ {Point}, {Point} ] line defined through two points
92
- * @return {Float} distance
93
- */
94
- export function getDistancePointLine(point, line) {
95
-
96
- var pfPoint = perpendicularFoot(point, line);
97
-
98
- // distance vector
99
- var connectionVector = {
100
- x: pfPoint.x - point.x,
101
- y: pfPoint.y - point.y
102
- };
103
-
104
- return vectorLength(connectionVector);
105
- }
106
-
107
-
108
- /**
109
- * Calculates the distance between two points
110
- *
111
- * @param {Point}
112
- * @param {Point}
113
- * @return {Float} distance
114
- */
115
- export function getDistancePointPoint(point1, point2) {
116
-
117
- return vectorLength({
118
- x: point1.x - point2.x,
119
- y: point1.y - point2.y
120
- });
121
- }
1
+ export * from 'diagram-js/lib/features/bendpoints/GeometricUtil';
@@ -1,95 +1,7 @@
1
- import {
2
- getDistancePointPoint,
3
- rotateVector,
4
- getAngle
5
- } from './GeometricUtil';
6
-
7
- import {
8
- getAttachment
9
- } from './LineAttachmentUtil';
10
-
11
- import {
12
- roundPoint
13
- } from 'diagram-js/lib/layout/LayoutUtil';
14
-
1
+ import { findNewLineStartIndex, getAnchorPointAdjustment } from './LayoutUtil';
15
2
 
16
3
  export function findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachment, hints) {
17
-
18
- var index = attachment.segmentIndex;
19
-
20
- var offset = newWaypoints.length - oldWaypoints.length;
21
-
22
- // segmentMove happened
23
- if (hints.segmentMove) {
24
-
25
- var oldSegmentStartIndex = hints.segmentMove.segmentStartIndex,
26
- newSegmentStartIndex = hints.segmentMove.newSegmentStartIndex;
27
-
28
- // if label was on moved segment return new segment index
29
- if (index === oldSegmentStartIndex) {
30
- return newSegmentStartIndex;
31
- }
32
-
33
- // label is after new segment index
34
- if (index >= newSegmentStartIndex) {
35
- return (index+offset < newSegmentStartIndex) ? newSegmentStartIndex : index+offset;
36
- }
37
-
38
- // if label is before new segment index
39
- return index;
40
- }
41
-
42
- // bendpointMove happened
43
- if (hints.bendpointMove) {
44
-
45
- var insert = hints.bendpointMove.insert,
46
- bendpointIndex = hints.bendpointMove.bendpointIndex,
47
- newIndex;
48
-
49
- // waypoints length didnt change
50
- if (offset === 0) {
51
- return index;
52
- }
53
-
54
- // label behind new/removed bendpoint
55
- if (index >= bendpointIndex) {
56
- newIndex = insert ? index + 1 : index - 1;
57
- }
58
-
59
- // label before new/removed bendpoint
60
- if (index < bendpointIndex) {
61
-
62
- newIndex = index;
63
-
64
- // decide label should take right or left segment
65
- if (insert && attachment.type !== 'bendpoint' && bendpointIndex-1 === index) {
66
-
67
- var rel = relativePositionMidWaypoint(newWaypoints, bendpointIndex);
68
-
69
- if (rel < attachment.relativeLocation) {
70
- newIndex++;
71
- }
72
- }
73
- }
74
-
75
- return newIndex;
76
- }
77
-
78
- // start/end changed
79
- if (offset === 0) {
80
- return index;
81
- }
82
-
83
- if (hints.connectionStart) {
84
- return (index === 0) ? 0 : null;
85
- }
86
-
87
- if (hints.connectionEnd) {
88
- return (index === oldWaypoints.length - 2) ? newWaypoints.length - 2 : null;
89
- }
90
-
91
- // if nothing fits, return null
92
- return null;
4
+ return findNewLineStartIndex(oldWaypoints, newWaypoints, attachment, hints);
93
5
  }
94
6
 
95
7
 
@@ -105,118 +17,17 @@ export function findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachmen
105
17
  * @return {Point} delta
106
18
  */
107
19
  export function getLabelAdjustment(label, newWaypoints, oldWaypoints, hints) {
108
-
109
- var x = 0,
110
- y = 0;
111
-
112
20
  var labelPosition = getLabelMid(label);
113
21
 
114
- // get closest attachment
115
- var attachment = getAttachment(labelPosition, oldWaypoints),
116
- oldLabelLineIndex = attachment.segmentIndex,
117
- newLabelLineIndex = findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachment, hints);
118
-
119
- if (newLabelLineIndex === null) {
120
- return { x: x, y: y };
121
- }
122
-
123
- // should never happen
124
- // TODO(@janstuemmel): throw an error here when connectionSegmentMove is refactored
125
- if (newLabelLineIndex < 0 ||
126
- newLabelLineIndex > newWaypoints.length - 2) {
127
- return { x: x, y: y };
128
- }
129
-
130
- var oldLabelLine = getLine(oldWaypoints, oldLabelLineIndex),
131
- newLabelLine = getLine(newWaypoints, newLabelLineIndex),
132
- oldFoot = attachment.position;
133
-
134
- var relativeFootPosition = getRelativeFootPosition(oldLabelLine, oldFoot),
135
- angleDelta = getAngleDelta(oldLabelLine, newLabelLine);
136
-
137
- // special rule if label on bendpoint
138
- if (attachment.type === 'bendpoint') {
139
-
140
- var offset = newWaypoints.length - oldWaypoints.length,
141
- oldBendpointIndex = attachment.bendpointIndex,
142
- oldBendpoint = oldWaypoints[oldBendpointIndex];
143
-
144
- // bendpoint position hasn't changed, return same position
145
- if (newWaypoints.indexOf(oldBendpoint) !== -1) {
146
- return { x: x, y: y };
147
- }
148
-
149
- // new bendpoint and old bendpoint have same index, then just return the offset
150
- if (offset === 0) {
151
- var newBendpoint = newWaypoints[oldBendpointIndex];
152
-
153
- return {
154
- x: newBendpoint.x - attachment.position.x,
155
- y: newBendpoint.y - attachment.position.y
156
- };
157
- }
158
-
159
- // if bendpoints get removed
160
- if (offset < 0 && oldBendpointIndex !== 0 && oldBendpointIndex < oldWaypoints.length - 1) {
161
- relativeFootPosition = relativePositionMidWaypoint(oldWaypoints, oldBendpointIndex);
162
- }
163
- }
164
-
165
- var newFoot = {
166
- x: (newLabelLine[1].x - newLabelLine[0].x) * relativeFootPosition + newLabelLine[0].x,
167
- y: (newLabelLine[1].y - newLabelLine[0].y) * relativeFootPosition + newLabelLine[0].y
168
- };
169
-
170
- // the rotated vector to label
171
- var newLabelVector = rotateVector({
172
- x: labelPosition.x - oldFoot.x,
173
- y: labelPosition.y - oldFoot.y
174
- }, angleDelta);
175
-
176
- // the new relative position
177
- x = newFoot.x + newLabelVector.x - labelPosition.x;
178
- y = newFoot.y + newLabelVector.y - labelPosition.y;
179
-
180
- return roundPoint({
181
- x: x,
182
- y: y
183
- });
22
+ return getAnchorPointAdjustment(labelPosition, newWaypoints, oldWaypoints, hints).delta;
184
23
  }
185
24
 
186
25
 
187
26
  // HELPERS //////////////////////
188
27
 
189
- function relativePositionMidWaypoint(waypoints, idx) {
190
-
191
- var distanceSegment1 = getDistancePointPoint(waypoints[idx-1], waypoints[idx]),
192
- distanceSegment2 = getDistancePointPoint(waypoints[idx], waypoints[idx+1]);
193
-
194
- var relativePosition = distanceSegment1 / (distanceSegment1 + distanceSegment2);
195
-
196
- return relativePosition;
197
- }
198
-
199
28
  function getLabelMid(label) {
200
29
  return {
201
30
  x: label.x + label.width / 2,
202
31
  y: label.y + label.height / 2
203
32
  };
204
33
  }
205
-
206
- function getAngleDelta(l1, l2) {
207
- var a1 = getAngle(l1),
208
- a2 = getAngle(l2);
209
- return a2 - a1;
210
- }
211
-
212
- function getLine(waypoints, idx) {
213
- return [ waypoints[idx], waypoints[idx+1] ];
214
- }
215
-
216
- function getRelativeFootPosition(line, foot) {
217
-
218
- var length = getDistancePointPoint(line[0], line[1]),
219
- lengthToFoot = getDistancePointPoint(line[0], foot);
220
-
221
- return length === 0 ? 0 : lengthToFoot / length;
222
- }
@@ -0,0 +1,230 @@
1
+ import {
2
+ getDistancePointPoint,
3
+ rotateVector,
4
+ getAngle
5
+ } from './GeometricUtil';
6
+
7
+ import {
8
+ getAttachment
9
+ } from './LineAttachmentUtil';
10
+
11
+ import {
12
+ roundPoint
13
+ } from 'diagram-js/lib/layout/LayoutUtil';
14
+
15
+
16
+ export function findNewLineStartIndex(oldWaypoints, newWaypoints, attachment, hints) {
17
+
18
+ var index = attachment.segmentIndex;
19
+
20
+ var offset = newWaypoints.length - oldWaypoints.length;
21
+
22
+ // segmentMove happened
23
+ if (hints.segmentMove) {
24
+
25
+ var oldSegmentStartIndex = hints.segmentMove.segmentStartIndex,
26
+ newSegmentStartIndex = hints.segmentMove.newSegmentStartIndex;
27
+
28
+ // if point was on moved segment return new segment index
29
+ if (index === oldSegmentStartIndex) {
30
+ return newSegmentStartIndex;
31
+ }
32
+
33
+ // point is after new segment index
34
+ if (index >= newSegmentStartIndex) {
35
+ return (index+offset < newSegmentStartIndex) ? newSegmentStartIndex : index+offset;
36
+ }
37
+
38
+ // if point is before new segment index
39
+ return index;
40
+ }
41
+
42
+ // bendpointMove happened
43
+ if (hints.bendpointMove) {
44
+
45
+ var insert = hints.bendpointMove.insert,
46
+ bendpointIndex = hints.bendpointMove.bendpointIndex,
47
+ newIndex;
48
+
49
+ // waypoints length didnt change
50
+ if (offset === 0) {
51
+ return index;
52
+ }
53
+
54
+ // point behind new/removed bendpoint
55
+ if (index >= bendpointIndex) {
56
+ newIndex = insert ? index + 1 : index - 1;
57
+ }
58
+
59
+ // point before new/removed bendpoint
60
+ if (index < bendpointIndex) {
61
+
62
+ newIndex = index;
63
+
64
+ // decide point should take right or left segment
65
+ if (insert && attachment.type !== 'bendpoint' && bendpointIndex-1 === index) {
66
+
67
+ var rel = relativePositionMidWaypoint(newWaypoints, bendpointIndex);
68
+
69
+ if (rel < attachment.relativeLocation) {
70
+ newIndex++;
71
+ }
72
+ }
73
+ }
74
+
75
+ return newIndex;
76
+ }
77
+
78
+ // start/end changed
79
+ if (offset === 0) {
80
+ return index;
81
+ }
82
+
83
+ if (hints.connectionStart && index === 0) {
84
+ return 0;
85
+ }
86
+
87
+ if (hints.connectionEnd && index === oldWaypoints.length - 2) {
88
+ return newWaypoints.length - 2;
89
+ }
90
+
91
+ // if nothing fits, take the middle segment
92
+ return Math.floor((newWaypoints.length - 2)/2);
93
+ }
94
+
95
+
96
+ /**
97
+ * Calculate the required adjustment (move delta) for the given point
98
+ * after the connection waypoints got updated.
99
+ *
100
+ * @param {Point} position
101
+ * @param {Array<Point>} newWaypoints
102
+ * @param {Array<Point>} oldWaypoints
103
+ * @param {Object} hints
104
+ *
105
+ * @return {Object} result
106
+ * @return {Point} result.point
107
+ * @return {Point} result.delta
108
+ */
109
+ export function getAnchorPointAdjustment(position, newWaypoints, oldWaypoints, hints) {
110
+
111
+ var dx = 0,
112
+ dy = 0;
113
+
114
+ var oldPosition = {
115
+ point: position,
116
+ delta: { x: 0, y: 0 }
117
+ };
118
+
119
+ // get closest attachment
120
+ var attachment = getAttachment(position, oldWaypoints),
121
+ oldLabelLineIndex = attachment.segmentIndex,
122
+ newLabelLineIndex = findNewLineStartIndex(oldWaypoints, newWaypoints, attachment, hints);
123
+
124
+
125
+ // should never happen
126
+ // TODO(@janstuemmel): throw an error here when connectionSegmentMove is refactored
127
+ if (newLabelLineIndex < 0 ||
128
+ newLabelLineIndex > newWaypoints.length - 2 ||
129
+ newLabelLineIndex === null) {
130
+ return oldPosition;
131
+ }
132
+
133
+ var oldLabelLine = getLine(oldWaypoints, oldLabelLineIndex),
134
+ newLabelLine = getLine(newWaypoints, newLabelLineIndex),
135
+ oldFoot = attachment.position;
136
+
137
+ var relativeFootPosition = getRelativeFootPosition(oldLabelLine, oldFoot),
138
+ angleDelta = getAngleDelta(oldLabelLine, newLabelLine);
139
+
140
+ // special rule if label on bendpoint
141
+ if (attachment.type === 'bendpoint') {
142
+
143
+ var offset = newWaypoints.length - oldWaypoints.length,
144
+ oldBendpointIndex = attachment.bendpointIndex,
145
+ oldBendpoint = oldWaypoints[oldBendpointIndex];
146
+
147
+ // bendpoint position hasn't changed, return same position
148
+ if (newWaypoints.indexOf(oldBendpoint) !== -1) {
149
+ return oldPosition;
150
+ }
151
+
152
+ // new bendpoint and old bendpoint have same index, then just return the offset
153
+ if (offset === 0) {
154
+ var newBendpoint = newWaypoints[oldBendpointIndex];
155
+
156
+ dx = newBendpoint.x - attachment.position.x,
157
+ dy = newBendpoint.y - attachment.position.y;
158
+
159
+ return {
160
+ delta: {
161
+ x: dx,
162
+ y: dy
163
+ },
164
+ point: {
165
+ x: position.x + dx,
166
+ y: position.y + dy
167
+ }
168
+ };
169
+ }
170
+
171
+ // if bendpoints get removed
172
+ if (offset < 0 && oldBendpointIndex !== 0 && oldBendpointIndex < oldWaypoints.length - 1) {
173
+ relativeFootPosition = relativePositionMidWaypoint(oldWaypoints, oldBendpointIndex);
174
+ }
175
+ }
176
+
177
+ var newFoot = {
178
+ x: (newLabelLine[1].x - newLabelLine[0].x) * relativeFootPosition + newLabelLine[0].x,
179
+ y: (newLabelLine[1].y - newLabelLine[0].y) * relativeFootPosition + newLabelLine[0].y
180
+ };
181
+
182
+ // the rotated vector to label
183
+ var newLabelVector = rotateVector({
184
+ x: position.x - oldFoot.x,
185
+ y: position.y - oldFoot.y
186
+ }, angleDelta);
187
+
188
+ // the new relative position
189
+ dx = newFoot.x + newLabelVector.x - position.x;
190
+ dy = newFoot.y + newLabelVector.y - position.y;
191
+
192
+ return {
193
+ point: roundPoint(newFoot),
194
+ delta: roundPoint({
195
+ x: dx,
196
+ y: dy
197
+ })
198
+ };
199
+ }
200
+
201
+
202
+ // HELPERS //////////////////////
203
+
204
+ function relativePositionMidWaypoint(waypoints, idx) {
205
+
206
+ var distanceSegment1 = getDistancePointPoint(waypoints[idx-1], waypoints[idx]),
207
+ distanceSegment2 = getDistancePointPoint(waypoints[idx], waypoints[idx+1]);
208
+
209
+ var relativePosition = distanceSegment1 / (distanceSegment1 + distanceSegment2);
210
+
211
+ return relativePosition;
212
+ }
213
+
214
+ function getAngleDelta(l1, l2) {
215
+ var a1 = getAngle(l1),
216
+ a2 = getAngle(l2);
217
+ return a2 - a1;
218
+ }
219
+
220
+ function getLine(waypoints, idx) {
221
+ return [ waypoints[idx], waypoints[idx+1] ];
222
+ }
223
+
224
+ function getRelativeFootPosition(line, foot) {
225
+
226
+ var length = getDistancePointPoint(line[0], line[1]),
227
+ lengthToFoot = getDistancePointPoint(line[0], foot);
228
+
229
+ return length === 0 ? 0 : lengthToFoot / length;
230
+ }
@@ -9,6 +9,10 @@ import {
9
9
  getDi
10
10
  } from '../../../util/ModelUtil';
11
11
 
12
+ import {
13
+ isLabel
14
+ } from '../../../util/LabelUtil';
15
+
12
16
  var DEFAULT_COLORS = {
13
17
  fill: undefined,
14
18
  stroke: undefined
@@ -66,14 +70,14 @@ SetColorHandler.prototype.postExecute = function(context) {
66
70
  // TODO @barmac: remove once we drop bpmn.io properties
67
71
  ensureLegacySupport(assignedDi);
68
72
 
69
- if (element.labelTarget) {
73
+ if (isLabel(element)) {
70
74
 
71
75
  // set label colors as bpmndi:BPMNLabel#color
72
76
  self._commandStack.execute('element.updateModdleProperties', {
73
77
  element: element,
74
78
  moddleElement: getDi(element).label,
75
79
  properties: {
76
- color: di['background-color']
80
+ color: di['border-color']
77
81
  }
78
82
  });
79
83
  } else {
@@ -1,4 +1,4 @@
1
- import inherits from 'inherits';
1
+ import inherits from 'inherits-browser';
2
2
 
3
3
  import OrderingProvider from 'diagram-js/lib/features/ordering/OrderingProvider';
4
4