bpmn-js 18.6.1 → 18.6.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.
@@ -1,2391 +1,2413 @@
1
- import inherits from 'inherits-browser';
2
-
3
- import {
4
- assign,
5
- forEach,
6
- isObject
7
- } from 'min-dash';
8
-
9
- import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';
10
-
11
- import {
12
- isExpanded,
13
- isHorizontal,
14
- isEventSubProcess
15
- } from '../util/DiUtil';
16
-
17
- import {
18
- getLabel
19
- } from '../util/LabelUtil';
20
-
21
- import {
22
- is
23
- } from '../util/ModelUtil';
24
-
25
- import {
26
- createLine
27
- } from 'diagram-js/lib/util/RenderUtil';
28
-
29
- import {
30
- isTypedEvent,
31
- isThrowEvent,
32
- isCollection,
33
- getBounds,
34
- getDi,
35
- getSemantic,
36
- getCirclePath,
37
- getRoundRectPath,
38
- getDiamondPath,
39
- getRectPath,
40
- getFillColor,
41
- getStrokeColor,
42
- getLabelColor,
43
- getHeight,
44
- getWidth
45
- } from './BpmnRenderUtil';
46
-
47
- import {
48
- query as domQuery
49
- } from 'min-dom';
50
-
51
- import {
52
- append as svgAppend,
53
- attr as svgAttr,
54
- create as svgCreate,
55
- classes as svgClasses
56
- } from 'tiny-svg';
57
-
58
- import {
59
- rotate,
60
- transform,
61
- translate
62
- } from 'diagram-js/lib/util/SvgTransformUtil';
63
-
64
- import Ids from 'ids';
65
-
66
- import { black } from './BpmnRenderUtil';
67
-
68
- var markerIds = new Ids();
69
-
70
- var ELEMENT_LABEL_DISTANCE = 10,
71
- INNER_OUTER_DIST = 3,
72
- PARTICIPANT_STROKE_WIDTH = 1.5,
73
- TASK_BORDER_RADIUS = 10;
74
-
75
- var DEFAULT_OPACITY = 0.95,
76
- FULL_OPACITY = 1,
77
- LOW_OPACITY = 0.25;
78
-
79
- /**
80
- * @typedef { Partial<{
81
- * defaultFillColor: string,
82
- * defaultStrokeColor: string,
83
- * defaultLabelColor: string
84
- * }> } BpmnRendererConfig
85
- *
86
- * @typedef { Partial<{
87
- * fill: string,
88
- * stroke: string,
89
- * width: string,
90
- * height: string
91
- * }> } Attrs
92
- */
93
-
94
- /**
95
- * @typedef { import('../model/Types').Element } Element
96
- * @typedef { import('../model/Types').Shape } Shape
97
- * @typedef { import('../model/Types').Connection } Connection
98
- */
99
-
100
- /**
101
- * A renderer for BPMN elements
102
- *
103
- * @param {BpmnRendererConfig} config
104
- * @param {import('diagram-js/lib/core/EventBus').default} eventBus
105
- * @param {import('diagram-js/lib/draw/Styles').default} styles
106
- * @param {import('./PathMap').default} pathMap
107
- * @param {import('diagram-js/lib/core/Canvas').default} canvas
108
- * @param {import('./TextRenderer').default} textRenderer
109
- * @param {number} [priority]
110
- */
111
- export default function BpmnRenderer(
112
- config, eventBus, styles, pathMap,
113
- canvas, textRenderer, priority) {
114
-
115
- BaseRenderer.call(this, eventBus, priority);
116
-
117
- var defaultFillColor = config && config.defaultFillColor,
118
- defaultStrokeColor = config && config.defaultStrokeColor,
119
- defaultLabelColor = config && config.defaultLabelColor;
120
-
121
- function shapeStyle(attrs) {
122
- return styles.computeStyle(attrs, {
123
- strokeLinecap: 'round',
124
- strokeLinejoin: 'round',
125
- stroke: black,
126
- strokeWidth: 2,
127
- fill: 'white'
128
- });
129
- }
130
-
131
- function lineStyle(attrs) {
132
- return styles.computeStyle(attrs, [ 'no-fill' ], {
133
- strokeLinecap: 'round',
134
- strokeLinejoin: 'round',
135
- stroke: black,
136
- strokeWidth: 2
137
- });
138
- }
139
-
140
- function addMarker(id, options) {
141
- var {
142
- ref = { x: 0, y: 0 },
143
- scale = 1,
144
- element,
145
- parentGfx = canvas._svg
146
- } = options;
147
-
148
- var marker = svgCreate('marker', {
149
- id: id,
150
- viewBox: '0 0 20 20',
151
- refX: ref.x,
152
- refY: ref.y,
153
- markerWidth: 20 * scale,
154
- markerHeight: 20 * scale,
155
- orient: 'auto'
156
- });
157
-
158
- svgAppend(marker, element);
159
-
160
- var defs = domQuery(':scope > defs', parentGfx);
161
-
162
- if (!defs) {
163
- defs = svgCreate('defs');
164
-
165
- svgAppend(parentGfx, defs);
166
- }
167
-
168
- svgAppend(defs, marker);
169
- }
170
-
171
- function marker(parentGfx, type, fill, stroke) {
172
-
173
-
174
- var id = markerIds.nextPrefixed('marker-');
175
-
176
- createMarker(parentGfx, id, type, fill, stroke);
177
-
178
- return 'url(#' + id + ')';
179
- }
180
-
181
- function createMarker(parentGfx, id, type, fill, stroke) {
182
-
183
- if (type === 'sequenceflow-end') {
184
- var sequenceflowEnd = svgCreate('path', {
185
- d: 'M 1 5 L 11 10 L 1 15 Z',
186
- ...shapeStyle({
187
- fill: stroke,
188
- stroke: stroke,
189
- strokeWidth: 1
190
- })
191
- });
192
-
193
- addMarker(id, {
194
- element: sequenceflowEnd,
195
- ref: { x: 11, y: 10 },
196
- scale: 0.5,
197
- parentGfx
198
- });
199
- }
200
-
201
- if (type === 'messageflow-start') {
202
- var messageflowStart = svgCreate('circle', {
203
- cx: 6,
204
- cy: 6,
205
- r: 3.5,
206
- ...shapeStyle({
207
- fill,
208
- stroke: stroke,
209
- strokeWidth: 1,
210
-
211
- // fix for safari / chrome / firefox bug not correctly
212
- // resetting stroke dash array
213
- strokeDasharray: [ 10000, 1 ]
214
- })
215
- });
216
-
217
- addMarker(id, {
218
- element: messageflowStart,
219
- ref: { x: 6, y: 6 },
220
- parentGfx
221
- });
222
- }
223
-
224
- if (type === 'messageflow-end') {
225
- var messageflowEnd = svgCreate('path', {
226
- d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z',
227
- ...shapeStyle({
228
- fill,
229
- stroke: stroke,
230
- strokeWidth: 1,
231
-
232
- // fix for safari / chrome / firefox bug not correctly
233
- // resetting stroke dash array
234
- strokeDasharray: [ 10000, 1 ]
235
- })
236
- });
237
-
238
- addMarker(id, {
239
- element: messageflowEnd,
240
- ref: { x: 8.5, y: 5 },
241
- parentGfx
242
- });
243
- }
244
-
245
- if (type === 'association-start') {
246
- var associationStart = svgCreate('path', {
247
- d: 'M 11 5 L 1 10 L 11 15',
248
- ...lineStyle({
249
- fill: 'none',
250
- stroke,
251
- strokeWidth: 1.5,
252
-
253
- // fix for safari / chrome / firefox bug not correctly
254
- // resetting stroke dash array
255
- strokeDasharray: [ 10000, 1 ]
256
- })
257
- });
258
-
259
- addMarker(id, {
260
- element: associationStart,
261
- ref: { x: 1, y: 10 },
262
- scale: 0.5,
263
- parentGfx
264
- });
265
- }
266
-
267
- if (type === 'association-end') {
268
- var associationEnd = svgCreate('path', {
269
- d: 'M 1 5 L 11 10 L 1 15',
270
- ...lineStyle({
271
- fill: 'none',
272
- stroke,
273
- strokeWidth: 1.5,
274
-
275
- // fix for safari / chrome / firefox bug not correctly
276
- // resetting stroke dash array
277
- strokeDasharray: [ 10000, 1 ]
278
- })
279
- });
280
-
281
- addMarker(id, {
282
- element: associationEnd,
283
- ref: { x: 11, y: 10 },
284
- scale: 0.5,
285
- parentGfx
286
- });
287
- }
288
-
289
- if (type === 'conditional-flow-marker') {
290
- var conditionalFlowMarker = svgCreate('path', {
291
- d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z',
292
- ...shapeStyle({
293
- fill,
294
- stroke: stroke
295
- })
296
- });
297
-
298
- addMarker(id, {
299
- element: conditionalFlowMarker,
300
- ref: { x: -1, y: 10 },
301
- scale: 0.5,
302
- parentGfx
303
- });
304
- }
305
-
306
- if (type === 'conditional-default-flow-marker') {
307
- var defaultFlowMarker = svgCreate('path', {
308
- d: 'M 6 4 L 10 16',
309
- ...shapeStyle({
310
- stroke: stroke,
311
- fill: 'none'
312
- })
313
- });
314
-
315
- addMarker(id, {
316
- element: defaultFlowMarker,
317
- ref: { x: 0, y: 10 },
318
- scale: 0.5,
319
- parentGfx
320
- });
321
- }
322
- }
323
-
324
- function drawCircle(parentGfx, width, height, offset, attrs = {}) {
325
-
326
- if (isObject(offset)) {
327
- attrs = offset;
328
- offset = 0;
329
- }
330
-
331
- offset = offset || 0;
332
-
333
- attrs = shapeStyle(attrs);
334
-
335
- var cx = width / 2,
336
- cy = height / 2;
337
-
338
- var circle = svgCreate('circle', {
339
- cx: cx,
340
- cy: cy,
341
- r: Math.round((width + height) / 4 - offset),
342
- ...attrs
343
- });
344
-
345
- svgAppend(parentGfx, circle);
346
-
347
- return circle;
348
- }
349
-
350
- function drawRect(parentGfx, width, height, r, offset, attrs) {
351
-
352
- if (isObject(offset)) {
353
- attrs = offset;
354
- offset = 0;
355
- }
356
-
357
- offset = offset || 0;
358
-
359
- attrs = shapeStyle(attrs);
360
-
361
- var rect = svgCreate('rect', {
362
- x: offset,
363
- y: offset,
364
- width: width - offset * 2,
365
- height: height - offset * 2,
366
- rx: r,
367
- ry: r,
368
- ...attrs
369
- });
370
-
371
- svgAppend(parentGfx, rect);
372
-
373
- return rect;
374
- }
375
-
376
- function drawDiamond(parentGfx, width, height, attrs) {
377
-
378
- var x_2 = width / 2;
379
- var y_2 = height / 2;
380
-
381
- var points = [
382
- { x: x_2, y: 0 },
383
- { x: width, y: y_2 },
384
- { x: x_2, y: height },
385
- { x: 0, y: y_2 }
386
- ];
387
-
388
- var pointsString = points.map(function(point) {
389
- return point.x + ',' + point.y;
390
- }).join(' ');
391
-
392
- attrs = shapeStyle(attrs);
393
-
394
- var polygon = svgCreate('polygon', {
395
- ...attrs,
396
- points: pointsString
397
- });
398
-
399
- svgAppend(parentGfx, polygon);
400
-
401
- return polygon;
402
- }
403
-
404
- /**
405
- * @param {SVGElement} parentGfx
406
- * @param {Point[]} waypoints
407
- * @param {any} attrs
408
- * @param {number} [radius]
409
- *
410
- * @return {SVGElement}
411
- */
412
- function drawLine(parentGfx, waypoints, attrs, radius) {
413
- attrs = lineStyle(attrs);
414
-
415
- var line = createLine(waypoints, attrs, radius);
416
-
417
- svgAppend(parentGfx, line);
418
-
419
- return line;
420
- }
421
-
422
- /**
423
- * @param {SVGElement} parentGfx
424
- * @param {Point[]} waypoints
425
- * @param {any} attrs
426
- *
427
- * @return {SVGElement}
428
- */
429
- function drawConnectionSegments(parentGfx, waypoints, attrs) {
430
- return drawLine(parentGfx, waypoints, attrs, 5);
431
- }
432
-
433
- function drawPath(parentGfx, d, attrs) {
434
- attrs = lineStyle(attrs);
435
-
436
- var path = svgCreate('path', {
437
- ...attrs,
438
- d
439
- });
440
-
441
- svgAppend(parentGfx, path);
442
-
443
- return path;
444
- }
445
-
446
- function drawMarker(type, parentGfx, path, attrs) {
447
- return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
448
- }
449
-
450
- function renderer(type) {
451
- return handlers[type];
452
- }
453
-
454
- function as(type) {
455
- return function(parentGfx, element, attrs) {
456
- return renderer(type)(parentGfx, element, attrs);
457
- };
458
- }
459
-
460
- var eventIconRenderers = {
461
- 'bpmn:MessageEventDefinition': function(parentGfx, element, attrs = {}, isThrowing) {
462
- var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
463
- xScaleFactor: 0.9,
464
- yScaleFactor: 0.9,
465
- containerWidth: attrs.width || element.width,
466
- containerHeight: attrs.height || element.height,
467
- position: {
468
- mx: 0.235,
469
- my: 0.315
470
- }
471
- });
472
-
473
- var fill = isThrowing
474
- ? getStrokeColor(element, defaultStrokeColor, attrs.stroke)
475
- : getFillColor(element, defaultFillColor, attrs.fill);
476
-
477
- var stroke = isThrowing
478
- ? getFillColor(element, defaultFillColor, attrs.fill)
479
- : getStrokeColor(element, defaultStrokeColor, attrs.stroke);
480
-
481
- var messagePath = drawPath(parentGfx, pathData, {
482
- fill,
483
- stroke,
484
- strokeWidth: 1
485
- });
486
-
487
- return messagePath;
488
- },
489
- 'bpmn:TimerEventDefinition': function(parentGfx, element, attrs = {}) {
490
- var baseWidth = attrs.width || element.width;
491
- var baseHeight = attrs.height || element.height;
492
-
493
- // use a lighter stroke for event suprocess icons
494
- var strokeWidth = attrs.width ? 1 : 2;
495
-
496
- var circle = drawCircle(parentGfx, baseWidth, baseHeight, 0.2 * baseHeight, {
497
- fill: getFillColor(element, defaultFillColor, attrs.fill),
498
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
499
- strokeWidth: strokeWidth
500
- });
501
-
502
- var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
503
- xScaleFactor: 0.75,
504
- yScaleFactor: 0.75,
505
- containerWidth: baseWidth,
506
- containerHeight: baseHeight,
507
- position: {
508
- mx: 0.5,
509
- my: 0.5
510
- }
511
- });
512
-
513
- drawPath(parentGfx, pathData, {
514
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
515
- strokeWidth: strokeWidth
516
- });
517
-
518
- for (var i = 0; i < 12; i++) {
519
- var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
520
- xScaleFactor: 0.75,
521
- yScaleFactor: 0.75,
522
- containerWidth: baseWidth,
523
- containerHeight: baseHeight,
524
- position: {
525
- mx: 0.5,
526
- my: 0.5
527
- }
528
- });
529
-
530
- var width = baseWidth / 2,
531
- height = baseHeight / 2;
532
-
533
- drawPath(parentGfx, linePathData, {
534
- strokeWidth: 1,
535
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
536
- transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
537
- });
538
- }
539
-
540
- return circle;
541
- },
542
- 'bpmn:EscalationEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
543
- var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
544
- xScaleFactor: 1,
545
- yScaleFactor: 1,
546
- containerWidth: attrs.width || event.width,
547
- containerHeight: attrs.height || event.height,
548
- position: {
549
- mx: 0.5,
550
- my: 0.2
551
- }
552
- });
553
-
554
- var fill = isThrowing
555
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
556
- : getFillColor(event, defaultFillColor, attrs.fill);
557
-
558
- return drawPath(parentGfx, pathData, {
559
- fill,
560
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
561
- strokeWidth: 1
562
- });
563
- },
564
- 'bpmn:ConditionalEventDefinition': function(parentGfx, event, attrs = {}) {
565
- var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
566
- xScaleFactor: 1,
567
- yScaleFactor: 1,
568
- containerWidth: attrs.width || event.width,
569
- containerHeight: attrs.height || event.height,
570
- position: {
571
- mx: 0.5,
572
- my: 0.222
573
- }
574
- });
575
-
576
- return drawPath(parentGfx, pathData, {
577
- fill: getFillColor(event, defaultFillColor, attrs.fill),
578
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
579
- strokeWidth: 1
580
- });
581
- },
582
- 'bpmn:LinkEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
583
- var pathData = pathMap.getScaledPath('EVENT_LINK', {
584
- xScaleFactor: 1,
585
- yScaleFactor: 1,
586
- containerWidth: event.width,
587
- containerHeight: event.height,
588
- position: {
589
- mx: 0.57,
590
- my: 0.263
591
- }
592
- });
593
-
594
- var fill = isThrowing
595
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
596
- : getFillColor(event, defaultFillColor, attrs.fill);
597
-
598
- return drawPath(parentGfx, pathData, {
599
- fill,
600
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
601
- strokeWidth: 1
602
- });
603
- },
604
- 'bpmn:ErrorEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
605
- var pathData = pathMap.getScaledPath('EVENT_ERROR', {
606
- xScaleFactor: 1.1,
607
- yScaleFactor: 1.1,
608
- containerWidth: attrs.width || event.width,
609
- containerHeight: attrs.height || event.height,
610
- position: {
611
- mx: 0.2,
612
- my: 0.722
613
- }
614
- });
615
-
616
- var fill = isThrowing
617
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
618
- : getFillColor(event, defaultFillColor, attrs.fill);
619
-
620
- return drawPath(parentGfx, pathData, {
621
- fill,
622
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
623
- strokeWidth: 1
624
- });
625
- },
626
- 'bpmn:CancelEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
627
- var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
628
- xScaleFactor: 1.0,
629
- yScaleFactor: 1.0,
630
- containerWidth: event.width,
631
- containerHeight: event.height,
632
- position: {
633
- mx: 0.638,
634
- my: -0.055
635
- }
636
- });
637
-
638
- var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor, attrs.stroke) : 'none';
639
-
640
- var path = drawPath(parentGfx, pathData, {
641
- fill,
642
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
643
- strokeWidth: 1
644
- });
645
-
646
- rotate(path, 45);
647
-
648
- return path;
649
- },
650
- 'bpmn:CompensateEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
651
- var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
652
- xScaleFactor: 1,
653
- yScaleFactor: 1,
654
- containerWidth: attrs.width || event.width,
655
- containerHeight: attrs.height || event.height,
656
- position: {
657
- mx: 0.22,
658
- my: 0.5
659
- }
660
- });
661
-
662
- var fill = isThrowing
663
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
664
- : getFillColor(event, defaultFillColor, attrs.fill);
665
-
666
- return drawPath(parentGfx, pathData, {
667
- fill,
668
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
669
- strokeWidth: 1
670
- });
671
- },
672
- 'bpmn:SignalEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
673
- var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
674
- xScaleFactor: 0.9,
675
- yScaleFactor: 0.9,
676
- containerWidth: attrs.width || event.width,
677
- containerHeight: attrs.height || event.height,
678
- position: {
679
- mx: 0.5,
680
- my: 0.2
681
- }
682
- });
683
-
684
- var fill = isThrowing
685
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
686
- : getFillColor(event, defaultFillColor, attrs.fill);
687
-
688
- return drawPath(parentGfx, pathData, {
689
- strokeWidth: 1,
690
- fill,
691
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke)
692
- });
693
- },
694
- 'bpmn:MultipleEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
695
- var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
696
- xScaleFactor: 1.1,
697
- yScaleFactor: 1.1,
698
- containerWidth: attrs.width || event.width,
699
- containerHeight: attrs.height || event.height,
700
- position: {
701
- mx: 0.211,
702
- my: 0.36
703
- }
704
- });
705
-
706
- var fill = isThrowing
707
- ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
708
- : getFillColor(event, defaultFillColor, attrs.fill);
709
-
710
- return drawPath(parentGfx, pathData, {
711
- fill,
712
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
713
- strokeWidth: 1
714
- });
715
- },
716
- 'bpmn:ParallelMultipleEventDefinition': function(parentGfx, event, attrs = {}) {
717
- var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
718
- xScaleFactor: 1.2,
719
- yScaleFactor: 1.2,
720
- containerWidth: attrs.width || event.width,
721
- containerHeight: attrs.height || event.height,
722
- position: {
723
- mx: 0.458,
724
- my: 0.194
725
- }
726
- });
727
-
728
- return drawPath(parentGfx, pathData, {
729
- fill: getFillColor(event, defaultFillColor, attrs.fill),
730
- stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
731
- strokeWidth: 1
732
- });
733
- },
734
- 'bpmn:TerminateEventDefinition': function(parentGfx, element, attrs = {}) {
735
- var circle = drawCircle(parentGfx, element.width, element.height, 8, {
736
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
737
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
738
- strokeWidth: 4
739
- });
740
-
741
- return circle;
742
- }
743
- };
744
-
745
- function renderEventIcon(element, parentGfx, attrs = {}, proxyElement) {
746
- var semantic = getSemantic(element),
747
- isThrowing = isThrowEvent(semantic);
748
-
749
- var nodeElement = proxyElement || element;
750
-
751
- if (semantic.get('eventDefinitions') && semantic.get('eventDefinitions').length > 1) {
752
- if (semantic.get('parallelMultiple')) {
753
- return eventIconRenderers[ 'bpmn:ParallelMultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
754
- }
755
- else {
756
- return eventIconRenderers[ 'bpmn:MultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
757
- }
758
- }
759
-
760
- if (isTypedEvent(semantic, 'bpmn:MessageEventDefinition')) {
761
- return eventIconRenderers[ 'bpmn:MessageEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
762
- }
763
-
764
- if (isTypedEvent(semantic, 'bpmn:TimerEventDefinition')) {
765
- return eventIconRenderers[ 'bpmn:TimerEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
766
- }
767
-
768
- if (isTypedEvent(semantic, 'bpmn:ConditionalEventDefinition')) {
769
- return eventIconRenderers[ 'bpmn:ConditionalEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
770
- }
771
-
772
- if (isTypedEvent(semantic, 'bpmn:SignalEventDefinition')) {
773
- return eventIconRenderers[ 'bpmn:SignalEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
774
- }
775
-
776
- if (isTypedEvent(semantic, 'bpmn:EscalationEventDefinition')) {
777
- return eventIconRenderers[ 'bpmn:EscalationEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
778
- }
779
-
780
- if (isTypedEvent(semantic, 'bpmn:LinkEventDefinition')) {
781
- return eventIconRenderers[ 'bpmn:LinkEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
782
- }
783
-
784
- if (isTypedEvent(semantic, 'bpmn:ErrorEventDefinition')) {
785
- return eventIconRenderers[ 'bpmn:ErrorEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
786
- }
787
-
788
- if (isTypedEvent(semantic, 'bpmn:CancelEventDefinition')) {
789
- return eventIconRenderers[ 'bpmn:CancelEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
790
- }
791
-
792
- if (isTypedEvent(semantic, 'bpmn:CompensateEventDefinition')) {
793
- return eventIconRenderers[ 'bpmn:CompensateEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
794
- }
795
-
796
- if (isTypedEvent(semantic, 'bpmn:TerminateEventDefinition')) {
797
- return eventIconRenderers[ 'bpmn:TerminateEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
798
- }
799
-
800
- return null;
801
- }
802
-
803
- var taskMarkerRenderers = {
804
- 'ParticipantMultiplicityMarker': function(parentGfx, element, attrs = {}) {
805
- var width = getWidth(element, attrs),
806
- height = getHeight(element, attrs);
807
-
808
- var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
809
- xScaleFactor: 1,
810
- yScaleFactor: 1,
811
- containerWidth: width,
812
- containerHeight: height,
813
- position: {
814
- mx: ((width / 2 - 6) / width),
815
- my: (height - 15) / height
816
- }
817
- });
818
-
819
- drawMarker('participant-multiplicity', parentGfx, markerPath, {
820
- strokeWidth: 2,
821
- fill: getFillColor(element, defaultFillColor, attrs.fill),
822
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
823
- });
824
- },
825
- 'SubProcessMarker': function(parentGfx, element, attrs = {}) {
826
- var markerRect = drawRect(parentGfx, 14, 14, 0, {
827
- strokeWidth: 1,
828
- fill: getFillColor(element, defaultFillColor, attrs.fill),
829
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
830
- });
831
-
832
- translate(markerRect, element.width / 2 - 7.5, element.height - 20);
833
-
834
- var markerPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
835
- xScaleFactor: 1.5,
836
- yScaleFactor: 1.5,
837
- containerWidth: element.width,
838
- containerHeight: element.height,
839
- position: {
840
- mx: (element.width / 2 - 7.5) / element.width,
841
- my: (element.height - 20) / element.height
842
- }
843
- });
844
-
845
- drawMarker('sub-process', parentGfx, markerPath, {
846
- fill: getFillColor(element, defaultFillColor, attrs.fill),
847
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
848
- });
849
- },
850
- 'ParallelMarker': function(parentGfx, element, attrs) {
851
- var width = getWidth(element, attrs),
852
- height = getHeight(element, attrs);
853
-
854
- var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
855
- xScaleFactor: 1,
856
- yScaleFactor: 1,
857
- containerWidth: width,
858
- containerHeight: height,
859
- position: {
860
- mx: ((width / 2 + attrs.parallel) / width),
861
- my: (height - 20) / height
862
- }
863
- });
864
-
865
- drawMarker('parallel', parentGfx, markerPath, {
866
- fill: getFillColor(element, defaultFillColor, attrs.fill),
867
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
868
- });
869
- },
870
- 'SequentialMarker': function(parentGfx, element, attrs) {
871
- var markerPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
872
- xScaleFactor: 1,
873
- yScaleFactor: 1,
874
- containerWidth: element.width,
875
- containerHeight: element.height,
876
- position: {
877
- mx: ((element.width / 2 + attrs.seq) / element.width),
878
- my: (element.height - 19) / element.height
879
- }
880
- });
881
-
882
- drawMarker('sequential', parentGfx, markerPath, {
883
- fill: getFillColor(element, defaultFillColor, attrs.fill),
884
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
885
- });
886
- },
887
- 'CompensationMarker': function(parentGfx, element, attrs) {
888
- var markerMath = pathMap.getScaledPath('MARKER_COMPENSATION', {
889
- xScaleFactor: 1,
890
- yScaleFactor: 1,
891
- containerWidth: element.width,
892
- containerHeight: element.height,
893
- position: {
894
- mx: ((element.width / 2 + attrs.compensation) / element.width),
895
- my: (element.height - 13) / element.height
896
- }
897
- });
898
-
899
- drawMarker('compensation', parentGfx, markerMath, {
900
- strokeWidth: 1,
901
- fill: getFillColor(element, defaultFillColor, attrs.fill),
902
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
903
- });
904
- },
905
- 'LoopMarker': function(parentGfx, element, attrs) {
906
- var width = getWidth(element, attrs),
907
- height = getHeight(element, attrs);
908
-
909
- var markerPath = pathMap.getScaledPath('MARKER_LOOP', {
910
- xScaleFactor: 1,
911
- yScaleFactor: 1,
912
- containerWidth: width,
913
- containerHeight: height,
914
- position: {
915
- mx: ((width / 2 + attrs.loop) / width),
916
- my: (height - 7) / height
917
- }
918
- });
919
-
920
- drawMarker('loop', parentGfx, markerPath, {
921
- strokeWidth: 1.5,
922
- fill: 'none',
923
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
924
- strokeMiterlimit: 0.5
925
- });
926
- },
927
- 'AdhocMarker': function(parentGfx, element, attrs) {
928
- var width = getWidth(element, attrs),
929
- height = getHeight(element, attrs);
930
-
931
- var markerPath = pathMap.getScaledPath('MARKER_ADHOC', {
932
- xScaleFactor: 1,
933
- yScaleFactor: 1,
934
- containerWidth: width,
935
- containerHeight: height,
936
- position: {
937
- mx: ((width / 2 + attrs.adhoc) / width),
938
- my: (height - 15) / height
939
- }
940
- });
941
-
942
- drawMarker('adhoc', parentGfx, markerPath, {
943
- strokeWidth: 1,
944
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
945
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
946
- });
947
- }
948
- };
949
-
950
- function renderTaskMarker(type, parentGfx, element, attrs) {
951
- taskMarkerRenderers[ type ](parentGfx, element, attrs);
952
- }
953
-
954
- function renderTaskMarkers(parentGfx, element, taskMarkers, attrs = {}) {
955
- attrs = {
956
- fill: attrs.fill,
957
- stroke: attrs.stroke,
958
- width: getWidth(element, attrs),
959
- height: getHeight(element, attrs)
960
- };
961
-
962
- var semantic = getSemantic(element);
963
-
964
- var subprocess = taskMarkers && taskMarkers.includes('SubProcessMarker');
965
-
966
- if (subprocess) {
967
- attrs = {
968
- ...attrs,
969
- seq: -21,
970
- parallel: -22,
971
- compensation: -42,
972
- loop: -18,
973
- adhoc: 10
974
- };
975
- } else {
976
- attrs = {
977
- ...attrs,
978
- seq: -5,
979
- parallel: -6,
980
- compensation: -27,
981
- loop: 0,
982
- adhoc: 10
983
- };
984
- }
985
-
986
- forEach(taskMarkers, function(marker) {
987
- renderTaskMarker(marker, parentGfx, element, attrs);
988
- });
989
-
990
- if (semantic.get('isForCompensation')) {
991
- renderTaskMarker('CompensationMarker', parentGfx, element, attrs);
992
- }
993
-
994
- if (is(semantic, 'bpmn:AdHocSubProcess')) {
995
- renderTaskMarker('AdhocMarker', parentGfx, element, attrs);
996
- }
997
-
998
- var loopCharacteristics = semantic.get('loopCharacteristics'),
999
- isSequential = loopCharacteristics && loopCharacteristics.get('isSequential');
1000
-
1001
- if (loopCharacteristics) {
1002
-
1003
- if (isSequential === undefined) {
1004
- renderTaskMarker('LoopMarker', parentGfx, element, attrs);
1005
- }
1006
-
1007
- if (isSequential === false) {
1008
- renderTaskMarker('ParallelMarker', parentGfx, element, attrs);
1009
- }
1010
-
1011
- if (isSequential === true) {
1012
- renderTaskMarker('SequentialMarker', parentGfx, element, attrs);
1013
- }
1014
- }
1015
- }
1016
-
1017
- function renderLabel(parentGfx, label, attrs = {}) {
1018
- attrs = assign({
1019
- size: {
1020
- width: 100
1021
- }
1022
- }, attrs);
1023
-
1024
- var text = textRenderer.createText(label || '', attrs);
1025
-
1026
- svgClasses(text).add('djs-label');
1027
-
1028
- svgAppend(parentGfx, text);
1029
-
1030
- return text;
1031
- }
1032
-
1033
- function renderEmbeddedLabel(parentGfx, element, align, attrs = {}) {
1034
- var semantic = getSemantic(element);
1035
-
1036
- var box = getBounds({
1037
- x: element.x,
1038
- y: element.y,
1039
- width: element.width,
1040
- height: element.height
1041
- }, attrs);
1042
-
1043
- return renderLabel(parentGfx, semantic.name, {
1044
- align,
1045
- box,
1046
- padding: 7,
1047
- style: {
1048
- fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1049
- }
1050
- });
1051
- }
1052
-
1053
- function renderExternalLabel(parentGfx, element, attrs = {}) {
1054
- var box = {
1055
- width: 90,
1056
- height: 30,
1057
- x: element.width / 2 + element.x,
1058
- y: element.height / 2 + element.y
1059
- };
1060
-
1061
- return renderLabel(parentGfx, getLabel(element), {
1062
- box: box,
1063
- fitBox: true,
1064
- style: assign(
1065
- {},
1066
- textRenderer.getExternalStyle(),
1067
- {
1068
- fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1069
- }
1070
- )
1071
- });
1072
- }
1073
-
1074
- function renderLaneLabel(parentGfx, text, element, attrs = {}) {
1075
- var isHorizontalLane = isHorizontal(element);
1076
-
1077
- var textBox = renderLabel(parentGfx, text, {
1078
- box: {
1079
- height: 30,
1080
- width: isHorizontalLane ? getHeight(element, attrs) : getWidth(element, attrs),
1081
- },
1082
- align: 'center-middle',
1083
- style: {
1084
- fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1085
- }
1086
- });
1087
-
1088
- if (isHorizontalLane) {
1089
- var top = -1 * getHeight(element, attrs);
1090
- transform(textBox, 0, -top, 270);
1091
- }
1092
- }
1093
-
1094
- function renderActivity(parentGfx, element, attrs = {}) {
1095
- var {
1096
- width,
1097
- height
1098
- } = getBounds(element, attrs);
1099
-
1100
- return drawRect(parentGfx, width, height, TASK_BORDER_RADIUS, {
1101
- ...attrs,
1102
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1103
- fillOpacity: DEFAULT_OPACITY,
1104
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1105
- });
1106
- }
1107
-
1108
- function renderAssociation(parentGfx, element, attrs = {}) {
1109
- var semantic = getSemantic(element);
1110
-
1111
- var fill = getFillColor(element, defaultFillColor, attrs.fill),
1112
- stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1113
-
1114
- if (semantic.get('associationDirection') === 'One' ||
1115
- semantic.get('associationDirection') === 'Both') {
1116
- attrs.markerEnd = marker(parentGfx, 'association-end', fill, stroke);
1117
- }
1118
-
1119
- if (semantic.get('associationDirection') === 'Both') {
1120
- attrs.markerStart = marker(parentGfx, 'association-start', fill, stroke);
1121
- }
1122
-
1123
- attrs = pickAttrs(attrs, [
1124
- 'markerStart',
1125
- 'markerEnd'
1126
- ]);
1127
-
1128
- return drawConnectionSegments(parentGfx, element.waypoints, {
1129
- ...attrs,
1130
- stroke,
1131
- strokeDasharray: '0, 5'
1132
- });
1133
- }
1134
-
1135
- function renderDataObject(parentGfx, element, attrs = {}) {
1136
- var fill = getFillColor(element, defaultFillColor, attrs.fill),
1137
- stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1138
-
1139
- var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
1140
- xScaleFactor: 1,
1141
- yScaleFactor: 1,
1142
- containerWidth: element.width,
1143
- containerHeight: element.height,
1144
- position: {
1145
- mx: 0.474,
1146
- my: 0.296
1147
- }
1148
- });
1149
-
1150
- var dataObject = drawPath(parentGfx, pathData, {
1151
- fill,
1152
- fillOpacity: DEFAULT_OPACITY,
1153
- stroke
1154
- });
1155
-
1156
- var semantic = getSemantic(element);
1157
-
1158
- if (isCollection(semantic)) {
1159
- var collectionPathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
1160
- xScaleFactor: 1,
1161
- yScaleFactor: 1,
1162
- containerWidth: element.width,
1163
- containerHeight: element.height,
1164
- position: {
1165
- mx: 0.33,
1166
- my: (element.height - 18) / element.height
1167
- }
1168
- });
1169
-
1170
- drawPath(parentGfx, collectionPathData, {
1171
- strokeWidth: 2,
1172
- fill,
1173
- stroke
1174
- });
1175
- }
1176
-
1177
- return dataObject;
1178
- }
1179
-
1180
- function renderEvent(parentGfx, element, attrs = {}) {
1181
- return drawCircle(parentGfx, element.width, element.height, {
1182
- fillOpacity: DEFAULT_OPACITY,
1183
- ...attrs,
1184
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1185
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1186
- });
1187
- }
1188
-
1189
- function renderGateway(parentGfx, element, attrs = {}) {
1190
- return drawDiamond(parentGfx, element.width, element.height, {
1191
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1192
- fillOpacity: DEFAULT_OPACITY,
1193
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1194
- });
1195
- }
1196
-
1197
- function renderLane(parentGfx, element, attrs = {}) {
1198
- var lane = drawRect(parentGfx, getWidth(element, attrs), getHeight(element, attrs), 0, {
1199
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1200
- fillOpacity: attrs.fillOpacity || DEFAULT_OPACITY,
1201
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1202
- strokeWidth: 1.5
1203
- });
1204
-
1205
- var semantic = getSemantic(element);
1206
-
1207
- if (is(semantic, 'bpmn:Lane')) {
1208
- var text = semantic.get('name');
1209
-
1210
- renderLaneLabel(parentGfx, text, element, attrs);
1211
- }
1212
-
1213
- return lane;
1214
- }
1215
-
1216
- function renderSubProcess(parentGfx, element, attrs = {}) {
1217
- var activity = renderActivity(parentGfx, element, attrs);
1218
-
1219
- var expanded = isExpanded(element);
1220
-
1221
- if (isEventSubProcess(element)) {
1222
- svgAttr(activity, {
1223
- strokeDasharray: '0, 5.5',
1224
- strokeWidth: 2.5
1225
- });
1226
-
1227
- if (!expanded) {
1228
- var flowElements = getSemantic(element).flowElements || [];
1229
- var startEvents = flowElements.filter(e => is(e, 'bpmn:StartEvent'));
1230
-
1231
- if (startEvents.length === 1) {
1232
- renderEventSubProcessIcon(startEvents[0], parentGfx, attrs, element);
1233
- }
1234
- }
1235
- }
1236
-
1237
- renderEmbeddedLabel(parentGfx, element, expanded ? 'center-top' : 'center-middle', attrs);
1238
-
1239
- if (expanded) {
1240
- renderTaskMarkers(parentGfx, element, undefined, attrs);
1241
- } else {
1242
- renderTaskMarkers(parentGfx, element, [ 'SubProcessMarker' ], attrs);
1243
- }
1244
-
1245
- return activity;
1246
- }
1247
-
1248
- function renderEventSubProcessIcon(startEvent, parentGfx, attrs, proxyElement) {
1249
- var iconSize = 22;
1250
-
1251
- // match the colors of the enclosing subprocess
1252
- var proxyAttrs = {
1253
- fill: getFillColor(proxyElement, defaultFillColor, attrs.fill),
1254
- stroke: getStrokeColor(proxyElement, defaultStrokeColor, attrs.stroke),
1255
- width: iconSize,
1256
- height: iconSize
1257
- };
1258
-
1259
- var interrupting = getSemantic(startEvent).isInterrupting;
1260
- var strokeDasharray = interrupting ? 0 : 3;
1261
-
1262
- // better visibility for non-interrupting events
1263
- var strokeWidth = interrupting ? 1 : 1.2;
1264
-
1265
- // make the icon look larger by drawing a smaller circle
1266
- var circleSize = 20;
1267
- var shift = (iconSize - circleSize) / 2;
1268
- var transform = 'translate(' + shift + ',' + shift + ')';
1269
-
1270
- drawCircle(parentGfx, circleSize, circleSize, {
1271
- fill: proxyAttrs.fill,
1272
- stroke: proxyAttrs.stroke,
1273
- strokeWidth,
1274
- strokeDasharray,
1275
- transform
1276
- });
1277
-
1278
- renderEventIcon(startEvent, parentGfx, proxyAttrs, proxyElement);
1279
- }
1280
-
1281
- function renderTask(parentGfx, element, attrs = {}) {
1282
- var activity = renderActivity(parentGfx, element, attrs);
1283
-
1284
- renderEmbeddedLabel(parentGfx, element, 'center-middle', attrs);
1285
-
1286
- renderTaskMarkers(parentGfx, element, undefined, attrs);
1287
-
1288
- return activity;
1289
- }
1290
-
1291
- var handlers = this.handlers = {
1292
- 'bpmn:AdHocSubProcess': function(parentGfx, element, attrs = {}) {
1293
- if (isExpanded(element)) {
1294
- attrs = pickAttrs(attrs, [
1295
- 'fill',
1296
- 'stroke',
1297
- 'width',
1298
- 'height'
1299
- ]);
1300
- } else {
1301
- attrs = pickAttrs(attrs, [
1302
- 'fill',
1303
- 'stroke'
1304
- ]);
1305
- }
1306
-
1307
- return renderSubProcess(parentGfx, element, attrs);
1308
- },
1309
- 'bpmn:Association': function(parentGfx, element, attrs = {}) {
1310
- attrs = pickAttrs(attrs, [
1311
- 'fill',
1312
- 'stroke'
1313
- ]);
1314
-
1315
- return renderAssociation(parentGfx, element, attrs);
1316
- },
1317
- 'bpmn:BoundaryEvent': function(parentGfx, element, attrs = {}) {
1318
- var { renderIcon = true } = attrs;
1319
-
1320
- attrs = pickAttrs(attrs, [
1321
- 'fill',
1322
- 'stroke'
1323
- ]);
1324
-
1325
- var semantic = getSemantic(element),
1326
- cancelActivity = semantic.get('cancelActivity');
1327
-
1328
- attrs = {
1329
- strokeWidth: 1.5,
1330
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1331
- fillOpacity: FULL_OPACITY,
1332
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1333
- };
1334
-
1335
- if (!cancelActivity) {
1336
- attrs.strokeDasharray = '6';
1337
- }
1338
-
1339
- var event = renderEvent(parentGfx, element, attrs);
1340
-
1341
- drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
1342
- ...attrs,
1343
- fill: 'none'
1344
- });
1345
-
1346
- if (renderIcon) {
1347
- renderEventIcon(element, parentGfx, attrs);
1348
- }
1349
-
1350
- return event;
1351
- },
1352
- 'bpmn:BusinessRuleTask': function(parentGfx, element, attrs = {}) {
1353
- attrs = pickAttrs(attrs, [
1354
- 'fill',
1355
- 'stroke'
1356
- ]);
1357
-
1358
- var task = renderTask(parentGfx, element, attrs);
1359
-
1360
- var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
1361
- abspos: {
1362
- x: 8,
1363
- y: 8
1364
- }
1365
- });
1366
-
1367
- var businessPath = drawPath(parentGfx, headerData);
1368
-
1369
- svgAttr(businessPath, {
1370
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1371
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1372
- strokeWidth: 1
1373
- });
1374
-
1375
- var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
1376
- abspos: {
1377
- x: 8,
1378
- y: 8
1379
- }
1380
- });
1381
-
1382
- var businessHeaderPath = drawPath(parentGfx, headerPathData);
1383
-
1384
- svgAttr(businessHeaderPath, {
1385
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1386
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1387
- strokeWidth: 1
1388
- });
1389
-
1390
- return task;
1391
- },
1392
- 'bpmn:CallActivity': function(parentGfx, element, attrs = {}) {
1393
- attrs = pickAttrs(attrs, [
1394
- 'fill',
1395
- 'stroke'
1396
- ]);
1397
-
1398
- return renderSubProcess(parentGfx, element, {
1399
- strokeWidth: 5,
1400
- ...attrs
1401
- });
1402
- },
1403
- 'bpmn:ComplexGateway': function(parentGfx, element, attrs = {}) {
1404
- attrs = pickAttrs(attrs, [
1405
- 'fill',
1406
- 'stroke'
1407
- ]);
1408
-
1409
- var gateway = renderGateway(parentGfx, element, attrs);
1410
-
1411
- var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
1412
- xScaleFactor: 0.5,
1413
- yScaleFactor:0.5,
1414
- containerWidth: element.width,
1415
- containerHeight: element.height,
1416
- position: {
1417
- mx: 0.46,
1418
- my: 0.26
1419
- }
1420
- });
1421
-
1422
- drawPath(parentGfx, pathData, {
1423
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1424
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1425
- strokeWidth: 1
1426
- });
1427
-
1428
- return gateway;
1429
- },
1430
- 'bpmn:DataInput': function(parentGfx, element, attrs = {}) {
1431
- attrs = pickAttrs(attrs, [
1432
- 'fill',
1433
- 'stroke'
1434
- ]);
1435
-
1436
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1437
-
1438
- var dataObject = renderDataObject(parentGfx, element, attrs);
1439
-
1440
- drawPath(parentGfx, arrowPathData, {
1441
- fill: 'none',
1442
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1443
- strokeWidth: 1
1444
- });
1445
-
1446
- return dataObject;
1447
- },
1448
- 'bpmn:DataInputAssociation': function(parentGfx, element, attrs = {}) {
1449
- attrs = pickAttrs(attrs, [
1450
- 'fill',
1451
- 'stroke'
1452
- ]);
1453
-
1454
- return renderAssociation(parentGfx, element, {
1455
- ...attrs,
1456
- markerEnd: marker(parentGfx, 'association-end', getFillColor(element, defaultFillColor, attrs.fill), getStrokeColor(element, defaultStrokeColor, attrs.stroke))
1457
- });
1458
- },
1459
- 'bpmn:DataObject': function(parentGfx, element, attrs = {}) {
1460
- attrs = pickAttrs(attrs, [
1461
- 'fill',
1462
- 'stroke'
1463
- ]);
1464
-
1465
- return renderDataObject(parentGfx, element, attrs);
1466
- },
1467
- 'bpmn:DataObjectReference': as('bpmn:DataObject'),
1468
- 'bpmn:DataOutput': function(parentGfx, element, attrs = {}) {
1469
- attrs = pickAttrs(attrs, [
1470
- 'fill',
1471
- 'stroke'
1472
- ]);
1473
-
1474
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1475
-
1476
- var dataObject = renderDataObject(parentGfx, element, attrs);
1477
-
1478
- drawPath(parentGfx, arrowPathData, {
1479
- strokeWidth: 1,
1480
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1481
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1482
- });
1483
-
1484
- return dataObject;
1485
- },
1486
- 'bpmn:DataOutputAssociation': function(parentGfx, element, attrs = {}) {
1487
- attrs = pickAttrs(attrs, [
1488
- 'fill',
1489
- 'stroke'
1490
- ]);
1491
-
1492
- return renderAssociation(parentGfx, element, {
1493
- ...attrs,
1494
- markerEnd: marker(parentGfx, 'association-end', getFillColor(element, defaultFillColor, attrs.fill), getStrokeColor(element, defaultStrokeColor, attrs.stroke))
1495
- });
1496
- },
1497
- 'bpmn:DataStoreReference': function(parentGfx, element, attrs = {}) {
1498
- attrs = pickAttrs(attrs, [
1499
- 'fill',
1500
- 'stroke'
1501
- ]);
1502
-
1503
- var dataStorePath = pathMap.getScaledPath('DATA_STORE', {
1504
- xScaleFactor: 1,
1505
- yScaleFactor: 1,
1506
- containerWidth: element.width,
1507
- containerHeight: element.height,
1508
- position: {
1509
- mx: 0,
1510
- my: 0.133
1511
- }
1512
- });
1513
-
1514
- return drawPath(parentGfx, dataStorePath, {
1515
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1516
- fillOpacity: DEFAULT_OPACITY,
1517
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1518
- strokeWidth: 2
1519
- });
1520
- },
1521
- 'bpmn:EndEvent': function(parentGfx, element, attrs = {}) {
1522
- var { renderIcon = true } = attrs;
1523
-
1524
- attrs = pickAttrs(attrs, [
1525
- 'fill',
1526
- 'stroke'
1527
- ]);
1528
-
1529
- var event = renderEvent(parentGfx, element, {
1530
- ...attrs,
1531
- strokeWidth: 4
1532
- });
1533
-
1534
- if (renderIcon) {
1535
- renderEventIcon(element, parentGfx, attrs);
1536
- }
1537
-
1538
- return event;
1539
- },
1540
- 'bpmn:EventBasedGateway': function(parentGfx, element, attrs = {}) {
1541
- attrs = pickAttrs(attrs, [
1542
- 'fill',
1543
- 'stroke'
1544
- ]);
1545
-
1546
- var semantic = getSemantic(element);
1547
-
1548
- var diamond = renderGateway(parentGfx, element, attrs);
1549
-
1550
- drawCircle(parentGfx, element.width, element.height, element.height * 0.20, {
1551
- fill: getFillColor(element, 'none', attrs.fill),
1552
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1553
- strokeWidth: 1
1554
- });
1555
-
1556
- var type = semantic.get('eventGatewayType'),
1557
- instantiate = !!semantic.get('instantiate');
1558
-
1559
- function drawEvent() {
1560
-
1561
- var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
1562
- xScaleFactor: 0.18,
1563
- yScaleFactor: 0.18,
1564
- containerWidth: element.width,
1565
- containerHeight: element.height,
1566
- position: {
1567
- mx: 0.36,
1568
- my: 0.44
1569
- }
1570
- });
1571
-
1572
- drawPath(parentGfx, pathData, {
1573
- fill: 'none',
1574
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1575
- strokeWidth: 2
1576
- });
1577
- }
1578
-
1579
- if (type === 'Parallel') {
1580
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1581
- xScaleFactor: 0.4,
1582
- yScaleFactor: 0.4,
1583
- containerWidth: element.width,
1584
- containerHeight: element.height,
1585
- position: {
1586
- mx: 0.474,
1587
- my: 0.296
1588
- }
1589
- });
1590
-
1591
- drawPath(parentGfx, pathData, {
1592
- fill: 'none',
1593
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1594
- strokeWidth: 1
1595
- });
1596
- } else if (type === 'Exclusive') {
1597
- if (!instantiate) {
1598
- drawCircle(parentGfx, element.width, element.height, element.height * 0.26, {
1599
- fill: 'none',
1600
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1601
- strokeWidth: 1
1602
- });
1603
- }
1604
-
1605
- drawEvent();
1606
- }
1607
-
1608
-
1609
- return diamond;
1610
- },
1611
- 'bpmn:ExclusiveGateway': function(parentGfx, element, attrs = {}) {
1612
- attrs = pickAttrs(attrs, [
1613
- 'fill',
1614
- 'stroke'
1615
- ]);
1616
-
1617
- var gateway = renderGateway(parentGfx, element, attrs);
1618
-
1619
- var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
1620
- xScaleFactor: 0.4,
1621
- yScaleFactor: 0.4,
1622
- containerWidth: element.width,
1623
- containerHeight: element.height,
1624
- position: {
1625
- mx: 0.32,
1626
- my: 0.3
1627
- }
1628
- });
1629
-
1630
- var di = getDi(element);
1631
-
1632
- if (di.get('isMarkerVisible')) {
1633
- drawPath(parentGfx, pathData, {
1634
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1635
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1636
- strokeWidth: 1
1637
- });
1638
- }
1639
-
1640
- return gateway;
1641
- },
1642
- 'bpmn:Gateway': function(parentGfx, element, attrs = {}) {
1643
- attrs = pickAttrs(attrs, [
1644
- 'fill',
1645
- 'stroke'
1646
- ]);
1647
-
1648
- return renderGateway(parentGfx, element, attrs);
1649
- },
1650
- 'bpmn:Group': function(parentGfx, element, attrs = {}) {
1651
- attrs = pickAttrs(attrs, [
1652
- 'fill',
1653
- 'stroke',
1654
- 'width',
1655
- 'height'
1656
- ]);
1657
-
1658
- return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, {
1659
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1660
- strokeWidth: 1.5,
1661
- strokeDasharray: '10, 6, 0, 6',
1662
- fill: 'none',
1663
- pointerEvents: 'none',
1664
- width: getWidth(element, attrs),
1665
- height: getHeight(element, attrs)
1666
- });
1667
- },
1668
- 'bpmn:InclusiveGateway': function(parentGfx, element, attrs = {}) {
1669
- attrs = pickAttrs(attrs, [
1670
- 'fill',
1671
- 'stroke'
1672
- ]);
1673
-
1674
- var gateway = renderGateway(parentGfx, element, attrs);
1675
-
1676
- drawCircle(parentGfx, element.width, element.height, element.height * 0.24, {
1677
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1678
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1679
- strokeWidth: 2.5
1680
- });
1681
-
1682
- return gateway;
1683
- },
1684
- 'bpmn:IntermediateEvent': function(parentGfx, element, attrs = {}) {
1685
- var { renderIcon = true } = attrs;
1686
-
1687
- attrs = pickAttrs(attrs, [
1688
- 'fill',
1689
- 'stroke'
1690
- ]);
1691
-
1692
- var outer = renderEvent(parentGfx, element, {
1693
- ...attrs,
1694
- strokeWidth: 1.5
1695
- });
1696
-
1697
- drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
1698
- fill: 'none',
1699
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1700
- strokeWidth: 1.5
1701
- });
1702
-
1703
- if (renderIcon) {
1704
- renderEventIcon(element, parentGfx, attrs);
1705
- }
1706
-
1707
- return outer;
1708
- },
1709
- 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
1710
- 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
1711
- 'bpmn:Lane': function(parentGfx, element, attrs = {}) {
1712
- attrs = pickAttrs(attrs, [
1713
- 'fill',
1714
- 'stroke',
1715
- 'width',
1716
- 'height'
1717
- ]);
1718
-
1719
- return renderLane(parentGfx, element, {
1720
- ...attrs,
1721
- fillOpacity: LOW_OPACITY
1722
- });
1723
- },
1724
- 'bpmn:ManualTask': function(parentGfx, element, attrs = {}) {
1725
- attrs = pickAttrs(attrs, [
1726
- 'fill',
1727
- 'stroke'
1728
- ]);
1729
-
1730
- var task = renderTask(parentGfx, element, attrs);
1731
-
1732
- var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
1733
- abspos: {
1734
- x: 17,
1735
- y: 15
1736
- }
1737
- });
1738
-
1739
- drawPath(parentGfx, pathData, {
1740
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1741
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1742
- strokeWidth: 0.5
1743
- });
1744
-
1745
- return task;
1746
- },
1747
- 'bpmn:MessageFlow': function(parentGfx, element, attrs = {}) {
1748
- attrs = pickAttrs(attrs, [
1749
- 'fill',
1750
- 'stroke'
1751
- ]);
1752
-
1753
- var semantic = getSemantic(element),
1754
- di = getDi(element);
1755
-
1756
- var fill = getFillColor(element, defaultFillColor, attrs.fill),
1757
- stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1758
-
1759
- var path = drawConnectionSegments(parentGfx, element.waypoints, {
1760
- markerEnd: marker(parentGfx, 'messageflow-end', fill, stroke),
1761
- markerStart: marker(parentGfx, 'messageflow-start', fill, stroke),
1762
- stroke,
1763
- strokeDasharray: '10, 11',
1764
- strokeWidth: 1.5
1765
- });
1766
-
1767
- if (semantic.get('messageRef')) {
1768
- var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
1769
-
1770
- var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
1771
- abspos: {
1772
- x: midPoint.x,
1773
- y: midPoint.y
1774
- }
1775
- });
1776
-
1777
- var messageAttrs = {
1778
- strokeWidth: 1
1779
- };
1780
-
1781
- if (di.get('messageVisibleKind') === 'initiating') {
1782
- messageAttrs.fill = fill;
1783
- messageAttrs.stroke = stroke;
1784
- } else {
1785
- messageAttrs.fill = stroke;
1786
- messageAttrs.stroke = fill;
1787
- }
1788
-
1789
- var message = drawPath(parentGfx, markerPathData, messageAttrs);
1790
-
1791
- var messageRef = semantic.get('messageRef'),
1792
- name = messageRef.get('name');
1793
-
1794
- var label = renderLabel(parentGfx, name, {
1795
- align: 'center-top',
1796
- fitBox: true,
1797
- style: {
1798
- fill: stroke
1799
- }
1800
- });
1801
-
1802
- var messageBounds = message.getBBox(),
1803
- labelBounds = label.getBBox();
1804
-
1805
- var translateX = midPoint.x - labelBounds.width / 2,
1806
- translateY = midPoint.y + messageBounds.height / 2 + ELEMENT_LABEL_DISTANCE;
1807
-
1808
- transform(label, translateX, translateY, 0);
1809
- }
1810
-
1811
- return path;
1812
- },
1813
- 'bpmn:ParallelGateway': function(parentGfx, element, attrs = {}) {
1814
- attrs = pickAttrs(attrs, [
1815
- 'fill',
1816
- 'stroke'
1817
- ]);
1818
-
1819
- var diamond = renderGateway(parentGfx, element, attrs);
1820
-
1821
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1822
- xScaleFactor: 0.6,
1823
- yScaleFactor: 0.6,
1824
- containerWidth: element.width,
1825
- containerHeight: element.height,
1826
- position: {
1827
- mx: 0.46,
1828
- my: 0.2
1829
- }
1830
- });
1831
-
1832
- drawPath(parentGfx, pathData, {
1833
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1834
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1835
- strokeWidth: 1
1836
- });
1837
-
1838
- return diamond;
1839
- },
1840
- 'bpmn:Participant': function(parentGfx, element, attrs = {}) {
1841
- attrs = pickAttrs(attrs, [
1842
- 'fill',
1843
- 'stroke',
1844
- 'width',
1845
- 'height'
1846
- ]);
1847
-
1848
- var participant = renderLane(parentGfx, element, attrs);
1849
-
1850
- var expandedParticipant = isExpanded(element);
1851
- var horizontalParticipant = isHorizontal(element);
1852
-
1853
- var semantic = getSemantic(element),
1854
- name = semantic.get('name');
1855
-
1856
- if (expandedParticipant) {
1857
- var waypoints = horizontalParticipant ? [
1858
- {
1859
- x: 30,
1860
- y: 0
1861
- },
1862
- {
1863
- x: 30,
1864
- y: getHeight(element, attrs)
1865
- }
1866
- ] : [
1867
- {
1868
- x: 0,
1869
- y: 30
1870
- },
1871
- {
1872
- x: getWidth(element, attrs),
1873
- y: 30
1874
- }
1875
- ];
1876
-
1877
- drawLine(parentGfx, waypoints, {
1878
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1879
- strokeWidth: PARTICIPANT_STROKE_WIDTH
1880
- });
1881
-
1882
- renderLaneLabel(parentGfx, name, element, attrs);
1883
- } else {
1884
- var bounds = getBounds(element, attrs);
1885
-
1886
- if (!horizontalParticipant) {
1887
- bounds.height = getWidth(element, attrs);
1888
- bounds.width = getHeight(element, attrs);
1889
- }
1890
-
1891
- var textBox = renderLabel(parentGfx, name, {
1892
- box: bounds,
1893
- align: 'center-middle',
1894
- style: {
1895
- fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1896
- }
1897
- });
1898
-
1899
- if (!horizontalParticipant) {
1900
- var top = -1 * getHeight(element, attrs);
1901
- transform(textBox, 0, -top, 270);
1902
- }
1903
- }
1904
-
1905
- if (semantic.get('participantMultiplicity')) {
1906
- renderTaskMarker('ParticipantMultiplicityMarker', parentGfx, element, attrs);
1907
- }
1908
-
1909
- return participant;
1910
- },
1911
- 'bpmn:ReceiveTask' : function(parentGfx, element, attrs = {}) {
1912
- attrs = pickAttrs(attrs, [
1913
- 'fill',
1914
- 'stroke'
1915
- ]);
1916
-
1917
- var semantic = getSemantic(element);
1918
-
1919
- var task = renderTask(parentGfx, element, attrs);
1920
-
1921
- var pathData;
1922
-
1923
- if (semantic.get('instantiate')) {
1924
- drawCircle(parentGfx, 28, 28, 20 * 0.22, {
1925
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1926
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1927
- strokeWidth: 1
1928
- });
1929
-
1930
- pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
1931
- abspos: {
1932
- x: 7.77,
1933
- y: 9.52
1934
- }
1935
- });
1936
- } else {
1937
- pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
1938
- xScaleFactor: 0.9,
1939
- yScaleFactor: 0.9,
1940
- containerWidth: 21,
1941
- containerHeight: 14,
1942
- position: {
1943
- mx: 0.3,
1944
- my: 0.4
1945
- }
1946
- });
1947
- }
1948
-
1949
- drawPath(parentGfx, pathData, {
1950
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1951
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1952
- strokeWidth: 1
1953
- });
1954
-
1955
- return task;
1956
- },
1957
- 'bpmn:ScriptTask': function(parentGfx, element, attrs = {}) {
1958
- attrs = pickAttrs(attrs, [
1959
- 'fill',
1960
- 'stroke'
1961
- ]);
1962
-
1963
- var task = renderTask(parentGfx, element, attrs);
1964
-
1965
- var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
1966
- abspos: {
1967
- x: 15,
1968
- y: 20
1969
- }
1970
- });
1971
-
1972
- drawPath(parentGfx, pathData, {
1973
- fill: getFillColor(element, defaultFillColor, attrs.fill),
1974
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1975
- strokeWidth: 1
1976
- });
1977
-
1978
- return task;
1979
- },
1980
- 'bpmn:SendTask': function(parentGfx, element, attrs = {}) {
1981
- attrs = pickAttrs(attrs, [
1982
- 'fill',
1983
- 'stroke'
1984
- ]);
1985
-
1986
- var task = renderTask(parentGfx, element, attrs);
1987
-
1988
- var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
1989
- xScaleFactor: 1,
1990
- yScaleFactor: 1,
1991
- containerWidth: 21,
1992
- containerHeight: 14,
1993
- position: {
1994
- mx: 0.285,
1995
- my: 0.357
1996
- }
1997
- });
1998
-
1999
- drawPath(parentGfx, pathData, {
2000
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2001
- stroke: getFillColor(element, defaultFillColor, attrs.fill),
2002
- strokeWidth: 1
2003
- });
2004
-
2005
- return task;
2006
- },
2007
- 'bpmn:SequenceFlow': function(parentGfx, element, attrs = {}) {
2008
- attrs = pickAttrs(attrs, [
2009
- 'fill',
2010
- 'stroke'
2011
- ]);
2012
-
2013
- var fill = getFillColor(element, defaultFillColor, attrs.fill),
2014
- stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
2015
-
2016
- var connection = drawConnectionSegments(parentGfx, element.waypoints, {
2017
- markerEnd: marker(parentGfx, 'sequenceflow-end', fill, stroke),
2018
- stroke
2019
- });
2020
-
2021
- var semantic = getSemantic(element);
2022
-
2023
- var { source } = element;
2024
-
2025
- if (source) {
2026
- var sourceSemantic = getSemantic(source);
2027
-
2028
- // conditional flow marker
2029
- if (semantic.get('conditionExpression') && is(sourceSemantic, 'bpmn:Activity')) {
2030
- svgAttr(connection, {
2031
- markerStart: marker(parentGfx, 'conditional-flow-marker', fill, stroke)
2032
- });
2033
- }
2034
-
2035
- // default marker
2036
- if (sourceSemantic.get('default') && (is(sourceSemantic, 'bpmn:Gateway') || is(sourceSemantic, 'bpmn:Activity')) &&
2037
- sourceSemantic.get('default') === semantic) {
2038
- svgAttr(connection, {
2039
- markerStart: marker(parentGfx, 'conditional-default-flow-marker', fill, stroke)
2040
- });
2041
- }
2042
- }
2043
-
2044
- return connection;
2045
- },
2046
- 'bpmn:ServiceTask': function(parentGfx, element, attrs = {}) {
2047
- attrs = pickAttrs(attrs, [
2048
- 'fill',
2049
- 'stroke'
2050
- ]);
2051
-
2052
- var task = renderTask(parentGfx, element, attrs);
2053
-
2054
- drawCircle(parentGfx, 10, 10, {
2055
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2056
- stroke: 'none',
2057
- transform: 'translate(6, 6)'
2058
- });
2059
-
2060
- var pathDataService1 = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
2061
- abspos: {
2062
- x: 12,
2063
- y: 18
2064
- }
2065
- });
2066
-
2067
- drawPath(parentGfx, pathDataService1, {
2068
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2069
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2070
- strokeWidth: 1
2071
- });
2072
-
2073
- drawCircle(parentGfx, 10, 10, {
2074
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2075
- stroke: 'none',
2076
- transform: 'translate(11, 10)'
2077
- });
2078
-
2079
- var pathDataService2 = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
2080
- abspos: {
2081
- x: 17,
2082
- y: 22
2083
- }
2084
- });
2085
-
2086
- drawPath(parentGfx, pathDataService2, {
2087
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2088
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2089
- strokeWidth: 1
2090
- });
2091
-
2092
- return task;
2093
- },
2094
- 'bpmn:StartEvent': function(parentGfx, element, attrs = {}) {
2095
- var { renderIcon = true } = attrs;
2096
-
2097
- attrs = pickAttrs(attrs, [
2098
- 'fill',
2099
- 'stroke'
2100
- ]);
2101
-
2102
- var semantic = getSemantic(element);
2103
-
2104
- if (!semantic.get('isInterrupting')) {
2105
- attrs = {
2106
- ...attrs,
2107
- strokeDasharray: '6'
2108
- };
2109
- }
2110
-
2111
- var event = renderEvent(parentGfx, element, attrs);
2112
-
2113
- if (renderIcon) {
2114
- renderEventIcon(element, parentGfx, attrs);
2115
- }
2116
-
2117
- return event;
2118
- },
2119
- 'bpmn:SubProcess': function(parentGfx, element, attrs = {}) {
2120
- if (isExpanded(element)) {
2121
- attrs = pickAttrs(attrs, [
2122
- 'fill',
2123
- 'stroke',
2124
- 'width',
2125
- 'height'
2126
- ]);
2127
- } else {
2128
- attrs = pickAttrs(attrs, [
2129
- 'fill',
2130
- 'stroke'
2131
- ]);
2132
- }
2133
-
2134
- return renderSubProcess(parentGfx, element, attrs);
2135
- },
2136
- 'bpmn:Task': function(parentGfx, element, attrs = {}) {
2137
- attrs = pickAttrs(attrs, [
2138
- 'fill',
2139
- 'stroke'
2140
- ]);
2141
-
2142
- return renderTask(parentGfx, element, attrs);
2143
- },
2144
- 'bpmn:TextAnnotation': function(parentGfx, element, attrs = {}) {
2145
- attrs = pickAttrs(attrs, [
2146
- 'fill',
2147
- 'stroke',
2148
- 'width',
2149
- 'height'
2150
- ]);
2151
-
2152
- var {
2153
- width,
2154
- height
2155
- } = getBounds(element, attrs);
2156
-
2157
- var textElement = drawRect(parentGfx, width, height, 0, 0, {
2158
- fill: 'none',
2159
- stroke: 'none'
2160
- });
2161
-
2162
- var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
2163
- xScaleFactor: 1,
2164
- yScaleFactor: 1,
2165
- containerWidth: width,
2166
- containerHeight: height,
2167
- position: {
2168
- mx: 0.0,
2169
- my: 0.0
2170
- }
2171
- });
2172
-
2173
- drawPath(parentGfx, textPathData, {
2174
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
2175
- });
2176
-
2177
- var semantic = getSemantic(element),
2178
- text = semantic.get('text') || '';
2179
-
2180
- renderLabel(parentGfx, text, {
2181
- align: 'left-top',
2182
- box: getBounds(element, attrs),
2183
- padding: 7,
2184
- style: {
2185
- fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
2186
- }
2187
- });
2188
-
2189
- return textElement;
2190
- },
2191
- 'bpmn:Transaction': function(parentGfx, element, attrs = {}) {
2192
- if (isExpanded(element)) {
2193
- attrs = pickAttrs(attrs, [
2194
- 'fill',
2195
- 'stroke',
2196
- 'width',
2197
- 'height'
2198
- ]);
2199
- } else {
2200
- attrs = pickAttrs(attrs, [
2201
- 'fill',
2202
- 'stroke'
2203
- ]);
2204
- }
2205
-
2206
- var outer = renderSubProcess(parentGfx, element, {
2207
- strokeWidth: 1.5,
2208
- ...attrs
2209
- });
2210
-
2211
- var innerAttrs = styles.style([ 'no-fill', 'no-events' ], {
2212
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2213
- strokeWidth: 1.5
2214
- });
2215
-
2216
- var expanded = isExpanded(element);
2217
-
2218
- if (!expanded) {
2219
- attrs = {};
2220
- }
2221
-
2222
- drawRect(
2223
- parentGfx,
2224
- getWidth(element, attrs),
2225
- getHeight(element, attrs),
2226
- TASK_BORDER_RADIUS - INNER_OUTER_DIST,
2227
- INNER_OUTER_DIST,
2228
- innerAttrs
2229
- );
2230
-
2231
- return outer;
2232
- },
2233
- 'bpmn:UserTask': function(parentGfx, element, attrs = {}) {
2234
- attrs = pickAttrs(attrs, [
2235
- 'fill',
2236
- 'stroke'
2237
- ]);
2238
-
2239
- var task = renderTask(parentGfx, element, attrs);
2240
-
2241
- var x = 15;
2242
- var y = 12;
2243
-
2244
- var pathDataUser1 = pathMap.getScaledPath('TASK_TYPE_USER_1', {
2245
- abspos: {
2246
- x: x,
2247
- y: y
2248
- }
2249
- });
2250
-
2251
- drawPath(parentGfx, pathDataUser1, {
2252
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2253
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2254
- strokeWidth: 0.5
2255
- });
2256
-
2257
- var pathDataUser2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
2258
- abspos: {
2259
- x: x,
2260
- y: y
2261
- }
2262
- });
2263
-
2264
- drawPath(parentGfx, pathDataUser2, {
2265
- fill: getFillColor(element, defaultFillColor, attrs.fill),
2266
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2267
- strokeWidth: 0.5
2268
- });
2269
-
2270
- var pathDataUser3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
2271
- abspos: {
2272
- x: x,
2273
- y: y
2274
- }
2275
- });
2276
-
2277
- drawPath(parentGfx, pathDataUser3, {
2278
- fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2279
- stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2280
- strokeWidth: 0.5
2281
- });
2282
-
2283
- return task;
2284
- },
2285
- 'label': function(parentGfx, element, attrs = {}) {
2286
- return renderExternalLabel(parentGfx, element, attrs);
2287
- }
2288
- };
2289
-
2290
- // extension API, use at your own risk
2291
- this._drawPath = drawPath;
2292
-
2293
- this._renderer = renderer;
2294
- }
2295
-
2296
-
2297
- inherits(BpmnRenderer, BaseRenderer);
2298
-
2299
- BpmnRenderer.$inject = [
2300
- 'config.bpmnRenderer',
2301
- 'eventBus',
2302
- 'styles',
2303
- 'pathMap',
2304
- 'canvas',
2305
- 'textRenderer'
2306
- ];
2307
-
2308
-
2309
- /**
2310
- * @param {Element} element
2311
- *
2312
- * @return {boolean}
2313
- */
2314
- BpmnRenderer.prototype.canRender = function(element) {
2315
- return is(element, 'bpmn:BaseElement');
2316
- };
2317
-
2318
- /**
2319
- * Draw shape into parentGfx.
2320
- *
2321
- * @param {SVGElement} parentGfx
2322
- * @param {Shape} shape
2323
- * @param {Attrs} [attrs]
2324
- *
2325
- * @return {SVGElement} mainGfx
2326
- */
2327
- BpmnRenderer.prototype.drawShape = function(parentGfx, shape, attrs = {}) {
2328
- var { type } = shape;
2329
-
2330
- var handler = this._renderer(type);
2331
-
2332
- return handler(parentGfx, shape, attrs);
2333
- };
2334
-
2335
- /**
2336
- * Draw connection into parentGfx.
2337
- *
2338
- * @param {SVGElement} parentGfx
2339
- * @param {Connection} connection
2340
- * @param {Attrs} [attrs]
2341
- *
2342
- * @return {SVGElement} mainGfx
2343
- */
2344
- BpmnRenderer.prototype.drawConnection = function(parentGfx, connection, attrs = {}) {
2345
- var { type } = connection;
2346
-
2347
- var handler = this._renderer(type);
2348
-
2349
- return handler(parentGfx, connection, attrs);
2350
- };
2351
-
2352
- /**
2353
- * Get shape path.
2354
- *
2355
- * @param {Shape} shape
2356
- *
2357
- * @return {string} path
2358
- */
2359
- BpmnRenderer.prototype.getShapePath = function(shape) {
2360
- if (is(shape, 'bpmn:Event')) {
2361
- return getCirclePath(shape);
2362
- }
2363
-
2364
- if (is(shape, 'bpmn:Activity')) {
2365
- return getRoundRectPath(shape, TASK_BORDER_RADIUS);
2366
- }
2367
-
2368
- if (is(shape, 'bpmn:Gateway')) {
2369
- return getDiamondPath(shape);
2370
- }
2371
-
2372
- return getRectPath(shape);
2373
- };
2374
-
2375
- /**
2376
- * Pick attributes if they exist.
2377
- *
2378
- * @param {Object} attrs
2379
- * @param {string[]} keys
2380
- *
2381
- * @returns {Object}
2382
- */
2383
- function pickAttrs(attrs, keys = []) {
2384
- return keys.reduce((pickedAttrs, key) => {
2385
- if (attrs[ key ]) {
2386
- pickedAttrs[ key ] = attrs[ key ];
2387
- }
2388
-
2389
- return pickedAttrs;
2390
- }, {});
1
+ import inherits from 'inherits-browser';
2
+
3
+ import {
4
+ assign,
5
+ forEach,
6
+ isObject
7
+ } from 'min-dash';
8
+
9
+ import BaseRenderer from 'diagram-js/lib/draw/BaseRenderer';
10
+
11
+ import {
12
+ isExpanded,
13
+ isHorizontal,
14
+ isEventSubProcess
15
+ } from '../util/DiUtil';
16
+
17
+ import {
18
+ getLabel
19
+ } from '../util/LabelUtil';
20
+
21
+ import {
22
+ is
23
+ } from '../util/ModelUtil';
24
+
25
+ import {
26
+ createLine
27
+ } from 'diagram-js/lib/util/RenderUtil';
28
+
29
+ import {
30
+ isTypedEvent,
31
+ isThrowEvent,
32
+ isCollection,
33
+ getBounds,
34
+ getDi,
35
+ getSemantic,
36
+ getCirclePath,
37
+ getRoundRectPath,
38
+ getDiamondPath,
39
+ getRectPath,
40
+ getFillColor,
41
+ getStrokeColor,
42
+ getLabelColor,
43
+ getHeight,
44
+ getWidth
45
+ } from './BpmnRenderUtil';
46
+
47
+ import {
48
+ query as domQuery
49
+ } from 'min-dom';
50
+
51
+ import {
52
+ append as svgAppend,
53
+ attr as svgAttr,
54
+ create as svgCreate,
55
+ classes as svgClasses
56
+ } from 'tiny-svg';
57
+
58
+ import {
59
+ rotate,
60
+ transform,
61
+ translate
62
+ } from 'diagram-js/lib/util/SvgTransformUtil';
63
+
64
+ import Ids from 'ids';
65
+
66
+ import { black } from './BpmnRenderUtil';
67
+
68
+ var markerIds = new Ids();
69
+
70
+ var ELEMENT_LABEL_DISTANCE = 10,
71
+ INNER_OUTER_DIST = 3,
72
+ PARTICIPANT_STROKE_WIDTH = 1.5,
73
+ TASK_BORDER_RADIUS = 10;
74
+
75
+ var DEFAULT_OPACITY = 0.95,
76
+ FULL_OPACITY = 1,
77
+ LOW_OPACITY = 0.25;
78
+
79
+ /**
80
+ * @typedef { Partial<{
81
+ * defaultFillColor: string,
82
+ * defaultStrokeColor: string,
83
+ * defaultLabelColor: string
84
+ * }> } BpmnRendererConfig
85
+ *
86
+ * @typedef { Partial<{
87
+ * fill: string,
88
+ * stroke: string,
89
+ * width: string,
90
+ * height: string
91
+ * }> } Attrs
92
+ */
93
+
94
+ /**
95
+ * @typedef { import('../model/Types').Element } Element
96
+ * @typedef { import('../model/Types').Shape } Shape
97
+ * @typedef { import('../model/Types').Connection } Connection
98
+ */
99
+
100
+ /**
101
+ * A renderer for BPMN elements
102
+ *
103
+ * @param {BpmnRendererConfig} config
104
+ * @param {import('diagram-js/lib/core/EventBus').default} eventBus
105
+ * @param {import('diagram-js/lib/draw/Styles').default} styles
106
+ * @param {import('./PathMap').default} pathMap
107
+ * @param {import('diagram-js/lib/core/Canvas').default} canvas
108
+ * @param {import('./TextRenderer').default} textRenderer
109
+ * @param {number} [priority]
110
+ */
111
+ export default function BpmnRenderer(
112
+ config, eventBus, styles, pathMap,
113
+ canvas, textRenderer, priority) {
114
+
115
+ BaseRenderer.call(this, eventBus, priority);
116
+
117
+ var defaultFillColor = config && config.defaultFillColor,
118
+ defaultStrokeColor = config && config.defaultStrokeColor,
119
+ defaultLabelColor = config && config.defaultLabelColor;
120
+
121
+ function shapeStyle(attrs) {
122
+ return styles.computeStyle(attrs, {
123
+ strokeLinecap: 'round',
124
+ strokeLinejoin: 'round',
125
+ stroke: black,
126
+ strokeWidth: 2,
127
+ fill: 'white'
128
+ });
129
+ }
130
+
131
+ function lineStyle(attrs) {
132
+ return styles.computeStyle(attrs, [ 'no-fill' ], {
133
+ strokeLinecap: 'round',
134
+ strokeLinejoin: 'round',
135
+ stroke: black,
136
+ strokeWidth: 2
137
+ });
138
+ }
139
+
140
+ function addMarker(id, options) {
141
+ var {
142
+ ref = { x: 0, y: 0 },
143
+ scale = 1,
144
+ element,
145
+ parentGfx = canvas._svg
146
+ } = options;
147
+
148
+ var marker = svgCreate('marker', {
149
+ id: id,
150
+ viewBox: '0 0 20 20',
151
+ refX: ref.x,
152
+ refY: ref.y,
153
+ markerWidth: 20 * scale,
154
+ markerHeight: 20 * scale,
155
+ orient: 'auto'
156
+ });
157
+
158
+ svgAppend(marker, element);
159
+
160
+ var defs = domQuery(':scope > defs', parentGfx);
161
+
162
+ if (!defs) {
163
+ defs = svgCreate('defs');
164
+
165
+ svgAppend(parentGfx, defs);
166
+ }
167
+
168
+ svgAppend(defs, marker);
169
+ }
170
+
171
+ function marker(parentGfx, type, fill, stroke) {
172
+
173
+
174
+ var id = markerIds.nextPrefixed('marker-');
175
+
176
+ createMarker(parentGfx, id, type, fill, stroke);
177
+
178
+ return 'url(#' + id + ')';
179
+ }
180
+
181
+ function createMarker(parentGfx, id, type, fill, stroke) {
182
+
183
+ if (type === 'sequenceflow-end') {
184
+ var sequenceflowEnd = svgCreate('path', {
185
+ d: 'M 1 5 L 11 10 L 1 15 Z',
186
+ ...shapeStyle({
187
+ fill: stroke,
188
+ stroke: stroke,
189
+ strokeWidth: 1
190
+ })
191
+ });
192
+
193
+ addMarker(id, {
194
+ element: sequenceflowEnd,
195
+ ref: { x: 11, y: 10 },
196
+ scale: 0.5,
197
+ parentGfx
198
+ });
199
+ }
200
+
201
+ if (type === 'messageflow-start') {
202
+ var messageflowStart = svgCreate('circle', {
203
+ cx: 6,
204
+ cy: 6,
205
+ r: 3.5,
206
+ ...shapeStyle({
207
+ fill,
208
+ stroke: stroke,
209
+ strokeWidth: 1,
210
+
211
+ // fix for safari / chrome / firefox bug not correctly
212
+ // resetting stroke dash array
213
+ strokeDasharray: [ 10000, 1 ]
214
+ })
215
+ });
216
+
217
+ addMarker(id, {
218
+ element: messageflowStart,
219
+ ref: { x: 6, y: 6 },
220
+ parentGfx
221
+ });
222
+ }
223
+
224
+ if (type === 'messageflow-end') {
225
+ var messageflowEnd = svgCreate('path', {
226
+ d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z',
227
+ ...shapeStyle({
228
+ fill,
229
+ stroke: stroke,
230
+ strokeWidth: 1,
231
+
232
+ // fix for safari / chrome / firefox bug not correctly
233
+ // resetting stroke dash array
234
+ strokeDasharray: [ 10000, 1 ]
235
+ })
236
+ });
237
+
238
+ addMarker(id, {
239
+ element: messageflowEnd,
240
+ ref: { x: 8.5, y: 5 },
241
+ parentGfx
242
+ });
243
+ }
244
+
245
+ if (type === 'association-start') {
246
+ var associationStart = svgCreate('path', {
247
+ d: 'M 11 5 L 1 10 L 11 15',
248
+ ...lineStyle({
249
+ fill: 'none',
250
+ stroke,
251
+ strokeWidth: 1.5,
252
+
253
+ // fix for safari / chrome / firefox bug not correctly
254
+ // resetting stroke dash array
255
+ strokeDasharray: [ 10000, 1 ]
256
+ })
257
+ });
258
+
259
+ addMarker(id, {
260
+ element: associationStart,
261
+ ref: { x: 1, y: 10 },
262
+ scale: 0.5,
263
+ parentGfx
264
+ });
265
+ }
266
+
267
+ if (type === 'association-end') {
268
+ var associationEnd = svgCreate('path', {
269
+ d: 'M 1 5 L 11 10 L 1 15',
270
+ ...lineStyle({
271
+ fill: 'none',
272
+ stroke,
273
+ strokeWidth: 1.5,
274
+
275
+ // fix for safari / chrome / firefox bug not correctly
276
+ // resetting stroke dash array
277
+ strokeDasharray: [ 10000, 1 ]
278
+ })
279
+ });
280
+
281
+ addMarker(id, {
282
+ element: associationEnd,
283
+ ref: { x: 11, y: 10 },
284
+ scale: 0.5,
285
+ parentGfx
286
+ });
287
+ }
288
+
289
+ if (type === 'conditional-flow-marker') {
290
+ var conditionalFlowMarker = svgCreate('path', {
291
+ d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z',
292
+ ...shapeStyle({
293
+ fill,
294
+ stroke: stroke
295
+ })
296
+ });
297
+
298
+ addMarker(id, {
299
+ element: conditionalFlowMarker,
300
+ ref: { x: -1, y: 10 },
301
+ scale: 0.5,
302
+ parentGfx
303
+ });
304
+ }
305
+
306
+ if (type === 'conditional-default-flow-marker') {
307
+ var defaultFlowMarker = svgCreate('path', {
308
+ d: 'M 6 4 L 10 16',
309
+ ...shapeStyle({
310
+ stroke: stroke,
311
+ fill: 'none'
312
+ })
313
+ });
314
+
315
+ addMarker(id, {
316
+ element: defaultFlowMarker,
317
+ ref: { x: 0, y: 10 },
318
+ scale: 0.5,
319
+ parentGfx
320
+ });
321
+ }
322
+ }
323
+
324
+ function drawCircle(parentGfx, width, height, offset, attrs = {}) {
325
+
326
+ if (isObject(offset)) {
327
+ attrs = offset;
328
+ offset = 0;
329
+ }
330
+
331
+ offset = offset || 0;
332
+
333
+ attrs = shapeStyle(attrs);
334
+
335
+ var cx = width / 2,
336
+ cy = height / 2;
337
+
338
+ var circle = svgCreate('circle', {
339
+ cx: cx,
340
+ cy: cy,
341
+ r: Math.round((width + height) / 4 - offset),
342
+ ...attrs
343
+ });
344
+
345
+ svgAppend(parentGfx, circle);
346
+
347
+ return circle;
348
+ }
349
+
350
+ function drawRect(parentGfx, width, height, r, offset, attrs) {
351
+
352
+ if (isObject(offset)) {
353
+ attrs = offset;
354
+ offset = 0;
355
+ }
356
+
357
+ offset = offset || 0;
358
+
359
+ attrs = shapeStyle(attrs);
360
+
361
+ var rect = svgCreate('rect', {
362
+ x: offset,
363
+ y: offset,
364
+ width: width - offset * 2,
365
+ height: height - offset * 2,
366
+ rx: r,
367
+ ry: r,
368
+ ...attrs
369
+ });
370
+
371
+ svgAppend(parentGfx, rect);
372
+
373
+ return rect;
374
+ }
375
+
376
+ function drawDiamond(parentGfx, width, height, attrs) {
377
+
378
+ var x_2 = width / 2;
379
+ var y_2 = height / 2;
380
+
381
+ var points = [
382
+ { x: x_2, y: 0 },
383
+ { x: width, y: y_2 },
384
+ { x: x_2, y: height },
385
+ { x: 0, y: y_2 }
386
+ ];
387
+
388
+ var pointsString = points.map(function(point) {
389
+ return point.x + ',' + point.y;
390
+ }).join(' ');
391
+
392
+ attrs = shapeStyle(attrs);
393
+
394
+ var polygon = svgCreate('polygon', {
395
+ ...attrs,
396
+ points: pointsString
397
+ });
398
+
399
+ svgAppend(parentGfx, polygon);
400
+
401
+ return polygon;
402
+ }
403
+
404
+ /**
405
+ * @param {SVGElement} parentGfx
406
+ * @param {Point[]} waypoints
407
+ * @param {any} attrs
408
+ * @param {number} [radius]
409
+ *
410
+ * @return {SVGElement}
411
+ */
412
+ function drawLine(parentGfx, waypoints, attrs, radius) {
413
+ attrs = lineStyle(attrs);
414
+
415
+ var line = createLine(waypoints, attrs, radius);
416
+
417
+ svgAppend(parentGfx, line);
418
+
419
+ return line;
420
+ }
421
+
422
+ /**
423
+ * @param {SVGElement} parentGfx
424
+ * @param {Point[]} waypoints
425
+ * @param {any} attrs
426
+ *
427
+ * @return {SVGElement}
428
+ */
429
+ function drawConnectionSegments(parentGfx, waypoints, attrs) {
430
+ return drawLine(parentGfx, waypoints, attrs, 5);
431
+ }
432
+
433
+ function drawPath(parentGfx, d, attrs) {
434
+ attrs = lineStyle(attrs);
435
+
436
+ var path = svgCreate('path', {
437
+ ...attrs,
438
+ d
439
+ });
440
+
441
+ svgAppend(parentGfx, path);
442
+
443
+ return path;
444
+ }
445
+
446
+ function drawMarker(type, parentGfx, path, attrs) {
447
+ return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
448
+ }
449
+
450
+ function renderer(type) {
451
+ return handlers[type];
452
+ }
453
+
454
+ function as(type) {
455
+ return function(parentGfx, element, attrs) {
456
+ return renderer(type)(parentGfx, element, attrs);
457
+ };
458
+ }
459
+
460
+ var eventIconRenderers = {
461
+ 'bpmn:MessageEventDefinition': function(parentGfx, element, attrs = {}, isThrowing) {
462
+ var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
463
+ xScaleFactor: 0.9,
464
+ yScaleFactor: 0.9,
465
+ containerWidth: attrs.width || element.width,
466
+ containerHeight: attrs.height || element.height,
467
+ position: {
468
+ mx: 0.235,
469
+ my: 0.315
470
+ }
471
+ });
472
+
473
+ var fill = isThrowing
474
+ ? getStrokeColor(element, defaultStrokeColor, attrs.stroke)
475
+ : getFillColor(element, defaultFillColor, attrs.fill);
476
+
477
+ var stroke = isThrowing
478
+ ? getFillColor(element, defaultFillColor, attrs.fill)
479
+ : getStrokeColor(element, defaultStrokeColor, attrs.stroke);
480
+
481
+ var messagePath = drawPath(parentGfx, pathData, {
482
+ fill,
483
+ stroke,
484
+ strokeWidth: 1
485
+ });
486
+
487
+ return messagePath;
488
+ },
489
+ 'bpmn:TimerEventDefinition': function(parentGfx, element, attrs = {}) {
490
+ var baseWidth = attrs.width || element.width;
491
+ var baseHeight = attrs.height || element.height;
492
+
493
+ // use a lighter stroke for event suprocess icons
494
+ var strokeWidth = attrs.width ? 1 : 2;
495
+
496
+ var circle = drawCircle(parentGfx, baseWidth, baseHeight, 0.2 * baseHeight, {
497
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
498
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
499
+ strokeWidth: strokeWidth
500
+ });
501
+
502
+ var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
503
+ xScaleFactor: 0.75,
504
+ yScaleFactor: 0.75,
505
+ containerWidth: baseWidth,
506
+ containerHeight: baseHeight,
507
+ position: {
508
+ mx: 0.5,
509
+ my: 0.5
510
+ }
511
+ });
512
+
513
+ drawPath(parentGfx, pathData, {
514
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
515
+ strokeWidth: strokeWidth
516
+ });
517
+
518
+ for (var i = 0; i < 12; i++) {
519
+ var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
520
+ xScaleFactor: 0.75,
521
+ yScaleFactor: 0.75,
522
+ containerWidth: baseWidth,
523
+ containerHeight: baseHeight,
524
+ position: {
525
+ mx: 0.5,
526
+ my: 0.5
527
+ }
528
+ });
529
+
530
+ var width = baseWidth / 2,
531
+ height = baseHeight / 2;
532
+
533
+ drawPath(parentGfx, linePathData, {
534
+ strokeWidth: 1,
535
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
536
+ transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
537
+ });
538
+ }
539
+
540
+ return circle;
541
+ },
542
+ 'bpmn:EscalationEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
543
+ var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
544
+ xScaleFactor: 1,
545
+ yScaleFactor: 1,
546
+ containerWidth: attrs.width || event.width,
547
+ containerHeight: attrs.height || event.height,
548
+ position: {
549
+ mx: 0.5,
550
+ my: 0.2
551
+ }
552
+ });
553
+
554
+ var fill = isThrowing
555
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
556
+ : getFillColor(event, defaultFillColor, attrs.fill);
557
+
558
+ return drawPath(parentGfx, pathData, {
559
+ fill,
560
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
561
+ strokeWidth: 1
562
+ });
563
+ },
564
+ 'bpmn:ConditionalEventDefinition': function(parentGfx, event, attrs = {}) {
565
+ var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
566
+ xScaleFactor: 1,
567
+ yScaleFactor: 1,
568
+ containerWidth: attrs.width || event.width,
569
+ containerHeight: attrs.height || event.height,
570
+ position: {
571
+ mx: 0.5,
572
+ my: 0.222
573
+ }
574
+ });
575
+
576
+ return drawPath(parentGfx, pathData, {
577
+ fill: getFillColor(event, defaultFillColor, attrs.fill),
578
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
579
+ strokeWidth: 1
580
+ });
581
+ },
582
+ 'bpmn:LinkEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
583
+ var pathData = pathMap.getScaledPath('EVENT_LINK', {
584
+ xScaleFactor: 1,
585
+ yScaleFactor: 1,
586
+ containerWidth: event.width,
587
+ containerHeight: event.height,
588
+ position: {
589
+ mx: 0.57,
590
+ my: 0.263
591
+ }
592
+ });
593
+
594
+ var fill = isThrowing
595
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
596
+ : getFillColor(event, defaultFillColor, attrs.fill);
597
+
598
+ return drawPath(parentGfx, pathData, {
599
+ fill,
600
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
601
+ strokeWidth: 1
602
+ });
603
+ },
604
+ 'bpmn:ErrorEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
605
+ var pathData = pathMap.getScaledPath('EVENT_ERROR', {
606
+ xScaleFactor: 1.1,
607
+ yScaleFactor: 1.1,
608
+ containerWidth: attrs.width || event.width,
609
+ containerHeight: attrs.height || event.height,
610
+ position: {
611
+ mx: 0.2,
612
+ my: 0.722
613
+ }
614
+ });
615
+
616
+ var fill = isThrowing
617
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
618
+ : getFillColor(event, defaultFillColor, attrs.fill);
619
+
620
+ return drawPath(parentGfx, pathData, {
621
+ fill,
622
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
623
+ strokeWidth: 1
624
+ });
625
+ },
626
+ 'bpmn:CancelEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
627
+ var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
628
+ xScaleFactor: 1.0,
629
+ yScaleFactor: 1.0,
630
+ containerWidth: event.width,
631
+ containerHeight: event.height,
632
+ position: {
633
+ mx: 0.638,
634
+ my: -0.055
635
+ }
636
+ });
637
+
638
+ var fill = isThrowing ? getStrokeColor(event, defaultStrokeColor, attrs.stroke) : 'none';
639
+
640
+ var path = drawPath(parentGfx, pathData, {
641
+ fill,
642
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
643
+ strokeWidth: 1
644
+ });
645
+
646
+ rotate(path, 45);
647
+
648
+ return path;
649
+ },
650
+ 'bpmn:CompensateEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
651
+ var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
652
+ xScaleFactor: 1,
653
+ yScaleFactor: 1,
654
+ containerWidth: attrs.width || event.width,
655
+ containerHeight: attrs.height || event.height,
656
+ position: {
657
+ mx: 0.22,
658
+ my: 0.5
659
+ }
660
+ });
661
+
662
+ var fill = isThrowing
663
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
664
+ : getFillColor(event, defaultFillColor, attrs.fill);
665
+
666
+ return drawPath(parentGfx, pathData, {
667
+ fill,
668
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
669
+ strokeWidth: 1
670
+ });
671
+ },
672
+ 'bpmn:SignalEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
673
+ var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
674
+ xScaleFactor: 0.9,
675
+ yScaleFactor: 0.9,
676
+ containerWidth: attrs.width || event.width,
677
+ containerHeight: attrs.height || event.height,
678
+ position: {
679
+ mx: 0.5,
680
+ my: 0.2
681
+ }
682
+ });
683
+
684
+ var fill = isThrowing
685
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
686
+ : getFillColor(event, defaultFillColor, attrs.fill);
687
+
688
+ return drawPath(parentGfx, pathData, {
689
+ strokeWidth: 1,
690
+ fill,
691
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke)
692
+ });
693
+ },
694
+ 'bpmn:MultipleEventDefinition': function(parentGfx, event, attrs = {}, isThrowing) {
695
+ var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
696
+ xScaleFactor: 1.1,
697
+ yScaleFactor: 1.1,
698
+ containerWidth: attrs.width || event.width,
699
+ containerHeight: attrs.height || event.height,
700
+ position: {
701
+ mx: 0.211,
702
+ my: 0.36
703
+ }
704
+ });
705
+
706
+ var fill = isThrowing
707
+ ? getStrokeColor(event, defaultStrokeColor, attrs.stroke)
708
+ : getFillColor(event, defaultFillColor, attrs.fill);
709
+
710
+ return drawPath(parentGfx, pathData, {
711
+ fill,
712
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
713
+ strokeWidth: 1
714
+ });
715
+ },
716
+ 'bpmn:ParallelMultipleEventDefinition': function(parentGfx, event, attrs = {}) {
717
+ var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
718
+ xScaleFactor: 1.2,
719
+ yScaleFactor: 1.2,
720
+ containerWidth: attrs.width || event.width,
721
+ containerHeight: attrs.height || event.height,
722
+ position: {
723
+ mx: 0.458,
724
+ my: 0.194
725
+ }
726
+ });
727
+
728
+ return drawPath(parentGfx, pathData, {
729
+ fill: getFillColor(event, defaultFillColor, attrs.fill),
730
+ stroke: getStrokeColor(event, defaultStrokeColor, attrs.stroke),
731
+ strokeWidth: 1
732
+ });
733
+ },
734
+ 'bpmn:TerminateEventDefinition': function(parentGfx, element, attrs = {}) {
735
+ var circle = drawCircle(parentGfx, element.width, element.height, 8, {
736
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
737
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
738
+ strokeWidth: 4
739
+ });
740
+
741
+ return circle;
742
+ }
743
+ };
744
+
745
+ function renderEventIcon(element, parentGfx, attrs = {}, proxyElement) {
746
+ var semantic = getSemantic(element),
747
+ isThrowing = isThrowEvent(semantic);
748
+
749
+ var nodeElement = proxyElement || element;
750
+
751
+ if (semantic.get('eventDefinitions') && semantic.get('eventDefinitions').length > 1) {
752
+ if (semantic.get('parallelMultiple')) {
753
+ return eventIconRenderers[ 'bpmn:ParallelMultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
754
+ }
755
+ else {
756
+ return eventIconRenderers[ 'bpmn:MultipleEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
757
+ }
758
+ }
759
+
760
+ if (isTypedEvent(semantic, 'bpmn:MessageEventDefinition')) {
761
+ return eventIconRenderers[ 'bpmn:MessageEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
762
+ }
763
+
764
+ if (isTypedEvent(semantic, 'bpmn:TimerEventDefinition')) {
765
+ return eventIconRenderers[ 'bpmn:TimerEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
766
+ }
767
+
768
+ if (isTypedEvent(semantic, 'bpmn:ConditionalEventDefinition')) {
769
+ return eventIconRenderers[ 'bpmn:ConditionalEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
770
+ }
771
+
772
+ if (isTypedEvent(semantic, 'bpmn:SignalEventDefinition')) {
773
+ return eventIconRenderers[ 'bpmn:SignalEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
774
+ }
775
+
776
+ if (isTypedEvent(semantic, 'bpmn:EscalationEventDefinition')) {
777
+ return eventIconRenderers[ 'bpmn:EscalationEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
778
+ }
779
+
780
+ if (isTypedEvent(semantic, 'bpmn:LinkEventDefinition')) {
781
+ return eventIconRenderers[ 'bpmn:LinkEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
782
+ }
783
+
784
+ if (isTypedEvent(semantic, 'bpmn:ErrorEventDefinition')) {
785
+ return eventIconRenderers[ 'bpmn:ErrorEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
786
+ }
787
+
788
+ if (isTypedEvent(semantic, 'bpmn:CancelEventDefinition')) {
789
+ return eventIconRenderers[ 'bpmn:CancelEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
790
+ }
791
+
792
+ if (isTypedEvent(semantic, 'bpmn:CompensateEventDefinition')) {
793
+ return eventIconRenderers[ 'bpmn:CompensateEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
794
+ }
795
+
796
+ if (isTypedEvent(semantic, 'bpmn:TerminateEventDefinition')) {
797
+ return eventIconRenderers[ 'bpmn:TerminateEventDefinition' ](parentGfx, nodeElement, attrs, isThrowing);
798
+ }
799
+
800
+ return null;
801
+ }
802
+
803
+ var taskMarkerRenderers = {
804
+ 'ParticipantMultiplicityMarker': function(parentGfx, element, attrs = {}) {
805
+ var width = getWidth(element, attrs),
806
+ height = getHeight(element, attrs);
807
+
808
+ var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
809
+ xScaleFactor: 1,
810
+ yScaleFactor: 1,
811
+ containerWidth: width,
812
+ containerHeight: height,
813
+ position: {
814
+ mx: ((width / 2 - 6) / width),
815
+ my: (height - 15) / height
816
+ }
817
+ });
818
+
819
+ drawMarker('participant-multiplicity', parentGfx, markerPath, {
820
+ strokeWidth: 2,
821
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
822
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
823
+ });
824
+ },
825
+ 'SubProcessMarker': function(parentGfx, element, attrs = {}) {
826
+ var markerRect = drawRect(parentGfx, 14, 14, 0, {
827
+ strokeWidth: 1,
828
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
829
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
830
+ });
831
+
832
+ translate(markerRect, element.width / 2 - 7.5, element.height - 20);
833
+
834
+ var markerPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
835
+ xScaleFactor: 1.5,
836
+ yScaleFactor: 1.5,
837
+ containerWidth: element.width,
838
+ containerHeight: element.height,
839
+ position: {
840
+ mx: (element.width / 2 - 7.5) / element.width,
841
+ my: (element.height - 20) / element.height
842
+ }
843
+ });
844
+
845
+ drawMarker('sub-process', parentGfx, markerPath, {
846
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
847
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
848
+ });
849
+ },
850
+ 'ParallelMarker': function(parentGfx, element, attrs) {
851
+ var width = getWidth(element, attrs),
852
+ height = getHeight(element, attrs);
853
+
854
+ var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
855
+ xScaleFactor: 1,
856
+ yScaleFactor: 1,
857
+ containerWidth: width,
858
+ containerHeight: height,
859
+ position: {
860
+ mx: ((width / 2 + attrs.parallel) / width),
861
+ my: (height - 20) / height
862
+ }
863
+ });
864
+
865
+ drawMarker('parallel', parentGfx, markerPath, {
866
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
867
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
868
+ });
869
+ },
870
+ 'SequentialMarker': function(parentGfx, element, attrs) {
871
+ var markerPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
872
+ xScaleFactor: 1,
873
+ yScaleFactor: 1,
874
+ containerWidth: element.width,
875
+ containerHeight: element.height,
876
+ position: {
877
+ mx: ((element.width / 2 + attrs.seq) / element.width),
878
+ my: (element.height - 19) / element.height
879
+ }
880
+ });
881
+
882
+ drawMarker('sequential', parentGfx, markerPath, {
883
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
884
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
885
+ });
886
+ },
887
+ 'CompensationMarker': function(parentGfx, element, attrs) {
888
+ var markerMath = pathMap.getScaledPath('MARKER_COMPENSATION', {
889
+ xScaleFactor: 1,
890
+ yScaleFactor: 1,
891
+ containerWidth: element.width,
892
+ containerHeight: element.height,
893
+ position: {
894
+ mx: ((element.width / 2 + attrs.compensation) / element.width),
895
+ my: (element.height - 13) / element.height
896
+ }
897
+ });
898
+
899
+ drawMarker('compensation', parentGfx, markerMath, {
900
+ strokeWidth: 1,
901
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
902
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
903
+ });
904
+ },
905
+ 'LoopMarker': function(parentGfx, element, attrs) {
906
+ var width = getWidth(element, attrs),
907
+ height = getHeight(element, attrs);
908
+
909
+ var markerPath = pathMap.getScaledPath('MARKER_LOOP', {
910
+ xScaleFactor: 1,
911
+ yScaleFactor: 1,
912
+ containerWidth: width,
913
+ containerHeight: height,
914
+ position: {
915
+ mx: ((width / 2 + attrs.loop) / width),
916
+ my: (height - 7) / height
917
+ }
918
+ });
919
+
920
+ drawMarker('loop', parentGfx, markerPath, {
921
+ strokeWidth: 1.5,
922
+ fill: 'none',
923
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
924
+ strokeMiterlimit: 0.5
925
+ });
926
+ },
927
+ 'AdhocMarker': function(parentGfx, element, attrs) {
928
+ var width = getWidth(element, attrs),
929
+ height = getHeight(element, attrs);
930
+
931
+ var markerPath = pathMap.getScaledPath('MARKER_ADHOC', {
932
+ xScaleFactor: 1,
933
+ yScaleFactor: 1,
934
+ containerWidth: width,
935
+ containerHeight: height,
936
+ position: {
937
+ mx: ((width / 2 + attrs.adhoc) / width),
938
+ my: (height - 15) / height
939
+ }
940
+ });
941
+
942
+ drawMarker('adhoc', parentGfx, markerPath, {
943
+ strokeWidth: 1,
944
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
945
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
946
+ });
947
+ }
948
+ };
949
+
950
+ function renderTaskMarker(type, parentGfx, element, attrs) {
951
+ taskMarkerRenderers[ type ](parentGfx, element, attrs);
952
+ }
953
+
954
+ function renderTaskMarkers(parentGfx, element, taskMarkers = [], attrs = {}) {
955
+ attrs = {
956
+ fill: attrs.fill,
957
+ stroke: attrs.stroke,
958
+ width: getWidth(element, attrs),
959
+ height: getHeight(element, attrs)
960
+ };
961
+
962
+ var semantic = getSemantic(element);
963
+
964
+ var subprocess = taskMarkers.includes('SubProcessMarker');
965
+
966
+ if (subprocess) {
967
+ attrs = {
968
+ ...attrs,
969
+ seq: -21,
970
+ parallel: -22,
971
+ compensation: -25,
972
+ loop: -18,
973
+ adhoc: 10
974
+ };
975
+ } else {
976
+ attrs = {
977
+ ...attrs,
978
+ seq: -5,
979
+ parallel: -6,
980
+ compensation: -7,
981
+ loop: 0,
982
+ adhoc: -8
983
+ };
984
+ }
985
+
986
+ if (semantic.get('isForCompensation')) {
987
+ taskMarkers.push('CompensationMarker');
988
+ }
989
+
990
+ if (is(semantic, 'bpmn:AdHocSubProcess')) {
991
+ taskMarkers.push('AdhocMarker');
992
+
993
+ if (!subprocess) {
994
+ assign(attrs, { compensation: attrs.compensation - 18 });
995
+ }
996
+ }
997
+
998
+ var loopCharacteristics = semantic.get('loopCharacteristics'),
999
+ isSequential = loopCharacteristics && loopCharacteristics.get('isSequential');
1000
+
1001
+ if (loopCharacteristics) {
1002
+
1003
+ assign(attrs, {
1004
+ compensation: attrs.compensation - 18,
1005
+ });
1006
+
1007
+ if (taskMarkers.includes('AdhocMarker')) {
1008
+ assign(attrs, {
1009
+ seq: -23,
1010
+ loop: -18,
1011
+ parallel: -24
1012
+ });
1013
+ }
1014
+
1015
+ if (isSequential === undefined) {
1016
+ taskMarkers.push('LoopMarker');
1017
+ }
1018
+
1019
+ if (isSequential === false) {
1020
+ taskMarkers.push('ParallelMarker');
1021
+ }
1022
+
1023
+ if (isSequential === true) {
1024
+ taskMarkers.push('SequentialMarker');
1025
+ }
1026
+ }
1027
+
1028
+ if (taskMarkers.includes('CompensationMarker') && taskMarkers.length === 1) {
1029
+ assign(attrs, {
1030
+ compensation: -8
1031
+ });
1032
+ }
1033
+
1034
+ forEach(taskMarkers, function(marker) {
1035
+ renderTaskMarker(marker, parentGfx, element, attrs);
1036
+ });
1037
+ }
1038
+
1039
+ function renderLabel(parentGfx, label, attrs = {}) {
1040
+ attrs = assign({
1041
+ size: {
1042
+ width: 100
1043
+ }
1044
+ }, attrs);
1045
+
1046
+ var text = textRenderer.createText(label || '', attrs);
1047
+
1048
+ svgClasses(text).add('djs-label');
1049
+
1050
+ svgAppend(parentGfx, text);
1051
+
1052
+ return text;
1053
+ }
1054
+
1055
+ function renderEmbeddedLabel(parentGfx, element, align, attrs = {}) {
1056
+ var semantic = getSemantic(element);
1057
+
1058
+ var box = getBounds({
1059
+ x: element.x,
1060
+ y: element.y,
1061
+ width: element.width,
1062
+ height: element.height
1063
+ }, attrs);
1064
+
1065
+ return renderLabel(parentGfx, semantic.name, {
1066
+ align,
1067
+ box,
1068
+ padding: 7,
1069
+ style: {
1070
+ fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1071
+ }
1072
+ });
1073
+ }
1074
+
1075
+ function renderExternalLabel(parentGfx, element, attrs = {}) {
1076
+ var box = {
1077
+ width: 90,
1078
+ height: 30,
1079
+ x: element.width / 2 + element.x,
1080
+ y: element.height / 2 + element.y
1081
+ };
1082
+
1083
+ return renderLabel(parentGfx, getLabel(element), {
1084
+ box: box,
1085
+ fitBox: true,
1086
+ style: assign(
1087
+ {},
1088
+ textRenderer.getExternalStyle(),
1089
+ {
1090
+ fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1091
+ }
1092
+ )
1093
+ });
1094
+ }
1095
+
1096
+ function renderLaneLabel(parentGfx, text, element, attrs = {}) {
1097
+ var isHorizontalLane = isHorizontal(element);
1098
+
1099
+ var textBox = renderLabel(parentGfx, text, {
1100
+ box: {
1101
+ height: 30,
1102
+ width: isHorizontalLane ? getHeight(element, attrs) : getWidth(element, attrs),
1103
+ },
1104
+ align: 'center-middle',
1105
+ style: {
1106
+ fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1107
+ }
1108
+ });
1109
+
1110
+ if (isHorizontalLane) {
1111
+ var top = -1 * getHeight(element, attrs);
1112
+ transform(textBox, 0, -top, 270);
1113
+ }
1114
+ }
1115
+
1116
+ function renderActivity(parentGfx, element, attrs = {}) {
1117
+ var {
1118
+ width,
1119
+ height
1120
+ } = getBounds(element, attrs);
1121
+
1122
+ return drawRect(parentGfx, width, height, TASK_BORDER_RADIUS, {
1123
+ ...attrs,
1124
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1125
+ fillOpacity: DEFAULT_OPACITY,
1126
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1127
+ });
1128
+ }
1129
+
1130
+ function renderAssociation(parentGfx, element, attrs = {}) {
1131
+ var semantic = getSemantic(element);
1132
+
1133
+ var fill = getFillColor(element, defaultFillColor, attrs.fill),
1134
+ stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1135
+
1136
+ if (semantic.get('associationDirection') === 'One' ||
1137
+ semantic.get('associationDirection') === 'Both') {
1138
+ attrs.markerEnd = marker(parentGfx, 'association-end', fill, stroke);
1139
+ }
1140
+
1141
+ if (semantic.get('associationDirection') === 'Both') {
1142
+ attrs.markerStart = marker(parentGfx, 'association-start', fill, stroke);
1143
+ }
1144
+
1145
+ attrs = pickAttrs(attrs, [
1146
+ 'markerStart',
1147
+ 'markerEnd'
1148
+ ]);
1149
+
1150
+ return drawConnectionSegments(parentGfx, element.waypoints, {
1151
+ ...attrs,
1152
+ stroke,
1153
+ strokeDasharray: '0, 5'
1154
+ });
1155
+ }
1156
+
1157
+ function renderDataObject(parentGfx, element, attrs = {}) {
1158
+ var fill = getFillColor(element, defaultFillColor, attrs.fill),
1159
+ stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1160
+
1161
+ var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
1162
+ xScaleFactor: 1,
1163
+ yScaleFactor: 1,
1164
+ containerWidth: element.width,
1165
+ containerHeight: element.height,
1166
+ position: {
1167
+ mx: 0.474,
1168
+ my: 0.296
1169
+ }
1170
+ });
1171
+
1172
+ var dataObject = drawPath(parentGfx, pathData, {
1173
+ fill,
1174
+ fillOpacity: DEFAULT_OPACITY,
1175
+ stroke
1176
+ });
1177
+
1178
+ var semantic = getSemantic(element);
1179
+
1180
+ if (isCollection(semantic)) {
1181
+ var collectionPathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
1182
+ xScaleFactor: 1,
1183
+ yScaleFactor: 1,
1184
+ containerWidth: element.width,
1185
+ containerHeight: element.height,
1186
+ position: {
1187
+ mx: 0.33,
1188
+ my: (element.height - 18) / element.height
1189
+ }
1190
+ });
1191
+
1192
+ drawPath(parentGfx, collectionPathData, {
1193
+ strokeWidth: 2,
1194
+ fill,
1195
+ stroke
1196
+ });
1197
+ }
1198
+
1199
+ return dataObject;
1200
+ }
1201
+
1202
+ function renderEvent(parentGfx, element, attrs = {}) {
1203
+ return drawCircle(parentGfx, element.width, element.height, {
1204
+ fillOpacity: DEFAULT_OPACITY,
1205
+ ...attrs,
1206
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1207
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1208
+ });
1209
+ }
1210
+
1211
+ function renderGateway(parentGfx, element, attrs = {}) {
1212
+ return drawDiamond(parentGfx, element.width, element.height, {
1213
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1214
+ fillOpacity: DEFAULT_OPACITY,
1215
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1216
+ });
1217
+ }
1218
+
1219
+ function renderLane(parentGfx, element, attrs = {}) {
1220
+ var lane = drawRect(parentGfx, getWidth(element, attrs), getHeight(element, attrs), 0, {
1221
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1222
+ fillOpacity: attrs.fillOpacity || DEFAULT_OPACITY,
1223
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1224
+ strokeWidth: 1.5
1225
+ });
1226
+
1227
+ var semantic = getSemantic(element);
1228
+
1229
+ if (is(semantic, 'bpmn:Lane')) {
1230
+ var text = semantic.get('name');
1231
+
1232
+ renderLaneLabel(parentGfx, text, element, attrs);
1233
+ }
1234
+
1235
+ return lane;
1236
+ }
1237
+
1238
+ function renderSubProcess(parentGfx, element, attrs = {}) {
1239
+ var activity = renderActivity(parentGfx, element, attrs);
1240
+
1241
+ var expanded = isExpanded(element);
1242
+
1243
+ if (isEventSubProcess(element)) {
1244
+ svgAttr(activity, {
1245
+ strokeDasharray: '0, 5.5',
1246
+ strokeWidth: 2.5
1247
+ });
1248
+
1249
+ if (!expanded) {
1250
+ var flowElements = getSemantic(element).flowElements || [];
1251
+ var startEvents = flowElements.filter(e => is(e, 'bpmn:StartEvent'));
1252
+
1253
+ if (startEvents.length === 1) {
1254
+ renderEventSubProcessIcon(startEvents[0], parentGfx, attrs, element);
1255
+ }
1256
+ }
1257
+ }
1258
+
1259
+ renderEmbeddedLabel(parentGfx, element, expanded ? 'center-top' : 'center-middle', attrs);
1260
+
1261
+ if (expanded) {
1262
+ renderTaskMarkers(parentGfx, element, undefined, attrs);
1263
+ } else {
1264
+ renderTaskMarkers(parentGfx, element, [ 'SubProcessMarker' ], attrs);
1265
+ }
1266
+
1267
+ return activity;
1268
+ }
1269
+
1270
+ function renderEventSubProcessIcon(startEvent, parentGfx, attrs, proxyElement) {
1271
+ var iconSize = 22;
1272
+
1273
+ // match the colors of the enclosing subprocess
1274
+ var proxyAttrs = {
1275
+ fill: getFillColor(proxyElement, defaultFillColor, attrs.fill),
1276
+ stroke: getStrokeColor(proxyElement, defaultStrokeColor, attrs.stroke),
1277
+ width: iconSize,
1278
+ height: iconSize
1279
+ };
1280
+
1281
+ var interrupting = getSemantic(startEvent).isInterrupting;
1282
+ var strokeDasharray = interrupting ? 0 : 3;
1283
+
1284
+ // better visibility for non-interrupting events
1285
+ var strokeWidth = interrupting ? 1 : 1.2;
1286
+
1287
+ // make the icon look larger by drawing a smaller circle
1288
+ var circleSize = 20;
1289
+ var shift = (iconSize - circleSize) / 2;
1290
+ var transform = 'translate(' + shift + ',' + shift + ')';
1291
+
1292
+ drawCircle(parentGfx, circleSize, circleSize, {
1293
+ fill: proxyAttrs.fill,
1294
+ stroke: proxyAttrs.stroke,
1295
+ strokeWidth,
1296
+ strokeDasharray,
1297
+ transform
1298
+ });
1299
+
1300
+ renderEventIcon(startEvent, parentGfx, proxyAttrs, proxyElement);
1301
+ }
1302
+
1303
+ function renderTask(parentGfx, element, attrs = {}) {
1304
+ var activity = renderActivity(parentGfx, element, attrs);
1305
+
1306
+ renderEmbeddedLabel(parentGfx, element, 'center-middle', attrs);
1307
+
1308
+ renderTaskMarkers(parentGfx, element, undefined, attrs);
1309
+
1310
+ return activity;
1311
+ }
1312
+
1313
+ var handlers = this.handlers = {
1314
+ 'bpmn:AdHocSubProcess': function(parentGfx, element, attrs = {}) {
1315
+ if (isExpanded(element)) {
1316
+ attrs = pickAttrs(attrs, [
1317
+ 'fill',
1318
+ 'stroke',
1319
+ 'width',
1320
+ 'height'
1321
+ ]);
1322
+ } else {
1323
+ attrs = pickAttrs(attrs, [
1324
+ 'fill',
1325
+ 'stroke'
1326
+ ]);
1327
+ }
1328
+
1329
+ return renderSubProcess(parentGfx, element, attrs);
1330
+ },
1331
+ 'bpmn:Association': function(parentGfx, element, attrs = {}) {
1332
+ attrs = pickAttrs(attrs, [
1333
+ 'fill',
1334
+ 'stroke'
1335
+ ]);
1336
+
1337
+ return renderAssociation(parentGfx, element, attrs);
1338
+ },
1339
+ 'bpmn:BoundaryEvent': function(parentGfx, element, attrs = {}) {
1340
+ var { renderIcon = true } = attrs;
1341
+
1342
+ attrs = pickAttrs(attrs, [
1343
+ 'fill',
1344
+ 'stroke'
1345
+ ]);
1346
+
1347
+ var semantic = getSemantic(element),
1348
+ cancelActivity = semantic.get('cancelActivity');
1349
+
1350
+ attrs = {
1351
+ strokeWidth: 1.5,
1352
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1353
+ fillOpacity: FULL_OPACITY,
1354
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1355
+ };
1356
+
1357
+ if (!cancelActivity) {
1358
+ attrs.strokeDasharray = '6';
1359
+ }
1360
+
1361
+ var event = renderEvent(parentGfx, element, attrs);
1362
+
1363
+ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
1364
+ ...attrs,
1365
+ fill: 'none'
1366
+ });
1367
+
1368
+ if (renderIcon) {
1369
+ renderEventIcon(element, parentGfx, attrs);
1370
+ }
1371
+
1372
+ return event;
1373
+ },
1374
+ 'bpmn:BusinessRuleTask': function(parentGfx, element, attrs = {}) {
1375
+ attrs = pickAttrs(attrs, [
1376
+ 'fill',
1377
+ 'stroke'
1378
+ ]);
1379
+
1380
+ var task = renderTask(parentGfx, element, attrs);
1381
+
1382
+ var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
1383
+ abspos: {
1384
+ x: 8,
1385
+ y: 8
1386
+ }
1387
+ });
1388
+
1389
+ var businessPath = drawPath(parentGfx, headerData);
1390
+
1391
+ svgAttr(businessPath, {
1392
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1393
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1394
+ strokeWidth: 1
1395
+ });
1396
+
1397
+ var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
1398
+ abspos: {
1399
+ x: 8,
1400
+ y: 8
1401
+ }
1402
+ });
1403
+
1404
+ var businessHeaderPath = drawPath(parentGfx, headerPathData);
1405
+
1406
+ svgAttr(businessHeaderPath, {
1407
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1408
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1409
+ strokeWidth: 1
1410
+ });
1411
+
1412
+ return task;
1413
+ },
1414
+ 'bpmn:CallActivity': function(parentGfx, element, attrs = {}) {
1415
+ attrs = pickAttrs(attrs, [
1416
+ 'fill',
1417
+ 'stroke'
1418
+ ]);
1419
+
1420
+ return renderSubProcess(parentGfx, element, {
1421
+ strokeWidth: 5,
1422
+ ...attrs
1423
+ });
1424
+ },
1425
+ 'bpmn:ComplexGateway': function(parentGfx, element, attrs = {}) {
1426
+ attrs = pickAttrs(attrs, [
1427
+ 'fill',
1428
+ 'stroke'
1429
+ ]);
1430
+
1431
+ var gateway = renderGateway(parentGfx, element, attrs);
1432
+
1433
+ var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
1434
+ xScaleFactor: 0.5,
1435
+ yScaleFactor:0.5,
1436
+ containerWidth: element.width,
1437
+ containerHeight: element.height,
1438
+ position: {
1439
+ mx: 0.46,
1440
+ my: 0.26
1441
+ }
1442
+ });
1443
+
1444
+ drawPath(parentGfx, pathData, {
1445
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1446
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1447
+ strokeWidth: 1
1448
+ });
1449
+
1450
+ return gateway;
1451
+ },
1452
+ 'bpmn:DataInput': function(parentGfx, element, attrs = {}) {
1453
+ attrs = pickAttrs(attrs, [
1454
+ 'fill',
1455
+ 'stroke'
1456
+ ]);
1457
+
1458
+ var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1459
+
1460
+ var dataObject = renderDataObject(parentGfx, element, attrs);
1461
+
1462
+ drawPath(parentGfx, arrowPathData, {
1463
+ fill: 'none',
1464
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1465
+ strokeWidth: 1
1466
+ });
1467
+
1468
+ return dataObject;
1469
+ },
1470
+ 'bpmn:DataInputAssociation': function(parentGfx, element, attrs = {}) {
1471
+ attrs = pickAttrs(attrs, [
1472
+ 'fill',
1473
+ 'stroke'
1474
+ ]);
1475
+
1476
+ return renderAssociation(parentGfx, element, {
1477
+ ...attrs,
1478
+ markerEnd: marker(parentGfx, 'association-end', getFillColor(element, defaultFillColor, attrs.fill), getStrokeColor(element, defaultStrokeColor, attrs.stroke))
1479
+ });
1480
+ },
1481
+ 'bpmn:DataObject': function(parentGfx, element, attrs = {}) {
1482
+ attrs = pickAttrs(attrs, [
1483
+ 'fill',
1484
+ 'stroke'
1485
+ ]);
1486
+
1487
+ return renderDataObject(parentGfx, element, attrs);
1488
+ },
1489
+ 'bpmn:DataObjectReference': as('bpmn:DataObject'),
1490
+ 'bpmn:DataOutput': function(parentGfx, element, attrs = {}) {
1491
+ attrs = pickAttrs(attrs, [
1492
+ 'fill',
1493
+ 'stroke'
1494
+ ]);
1495
+
1496
+ var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1497
+
1498
+ var dataObject = renderDataObject(parentGfx, element, attrs);
1499
+
1500
+ drawPath(parentGfx, arrowPathData, {
1501
+ strokeWidth: 1,
1502
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1503
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
1504
+ });
1505
+
1506
+ return dataObject;
1507
+ },
1508
+ 'bpmn:DataOutputAssociation': function(parentGfx, element, attrs = {}) {
1509
+ attrs = pickAttrs(attrs, [
1510
+ 'fill',
1511
+ 'stroke'
1512
+ ]);
1513
+
1514
+ return renderAssociation(parentGfx, element, {
1515
+ ...attrs,
1516
+ markerEnd: marker(parentGfx, 'association-end', getFillColor(element, defaultFillColor, attrs.fill), getStrokeColor(element, defaultStrokeColor, attrs.stroke))
1517
+ });
1518
+ },
1519
+ 'bpmn:DataStoreReference': function(parentGfx, element, attrs = {}) {
1520
+ attrs = pickAttrs(attrs, [
1521
+ 'fill',
1522
+ 'stroke'
1523
+ ]);
1524
+
1525
+ var dataStorePath = pathMap.getScaledPath('DATA_STORE', {
1526
+ xScaleFactor: 1,
1527
+ yScaleFactor: 1,
1528
+ containerWidth: element.width,
1529
+ containerHeight: element.height,
1530
+ position: {
1531
+ mx: 0,
1532
+ my: 0.133
1533
+ }
1534
+ });
1535
+
1536
+ return drawPath(parentGfx, dataStorePath, {
1537
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1538
+ fillOpacity: DEFAULT_OPACITY,
1539
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1540
+ strokeWidth: 2
1541
+ });
1542
+ },
1543
+ 'bpmn:EndEvent': function(parentGfx, element, attrs = {}) {
1544
+ var { renderIcon = true } = attrs;
1545
+
1546
+ attrs = pickAttrs(attrs, [
1547
+ 'fill',
1548
+ 'stroke'
1549
+ ]);
1550
+
1551
+ var event = renderEvent(parentGfx, element, {
1552
+ ...attrs,
1553
+ strokeWidth: 4
1554
+ });
1555
+
1556
+ if (renderIcon) {
1557
+ renderEventIcon(element, parentGfx, attrs);
1558
+ }
1559
+
1560
+ return event;
1561
+ },
1562
+ 'bpmn:EventBasedGateway': function(parentGfx, element, attrs = {}) {
1563
+ attrs = pickAttrs(attrs, [
1564
+ 'fill',
1565
+ 'stroke'
1566
+ ]);
1567
+
1568
+ var semantic = getSemantic(element);
1569
+
1570
+ var diamond = renderGateway(parentGfx, element, attrs);
1571
+
1572
+ drawCircle(parentGfx, element.width, element.height, element.height * 0.20, {
1573
+ fill: getFillColor(element, 'none', attrs.fill),
1574
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1575
+ strokeWidth: 1
1576
+ });
1577
+
1578
+ var type = semantic.get('eventGatewayType'),
1579
+ instantiate = !!semantic.get('instantiate');
1580
+
1581
+ function drawEvent() {
1582
+
1583
+ var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
1584
+ xScaleFactor: 0.18,
1585
+ yScaleFactor: 0.18,
1586
+ containerWidth: element.width,
1587
+ containerHeight: element.height,
1588
+ position: {
1589
+ mx: 0.36,
1590
+ my: 0.44
1591
+ }
1592
+ });
1593
+
1594
+ drawPath(parentGfx, pathData, {
1595
+ fill: 'none',
1596
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1597
+ strokeWidth: 2
1598
+ });
1599
+ }
1600
+
1601
+ if (type === 'Parallel') {
1602
+ var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1603
+ xScaleFactor: 0.4,
1604
+ yScaleFactor: 0.4,
1605
+ containerWidth: element.width,
1606
+ containerHeight: element.height,
1607
+ position: {
1608
+ mx: 0.474,
1609
+ my: 0.296
1610
+ }
1611
+ });
1612
+
1613
+ drawPath(parentGfx, pathData, {
1614
+ fill: 'none',
1615
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1616
+ strokeWidth: 1
1617
+ });
1618
+ } else if (type === 'Exclusive') {
1619
+ if (!instantiate) {
1620
+ drawCircle(parentGfx, element.width, element.height, element.height * 0.26, {
1621
+ fill: 'none',
1622
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1623
+ strokeWidth: 1
1624
+ });
1625
+ }
1626
+
1627
+ drawEvent();
1628
+ }
1629
+
1630
+
1631
+ return diamond;
1632
+ },
1633
+ 'bpmn:ExclusiveGateway': function(parentGfx, element, attrs = {}) {
1634
+ attrs = pickAttrs(attrs, [
1635
+ 'fill',
1636
+ 'stroke'
1637
+ ]);
1638
+
1639
+ var gateway = renderGateway(parentGfx, element, attrs);
1640
+
1641
+ var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
1642
+ xScaleFactor: 0.4,
1643
+ yScaleFactor: 0.4,
1644
+ containerWidth: element.width,
1645
+ containerHeight: element.height,
1646
+ position: {
1647
+ mx: 0.32,
1648
+ my: 0.3
1649
+ }
1650
+ });
1651
+
1652
+ var di = getDi(element);
1653
+
1654
+ if (di.get('isMarkerVisible')) {
1655
+ drawPath(parentGfx, pathData, {
1656
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1657
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1658
+ strokeWidth: 1
1659
+ });
1660
+ }
1661
+
1662
+ return gateway;
1663
+ },
1664
+ 'bpmn:Gateway': function(parentGfx, element, attrs = {}) {
1665
+ attrs = pickAttrs(attrs, [
1666
+ 'fill',
1667
+ 'stroke'
1668
+ ]);
1669
+
1670
+ return renderGateway(parentGfx, element, attrs);
1671
+ },
1672
+ 'bpmn:Group': function(parentGfx, element, attrs = {}) {
1673
+ attrs = pickAttrs(attrs, [
1674
+ 'fill',
1675
+ 'stroke',
1676
+ 'width',
1677
+ 'height'
1678
+ ]);
1679
+
1680
+ return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, {
1681
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1682
+ strokeWidth: 1.5,
1683
+ strokeDasharray: '10, 6, 0, 6',
1684
+ fill: 'none',
1685
+ pointerEvents: 'none',
1686
+ width: getWidth(element, attrs),
1687
+ height: getHeight(element, attrs)
1688
+ });
1689
+ },
1690
+ 'bpmn:InclusiveGateway': function(parentGfx, element, attrs = {}) {
1691
+ attrs = pickAttrs(attrs, [
1692
+ 'fill',
1693
+ 'stroke'
1694
+ ]);
1695
+
1696
+ var gateway = renderGateway(parentGfx, element, attrs);
1697
+
1698
+ drawCircle(parentGfx, element.width, element.height, element.height * 0.24, {
1699
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1700
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1701
+ strokeWidth: 2.5
1702
+ });
1703
+
1704
+ return gateway;
1705
+ },
1706
+ 'bpmn:IntermediateEvent': function(parentGfx, element, attrs = {}) {
1707
+ var { renderIcon = true } = attrs;
1708
+
1709
+ attrs = pickAttrs(attrs, [
1710
+ 'fill',
1711
+ 'stroke'
1712
+ ]);
1713
+
1714
+ var outer = renderEvent(parentGfx, element, {
1715
+ ...attrs,
1716
+ strokeWidth: 1.5
1717
+ });
1718
+
1719
+ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
1720
+ fill: 'none',
1721
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1722
+ strokeWidth: 1.5
1723
+ });
1724
+
1725
+ if (renderIcon) {
1726
+ renderEventIcon(element, parentGfx, attrs);
1727
+ }
1728
+
1729
+ return outer;
1730
+ },
1731
+ 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
1732
+ 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
1733
+ 'bpmn:Lane': function(parentGfx, element, attrs = {}) {
1734
+ attrs = pickAttrs(attrs, [
1735
+ 'fill',
1736
+ 'stroke',
1737
+ 'width',
1738
+ 'height'
1739
+ ]);
1740
+
1741
+ return renderLane(parentGfx, element, {
1742
+ ...attrs,
1743
+ fillOpacity: LOW_OPACITY
1744
+ });
1745
+ },
1746
+ 'bpmn:ManualTask': function(parentGfx, element, attrs = {}) {
1747
+ attrs = pickAttrs(attrs, [
1748
+ 'fill',
1749
+ 'stroke'
1750
+ ]);
1751
+
1752
+ var task = renderTask(parentGfx, element, attrs);
1753
+
1754
+ var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
1755
+ abspos: {
1756
+ x: 17,
1757
+ y: 15
1758
+ }
1759
+ });
1760
+
1761
+ drawPath(parentGfx, pathData, {
1762
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1763
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1764
+ strokeWidth: 0.5
1765
+ });
1766
+
1767
+ return task;
1768
+ },
1769
+ 'bpmn:MessageFlow': function(parentGfx, element, attrs = {}) {
1770
+ attrs = pickAttrs(attrs, [
1771
+ 'fill',
1772
+ 'stroke'
1773
+ ]);
1774
+
1775
+ var semantic = getSemantic(element),
1776
+ di = getDi(element);
1777
+
1778
+ var fill = getFillColor(element, defaultFillColor, attrs.fill),
1779
+ stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
1780
+
1781
+ var path = drawConnectionSegments(parentGfx, element.waypoints, {
1782
+ markerEnd: marker(parentGfx, 'messageflow-end', fill, stroke),
1783
+ markerStart: marker(parentGfx, 'messageflow-start', fill, stroke),
1784
+ stroke,
1785
+ strokeDasharray: '10, 11',
1786
+ strokeWidth: 1.5
1787
+ });
1788
+
1789
+ if (semantic.get('messageRef')) {
1790
+ var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
1791
+
1792
+ var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
1793
+ abspos: {
1794
+ x: midPoint.x,
1795
+ y: midPoint.y
1796
+ }
1797
+ });
1798
+
1799
+ var messageAttrs = {
1800
+ strokeWidth: 1
1801
+ };
1802
+
1803
+ if (di.get('messageVisibleKind') === 'initiating') {
1804
+ messageAttrs.fill = fill;
1805
+ messageAttrs.stroke = stroke;
1806
+ } else {
1807
+ messageAttrs.fill = stroke;
1808
+ messageAttrs.stroke = fill;
1809
+ }
1810
+
1811
+ var message = drawPath(parentGfx, markerPathData, messageAttrs);
1812
+
1813
+ var messageRef = semantic.get('messageRef'),
1814
+ name = messageRef.get('name');
1815
+
1816
+ var label = renderLabel(parentGfx, name, {
1817
+ align: 'center-top',
1818
+ fitBox: true,
1819
+ style: {
1820
+ fill: stroke
1821
+ }
1822
+ });
1823
+
1824
+ var messageBounds = message.getBBox(),
1825
+ labelBounds = label.getBBox();
1826
+
1827
+ var translateX = midPoint.x - labelBounds.width / 2,
1828
+ translateY = midPoint.y + messageBounds.height / 2 + ELEMENT_LABEL_DISTANCE;
1829
+
1830
+ transform(label, translateX, translateY, 0);
1831
+ }
1832
+
1833
+ return path;
1834
+ },
1835
+ 'bpmn:ParallelGateway': function(parentGfx, element, attrs = {}) {
1836
+ attrs = pickAttrs(attrs, [
1837
+ 'fill',
1838
+ 'stroke'
1839
+ ]);
1840
+
1841
+ var diamond = renderGateway(parentGfx, element, attrs);
1842
+
1843
+ var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1844
+ xScaleFactor: 0.6,
1845
+ yScaleFactor: 0.6,
1846
+ containerWidth: element.width,
1847
+ containerHeight: element.height,
1848
+ position: {
1849
+ mx: 0.46,
1850
+ my: 0.2
1851
+ }
1852
+ });
1853
+
1854
+ drawPath(parentGfx, pathData, {
1855
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1856
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1857
+ strokeWidth: 1
1858
+ });
1859
+
1860
+ return diamond;
1861
+ },
1862
+ 'bpmn:Participant': function(parentGfx, element, attrs = {}) {
1863
+ attrs = pickAttrs(attrs, [
1864
+ 'fill',
1865
+ 'stroke',
1866
+ 'width',
1867
+ 'height'
1868
+ ]);
1869
+
1870
+ var participant = renderLane(parentGfx, element, attrs);
1871
+
1872
+ var expandedParticipant = isExpanded(element);
1873
+ var horizontalParticipant = isHorizontal(element);
1874
+
1875
+ var semantic = getSemantic(element),
1876
+ name = semantic.get('name');
1877
+
1878
+ if (expandedParticipant) {
1879
+ var waypoints = horizontalParticipant ? [
1880
+ {
1881
+ x: 30,
1882
+ y: 0
1883
+ },
1884
+ {
1885
+ x: 30,
1886
+ y: getHeight(element, attrs)
1887
+ }
1888
+ ] : [
1889
+ {
1890
+ x: 0,
1891
+ y: 30
1892
+ },
1893
+ {
1894
+ x: getWidth(element, attrs),
1895
+ y: 30
1896
+ }
1897
+ ];
1898
+
1899
+ drawLine(parentGfx, waypoints, {
1900
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1901
+ strokeWidth: PARTICIPANT_STROKE_WIDTH
1902
+ });
1903
+
1904
+ renderLaneLabel(parentGfx, name, element, attrs);
1905
+ } else {
1906
+ var bounds = getBounds(element, attrs);
1907
+
1908
+ if (!horizontalParticipant) {
1909
+ bounds.height = getWidth(element, attrs);
1910
+ bounds.width = getHeight(element, attrs);
1911
+ }
1912
+
1913
+ var textBox = renderLabel(parentGfx, name, {
1914
+ box: bounds,
1915
+ align: 'center-middle',
1916
+ style: {
1917
+ fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
1918
+ }
1919
+ });
1920
+
1921
+ if (!horizontalParticipant) {
1922
+ var top = -1 * getHeight(element, attrs);
1923
+ transform(textBox, 0, -top, 270);
1924
+ }
1925
+ }
1926
+
1927
+ if (semantic.get('participantMultiplicity')) {
1928
+ renderTaskMarker('ParticipantMultiplicityMarker', parentGfx, element, attrs);
1929
+ }
1930
+
1931
+ return participant;
1932
+ },
1933
+ 'bpmn:ReceiveTask' : function(parentGfx, element, attrs = {}) {
1934
+ attrs = pickAttrs(attrs, [
1935
+ 'fill',
1936
+ 'stroke'
1937
+ ]);
1938
+
1939
+ var semantic = getSemantic(element);
1940
+
1941
+ var task = renderTask(parentGfx, element, attrs);
1942
+
1943
+ var pathData;
1944
+
1945
+ if (semantic.get('instantiate')) {
1946
+ drawCircle(parentGfx, 28, 28, 20 * 0.22, {
1947
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1948
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1949
+ strokeWidth: 1
1950
+ });
1951
+
1952
+ pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
1953
+ abspos: {
1954
+ x: 7.77,
1955
+ y: 9.52
1956
+ }
1957
+ });
1958
+ } else {
1959
+ pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
1960
+ xScaleFactor: 0.9,
1961
+ yScaleFactor: 0.9,
1962
+ containerWidth: 21,
1963
+ containerHeight: 14,
1964
+ position: {
1965
+ mx: 0.3,
1966
+ my: 0.4
1967
+ }
1968
+ });
1969
+ }
1970
+
1971
+ drawPath(parentGfx, pathData, {
1972
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1973
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1974
+ strokeWidth: 1
1975
+ });
1976
+
1977
+ return task;
1978
+ },
1979
+ 'bpmn:ScriptTask': function(parentGfx, element, attrs = {}) {
1980
+ attrs = pickAttrs(attrs, [
1981
+ 'fill',
1982
+ 'stroke'
1983
+ ]);
1984
+
1985
+ var task = renderTask(parentGfx, element, attrs);
1986
+
1987
+ var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
1988
+ abspos: {
1989
+ x: 15,
1990
+ y: 20
1991
+ }
1992
+ });
1993
+
1994
+ drawPath(parentGfx, pathData, {
1995
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
1996
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
1997
+ strokeWidth: 1
1998
+ });
1999
+
2000
+ return task;
2001
+ },
2002
+ 'bpmn:SendTask': function(parentGfx, element, attrs = {}) {
2003
+ attrs = pickAttrs(attrs, [
2004
+ 'fill',
2005
+ 'stroke'
2006
+ ]);
2007
+
2008
+ var task = renderTask(parentGfx, element, attrs);
2009
+
2010
+ var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
2011
+ xScaleFactor: 1,
2012
+ yScaleFactor: 1,
2013
+ containerWidth: 21,
2014
+ containerHeight: 14,
2015
+ position: {
2016
+ mx: 0.285,
2017
+ my: 0.357
2018
+ }
2019
+ });
2020
+
2021
+ drawPath(parentGfx, pathData, {
2022
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2023
+ stroke: getFillColor(element, defaultFillColor, attrs.fill),
2024
+ strokeWidth: 1
2025
+ });
2026
+
2027
+ return task;
2028
+ },
2029
+ 'bpmn:SequenceFlow': function(parentGfx, element, attrs = {}) {
2030
+ attrs = pickAttrs(attrs, [
2031
+ 'fill',
2032
+ 'stroke'
2033
+ ]);
2034
+
2035
+ var fill = getFillColor(element, defaultFillColor, attrs.fill),
2036
+ stroke = getStrokeColor(element, defaultStrokeColor, attrs.stroke);
2037
+
2038
+ var connection = drawConnectionSegments(parentGfx, element.waypoints, {
2039
+ markerEnd: marker(parentGfx, 'sequenceflow-end', fill, stroke),
2040
+ stroke
2041
+ });
2042
+
2043
+ var semantic = getSemantic(element);
2044
+
2045
+ var { source } = element;
2046
+
2047
+ if (source) {
2048
+ var sourceSemantic = getSemantic(source);
2049
+
2050
+ // conditional flow marker
2051
+ if (semantic.get('conditionExpression') && is(sourceSemantic, 'bpmn:Activity')) {
2052
+ svgAttr(connection, {
2053
+ markerStart: marker(parentGfx, 'conditional-flow-marker', fill, stroke)
2054
+ });
2055
+ }
2056
+
2057
+ // default marker
2058
+ if (sourceSemantic.get('default') && (is(sourceSemantic, 'bpmn:Gateway') || is(sourceSemantic, 'bpmn:Activity')) &&
2059
+ sourceSemantic.get('default') === semantic) {
2060
+ svgAttr(connection, {
2061
+ markerStart: marker(parentGfx, 'conditional-default-flow-marker', fill, stroke)
2062
+ });
2063
+ }
2064
+ }
2065
+
2066
+ return connection;
2067
+ },
2068
+ 'bpmn:ServiceTask': function(parentGfx, element, attrs = {}) {
2069
+ attrs = pickAttrs(attrs, [
2070
+ 'fill',
2071
+ 'stroke'
2072
+ ]);
2073
+
2074
+ var task = renderTask(parentGfx, element, attrs);
2075
+
2076
+ drawCircle(parentGfx, 10, 10, {
2077
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2078
+ stroke: 'none',
2079
+ transform: 'translate(6, 6)'
2080
+ });
2081
+
2082
+ var pathDataService1 = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
2083
+ abspos: {
2084
+ x: 12,
2085
+ y: 18
2086
+ }
2087
+ });
2088
+
2089
+ drawPath(parentGfx, pathDataService1, {
2090
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2091
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2092
+ strokeWidth: 1
2093
+ });
2094
+
2095
+ drawCircle(parentGfx, 10, 10, {
2096
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2097
+ stroke: 'none',
2098
+ transform: 'translate(11, 10)'
2099
+ });
2100
+
2101
+ var pathDataService2 = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
2102
+ abspos: {
2103
+ x: 17,
2104
+ y: 22
2105
+ }
2106
+ });
2107
+
2108
+ drawPath(parentGfx, pathDataService2, {
2109
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2110
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2111
+ strokeWidth: 1
2112
+ });
2113
+
2114
+ return task;
2115
+ },
2116
+ 'bpmn:StartEvent': function(parentGfx, element, attrs = {}) {
2117
+ var { renderIcon = true } = attrs;
2118
+
2119
+ attrs = pickAttrs(attrs, [
2120
+ 'fill',
2121
+ 'stroke'
2122
+ ]);
2123
+
2124
+ var semantic = getSemantic(element);
2125
+
2126
+ if (!semantic.get('isInterrupting')) {
2127
+ attrs = {
2128
+ ...attrs,
2129
+ strokeDasharray: '6'
2130
+ };
2131
+ }
2132
+
2133
+ var event = renderEvent(parentGfx, element, attrs);
2134
+
2135
+ if (renderIcon) {
2136
+ renderEventIcon(element, parentGfx, attrs);
2137
+ }
2138
+
2139
+ return event;
2140
+ },
2141
+ 'bpmn:SubProcess': function(parentGfx, element, attrs = {}) {
2142
+ if (isExpanded(element)) {
2143
+ attrs = pickAttrs(attrs, [
2144
+ 'fill',
2145
+ 'stroke',
2146
+ 'width',
2147
+ 'height'
2148
+ ]);
2149
+ } else {
2150
+ attrs = pickAttrs(attrs, [
2151
+ 'fill',
2152
+ 'stroke'
2153
+ ]);
2154
+ }
2155
+
2156
+ return renderSubProcess(parentGfx, element, attrs);
2157
+ },
2158
+ 'bpmn:Task': function(parentGfx, element, attrs = {}) {
2159
+ attrs = pickAttrs(attrs, [
2160
+ 'fill',
2161
+ 'stroke'
2162
+ ]);
2163
+
2164
+ return renderTask(parentGfx, element, attrs);
2165
+ },
2166
+ 'bpmn:TextAnnotation': function(parentGfx, element, attrs = {}) {
2167
+ attrs = pickAttrs(attrs, [
2168
+ 'fill',
2169
+ 'stroke',
2170
+ 'width',
2171
+ 'height'
2172
+ ]);
2173
+
2174
+ var {
2175
+ width,
2176
+ height
2177
+ } = getBounds(element, attrs);
2178
+
2179
+ var textElement = drawRect(parentGfx, width, height, 0, 0, {
2180
+ fill: 'none',
2181
+ stroke: 'none'
2182
+ });
2183
+
2184
+ var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
2185
+ xScaleFactor: 1,
2186
+ yScaleFactor: 1,
2187
+ containerWidth: width,
2188
+ containerHeight: height,
2189
+ position: {
2190
+ mx: 0.0,
2191
+ my: 0.0
2192
+ }
2193
+ });
2194
+
2195
+ drawPath(parentGfx, textPathData, {
2196
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke)
2197
+ });
2198
+
2199
+ var semantic = getSemantic(element),
2200
+ text = semantic.get('text') || '';
2201
+
2202
+ renderLabel(parentGfx, text, {
2203
+ align: 'left-top',
2204
+ box: getBounds(element, attrs),
2205
+ padding: 7,
2206
+ style: {
2207
+ fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
2208
+ }
2209
+ });
2210
+
2211
+ return textElement;
2212
+ },
2213
+ 'bpmn:Transaction': function(parentGfx, element, attrs = {}) {
2214
+ if (isExpanded(element)) {
2215
+ attrs = pickAttrs(attrs, [
2216
+ 'fill',
2217
+ 'stroke',
2218
+ 'width',
2219
+ 'height'
2220
+ ]);
2221
+ } else {
2222
+ attrs = pickAttrs(attrs, [
2223
+ 'fill',
2224
+ 'stroke'
2225
+ ]);
2226
+ }
2227
+
2228
+ var outer = renderSubProcess(parentGfx, element, {
2229
+ strokeWidth: 1.5,
2230
+ ...attrs
2231
+ });
2232
+
2233
+ var innerAttrs = styles.style([ 'no-fill', 'no-events' ], {
2234
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2235
+ strokeWidth: 1.5
2236
+ });
2237
+
2238
+ var expanded = isExpanded(element);
2239
+
2240
+ if (!expanded) {
2241
+ attrs = {};
2242
+ }
2243
+
2244
+ drawRect(
2245
+ parentGfx,
2246
+ getWidth(element, attrs),
2247
+ getHeight(element, attrs),
2248
+ TASK_BORDER_RADIUS - INNER_OUTER_DIST,
2249
+ INNER_OUTER_DIST,
2250
+ innerAttrs
2251
+ );
2252
+
2253
+ return outer;
2254
+ },
2255
+ 'bpmn:UserTask': function(parentGfx, element, attrs = {}) {
2256
+ attrs = pickAttrs(attrs, [
2257
+ 'fill',
2258
+ 'stroke'
2259
+ ]);
2260
+
2261
+ var task = renderTask(parentGfx, element, attrs);
2262
+
2263
+ var x = 15;
2264
+ var y = 12;
2265
+
2266
+ var pathDataUser1 = pathMap.getScaledPath('TASK_TYPE_USER_1', {
2267
+ abspos: {
2268
+ x: x,
2269
+ y: y
2270
+ }
2271
+ });
2272
+
2273
+ drawPath(parentGfx, pathDataUser1, {
2274
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2275
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2276
+ strokeWidth: 0.5
2277
+ });
2278
+
2279
+ var pathDataUser2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
2280
+ abspos: {
2281
+ x: x,
2282
+ y: y
2283
+ }
2284
+ });
2285
+
2286
+ drawPath(parentGfx, pathDataUser2, {
2287
+ fill: getFillColor(element, defaultFillColor, attrs.fill),
2288
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2289
+ strokeWidth: 0.5
2290
+ });
2291
+
2292
+ var pathDataUser3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
2293
+ abspos: {
2294
+ x: x,
2295
+ y: y
2296
+ }
2297
+ });
2298
+
2299
+ drawPath(parentGfx, pathDataUser3, {
2300
+ fill: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2301
+ stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
2302
+ strokeWidth: 0.5
2303
+ });
2304
+
2305
+ return task;
2306
+ },
2307
+ 'label': function(parentGfx, element, attrs = {}) {
2308
+ return renderExternalLabel(parentGfx, element, attrs);
2309
+ }
2310
+ };
2311
+
2312
+ // extension API, use at your own risk
2313
+ this._drawPath = drawPath;
2314
+
2315
+ this._renderer = renderer;
2316
+ }
2317
+
2318
+
2319
+ inherits(BpmnRenderer, BaseRenderer);
2320
+
2321
+ BpmnRenderer.$inject = [
2322
+ 'config.bpmnRenderer',
2323
+ 'eventBus',
2324
+ 'styles',
2325
+ 'pathMap',
2326
+ 'canvas',
2327
+ 'textRenderer'
2328
+ ];
2329
+
2330
+
2331
+ /**
2332
+ * @param {Element} element
2333
+ *
2334
+ * @return {boolean}
2335
+ */
2336
+ BpmnRenderer.prototype.canRender = function(element) {
2337
+ return is(element, 'bpmn:BaseElement');
2338
+ };
2339
+
2340
+ /**
2341
+ * Draw shape into parentGfx.
2342
+ *
2343
+ * @param {SVGElement} parentGfx
2344
+ * @param {Shape} shape
2345
+ * @param {Attrs} [attrs]
2346
+ *
2347
+ * @return {SVGElement} mainGfx
2348
+ */
2349
+ BpmnRenderer.prototype.drawShape = function(parentGfx, shape, attrs = {}) {
2350
+ var { type } = shape;
2351
+
2352
+ var handler = this._renderer(type);
2353
+
2354
+ return handler(parentGfx, shape, attrs);
2355
+ };
2356
+
2357
+ /**
2358
+ * Draw connection into parentGfx.
2359
+ *
2360
+ * @param {SVGElement} parentGfx
2361
+ * @param {Connection} connection
2362
+ * @param {Attrs} [attrs]
2363
+ *
2364
+ * @return {SVGElement} mainGfx
2365
+ */
2366
+ BpmnRenderer.prototype.drawConnection = function(parentGfx, connection, attrs = {}) {
2367
+ var { type } = connection;
2368
+
2369
+ var handler = this._renderer(type);
2370
+
2371
+ return handler(parentGfx, connection, attrs);
2372
+ };
2373
+
2374
+ /**
2375
+ * Get shape path.
2376
+ *
2377
+ * @param {Shape} shape
2378
+ *
2379
+ * @return {string} path
2380
+ */
2381
+ BpmnRenderer.prototype.getShapePath = function(shape) {
2382
+ if (is(shape, 'bpmn:Event')) {
2383
+ return getCirclePath(shape);
2384
+ }
2385
+
2386
+ if (is(shape, 'bpmn:Activity')) {
2387
+ return getRoundRectPath(shape, TASK_BORDER_RADIUS);
2388
+ }
2389
+
2390
+ if (is(shape, 'bpmn:Gateway')) {
2391
+ return getDiamondPath(shape);
2392
+ }
2393
+
2394
+ return getRectPath(shape);
2395
+ };
2396
+
2397
+ /**
2398
+ * Pick attributes if they exist.
2399
+ *
2400
+ * @param {Object} attrs
2401
+ * @param {string[]} keys
2402
+ *
2403
+ * @returns {Object}
2404
+ */
2405
+ function pickAttrs(attrs, keys = []) {
2406
+ return keys.reduce((pickedAttrs, key) => {
2407
+ if (attrs[ key ]) {
2408
+ pickedAttrs[ key ] = attrs[ key ];
2409
+ }
2410
+
2411
+ return pickedAttrs;
2412
+ }, {});
2391
2413
  }