bpmn-js 9.0.0-subprocesses.1 → 9.0.0-subprocesses.2

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.
@@ -1,55 +0,0 @@
1
- import { getBusinessObject, is } from '../../util/ModelUtil';
2
-
3
- export default function SubprocessElements(eventBus, elementRegistry, canvas, elementFactory) {
4
- var attachBoundaries = function() {
5
- var secondaryShapes = elementRegistry.filter(function(el) {
6
- return is(el, 'bpmn:SubProcess') && el.isSecondary;
7
- });
8
-
9
- secondaryShapes.forEach(function(process) {
10
-
11
- // Add Boundary events
12
- if (process.primaryShape && process.primaryShape.attachers) {
13
- process.primaryShape.attachers.forEach(function(boundary) {
14
- var bo = getBusinessObject(boundary);
15
-
16
- var primary = process.primaryShape;
17
-
18
- var relativeXPos = (boundary.x + 15 - primary.x) / primary.width;
19
- var relativeYPos = (boundary.y + 15 - primary.y) / primary.height;
20
-
21
- var dx = process.x + (process.width * relativeXPos) - 15;
22
- var dy = process.y + (process.height * relativeYPos) - 15;
23
-
24
- var boundaryShape = elementFactory.createShape({
25
- id: bo.id + '_secondary',
26
- businessObject: bo,
27
- type: 'bpmn:BoundaryEvent',
28
- hidden: false,
29
- x: dx,
30
- y: dy,
31
- width: 30,
32
- height: 30,
33
- isFrame: false,
34
- isSecondary: true,
35
- primaryShape: boundary,
36
- di: boundary.di
37
- });
38
-
39
- canvas.addShape(boundaryShape, process.parent);
40
-
41
- if (!process.attachers) {
42
- process.attachers = [];
43
- }
44
-
45
- process.attachers.push(boundaryShape);
46
- });
47
- }
48
- });
49
- };
50
-
51
- eventBus.on('import.done', attachBoundaries);
52
- }
53
-
54
-
55
- SubprocessElements.$inject = [ 'eventBus', 'elementRegistry', 'canvas', 'elementFactory' ];
@@ -1,109 +0,0 @@
1
- var FLOW_LENGTH = 50;
2
- var HIGH_RENDER_PRIORITY = 2000;
3
-
4
- export default function SubprocessFlows(eventBus, config) {
5
-
6
- var mutedStrokeColor = (config && config.mutedStrokeColor) || '#dddddd';
7
-
8
- function drawFakeFlows(element, parentGfx) {
9
- var primary = element.primaryShape;
10
-
11
- var drawFakeConnection = function(connection, isOutgoing) {
12
-
13
- var segment;
14
- if (isOutgoing) {
15
- segment = connection.waypoints.slice(0, 2);
16
-
17
- // Reverse order for normalizing
18
- segment = segment.reverse();
19
- } else {
20
- segment = connection.waypoints.slice(connection.waypoints.length - 2);
21
- }
22
-
23
- var endpoint = segment[1];
24
-
25
- var relativePosition = {
26
- x: (endpoint.x - primary.x) / primary.width,
27
- y: (endpoint.y - primary.y) / primary.height
28
- };
29
-
30
- var anchorPoint = {
31
- x: endpoint.x - (element.width * relativePosition.x),
32
- y: endpoint.y - (element.height * relativePosition.y)
33
- };
34
-
35
- var newWaypoints = segment.map(function(el) {
36
- return { x: el.x - anchorPoint.x, y: el.y - anchorPoint.y };
37
- });
38
-
39
- newWaypoints[0] = normalizeLength(newWaypoints[1], newWaypoints[0], FLOW_LENGTH);
40
-
41
- var attrs = {
42
- stroke: mutedStrokeColor
43
- };
44
-
45
- if (isOutgoing) {
46
-
47
- // Reverse order again for correct end marker position
48
- newWaypoints = newWaypoints.reverse();
49
- } else {
50
-
51
- // Remove start marker for incoming flows
52
- attrs.markerStart = undefined;
53
- }
54
-
55
- eventBus.fire('render.connection', {
56
- type: connection.type,
57
- gfx: parentGfx,
58
- element: {
59
- type: connection.type,
60
- waypoints: newWaypoints,
61
- di: connection.di,
62
- businessObject: connection.businessObject
63
- },
64
- attrs: attrs
65
- });
66
- };
67
-
68
- primary.incoming && primary.incoming.forEach(function(connection) {
69
- drawFakeConnection(connection, false);
70
- });
71
-
72
- primary.outgoing && primary.outgoing.forEach(function(connection) {
73
- drawFakeConnection(connection, true);
74
- });
75
- }
76
-
77
- eventBus.on([ 'render.shape' ], HIGH_RENDER_PRIORITY, function(evt, context) {
78
- var element = context.element,
79
- visuals = context.gfx;
80
-
81
- if (element.isSecondary && element.primaryShape) {
82
- drawFakeFlows(element, visuals);
83
- }
84
-
85
- });
86
-
87
- }
88
-
89
- SubprocessFlows.$inject = [ 'eventBus', 'config' ];
90
-
91
-
92
- // helpers
93
-
94
- function normalizeLength(fixedPoint, variablePoint, length) {
95
- var dx = fixedPoint.x - variablePoint.x,
96
- dy = fixedPoint.y - variablePoint.y,
97
- totalDistance = Math.abs(dx) + Math.abs(dy);
98
-
99
- dx = dx / totalDistance;
100
- dy = dy / totalDistance;
101
-
102
- dx *= length;
103
- dy *= length;
104
-
105
- return {
106
- x: fixedPoint.x - dx,
107
- y: fixedPoint.y - dy
108
- };
109
- }
@@ -1,18 +0,0 @@
1
- import OverlaysModule from 'diagram-js/lib/features/overlays';
2
- import ChangeSupportModule from 'diagram-js/lib/features/change-support';
3
-
4
- import SubprocessElements from './SubprocessElements';
5
- import SubprocessCentering from './SubprocessCentering';
6
- import SubprocessCompatibility from './SubprocessCompatibility';
7
- import SubprocessOverlays from './SubprocessOverlays';
8
- import SubprocessFlows from './SubprocessFlows';
9
-
10
- export default {
11
- __depends__: [ OverlaysModule, ChangeSupportModule ],
12
- __init__: [ 'subprocessElements', 'subprocessOverlays', 'subprocessCompatibility', 'subprocessCentering', 'subprocessFlows' ],
13
- subprocessElements: [ 'type', SubprocessElements ],
14
- subprocessOverlays: [ 'type', SubprocessOverlays ],
15
- subprocessCompatibility: [ 'type', SubprocessCompatibility ],
16
- subprocessCentering: [ 'type', SubprocessCentering ],
17
- subprocessFlows: ['type', SubprocessFlows]
18
- };