bpmn-js 18.1.2 → 18.2.0

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