bpmn-js 0.20.6 → 0.22.1

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 (410) hide show
  1. package/.eslintrc +33 -33
  2. package/.npmignore +8 -8
  3. package/.travis.yml +19 -17
  4. package/.wiredeps +88 -88
  5. package/CONTRIBUTING.md +55 -55
  6. package/Gruntfile.js +129 -129
  7. package/LICENSE +22 -22
  8. package/README.md +113 -113
  9. package/assets/bpmn-font/css/bpmn-embedded.css +159 -159
  10. package/assets/bpmn-font/css/bpmn.css +161 -161
  11. package/assets/bpmn-font/font/bpmn.svg +116 -116
  12. package/docs/architecture/overview.svg +48 -48
  13. package/docs/project/COMMIT_MESSAGES.md +82 -82
  14. package/docs/project/SETUP.md +66 -66
  15. package/docs/project/setup-alternative.sh +41 -41
  16. package/docs/project/setup.bat +45 -45
  17. package/docs/project/setup.sh +40 -40
  18. package/docs/translations.json +97 -97
  19. package/lib/Modeler.js +208 -208
  20. package/lib/NavigatedViewer.js +27 -27
  21. package/lib/Viewer.js +503 -503
  22. package/lib/core/index.js +5 -5
  23. package/lib/draw/BpmnRenderer.js +1934 -1934
  24. package/lib/draw/PathMap.js +478 -478
  25. package/lib/draw/index.js +5 -5
  26. package/lib/features/auto-resize/BpmnAutoResize.js +34 -34
  27. package/lib/features/auto-resize/BpmnAutoResizeProvider.js +51 -51
  28. package/lib/features/auto-resize/index.js +5 -5
  29. package/lib/features/context-pad/ContextPadProvider.js +374 -374
  30. package/lib/features/context-pad/index.js +11 -11
  31. package/lib/features/copy-paste/BpmnCopyPaste.js +157 -154
  32. package/lib/features/copy-paste/index.js +7 -7
  33. package/lib/features/distribute-elements/BpmnDistributeElements.js +34 -34
  34. package/lib/features/distribute-elements/index.js +7 -7
  35. package/lib/features/editor-actions/BpmnEditorActions.js +130 -130
  36. package/lib/features/editor-actions/index.js +15 -15
  37. package/lib/features/global-connect/BpmnGlobalConnect.js +49 -49
  38. package/lib/features/global-connect/index.js +7 -7
  39. package/lib/features/keyboard/BpmnKeyBindings.js +72 -72
  40. package/lib/features/keyboard/index.js +7 -7
  41. package/lib/features/label-editing/LabelEditingPreview.js +122 -0
  42. package/lib/features/label-editing/LabelEditingProvider.js +292 -193
  43. package/lib/features/label-editing/LabelUtil.js +43 -43
  44. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +116 -112
  45. package/lib/features/label-editing/index.js +14 -9
  46. package/lib/features/modeling/BpmnFactory.js +97 -97
  47. package/lib/features/modeling/BpmnLayouter.js +191 -191
  48. package/lib/features/modeling/BpmnUpdater.js +692 -688
  49. package/lib/features/modeling/ElementFactory.js +218 -218
  50. package/lib/features/modeling/Modeling.js +183 -183
  51. package/lib/features/modeling/behavior/AppendBehavior.js +42 -42
  52. package/lib/features/modeling/behavior/CopyPasteBehavior.js +69 -69
  53. package/lib/features/modeling/behavior/CreateBoundaryEventBehavior.js +51 -51
  54. package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +37 -37
  55. package/lib/features/modeling/behavior/CreateParticipantBehavior.js +91 -91
  56. package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +151 -151
  57. package/lib/features/modeling/behavior/DeleteLaneBehavior.js +107 -107
  58. package/lib/features/modeling/behavior/DropOnFlowBehavior.js +165 -131
  59. package/lib/features/modeling/behavior/ImportDockingFix.js +80 -80
  60. package/lib/features/modeling/behavior/LabelBehavior.js +222 -222
  61. package/lib/features/modeling/behavior/ModelingFeedback.js +50 -50
  62. package/lib/features/modeling/behavior/RemoveElementBehavior.js +73 -73
  63. package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +50 -50
  64. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +128 -128
  65. package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +118 -116
  66. package/lib/features/modeling/behavior/ResizeLaneBehavior.js +59 -59
  67. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +138 -138
  68. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +27 -27
  69. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +54 -54
  70. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +156 -156
  71. package/lib/features/modeling/behavior/index.js +44 -44
  72. package/lib/features/modeling/behavior/util/GeometricUtil.js +129 -129
  73. package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +218 -218
  74. package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +233 -233
  75. package/lib/features/modeling/behavior/util/LineIntersect.js +36 -36
  76. package/lib/features/modeling/cmd/AddLaneHandler.js +83 -83
  77. package/lib/features/modeling/cmd/IdClaimHandler.js +41 -41
  78. package/lib/features/modeling/cmd/ResizeLaneHandler.js +125 -125
  79. package/lib/features/modeling/cmd/SplitLaneHandler.js +82 -82
  80. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +78 -78
  81. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +185 -185
  82. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +264 -264
  83. package/lib/features/modeling/index.js +23 -23
  84. package/lib/features/modeling/util/LaneUtil.js +157 -157
  85. package/lib/features/modeling/util/ModelingUtil.js +48 -48
  86. package/lib/features/ordering/BpmnOrderingProvider.js +147 -147
  87. package/lib/features/ordering/index.js +6 -6
  88. package/lib/features/palette/PaletteProvider.js +158 -158
  89. package/lib/features/palette/index.js +13 -13
  90. package/lib/features/popup-menu/ReplaceMenuProvider.js +479 -479
  91. package/lib/features/popup-menu/index.js +7 -7
  92. package/lib/features/popup-menu/util/TypeUtil.js +41 -41
  93. package/lib/features/replace/BpmnReplace.js +197 -197
  94. package/lib/features/replace/ReplaceOptions.js +787 -787
  95. package/lib/features/replace/index.js +7 -7
  96. package/lib/features/replace-preview/BpmnReplacePreview.js +113 -113
  97. package/lib/features/replace-preview/index.js +5 -5
  98. package/lib/features/rules/BpmnRules.js +807 -806
  99. package/lib/features/rules/index.js +7 -7
  100. package/lib/features/search/BpmnSearchProvider.js +128 -128
  101. package/lib/features/search/index.js +7 -7
  102. package/lib/features/snapping/BpmnSnapping.js +511 -495
  103. package/lib/features/snapping/BpmnSnappingUtil.js +159 -159
  104. package/lib/features/snapping/index.js +3 -3
  105. package/lib/import/BpmnImporter.js +302 -302
  106. package/lib/import/BpmnTreeWalker.js +445 -445
  107. package/lib/import/Importer.js +69 -69
  108. package/lib/import/Util.js +8 -8
  109. package/lib/import/index.js +5 -5
  110. package/lib/util/DiUtil.js +60 -60
  111. package/lib/util/LabelUtil.js +139 -139
  112. package/lib/util/ModelUtil.js +31 -31
  113. package/lib/util/PoweredByUtil.js +82 -82
  114. package/lib/util/model/ModelCloneHelper.js +201 -201
  115. package/lib/util/model/ModelCloneUtils.js +35 -35
  116. package/package.json +22 -22
  117. package/resources/initial.bpmn +12 -12
  118. package/resources/screencast.gif +0 -0
  119. package/tasks/banner.txt +11 -11
  120. package/tasks/bundle.js +162 -162
  121. package/test/TestHelper.js +17 -17
  122. package/test/config/karma.unit.js +46 -46
  123. package/test/config/translation-reporter.js +48 -48
  124. package/test/fixtures/bpmn/align-elements.bpmn +136 -136
  125. package/test/fixtures/bpmn/basic.bpmn +17 -17
  126. package/test/fixtures/bpmn/boundary-events.bpmn +59 -59
  127. package/test/fixtures/bpmn/collaboration/collaboration-empty-participant.bpmn +13 -13
  128. package/test/fixtures/bpmn/collaboration/collaboration-message-flows.bpmn +89 -89
  129. package/test/fixtures/bpmn/collaboration/collaboration-participant.bpmn +59 -59
  130. package/test/fixtures/bpmn/collaboration/process-empty.bpmn +6 -6
  131. package/test/fixtures/bpmn/collaboration/process.bpmn +47 -47
  132. package/test/fixtures/bpmn/collaboration-data-items.bpmn +81 -81
  133. package/test/fixtures/bpmn/collaboration-message-flows.bpmn +82 -82
  134. package/test/fixtures/bpmn/collaboration-sequence-flows.bpmn +83 -83
  135. package/test/fixtures/bpmn/collaboration.bpmn +50 -50
  136. package/test/fixtures/bpmn/complex.bpmn +2151 -2151
  137. package/test/fixtures/bpmn/conditions.bpmn +82 -82
  138. package/test/fixtures/bpmn/containers.bpmn +128 -128
  139. package/test/fixtures/bpmn/distribute-elements-filtering.bpmn +58 -58
  140. package/test/fixtures/bpmn/distribute-elements.bpmn +232 -232
  141. package/test/fixtures/bpmn/draw/activity-markers-combination.bpmn +141 -141
  142. package/test/fixtures/bpmn/draw/activity-markers-simple.bpmn +47 -47
  143. package/test/fixtures/bpmn/draw/activity-markers.bpmn +212 -212
  144. package/test/fixtures/bpmn/draw/associations.bpmn +55 -55
  145. package/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn +81 -81
  146. package/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn +81 -81
  147. package/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn +82 -82
  148. package/test/fixtures/bpmn/draw/call-activity.bpmn +12 -12
  149. package/test/fixtures/bpmn/draw/colors.bpmn +411 -411
  150. package/test/fixtures/bpmn/draw/conditional-flow-default.bpmn +100 -100
  151. package/test/fixtures/bpmn/draw/conditional-flow-gateways.bpmn +72 -72
  152. package/test/fixtures/bpmn/draw/conditional-flow-typed-task.bpmn +33 -33
  153. package/test/fixtures/bpmn/draw/conditional-flow.bpmn +248 -248
  154. package/test/fixtures/bpmn/draw/data-objects.bpmn +265 -265
  155. package/test/fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn +200 -200
  156. package/test/fixtures/bpmn/draw/event-subprocesses-expanded.bpmn +274 -274
  157. package/test/fixtures/bpmn/draw/events-interrupting.bpmn +370 -370
  158. package/test/fixtures/bpmn/draw/events.bpmn +374 -374
  159. package/test/fixtures/bpmn/draw/gateway-type-default.bpmn +45 -45
  160. package/test/fixtures/bpmn/draw/gateways.bpmn +61 -61
  161. package/test/fixtures/bpmn/draw/group.bpmn +24 -24
  162. package/test/fixtures/bpmn/draw/message-marker.bpmn +112 -112
  163. package/test/fixtures/bpmn/draw/pools-with-collection-marker.bpmn +104 -104
  164. package/test/fixtures/bpmn/draw/pools.bpmn +82 -82
  165. package/test/fixtures/bpmn/draw/task-types.bpmn +77 -77
  166. package/test/fixtures/bpmn/draw/text-annotation.bpmn +71 -71
  167. package/test/fixtures/bpmn/draw/xor.bpmn +45 -45
  168. package/test/fixtures/bpmn/empty-definitions.bpmn +4 -4
  169. package/test/fixtures/bpmn/error/categoryValue.bpmn +26 -26
  170. package/test/fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn +9 -9
  171. package/test/fixtures/bpmn/error/duplicate-ids.bpmn +14 -14
  172. package/test/fixtures/bpmn/error/invalid-child.bpmn +6 -6
  173. package/test/fixtures/bpmn/error/missing-namespace.bpmn +12 -12
  174. package/test/fixtures/bpmn/event-sub-processes.bpmn +47 -47
  175. package/test/fixtures/bpmn/extension/camunda.bpmn +52 -52
  176. package/test/fixtures/bpmn/extension/custom-override.bpmn +53 -53
  177. package/test/fixtures/bpmn/extension/custom.bpmn +53 -53
  178. package/test/fixtures/bpmn/features/copy-paste/basic.bpmn +111 -111
  179. package/test/fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn +102 -102
  180. package/test/fixtures/bpmn/features/copy-paste/collaboration.bpmn +74 -74
  181. package/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn +61 -61
  182. package/test/fixtures/bpmn/features/copy-paste/properties.bpmn +43 -43
  183. package/test/fixtures/bpmn/features/drop/drop.bpmn +41 -41
  184. package/test/fixtures/bpmn/features/drop/recursive-task.bpmn +37 -37
  185. package/test/fixtures/bpmn/features/label-editing/labels.bpmn +178 -248
  186. package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -24
  187. package/test/fixtures/bpmn/features/replace/01_replace.bpmn +193 -193
  188. package/test/fixtures/bpmn/features/replace/association-gateways.bpmn +173 -173
  189. package/test/fixtures/bpmn/features/replace/cancel-events.bpmn +49 -49
  190. package/test/fixtures/bpmn/features/replace/clone-properties.bpmn +141 -141
  191. package/test/fixtures/bpmn/features/replace/connection.bpmn +42 -42
  192. package/test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn +72 -72
  193. package/test/fixtures/bpmn/features/rules/link-event.bpmn +35 -35
  194. package/test/fixtures/bpmn/features/rules/text-annotation-association.bpmn +30 -30
  195. package/test/fixtures/bpmn/flow-markers.bpmn +212 -212
  196. package/test/fixtures/bpmn/import/boundaryEvent.bpmn +33 -33
  197. package/test/fixtures/bpmn/import/collaboration.bpmn +50 -50
  198. package/test/fixtures/bpmn/import/collapsed/collaboration.bpmn +76 -76
  199. package/test/fixtures/bpmn/import/collapsed/process.bpmn +84 -84
  200. package/test/fixtures/bpmn/import/collapsed/processWithChildren.bpmn +273 -273
  201. package/test/fixtures/bpmn/import/default-attrs.bpmn +24 -24
  202. package/test/fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn +30 -30
  203. package/test/fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn +33 -33
  204. package/test/fixtures/bpmn/import/error/dangling-process-message-flow.bpmn +81 -81
  205. package/test/fixtures/bpmn/import/error/invalid-flow-element.bpmn +35 -35
  206. package/test/fixtures/bpmn/import/error/multiple-dis.bpmn +23 -23
  207. package/test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn +41 -41
  208. package/test/fixtures/bpmn/import/labels/collaboration.bpmn +72 -72
  209. package/test/fixtures/bpmn/import/labels/embedded.bpmn +39 -39
  210. package/test/fixtures/bpmn/import/labels/external-no-di.bpmn +42 -42
  211. package/test/fixtures/bpmn/import/labels/external.bpmn +69 -69
  212. package/test/fixtures/bpmn/import/position/position-testcase.bpmn +57 -57
  213. package/test/fixtures/bpmn/import/process.bpmn +60 -60
  214. package/test/fixtures/bpmn/nested-subprocesses.bpmn +118 -118
  215. package/test/fixtures/bpmn/sequence-flows.bpmn +60 -60
  216. package/test/fixtures/bpmn/simple-cropping.bpmn +84 -84
  217. package/test/fixtures/bpmn/simple-resizable.bpmn +50 -50
  218. package/test/fixtures/bpmn/simple.bpmn +60 -60
  219. package/test/fixtures/json/model/camunda.json +1042 -1042
  220. package/test/fixtures/json/model/custom-override.json +39 -39
  221. package/test/fixtures/json/model/custom.json +39 -39
  222. package/test/helper/TranslationCollector.js +17 -17
  223. package/test/helper/index.js +249 -249
  224. package/test/integration/CustomElementsSpec.js +223 -223
  225. package/test/integration/ReimportSpec.js +89 -89
  226. package/test/integration/SimpleModelingSpec.js +29 -29
  227. package/test/integration/custom-elements/CustomElementFactory.js +77 -77
  228. package/test/integration/custom-elements/CustomRenderer.js +151 -151
  229. package/test/integration/custom-elements/CustomRules.js +148 -148
  230. package/test/integration/custom-elements/CustomUpdater.js +115 -115
  231. package/test/integration/custom-elements/index.js +7 -7
  232. package/test/integration/model/BpmnModdleSpec.js +65 -65
  233. package/test/matchers/JSONMatcher.js +19 -19
  234. package/test/spec/ModelerSpec.js +401 -401
  235. package/test/spec/NavigatedViewerSpec.js +58 -58
  236. package/test/spec/ViewerSpec.js +977 -977
  237. package/test/spec/draw/BpmnRendererSpec.js +311 -311
  238. package/test/spec/environment/MockingSpec.js +53 -53
  239. package/test/spec/features/align-elements/BpmnAlignElementsSpec.js +137 -137
  240. package/test/spec/features/auto-resize/AutoResize.lanes.bpmn +54 -54
  241. package/test/spec/features/auto-resize/AutoResize.multi-selection.bpmn +22 -22
  242. package/test/spec/features/auto-resize/AutoResize.nested-sub-processes.bpmn +47 -47
  243. package/test/spec/features/auto-resize/AutoResize.participant.bpmn +38 -38
  244. package/test/spec/features/auto-resize/AutoResize.space-tool.bpmn +38 -38
  245. package/test/spec/features/auto-resize/AutoResize.sub-processes.bpmn +37 -37
  246. package/test/spec/features/auto-resize/AutoResizeSpec.js +607 -607
  247. package/test/spec/features/context-pad/ContextPad.activation.bpmn +51 -51
  248. package/test/spec/features/context-pad/ContextPadProviderSpec.js +440 -440
  249. package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +763 -725
  250. package/test/spec/features/copy-paste/DescriptorTree.js +58 -58
  251. package/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js +113 -113
  252. package/test/spec/features/editor-actions/BpmnEditorActionsSpec.js +72 -72
  253. package/test/spec/features/global-connect/BpmnGlobalConnectSpec.js +61 -61
  254. package/test/spec/features/keyboard/BpmnKeyBindingsSpec.js +142 -142
  255. package/test/spec/features/label-editing/LabelEditingPreviewSpec.js +133 -0
  256. package/test/spec/features/label-editing/LabelEditingProviderSpec.js +636 -601
  257. package/test/spec/features/label-editing/TouchIntegrationSpec.js +40 -40
  258. package/test/spec/features/modeling/AppendShapeSpec.js +332 -332
  259. package/test/spec/features/modeling/BendpointsSpec.js +25 -25
  260. package/test/spec/features/modeling/BpmnFactorySpec.js +73 -73
  261. package/test/spec/features/modeling/BpmnUpdater.bpmn +99 -99
  262. package/test/spec/features/modeling/BpmnUpdaterSpec.js +79 -79
  263. package/test/spec/features/modeling/CreateConnectionSpec.js +171 -171
  264. package/test/spec/features/modeling/DeleteConnectionSpec.js +75 -75
  265. package/test/spec/features/modeling/DeleteParticipantSpec.js +97 -97
  266. package/test/spec/features/modeling/DeleteShapeSpec.js +75 -75
  267. package/test/spec/features/modeling/DropSpec.js +123 -123
  268. package/test/spec/features/modeling/IdClaim.bpmn +13 -13
  269. package/test/spec/features/modeling/IdClaimSpec.js +50 -50
  270. package/test/spec/features/modeling/LabelBoundsSpec.js +342 -340
  271. package/test/spec/features/modeling/LabelBoundsSpec.simple.bpmn +27 -27
  272. package/test/spec/features/modeling/LabelLayouting.initial.bpmn +37 -37
  273. package/test/spec/features/modeling/LabelLayouting.move.bpmn +99 -99
  274. package/test/spec/features/modeling/LabelLayouting.special.bpmn +76 -76
  275. package/test/spec/features/modeling/LabelLayoutingSpec.js +603 -603
  276. package/test/spec/features/modeling/MoveConnectionSpec.js +101 -101
  277. package/test/spec/features/modeling/MoveElements.flow-collaboration.bpmn +45 -45
  278. package/test/spec/features/modeling/MoveElementsSpec.js +70 -70
  279. package/test/spec/features/modeling/MoveRulesSpec.js +151 -151
  280. package/test/spec/features/modeling/MoveShapeSpec.js +353 -353
  281. package/test/spec/features/modeling/ResizeShapeSpec.js +73 -73
  282. package/test/spec/features/modeling/SpaceToolSpec.js +251 -251
  283. package/test/spec/features/modeling/UpdateAttachmentSpec.js +96 -96
  284. package/test/spec/features/modeling/UpdateLabelSpec.js +130 -130
  285. package/test/spec/features/modeling/UpdatePropertiesSpec.js +503 -503
  286. package/test/spec/features/modeling/append/TextAnnotationSpec.js +136 -136
  287. package/test/spec/features/modeling/behavior/CompensationAssociationBehavior.bpmn +26 -26
  288. package/test/spec/features/modeling/behavior/CompensationAssociationBehaviorSpec.js +43 -43
  289. package/test/spec/features/modeling/behavior/CreateBoundaryEventBehaviorSpec.js +58 -58
  290. package/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +224 -224
  291. package/test/spec/features/modeling/behavior/DataInputAssociationBehavior.bpmn +33 -33
  292. package/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js +146 -146
  293. package/test/spec/features/modeling/behavior/DataObjectBehavior.create-data-association.bpmn +21 -21
  294. package/test/spec/features/modeling/behavior/DataObjectBehavior.data-object-reference.bpmn +13 -13
  295. package/test/spec/features/modeling/behavior/DataObjectBehavior.remove-data-association.bpmn +41 -41
  296. package/test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js +297 -297
  297. package/test/spec/features/modeling/behavior/DataStoreBehavior.bpmn +26 -26
  298. package/test/spec/features/modeling/behavior/DataStoreBehavior.connect.bpmn +57 -57
  299. package/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +228 -228
  300. package/test/spec/features/modeling/behavior/DropOnFlowBehavior.bpmn +71 -67
  301. package/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +591 -418
  302. package/test/spec/features/modeling/behavior/ImportDockingFix.bpmn +61 -61
  303. package/test/spec/features/modeling/behavior/ImportDockingFixSpec.js +37 -37
  304. package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +277 -277
  305. package/test/spec/features/modeling/behavior/ReconnectConnection.data-association.bpmn +41 -41
  306. package/test/spec/features/modeling/behavior/ReconnectConnectionSpec.js +120 -120
  307. package/test/spec/features/modeling/behavior/RemoveElementBehavior.bpmn +181 -181
  308. package/test/spec/features/modeling/behavior/RemoveElementBehavior.perpendicular.bpmn +159 -159
  309. package/test/spec/features/modeling/behavior/RemoveElementBehaviorSpec.js +251 -251
  310. package/test/spec/features/modeling/behavior/RemoveParticipantBehaviorSpec.js +125 -125
  311. package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.association.bpmn +26 -26
  312. package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.boundary-events.bpmn +40 -40
  313. package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.message-sequence-flow.bpmn +121 -121
  314. package/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js +439 -439
  315. package/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js +450 -450
  316. package/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js +653 -653
  317. package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.bpmn +48 -48
  318. package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js +77 -77
  319. package/test/spec/features/modeling/behavior/util/GeometricUtilSpec.js +127 -127
  320. package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -75
  321. package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +294 -294
  322. package/test/spec/features/modeling/behavior/util/LineIntersectSpec.js +32 -32
  323. package/test/spec/features/modeling/lanes/AddLaneSpec.js +263 -263
  324. package/test/spec/features/modeling/lanes/DeleteLaneSpec.js +126 -126
  325. package/test/spec/features/modeling/lanes/ResizeLaneSpec.js +366 -366
  326. package/test/spec/features/modeling/lanes/SplitLaneSpec.js +216 -216
  327. package/test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js +271 -271
  328. package/test/spec/features/modeling/lanes/flowNodeRefs.bpmn +56 -56
  329. package/test/spec/features/modeling/lanes/lanes.bpmn +83 -83
  330. package/test/spec/features/modeling/lanes/participant-lane.bpmn +27 -27
  331. package/test/spec/features/modeling/lanes/participant-no-lane.bpmn +22 -22
  332. package/test/spec/features/modeling/layout/Helper.js +64 -64
  333. package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +101 -101
  334. package/test/spec/features/modeling/layout/LayoutConnectionSpec.js +98 -98
  335. package/test/spec/features/modeling/layout/LayoutDataAssociationSpec.js +98 -98
  336. package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.bpmn +119 -119
  337. package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js +313 -313
  338. package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.boundaryEvents.bpmn +65 -65
  339. package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.flowElements.bpmn +70 -70
  340. package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js +323 -323
  341. package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +231 -231
  342. package/test/spec/features/ordering/Helper.js +185 -185
  343. package/test/spec/features/ordering/ordering-start-event.bpmn +17 -17
  344. package/test/spec/features/ordering/ordering-subprocesses.bpmn +41 -41
  345. package/test/spec/features/ordering/ordering.bpmn +105 -105
  346. package/test/spec/features/palette/PaletteProviderSpec.js +33 -33
  347. package/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn +13 -13
  348. package/test/spec/features/popup-menu/ReplaceMenuProvider.compensation-activity.bpmn +12 -12
  349. package/test/spec/features/popup-menu/ReplaceMenuProvider.conditionalFlows.bpmn +66 -66
  350. package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlows.bpmn +126 -126
  351. package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn +48 -48
  352. package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromInclusiveGateways.bpmn +48 -48
  353. package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +1957 -1957
  354. package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -70
  355. package/test/spec/features/replace/BpmnReplace.compensation.bpmn +12 -12
  356. package/test/spec/features/replace/BpmnReplace.eventSubProcesses.bpmn +126 -126
  357. package/test/spec/features/replace/BpmnReplaceSpec.js +1302 -1302
  358. package/test/spec/features/replace/ReplaceRulesSpec.js +78 -78
  359. package/test/spec/features/replace/SubProcess-collapsed.bpmn +36 -36
  360. package/test/spec/features/replace-preview/BpmnReplacePreviewSpec.js +304 -304
  361. package/test/spec/features/rules/BpmnRules.boundaryEvent.bpmn +93 -93
  362. package/test/spec/features/rules/BpmnRules.collaboration-dataAssociation.bpmn +35 -35
  363. package/test/spec/features/rules/BpmnRules.collaboration-lanes.bpmn +79 -79
  364. package/test/spec/features/rules/BpmnRules.collaboration.bpmn +138 -138
  365. package/test/spec/features/rules/BpmnRules.compensation.bpmn +65 -65
  366. package/test/spec/features/rules/BpmnRules.dataAssociation.bpmn +33 -33
  367. package/test/spec/features/rules/BpmnRules.eventBasedGateway.bpmn +82 -82
  368. package/test/spec/features/rules/BpmnRules.messageFlow.bpmn +27 -27
  369. package/test/spec/features/rules/BpmnRules.multiSelectionPools.bpmn +37 -37
  370. package/test/spec/features/rules/BpmnRules.process.bpmn +91 -91
  371. package/test/spec/features/rules/BpmnRules.subProcess-dataAssociation.bpmn +44 -44
  372. package/test/spec/features/rules/BpmnRulesSpec.js +1468 -1424
  373. package/test/spec/features/rules/Helper.js +82 -82
  374. package/test/spec/features/search/BpmnSearchProviderSpec.js +158 -158
  375. package/test/spec/features/search/bpmn-search-collaboration.bpmn +106 -106
  376. package/test/spec/features/search/bpmn-search.bpmn +100 -100
  377. package/test/spec/features/snapping/BpmnSnapping.connect.bpmn +36 -36
  378. package/test/spec/features/snapping/BpmnSnapping.labels.bpmn +27 -27
  379. package/test/spec/features/snapping/BpmnSnapping.lanes-resize.bpmn +43 -43
  380. package/test/spec/features/snapping/BpmnSnapping.participant-resize.bpmn +50 -50
  381. package/test/spec/features/snapping/BpmnSnapping.sequenceFlow.bpmn +41 -0
  382. package/test/spec/features/snapping/BpmnSnapping.subProcess-resize.bpmn +21 -21
  383. package/test/spec/features/snapping/BpmnSnapping.textAnnotation-resize.bpmn +22 -22
  384. package/test/spec/features/snapping/BpmnSnappingSpec.js +824 -758
  385. package/test/spec/features/snapping/BpmnSnappingUtil.lanes-flowNodes.bpmn +82 -82
  386. package/test/spec/features/snapping/BpmnSnappingUtil.lanes.bpmn +35 -35
  387. package/test/spec/features/snapping/BpmnSnappingUtilSpec.js +285 -285
  388. package/test/spec/i18n/custom-translate/custom-translate.js +14 -14
  389. package/test/spec/i18n/custom-translate/index.js +2 -2
  390. package/test/spec/i18n/translateSpec.js +56 -56
  391. package/test/spec/import/ImporterSpec.js +428 -428
  392. package/test/spec/import/ModelWiringSpec.js +194 -194
  393. package/test/spec/import/elements/AssociationSpec.collaboration.bpmn +51 -51
  394. package/test/spec/import/elements/AssociationSpec.compensation.bpmn +28 -28
  395. package/test/spec/import/elements/AssociationSpec.data-association.bpmn +39 -39
  396. package/test/spec/import/elements/AssociationSpec.data-input-output.bpmn +40 -40
  397. package/test/spec/import/elements/AssociationSpec.events.bpmn +51 -51
  398. package/test/spec/import/elements/AssociationSpec.js +175 -175
  399. package/test/spec/import/elements/AssociationSpec.text-annotation.bpmn +37 -37
  400. package/test/spec/import/elements/CollapsedSpec.js +118 -118
  401. package/test/spec/import/elements/LabelSpec.js +85 -85
  402. package/test/spec/import/lane-flowNodes.bpmn +44 -44
  403. package/test/spec/import/lane-missing-flowNodeRef.bpmn +24 -24
  404. package/test/spec/util/ModelCloneHelperSpec.js +381 -381
  405. package/test/spec/util/ModelUtilSpec.js +65 -65
  406. package/test/spec/util/camunda-moddle.js +70 -70
  407. package/test/util/MockEvents.js +62 -62
  408. package/test/util/ModelingUtil.js +117 -117
  409. package/test/util/custom-rules/CustomRules.js +18 -18
  410. package/test/util/custom-rules/index.js +4 -4
@@ -1,1934 +1,1934 @@
1
- 'use strict';
2
-
3
- var inherits = require('inherits'),
4
- isObject = require('lodash/lang/isObject'),
5
- assign = require('lodash/object/assign'),
6
- forEach = require('lodash/collection/forEach'),
7
- every = require('lodash/collection/every'),
8
- some = require('lodash/collection/some');
9
-
10
- var BaseRenderer = require('diagram-js/lib/draw/BaseRenderer'),
11
- TextUtil = require('diagram-js/lib/util/Text'),
12
- DiUtil = require('../util/DiUtil');
13
-
14
- var getBusinessObject = require('../util/ModelUtil').getBusinessObject,
15
- is = require('../util/ModelUtil').is;
16
-
17
- var RenderUtil = require('diagram-js/lib/util/RenderUtil');
18
-
19
- var componentsToPath = RenderUtil.componentsToPath,
20
- createLine = RenderUtil.createLine;
21
-
22
- var domQuery = require('min-dom/lib/query');
23
-
24
- var svgAppend = require('tiny-svg/lib/append'),
25
- svgAttr = require('tiny-svg/lib/attr'),
26
- svgCreate = require('tiny-svg/lib/create'),
27
- svgClasses = require('tiny-svg/lib/classes');
28
-
29
- var rotate = require('diagram-js/lib/util/SvgTransformUtil').rotate,
30
- transform = require('diagram-js/lib/util/SvgTransformUtil').transform,
31
- translate = require('diagram-js/lib/util/SvgTransformUtil').translate;
32
-
33
- var TASK_BORDER_RADIUS = 10;
34
- var INNER_OUTER_DIST = 3;
35
-
36
- var LABEL_STYLE = {
37
- fontFamily: 'Arial, sans-serif',
38
- fontSize: 12
39
- };
40
-
41
-
42
- function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
43
-
44
- BaseRenderer.call(this, eventBus, priority);
45
-
46
- var textUtil = new TextUtil({
47
- style: LABEL_STYLE,
48
- size: { width: 100 }
49
- });
50
-
51
- var markers = {};
52
-
53
- var computeStyle = styles.computeStyle;
54
-
55
- function addMarker(id, options) {
56
- var attrs = assign({
57
- fill: 'black',
58
- strokeWidth: 1,
59
- strokeLinecap: 'round',
60
- strokeDasharray: 'none'
61
- }, options.attrs);
62
-
63
- var ref = options.ref || { x: 0, y: 0 };
64
-
65
- var scale = options.scale || 1;
66
-
67
- // fix for safari / chrome / firefox bug not correctly
68
- // resetting stroke dash array
69
- if (attrs.strokeDasharray === 'none') {
70
- attrs.strokeDasharray = [10000, 1];
71
- }
72
-
73
- var marker = svgCreate('marker');
74
-
75
- svgAttr(options.element, attrs);
76
-
77
- svgAppend(marker, options.element);
78
-
79
- svgAttr(marker, {
80
- id: id,
81
- viewBox: '0 0 20 20',
82
- refX: ref.x,
83
- refY: ref.y,
84
- markerWidth: 20 * scale,
85
- markerHeight: 20 * scale,
86
- orient: 'auto'
87
- });
88
-
89
- var defs = domQuery('defs', canvas._svg);
90
-
91
- if (!defs) {
92
- defs = svgCreate('defs');
93
-
94
- svgAppend(canvas._svg, defs);
95
- }
96
-
97
- svgAppend(defs, marker);
98
-
99
- markers[id] = marker;
100
- }
101
-
102
- function marker(type, fill, stroke) {
103
- var id = type + '-' + fill + '-' + stroke;
104
-
105
- if (!markers[id]) {
106
- createMarker(type, fill, stroke);
107
- }
108
-
109
- return 'url(#' + id + ')';
110
- }
111
-
112
- function createMarker(type, fill, stroke) {
113
- var id = type + '-' + fill + '-' + stroke;
114
-
115
- if (type === 'sequenceflow-end') {
116
- var sequenceflowEnd = svgCreate('path');
117
- svgAttr(sequenceflowEnd, { d: 'M 1 5 L 11 10 L 1 15 Z' });
118
-
119
- addMarker(id, {
120
- element: sequenceflowEnd,
121
- ref: { x: 11, y: 10 },
122
- scale: 0.5,
123
- attrs: {
124
- fill: stroke,
125
- stroke: stroke
126
- }
127
- });
128
- }
129
-
130
- if (type === 'messageflow-start') {
131
- var messageflowStart = svgCreate('circle');
132
- svgAttr(messageflowStart, { cx: 6, cy: 6, r: 3.5 });
133
-
134
- addMarker(id, {
135
- element: messageflowStart,
136
- attrs: {
137
- fill: fill,
138
- stroke: stroke
139
- },
140
- ref: { x: 6, y: 6 }
141
- });
142
- }
143
-
144
- if (type === 'messageflow-end') {
145
- var messageflowEnd = svgCreate('path');
146
- svgAttr(messageflowEnd, { d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z' });
147
-
148
- addMarker(id, {
149
- element: messageflowEnd,
150
- attrs: {
151
- fill: fill,
152
- stroke: stroke,
153
- strokeLinecap: 'butt'
154
- },
155
- ref: { x: 8.5, y: 5 }
156
- });
157
- }
158
-
159
- if (type === 'association-start') {
160
- var associationStart = svgCreate('path');
161
- svgAttr(associationStart, { d: 'M 11 5 L 1 10 L 11 15' });
162
-
163
- addMarker(id, {
164
- element: associationStart,
165
- attrs: {
166
- fill: 'none',
167
- stroke: stroke,
168
- strokeWidth: 1.5
169
- },
170
- ref: { x: 1, y: 10 },
171
- scale: 0.5
172
- });
173
- }
174
-
175
- if (type === 'association-end') {
176
- var associationEnd = svgCreate('path');
177
- svgAttr(associationEnd, { d: 'M 1 5 L 11 10 L 1 15' });
178
-
179
- addMarker(id, {
180
- element: associationEnd,
181
- attrs: {
182
- fill: 'none',
183
- stroke: stroke,
184
- strokeWidth: 1.5
185
- },
186
- ref: { x: 12, y: 10 },
187
- scale: 0.5
188
- });
189
- }
190
-
191
- if (type === 'conditional-flow-marker') {
192
- var conditionalflowMarker = svgCreate('path');
193
- svgAttr(conditionalflowMarker, { d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z' });
194
-
195
- addMarker(id, {
196
- element: conditionalflowMarker,
197
- attrs: {
198
- fill: fill,
199
- stroke: stroke
200
- },
201
- ref: { x: -1, y: 10 },
202
- scale: 0.5
203
- });
204
- }
205
-
206
- if (type === 'conditional-default-flow-marker') {
207
- var conditionaldefaultflowMarker = svgCreate('path');
208
- svgAttr(conditionaldefaultflowMarker, { d: 'M 6 4 L 10 16' });
209
-
210
- addMarker(id, {
211
- element: conditionaldefaultflowMarker,
212
- attrs: {
213
- stroke: stroke
214
- },
215
- ref: { x: 0, y: 10 },
216
- scale: 0.5
217
- });
218
- }
219
- }
220
-
221
- function drawCircle(parentGfx, width, height, offset, attrs) {
222
-
223
- if (isObject(offset)) {
224
- attrs = offset;
225
- offset = 0;
226
- }
227
-
228
- offset = offset || 0;
229
-
230
- attrs = computeStyle(attrs, {
231
- stroke: 'black',
232
- strokeWidth: 2,
233
- fill: 'white'
234
- });
235
-
236
- var cx = width / 2,
237
- cy = height / 2;
238
-
239
- var circle = svgCreate('circle');
240
- svgAttr(circle, {
241
- cx: cx,
242
- cy: cy,
243
- r: Math.round((width + height) / 4 - offset)
244
- });
245
- svgAttr(circle, attrs);
246
-
247
- svgAppend(parentGfx, circle);
248
-
249
- return circle;
250
- }
251
-
252
- function drawRect(parentGfx, width, height, r, offset, attrs) {
253
-
254
- if (isObject(offset)) {
255
- attrs = offset;
256
- offset = 0;
257
- }
258
-
259
- offset = offset || 0;
260
-
261
- attrs = computeStyle(attrs, {
262
- stroke: 'black',
263
- strokeWidth: 2,
264
- fill: 'white'
265
- });
266
-
267
- var rect = svgCreate('rect');
268
- svgAttr(rect, {
269
- x: offset,
270
- y: offset,
271
- width: width - offset * 2,
272
- height: height - offset * 2,
273
- rx: r,
274
- ry: r
275
- });
276
- svgAttr(rect, attrs);
277
-
278
- svgAppend(parentGfx, rect);
279
-
280
- return rect;
281
- }
282
-
283
- function drawDiamond(parentGfx, width, height, attrs) {
284
-
285
- var x_2 = width / 2;
286
- var y_2 = height / 2;
287
-
288
- var points = [{ x: x_2, y: 0 }, { x: width, y: y_2 }, { x: x_2, y: height }, { x: 0, y: y_2 }];
289
-
290
- var pointsString = points.map(function(point) {
291
- return point.x + ',' + point.y;
292
- }).join(' ');
293
-
294
- attrs = computeStyle(attrs, {
295
- stroke: 'black',
296
- strokeWidth: 2,
297
- fill: 'white'
298
- });
299
-
300
- var polygon = svgCreate('polygon');
301
- svgAttr(polygon, {
302
- points: pointsString
303
- });
304
- svgAttr(polygon, attrs);
305
-
306
- svgAppend(parentGfx, polygon);
307
-
308
- return polygon;
309
- }
310
-
311
- function drawLine(parentGfx, waypoints, attrs) {
312
- attrs = computeStyle(attrs, [ 'no-fill' ], {
313
- stroke: 'black',
314
- strokeWidth: 2,
315
- fill: 'none'
316
- });
317
-
318
- var line = createLine(waypoints, attrs);
319
-
320
- svgAppend(parentGfx, line);
321
-
322
- return line;
323
- }
324
-
325
- function drawPath(parentGfx, d, attrs) {
326
-
327
- attrs = computeStyle(attrs, [ 'no-fill' ], {
328
- strokeWidth: 2,
329
- stroke: 'black'
330
- });
331
-
332
- var path = svgCreate('path');
333
- svgAttr(path, { d: d });
334
- svgAttr(path, attrs);
335
-
336
- svgAppend(parentGfx, path);
337
-
338
- return path;
339
- }
340
-
341
- function drawMarker(type, parentGfx, path, attrs) {
342
- return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
343
- }
344
-
345
- function as(type) {
346
- return function(parentGfx, element) {
347
- return handlers[type](parentGfx, element);
348
- };
349
- }
350
-
351
- function renderer(type) {
352
- return handlers[type];
353
- }
354
-
355
- function renderEventContent(element, parentGfx) {
356
-
357
- var event = getSemantic(element);
358
- var isThrowing = isThrowEvent(event);
359
-
360
- if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
361
- return renderer('bpmn:MessageEventDefinition')(parentGfx, element, isThrowing);
362
- }
363
-
364
- if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
365
- return renderer('bpmn:TimerEventDefinition')(parentGfx, element, isThrowing);
366
- }
367
-
368
- if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
369
- return renderer('bpmn:ConditionalEventDefinition')(parentGfx, element);
370
- }
371
-
372
- if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
373
- return renderer('bpmn:SignalEventDefinition')(parentGfx, element, isThrowing);
374
- }
375
-
376
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
377
- isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
378
- return renderer('bpmn:MultipleEventDefinition')(parentGfx, element, isThrowing);
379
- }
380
-
381
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
382
- isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
383
- return renderer('bpmn:ParallelMultipleEventDefinition')(parentGfx, element, isThrowing);
384
- }
385
-
386
- if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
387
- return renderer('bpmn:EscalationEventDefinition')(parentGfx, element, isThrowing);
388
- }
389
-
390
- if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
391
- return renderer('bpmn:LinkEventDefinition')(parentGfx, element, isThrowing);
392
- }
393
-
394
- if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
395
- return renderer('bpmn:ErrorEventDefinition')(parentGfx, element, isThrowing);
396
- }
397
-
398
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
399
- return renderer('bpmn:CancelEventDefinition')(parentGfx, element, isThrowing);
400
- }
401
-
402
- if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
403
- return renderer('bpmn:CompensateEventDefinition')(parentGfx, element, isThrowing);
404
- }
405
-
406
- if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
407
- return renderer('bpmn:TerminateEventDefinition')(parentGfx, element, isThrowing);
408
- }
409
-
410
- return null;
411
- }
412
-
413
- function renderLabel(parentGfx, label, options) {
414
- var text = textUtil.createText(label || '', options);
415
- svgClasses(text).add('djs-label');
416
- svgAppend(parentGfx, text);
417
-
418
- return text;
419
- }
420
-
421
- function renderEmbeddedLabel(parentGfx, element, align) {
422
- var semantic = getSemantic(element);
423
-
424
- return renderLabel(parentGfx, semantic.name, {
425
- box: element,
426
- align: align,
427
- padding: 5,
428
- style: {
429
- fill: getStrokeColor(element)
430
- }
431
- });
432
- }
433
-
434
- function renderExternalLabel(parentGfx, element) {
435
- var semantic = getSemantic(element);
436
- var box = {
437
- width: 90,
438
- height: 30,
439
- x: element.width / 2 + element.x,
440
- y: element.height / 2 + element.y
441
- };
442
-
443
- return renderLabel(parentGfx, semantic.name, {
444
- box: box,
445
- fitBox: true,
446
- style: { fontSize: '11px' }
447
- });
448
- }
449
-
450
- function renderLaneLabel(parentGfx, text, element) {
451
- var textBox = renderLabel(parentGfx, text, {
452
- box: { height: 30, width: element.height },
453
- align: 'center-middle',
454
- style: {
455
- fill: getStrokeColor(element)
456
- }
457
- });
458
-
459
- var top = -1 * element.height;
460
-
461
- transform(textBox, 0, -top, 270);
462
- }
463
-
464
- function createPathFromConnection(connection) {
465
- var waypoints = connection.waypoints;
466
-
467
- var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
468
- for (var i = 1; i < waypoints.length; i++) {
469
- pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
470
- }
471
- return pathData;
472
- }
473
-
474
- var handlers = this.handlers = {
475
- 'bpmn:Event': function(parentGfx, element, attrs) {
476
- return drawCircle(parentGfx, element.width, element.height, attrs);
477
- },
478
- 'bpmn:StartEvent': function(parentGfx, element) {
479
- var attrs = {
480
- fill: getFillColor(element),
481
- stroke: getStrokeColor(element)
482
- };
483
-
484
- var semantic = getSemantic(element);
485
-
486
- if (!semantic.isInterrupting) {
487
- attrs = {
488
- strokeDasharray: '6',
489
- strokeLinecap: 'round'
490
- };
491
- }
492
-
493
- var circle = renderer('bpmn:Event')(parentGfx, element, attrs);
494
-
495
- renderEventContent(element, parentGfx);
496
-
497
- return circle;
498
- },
499
- 'bpmn:MessageEventDefinition': function(parentGfx, element, isThrowing) {
500
- var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
501
- xScaleFactor: 0.9,
502
- yScaleFactor: 0.9,
503
- containerWidth: element.width,
504
- containerHeight: element.height,
505
- position: {
506
- mx: 0.235,
507
- my: 0.315
508
- }
509
- });
510
-
511
- var fill = isThrowing ? getStrokeColor(element) : getFillColor(element);
512
- var stroke = isThrowing ? getFillColor(element) : getStrokeColor(element);
513
-
514
- var messagePath = drawPath(parentGfx, pathData, {
515
- strokeWidth: 1,
516
- fill: fill,
517
- stroke: stroke
518
- });
519
-
520
- return messagePath;
521
- },
522
- 'bpmn:TimerEventDefinition': function(parentGfx, element) {
523
- var circle = drawCircle(parentGfx, element.width, element.height, 0.2 * element.height, {
524
- strokeWidth: 2,
525
- fill: getFillColor(element),
526
- stroke: getStrokeColor(element)
527
- });
528
-
529
- var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
530
- xScaleFactor: 0.75,
531
- yScaleFactor: 0.75,
532
- containerWidth: element.width,
533
- containerHeight: element.height,
534
- position: {
535
- mx: 0.5,
536
- my: 0.5
537
- }
538
- });
539
-
540
- drawPath(parentGfx, pathData, {
541
- strokeWidth: 2,
542
- strokeLinecap: 'square',
543
- stroke: getStrokeColor(element)
544
- });
545
-
546
- for (var i = 0;i < 12;i++) {
547
-
548
- var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
549
- xScaleFactor: 0.75,
550
- yScaleFactor: 0.75,
551
- containerWidth: element.width,
552
- containerHeight: element.height,
553
- position: {
554
- mx: 0.5,
555
- my: 0.5
556
- }
557
- });
558
-
559
- var width = element.width / 2;
560
- var height = element.height / 2;
561
-
562
- drawPath(parentGfx, linePathData, {
563
- strokeWidth: 1,
564
- strokeLinecap: 'square',
565
- transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')',
566
- stroke: getStrokeColor(element)
567
- });
568
- }
569
-
570
- return circle;
571
- },
572
- 'bpmn:EscalationEventDefinition': function(parentGfx, event, isThrowing) {
573
- var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
574
- xScaleFactor: 1,
575
- yScaleFactor: 1,
576
- containerWidth: event.width,
577
- containerHeight: event.height,
578
- position: {
579
- mx: 0.5,
580
- my: 0.2
581
- }
582
- });
583
-
584
- var fill = isThrowing ? getStrokeColor(event) : 'none';
585
-
586
- return drawPath(parentGfx, pathData, {
587
- strokeWidth: 1,
588
- fill: fill,
589
- stroke: getStrokeColor(event)
590
- });
591
- },
592
- 'bpmn:ConditionalEventDefinition': function(parentGfx, event) {
593
- var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
594
- xScaleFactor: 1,
595
- yScaleFactor: 1,
596
- containerWidth: event.width,
597
- containerHeight: event.height,
598
- position: {
599
- mx: 0.5,
600
- my: 0.222
601
- }
602
- });
603
-
604
- return drawPath(parentGfx, pathData, {
605
- strokeWidth: 1,
606
- stroke: getStrokeColor(event)
607
- });
608
- },
609
- 'bpmn:LinkEventDefinition': function(parentGfx, event, isThrowing) {
610
- var pathData = pathMap.getScaledPath('EVENT_LINK', {
611
- xScaleFactor: 1,
612
- yScaleFactor: 1,
613
- containerWidth: event.width,
614
- containerHeight: event.height,
615
- position: {
616
- mx: 0.57,
617
- my: 0.263
618
- }
619
- });
620
-
621
- var fill = isThrowing ? getStrokeColor(event) : 'none';
622
-
623
- return drawPath(parentGfx, pathData, {
624
- strokeWidth: 1,
625
- fill: fill,
626
- stroke: getStrokeColor(event)
627
- });
628
- },
629
- 'bpmn:ErrorEventDefinition': function(parentGfx, event, isThrowing) {
630
- var pathData = pathMap.getScaledPath('EVENT_ERROR', {
631
- xScaleFactor: 1.1,
632
- yScaleFactor: 1.1,
633
- containerWidth: event.width,
634
- containerHeight: event.height,
635
- position: {
636
- mx: 0.2,
637
- my: 0.722
638
- }
639
- });
640
-
641
- var fill = isThrowing ? getStrokeColor(event) : 'none';
642
-
643
- return drawPath(parentGfx, pathData, {
644
- strokeWidth: 1,
645
- fill: fill,
646
- stroke: getStrokeColor(event)
647
- });
648
- },
649
- 'bpmn:CancelEventDefinition': function(parentGfx, event, isThrowing) {
650
- var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
651
- xScaleFactor: 1.0,
652
- yScaleFactor: 1.0,
653
- containerWidth: event.width,
654
- containerHeight: event.height,
655
- position: {
656
- mx: 0.638,
657
- my: -0.055
658
- }
659
- });
660
-
661
- var fill = isThrowing ? 'black' : 'none';
662
-
663
- var path = drawPath(parentGfx, pathData, {
664
- strokeWidth: 1,
665
- fill: fill
666
- });
667
-
668
- rotate(path, 45);
669
-
670
- return path;
671
- },
672
- 'bpmn:CompensateEventDefinition': function(parentGfx, event, isThrowing) {
673
- var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
674
- xScaleFactor: 1,
675
- yScaleFactor: 1,
676
- containerWidth: event.width,
677
- containerHeight: event.height,
678
- position: {
679
- mx: 0.22,
680
- my: 0.5
681
- }
682
- });
683
-
684
- var fill = isThrowing ? getStrokeColor(event) : 'none';
685
-
686
- return drawPath(parentGfx, pathData, {
687
- strokeWidth: 1,
688
- fill: fill,
689
- stroke: getStrokeColor(event)
690
- });
691
- },
692
- 'bpmn:SignalEventDefinition': function(parentGfx, event, isThrowing) {
693
- var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
694
- xScaleFactor: 0.9,
695
- yScaleFactor: 0.9,
696
- containerWidth: event.width,
697
- containerHeight: event.height,
698
- position: {
699
- mx: 0.5,
700
- my: 0.2
701
- }
702
- });
703
-
704
- var fill = isThrowing ? getStrokeColor(event) : 'none';
705
-
706
- return drawPath(parentGfx, pathData, {
707
- strokeWidth: 1,
708
- fill: fill,
709
- stroke: getStrokeColor(event)
710
- });
711
- },
712
- 'bpmn:MultipleEventDefinition': function(parentGfx, event, isThrowing) {
713
- var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
714
- xScaleFactor: 1.1,
715
- yScaleFactor: 1.1,
716
- containerWidth: event.width,
717
- containerHeight: event.height,
718
- position: {
719
- mx: 0.222,
720
- my: 0.36
721
- }
722
- });
723
-
724
- var fill = isThrowing ? 'black' : 'none';
725
-
726
- return drawPath(parentGfx, pathData, {
727
- strokeWidth: 1,
728
- fill: fill
729
- });
730
- },
731
- 'bpmn:ParallelMultipleEventDefinition': function(parentGfx, event) {
732
- var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
733
- xScaleFactor: 1.2,
734
- yScaleFactor: 1.2,
735
- containerWidth: event.width,
736
- containerHeight: event.height,
737
- position: {
738
- mx: 0.458,
739
- my: 0.194
740
- }
741
- });
742
-
743
- return drawPath(parentGfx, pathData, {
744
- strokeWidth: 1,
745
- fill: getStrokeColor(event),
746
- stroke: getStrokeColor(event)
747
- });
748
- },
749
- 'bpmn:EndEvent': function(parentGfx, element) {
750
- var circle = renderer('bpmn:Event')(parentGfx, element, {
751
- strokeWidth: 4,
752
- fill: getFillColor(element),
753
- stroke: getStrokeColor(element)
754
- });
755
-
756
- renderEventContent(element, parentGfx, true);
757
-
758
- return circle;
759
- },
760
- 'bpmn:TerminateEventDefinition': function(parentGfx, element) {
761
- var circle = drawCircle(parentGfx, element.width, element.height, 8, {
762
- strokeWidth: 4,
763
- fill: getStrokeColor(element),
764
- stroke: getStrokeColor(element)
765
- });
766
-
767
- return circle;
768
- },
769
- 'bpmn:IntermediateEvent': function(parentGfx, element) {
770
- var outer = renderer('bpmn:Event')(parentGfx, element, {
771
- strokeWidth: 1,
772
- fill: getFillColor(element),
773
- stroke: getStrokeColor(element)
774
- });
775
-
776
- /* inner */ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
777
- strokeWidth: 1,
778
- fill: getFillColor(element, 'none'),
779
- stroke: getStrokeColor(element)
780
- });
781
-
782
- renderEventContent(element, parentGfx);
783
-
784
- return outer;
785
- },
786
- 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
787
- 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
788
-
789
- 'bpmn:Activity': function(parentGfx, element, attrs) {
790
- return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, attrs);
791
- },
792
-
793
- 'bpmn:Task': function(parentGfx, element) {
794
- var attrs = {
795
- fill: getFillColor(element),
796
- stroke: getStrokeColor(element)
797
- };
798
-
799
- var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
800
-
801
- renderEmbeddedLabel(parentGfx, element, 'center-middle');
802
- attachTaskMarkers(parentGfx, element);
803
-
804
- return rect;
805
- },
806
- 'bpmn:ServiceTask': function(parentGfx, element) {
807
- var task = renderer('bpmn:Task')(parentGfx, element);
808
-
809
- var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
810
- abspos: {
811
- x: 12,
812
- y: 18
813
- }
814
- });
815
-
816
- /* service bg */ drawPath(parentGfx, pathDataBG, {
817
- strokeWidth: 1,
818
- fill: getFillColor(element),
819
- stroke: getStrokeColor(element)
820
- });
821
-
822
- var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
823
- abspos: {
824
- x: 17.2,
825
- y: 18
826
- }
827
- });
828
-
829
- /* service fill */ drawPath(parentGfx, fillPathData, {
830
- strokeWidth: 0,
831
- fill: getFillColor(element)
832
- });
833
-
834
- var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
835
- abspos: {
836
- x: 17,
837
- y: 22
838
- }
839
- });
840
-
841
- /* service */ drawPath(parentGfx, pathData, {
842
- strokeWidth: 1,
843
- fill: getFillColor(element),
844
- stroke: getStrokeColor(element)
845
- });
846
-
847
- return task;
848
- },
849
- 'bpmn:UserTask': function(parentGfx, element) {
850
- var task = renderer('bpmn:Task')(parentGfx, element);
851
-
852
- var x = 15;
853
- var y = 12;
854
-
855
- var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
856
- abspos: {
857
- x: x,
858
- y: y
859
- }
860
- });
861
-
862
- /* user path */ drawPath(parentGfx, pathData, {
863
- strokeWidth: 0.5,
864
- fill: getFillColor(element),
865
- stroke: getStrokeColor(element)
866
- });
867
-
868
- var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
869
- abspos: {
870
- x: x,
871
- y: y
872
- }
873
- });
874
-
875
- /* user2 path */ drawPath(parentGfx, pathData2, {
876
- strokeWidth: 0.5,
877
- fill: getFillColor(element),
878
- stroke: getStrokeColor(element)
879
- });
880
-
881
- var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
882
- abspos: {
883
- x: x,
884
- y: y
885
- }
886
- });
887
-
888
- /* user3 path */ drawPath(parentGfx, pathData3, {
889
- strokeWidth: 0.5,
890
- fill: getStrokeColor(element),
891
- stroke: getStrokeColor(element)
892
- });
893
-
894
- return task;
895
- },
896
- 'bpmn:ManualTask': function(parentGfx, element) {
897
- var task = renderer('bpmn:Task')(parentGfx, element);
898
-
899
- var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
900
- abspos: {
901
- x: 17,
902
- y: 15
903
- }
904
- });
905
-
906
- /* manual path */ drawPath(parentGfx, pathData, {
907
- strokeWidth: 0.5, // 0.25,
908
- fill: getFillColor(element),
909
- stroke: getStrokeColor(element)
910
- });
911
-
912
- return task;
913
- },
914
- 'bpmn:SendTask': function(parentGfx, element) {
915
- var task = renderer('bpmn:Task')(parentGfx, element);
916
-
917
- var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
918
- xScaleFactor: 1,
919
- yScaleFactor: 1,
920
- containerWidth: 21,
921
- containerHeight: 14,
922
- position: {
923
- mx: 0.285,
924
- my: 0.357
925
- }
926
- });
927
-
928
- /* send path */ drawPath(parentGfx, pathData, {
929
- strokeWidth: 1,
930
- fill: getStrokeColor(element),
931
- stroke: getFillColor(element)
932
- });
933
-
934
- return task;
935
- },
936
- 'bpmn:ReceiveTask' : function(parentGfx, element) {
937
- var semantic = getSemantic(element);
938
-
939
- var task = renderer('bpmn:Task')(parentGfx, element);
940
- var pathData;
941
-
942
- if (semantic.instantiate) {
943
- drawCircle(parentGfx, 28, 28, 20 * 0.22, { strokeWidth: 1 });
944
-
945
- pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
946
- abspos: {
947
- x: 7.77,
948
- y: 9.52
949
- }
950
- });
951
- } else {
952
-
953
- pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
954
- xScaleFactor: 0.9,
955
- yScaleFactor: 0.9,
956
- containerWidth: 21,
957
- containerHeight: 14,
958
- position: {
959
- mx: 0.3,
960
- my: 0.4
961
- }
962
- });
963
- }
964
-
965
- /* receive path */ drawPath(parentGfx, pathData, {
966
- strokeWidth: 1,
967
- fill: getFillColor(element),
968
- stroke: getStrokeColor(element)
969
- });
970
-
971
- return task;
972
- },
973
- 'bpmn:ScriptTask': function(parentGfx, element) {
974
- var task = renderer('bpmn:Task')(parentGfx, element);
975
-
976
- var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
977
- abspos: {
978
- x: 15,
979
- y: 20
980
- }
981
- });
982
-
983
- /* script path */ drawPath(parentGfx, pathData, {
984
- strokeWidth: 1,
985
- stroke: getStrokeColor(element)
986
- });
987
-
988
- return task;
989
- },
990
- 'bpmn:BusinessRuleTask': function(parentGfx, element) {
991
- var task = renderer('bpmn:Task')(parentGfx, element);
992
-
993
- var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
994
- abspos: {
995
- x: 8,
996
- y: 8
997
- }
998
- });
999
-
1000
- var businessHeaderPath = drawPath(parentGfx, headerPathData);
1001
- svgAttr(businessHeaderPath, {
1002
- strokeWidth: 1,
1003
- fill: getFillColor(element, '#aaaaaa'),
1004
- stroke: getStrokeColor(element)
1005
- });
1006
-
1007
- var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
1008
- abspos: {
1009
- x: 8,
1010
- y: 8
1011
- }
1012
- });
1013
-
1014
- var businessPath = drawPath(parentGfx, headerData);
1015
- svgAttr(businessPath, {
1016
- strokeWidth: 1,
1017
- stroke: getStrokeColor(element)
1018
- });
1019
-
1020
- return task;
1021
- },
1022
- 'bpmn:SubProcess': function(parentGfx, element, attrs) {
1023
- attrs = assign({
1024
- fillOpacity: 0.95,
1025
- fill: getFillColor(element),
1026
- stroke: getStrokeColor(element)
1027
- }, attrs);
1028
-
1029
- var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
1030
-
1031
- var expanded = DiUtil.isExpanded(element);
1032
-
1033
- var isEventSubProcess = DiUtil.isEventSubProcess(element);
1034
-
1035
- if (isEventSubProcess) {
1036
- svgAttr(rect, {
1037
- strokeDasharray: '1,2'
1038
- });
1039
- }
1040
-
1041
- renderEmbeddedLabel(parentGfx, element, expanded ? 'center-top' : 'center-middle');
1042
-
1043
- if (expanded) {
1044
- attachTaskMarkers(parentGfx, element);
1045
- } else {
1046
- attachTaskMarkers(parentGfx, element, ['SubProcessMarker']);
1047
- }
1048
-
1049
- return rect;
1050
- },
1051
- 'bpmn:AdHocSubProcess': function(parentGfx, element) {
1052
- return renderer('bpmn:SubProcess')(parentGfx, element);
1053
- },
1054
- 'bpmn:Transaction': function(parentGfx, element) {
1055
- var outer = renderer('bpmn:SubProcess')(parentGfx, element);
1056
-
1057
- var innerAttrs = styles.style([ 'no-fill', 'no-events' ], {
1058
- stroke: getStrokeColor(element)
1059
- });
1060
-
1061
- /* inner path */ drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
1062
-
1063
- return outer;
1064
- },
1065
- 'bpmn:CallActivity': function(parentGfx, element) {
1066
- return renderer('bpmn:SubProcess')(parentGfx, element, {
1067
- strokeWidth: 5
1068
- });
1069
- },
1070
- 'bpmn:Participant': function(parentGfx, element) {
1071
-
1072
- var attrs = {
1073
- fillOpacity: 0.95,
1074
- fill: getFillColor(element),
1075
- stroke: getStrokeColor(element)
1076
- };
1077
-
1078
- var lane = renderer('bpmn:Lane')(parentGfx, element, attrs);
1079
-
1080
- var expandedPool = DiUtil.isExpanded(element);
1081
-
1082
- if (expandedPool) {
1083
- drawLine(parentGfx, [
1084
- { x: 30, y: 0 },
1085
- { x: 30, y: element.height }
1086
- ], {
1087
- stroke: getStrokeColor(element)
1088
- });
1089
- var text = getSemantic(element).name;
1090
- renderLaneLabel(parentGfx, text, element);
1091
- } else {
1092
- // Collapsed pool draw text inline
1093
- var text2 = getSemantic(element).name;
1094
- renderLabel(parentGfx, text2, {
1095
- box: element, align: 'center-middle',
1096
- style: {
1097
- fill: getStrokeColor(element)
1098
- }
1099
- });
1100
- }
1101
-
1102
- var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
1103
-
1104
- if (participantMultiplicity) {
1105
- renderer('ParticipantMultiplicityMarker')(parentGfx, element);
1106
- }
1107
-
1108
- return lane;
1109
- },
1110
- 'bpmn:Lane': function(parentGfx, element, attrs) {
1111
- var rect = drawRect(parentGfx, element.width, element.height, 0, assign({
1112
- fill: getFillColor(element),
1113
- stroke: getStrokeColor(element)
1114
- }, attrs));
1115
-
1116
- var semantic = getSemantic(element);
1117
-
1118
- if (semantic.$type === 'bpmn:Lane') {
1119
- var text = semantic.name;
1120
- renderLaneLabel(parentGfx, text, element);
1121
- }
1122
-
1123
- return rect;
1124
- },
1125
- 'bpmn:InclusiveGateway': function(parentGfx, element) {
1126
- var attrs = {
1127
- fill: getFillColor(element),
1128
- stroke: getStrokeColor(element)
1129
- };
1130
-
1131
- var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1132
-
1133
- /* circle path */
1134
- drawCircle(parentGfx, element.width, element.height, element.height * 0.24, {
1135
- strokeWidth: 2.5,
1136
- fill: getFillColor(element),
1137
- stroke: getStrokeColor(element)
1138
- });
1139
-
1140
- return diamond;
1141
- },
1142
- 'bpmn:ExclusiveGateway': function(parentGfx, element) {
1143
- var attrs = {
1144
- fill: getFillColor(element),
1145
- stroke: getStrokeColor(element)
1146
- };
1147
-
1148
- var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1149
-
1150
- var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
1151
- xScaleFactor: 0.4,
1152
- yScaleFactor: 0.4,
1153
- containerWidth: element.width,
1154
- containerHeight: element.height,
1155
- position: {
1156
- mx: 0.32,
1157
- my: 0.3
1158
- }
1159
- });
1160
-
1161
- if ((getDi(element).isMarkerVisible)) {
1162
- drawPath(parentGfx, pathData, {
1163
- strokeWidth: 1,
1164
- fill: getStrokeColor(element),
1165
- stroke: getStrokeColor(element)
1166
- });
1167
- }
1168
-
1169
- return diamond;
1170
- },
1171
- 'bpmn:ComplexGateway': function(parentGfx, element) {
1172
- var attrs = {
1173
- fill: getFillColor(element),
1174
- stroke: getStrokeColor(element)
1175
- };
1176
-
1177
- var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1178
-
1179
- var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
1180
- xScaleFactor: 0.5,
1181
- yScaleFactor:0.5,
1182
- containerWidth: element.width,
1183
- containerHeight: element.height,
1184
- position: {
1185
- mx: 0.46,
1186
- my: 0.26
1187
- }
1188
- });
1189
-
1190
- /* complex path */ drawPath(parentGfx, pathData, {
1191
- strokeWidth: 1,
1192
- fill: getStrokeColor(element),
1193
- stroke: getStrokeColor(element)
1194
- });
1195
-
1196
- return diamond;
1197
- },
1198
- 'bpmn:ParallelGateway': function(parentGfx, element) {
1199
- var attrs = {
1200
- fill: getFillColor(element),
1201
- stroke: getStrokeColor(element)
1202
- };
1203
-
1204
- var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1205
-
1206
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1207
- xScaleFactor: 0.6,
1208
- yScaleFactor:0.6,
1209
- containerWidth: element.width,
1210
- containerHeight: element.height,
1211
- position: {
1212
- mx: 0.46,
1213
- my: 0.2
1214
- }
1215
- });
1216
-
1217
- /* parallel path */ drawPath(parentGfx, pathData, {
1218
- strokeWidth: 1,
1219
- fill: getStrokeColor(element),
1220
- stroke: getStrokeColor(element)
1221
- });
1222
-
1223
- return diamond;
1224
- },
1225
- 'bpmn:EventBasedGateway': function(parentGfx, element) {
1226
-
1227
- var semantic = getSemantic(element);
1228
-
1229
- var attrs = {
1230
- fill: getFillColor(element),
1231
- stroke: getStrokeColor(element)
1232
- };
1233
-
1234
- var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1235
-
1236
- /* outer circle path */ drawCircle(parentGfx, element.width, element.height, element.height * 0.20, {
1237
- strokeWidth: 1,
1238
- fill: 'none',
1239
- stroke: getStrokeColor(element)
1240
- });
1241
-
1242
- var type = semantic.eventGatewayType;
1243
- var instantiate = !!semantic.instantiate;
1244
-
1245
- function drawEvent() {
1246
-
1247
- var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
1248
- xScaleFactor: 0.18,
1249
- yScaleFactor: 0.18,
1250
- containerWidth: element.width,
1251
- containerHeight: element.height,
1252
- position: {
1253
- mx: 0.36,
1254
- my: 0.44
1255
- }
1256
- });
1257
-
1258
- var attrs = {
1259
- strokeWidth: 2,
1260
- fill: getFillColor(element, 'none'),
1261
- stroke: getStrokeColor(element)
1262
- };
1263
-
1264
- /* event path */ drawPath(parentGfx, pathData, attrs);
1265
- }
1266
-
1267
- if (type === 'Parallel') {
1268
-
1269
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1270
- xScaleFactor: 0.4,
1271
- yScaleFactor:0.4,
1272
- containerWidth: element.width,
1273
- containerHeight: element.height,
1274
- position: {
1275
- mx: 0.474,
1276
- my: 0.296
1277
- }
1278
- });
1279
-
1280
- var parallelPath = drawPath(parentGfx, pathData);
1281
- svgAttr(parallelPath, {
1282
- strokeWidth: 1,
1283
- fill: 'none'
1284
- });
1285
- } else if (type === 'Exclusive') {
1286
-
1287
- if (!instantiate) {
1288
- var innerCircle = drawCircle(parentGfx, element.width, element.height, element.height * 0.26);
1289
- svgAttr(innerCircle, {
1290
- strokeWidth: 1,
1291
- fill: 'none',
1292
- stroke: getStrokeColor(element)
1293
- });
1294
- }
1295
-
1296
- drawEvent();
1297
- }
1298
-
1299
-
1300
- return diamond;
1301
- },
1302
- 'bpmn:Gateway': function(parentGfx, element) {
1303
- return drawDiamond(parentGfx, element.width, element.height);
1304
- },
1305
- 'bpmn:SequenceFlow': function(parentGfx, element) {
1306
- var pathData = createPathFromConnection(element);
1307
-
1308
- var fill = getFillColor(element),
1309
- stroke = getStrokeColor(element);
1310
-
1311
- var attrs = {
1312
- strokeLinejoin: 'round',
1313
- markerEnd: marker('sequenceflow-end', fill, stroke),
1314
- stroke: getStrokeColor(element)
1315
- };
1316
-
1317
- var path = drawPath(parentGfx, pathData, attrs);
1318
-
1319
- var sequenceFlow = getSemantic(element);
1320
- var source = element.source.businessObject;
1321
-
1322
- // conditional flow marker
1323
- if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
1324
- svgAttr(path, {
1325
- markerStart: marker('conditional-flow-marker', fill, stroke)
1326
- });
1327
- }
1328
-
1329
- // default marker
1330
- if (source.default && (source.$instanceOf('bpmn:Gateway') || source.$instanceOf('bpmn:Activity')) &&
1331
- source.default === sequenceFlow) {
1332
- svgAttr(path, {
1333
- markerStart: marker('conditional-default-flow-marker', fill, stroke)
1334
- });
1335
- }
1336
-
1337
- return path;
1338
- },
1339
- 'bpmn:Association': function(parentGfx, element, attrs) {
1340
-
1341
- var semantic = getSemantic(element);
1342
-
1343
- var fill = getFillColor(element),
1344
- stroke = getStrokeColor(element);
1345
-
1346
- attrs = assign({
1347
- strokeDasharray: '0.5, 5',
1348
- strokeLinecap: 'round',
1349
- strokeLinejoin: 'round',
1350
- stroke: getStrokeColor(element)
1351
- }, attrs || {});
1352
-
1353
- if (semantic.associationDirection === 'One' ||
1354
- semantic.associationDirection === 'Both') {
1355
- attrs.markerEnd = marker('association-end', fill, stroke);
1356
- }
1357
-
1358
- if (semantic.associationDirection === 'Both') {
1359
- attrs.markerStart = marker('association-start', fill, stroke);
1360
- }
1361
-
1362
- return drawLine(parentGfx, element.waypoints, attrs);
1363
- },
1364
- 'bpmn:DataInputAssociation': function(parentGfx, element) {
1365
- var fill = getFillColor(element),
1366
- stroke = getStrokeColor(element);
1367
-
1368
- return renderer('bpmn:Association')(parentGfx, element, {
1369
- markerEnd: marker('association-end', fill, stroke)
1370
- });
1371
- },
1372
- 'bpmn:DataOutputAssociation': function(parentGfx, element) {
1373
- var fill = getFillColor(element),
1374
- stroke = getStrokeColor(element);
1375
-
1376
- return renderer('bpmn:Association')(parentGfx, element, {
1377
- markerEnd: marker('association-end', fill, stroke)
1378
- });
1379
- },
1380
- 'bpmn:MessageFlow': function(parentGfx, element) {
1381
-
1382
- var semantic = getSemantic(element),
1383
- di = getDi(element);
1384
-
1385
- var fill = getFillColor(element),
1386
- stroke = getStrokeColor(element);
1387
-
1388
- var pathData = createPathFromConnection(element);
1389
-
1390
- var attrs = {
1391
- markerEnd: marker('messageflow-end', fill, stroke),
1392
- markerStart: marker('messageflow-start', fill, stroke),
1393
- strokeDasharray: '10, 12',
1394
- strokeLinecap: 'round',
1395
- strokeLinejoin: 'round',
1396
- strokeWidth: '1.5px',
1397
- stroke: getStrokeColor(element)
1398
- };
1399
-
1400
- var path = drawPath(parentGfx, pathData, attrs);
1401
-
1402
- if (semantic.messageRef) {
1403
- var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
1404
-
1405
- var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
1406
- abspos: {
1407
- x: midPoint.x,
1408
- y: midPoint.y
1409
- }
1410
- });
1411
-
1412
- var messageAttrs = { strokeWidth: 1 };
1413
-
1414
- if (di.messageVisibleKind === 'initiating') {
1415
- messageAttrs.fill = 'white';
1416
- messageAttrs.stroke = 'black';
1417
- } else {
1418
- messageAttrs.fill = '#888';
1419
- messageAttrs.stroke = 'white';
1420
- }
1421
-
1422
- drawPath(parentGfx, markerPathData, messageAttrs);
1423
- }
1424
-
1425
- return path;
1426
- },
1427
- 'bpmn:DataObject': function(parentGfx, element) {
1428
- var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
1429
- xScaleFactor: 1,
1430
- yScaleFactor: 1,
1431
- containerWidth: element.width,
1432
- containerHeight: element.height,
1433
- position: {
1434
- mx: 0.474,
1435
- my: 0.296
1436
- }
1437
- });
1438
-
1439
- var elementObject = drawPath(parentGfx, pathData, {
1440
- fill: getFillColor(element),
1441
- stroke: getStrokeColor(element)
1442
- });
1443
-
1444
- var semantic = getSemantic(element);
1445
-
1446
- if (isCollection(semantic)) {
1447
- renderDataItemCollection(parentGfx, element);
1448
- }
1449
-
1450
- return elementObject;
1451
- },
1452
- 'bpmn:DataObjectReference': as('bpmn:DataObject'),
1453
- 'bpmn:DataInput': function(parentGfx, element) {
1454
-
1455
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1456
-
1457
- // page
1458
- var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
1459
-
1460
- /* input arrow path */ drawPath(parentGfx, arrowPathData, { strokeWidth: 1 });
1461
-
1462
- return elementObject;
1463
- },
1464
- 'bpmn:DataOutput': function(parentGfx, element) {
1465
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1466
-
1467
- // page
1468
- var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
1469
-
1470
- /* output arrow path */ drawPath(parentGfx, arrowPathData, {
1471
- strokeWidth: 1,
1472
- fill: 'black'
1473
- });
1474
-
1475
- return elementObject;
1476
- },
1477
- 'bpmn:DataStoreReference': function(parentGfx, element) {
1478
- var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
1479
- xScaleFactor: 1,
1480
- yScaleFactor: 1,
1481
- containerWidth: element.width,
1482
- containerHeight: element.height,
1483
- position: {
1484
- mx: 0,
1485
- my: 0.133
1486
- }
1487
- });
1488
-
1489
- var elementStore = drawPath(parentGfx, DATA_STORE_PATH, {
1490
- strokeWidth: 2,
1491
- fill: getFillColor(element),
1492
- stroke: getStrokeColor(element)
1493
- });
1494
-
1495
- return elementStore;
1496
- },
1497
- 'bpmn:BoundaryEvent': function(parentGfx, element) {
1498
-
1499
- var semantic = getSemantic(element),
1500
- cancel = semantic.cancelActivity;
1501
-
1502
- var attrs = {
1503
- strokeWidth: 1,
1504
- fill: getFillColor(element),
1505
- stroke: getStrokeColor(element)
1506
- };
1507
-
1508
- if (!cancel) {
1509
- attrs.strokeDasharray = '6';
1510
- attrs.strokeLinecap = 'round';
1511
- }
1512
-
1513
- var outer = renderer('bpmn:Event')(parentGfx, element, attrs);
1514
- /* inner path */ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, assign(attrs, { fill: 'none' }));
1515
-
1516
- renderEventContent(element, parentGfx);
1517
-
1518
- return outer;
1519
- },
1520
- 'bpmn:Group': function(parentGfx, element) {
1521
- return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, {
1522
- strokeWidth: 1,
1523
- strokeDasharray: '8,3,1,3',
1524
- fill: 'none',
1525
- pointerEvents: 'none'
1526
- });
1527
- },
1528
- 'label': function(parentGfx, element) {
1529
- return renderExternalLabel(parentGfx, element);
1530
- },
1531
- 'bpmn:TextAnnotation': function(parentGfx, element) {
1532
- var style = {
1533
- 'fill': 'none',
1534
- 'stroke': 'none'
1535
- };
1536
-
1537
- var textElement = drawRect(parentGfx, element.width, element.height, 0, 0, style);
1538
-
1539
- var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
1540
- xScaleFactor: 1,
1541
- yScaleFactor: 1,
1542
- containerWidth: element.width,
1543
- containerHeight: element.height,
1544
- position: {
1545
- mx: 0.0,
1546
- my: 0.0
1547
- }
1548
- });
1549
- drawPath(parentGfx, textPathData, {
1550
- stroke: getStrokeColor(element)
1551
- });
1552
-
1553
- var text = getSemantic(element).text || '';
1554
- renderLabel(parentGfx, text, { box: element, align: 'left-middle', padding: 5 });
1555
-
1556
- return textElement;
1557
- },
1558
- 'ParticipantMultiplicityMarker': function(parentGfx, element) {
1559
- var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
1560
- xScaleFactor: 1,
1561
- yScaleFactor: 1,
1562
- containerWidth: element.width,
1563
- containerHeight: element.height,
1564
- position: {
1565
- mx: ((element.width / 2) / element.width),
1566
- my: (element.height - 15) / element.height
1567
- }
1568
- });
1569
-
1570
- drawMarker('participant-multiplicity', parentGfx, markerPath);
1571
- },
1572
- 'SubProcessMarker': function(parentGfx, element) {
1573
- var markerRect = drawRect(parentGfx, 14, 14, 0, {
1574
- strokeWidth: 1,
1575
- fill: getFillColor(element),
1576
- stroke: getStrokeColor(element)
1577
- });
1578
-
1579
- // Process marker is placed in the middle of the box
1580
- // therefore fixed values can be used here
1581
- translate(markerRect, element.width / 2 - 7.5, element.height - 20);
1582
-
1583
- var markerPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
1584
- xScaleFactor: 1.5,
1585
- yScaleFactor: 1.5,
1586
- containerWidth: element.width,
1587
- containerHeight: element.height,
1588
- position: {
1589
- mx: (element.width / 2 - 7.5) / element.width,
1590
- my: (element.height - 20) / element.height
1591
- }
1592
- });
1593
-
1594
- drawMarker('sub-process', parentGfx, markerPath, {
1595
- fill: getFillColor(element),
1596
- stroke: getStrokeColor(element)
1597
- });
1598
- },
1599
- 'ParallelMarker': function(parentGfx, element, position) {
1600
- var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
1601
- xScaleFactor: 1,
1602
- yScaleFactor: 1,
1603
- containerWidth: element.width,
1604
- containerHeight: element.height,
1605
- position: {
1606
- mx: ((element.width / 2 + position.parallel) / element.width),
1607
- my: (element.height - 20) / element.height
1608
- }
1609
- });
1610
-
1611
- drawMarker('parallel', parentGfx, markerPath);
1612
- },
1613
- 'SequentialMarker': function(parentGfx, element, position) {
1614
- var markerPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
1615
- xScaleFactor: 1,
1616
- yScaleFactor: 1,
1617
- containerWidth: element.width,
1618
- containerHeight: element.height,
1619
- position: {
1620
- mx: ((element.width / 2 + position.seq) / element.width),
1621
- my: (element.height - 19) / element.height
1622
- }
1623
- });
1624
-
1625
- drawMarker('sequential', parentGfx, markerPath);
1626
- },
1627
- 'CompensationMarker': function(parentGfx, element, position) {
1628
- var markerMath = pathMap.getScaledPath('MARKER_COMPENSATION', {
1629
- xScaleFactor: 1,
1630
- yScaleFactor: 1,
1631
- containerWidth: element.width,
1632
- containerHeight: element.height,
1633
- position: {
1634
- mx: ((element.width / 2 + position.compensation) / element.width),
1635
- my: (element.height - 13) / element.height
1636
- }
1637
- });
1638
-
1639
- drawMarker('compensation', parentGfx, markerMath, { strokeWidth: 1 });
1640
- },
1641
- 'LoopMarker': function(parentGfx, element, position) {
1642
- var markerPath = pathMap.getScaledPath('MARKER_LOOP', {
1643
- xScaleFactor: 1,
1644
- yScaleFactor: 1,
1645
- containerWidth: element.width,
1646
- containerHeight: element.height,
1647
- position: {
1648
- mx: ((element.width / 2 + position.loop) / element.width),
1649
- my: (element.height - 7) / element.height
1650
- }
1651
- });
1652
-
1653
- drawMarker('loop', parentGfx, markerPath, {
1654
- strokeWidth: 1,
1655
- fill: 'none',
1656
- strokeLinecap: 'round',
1657
- strokeMiterlimit: 0.5
1658
- });
1659
- },
1660
- 'AdhocMarker': function(parentGfx, element, position) {
1661
- var markerPath = pathMap.getScaledPath('MARKER_ADHOC', {
1662
- xScaleFactor: 1,
1663
- yScaleFactor: 1,
1664
- containerWidth: element.width,
1665
- containerHeight: element.height,
1666
- position: {
1667
- mx: ((element.width / 2 + position.adhoc) / element.width),
1668
- my: (element.height - 15) / element.height
1669
- }
1670
- });
1671
-
1672
- drawMarker('adhoc', parentGfx, markerPath, {
1673
- strokeWidth: 1,
1674
- fill: 'black'
1675
- });
1676
- }
1677
- };
1678
-
1679
- function attachTaskMarkers(parentGfx, element, taskMarkers) {
1680
- var obj = getSemantic(element);
1681
-
1682
- var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1;
1683
- var position;
1684
-
1685
- if (subprocess) {
1686
- position = {
1687
- seq: -21,
1688
- parallel: -22,
1689
- compensation: -42,
1690
- loop: -18,
1691
- adhoc: 10
1692
- };
1693
- } else {
1694
- position = {
1695
- seq: -3,
1696
- parallel: -6,
1697
- compensation: -27,
1698
- loop: 0,
1699
- adhoc: 10
1700
- };
1701
- }
1702
-
1703
- forEach(taskMarkers, function(marker) {
1704
- renderer(marker)(parentGfx, element, position);
1705
- });
1706
-
1707
- if (obj.isForCompensation) {
1708
- renderer('CompensationMarker')(parentGfx, element, position);
1709
- }
1710
-
1711
- if (obj.$type === 'bpmn:AdHocSubProcess') {
1712
- renderer('AdhocMarker')(parentGfx, element, position);
1713
- }
1714
-
1715
- var loopCharacteristics = obj.loopCharacteristics,
1716
- isSequential = loopCharacteristics && loopCharacteristics.isSequential;
1717
-
1718
- if (loopCharacteristics) {
1719
-
1720
- if (isSequential === undefined) {
1721
- renderer('LoopMarker')(parentGfx, element, position);
1722
- }
1723
-
1724
- if (isSequential === false) {
1725
- renderer('ParallelMarker')(parentGfx, element, position);
1726
- }
1727
-
1728
- if (isSequential === true) {
1729
- renderer('SequentialMarker')(parentGfx, element, position);
1730
- }
1731
- }
1732
- }
1733
-
1734
- function renderDataItemCollection(parentGfx, element) {
1735
-
1736
- var yPosition = (element.height - 16) / element.height;
1737
-
1738
- var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
1739
- xScaleFactor: 1,
1740
- yScaleFactor: 1,
1741
- containerWidth: element.width,
1742
- containerHeight: element.height,
1743
- position: {
1744
- mx: 0.451,
1745
- my: yPosition
1746
- }
1747
- });
1748
-
1749
- /* collection path */ drawPath(parentGfx, pathData, {
1750
- strokeWidth: 2
1751
- });
1752
- }
1753
- }
1754
-
1755
-
1756
- inherits(BpmnRenderer, BaseRenderer);
1757
-
1758
- BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap', 'canvas' ];
1759
-
1760
- module.exports = BpmnRenderer;
1761
-
1762
-
1763
- BpmnRenderer.prototype.canRender = function(element) {
1764
- return is(element, 'bpmn:BaseElement');
1765
- };
1766
-
1767
- BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
1768
- var type = element.type;
1769
- var h = this.handlers[type];
1770
-
1771
- /* jshint -W040 */
1772
- return h(parentGfx, element);
1773
- };
1774
-
1775
- BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
1776
- var type = element.type;
1777
- var h = this.handlers[type];
1778
-
1779
- /* jshint -W040 */
1780
- return h(parentGfx, element);
1781
- };
1782
-
1783
- BpmnRenderer.prototype.getShapePath = function(element) {
1784
-
1785
- if (is(element, 'bpmn:Event')) {
1786
- return getCirclePath(element);
1787
- }
1788
-
1789
- if (is(element, 'bpmn:Activity')) {
1790
- return getRoundRectPath(element, TASK_BORDER_RADIUS);
1791
- }
1792
-
1793
- if (is(element, 'bpmn:Gateway')) {
1794
- return getDiamondPath(element);
1795
- }
1796
-
1797
- return getRectPath(element);
1798
- };
1799
-
1800
-
1801
- ///////// helper functions /////////////////////////////
1802
-
1803
- /**
1804
- * Checks if eventDefinition of the given element matches with semantic type.
1805
- *
1806
- * @return {boolean} true if element is of the given semantic type
1807
- */
1808
- function isTypedEvent(event, eventDefinitionType, filter) {
1809
-
1810
- function matches(definition, filter) {
1811
- return every(filter, function(val, key) {
1812
-
1813
- // we want a == conversion here, to be able to catch
1814
- // undefined == false and friends
1815
- /* jshint -W116 */
1816
- return definition[key] == val;
1817
- });
1818
- }
1819
-
1820
- return some(event.eventDefinitions, function(definition) {
1821
- return definition.$type === eventDefinitionType && matches(event, filter);
1822
- });
1823
- }
1824
-
1825
- function isThrowEvent(event) {
1826
- return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
1827
- }
1828
-
1829
- function isCollection(element) {
1830
- var dataObject = element.dataObjectRef;
1831
-
1832
- return element.isCollection || (dataObject && dataObject.isCollection);
1833
- }
1834
-
1835
- function getDi(element) {
1836
- return element.businessObject.di;
1837
- }
1838
-
1839
- function getSemantic(element) {
1840
- return element.businessObject;
1841
- }
1842
-
1843
-
1844
-
1845
- /////// cropping path customizations /////////////////////////
1846
-
1847
- function getCirclePath(shape) {
1848
-
1849
- var cx = shape.x + shape.width / 2,
1850
- cy = shape.y + shape.height / 2,
1851
- radius = shape.width / 2;
1852
-
1853
- var circlePath = [
1854
- ['M', cx, cy],
1855
- ['m', 0, -radius],
1856
- ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
1857
- ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
1858
- ['z']
1859
- ];
1860
-
1861
- return componentsToPath(circlePath);
1862
- }
1863
-
1864
- function getRoundRectPath(shape, borderRadius) {
1865
-
1866
- var x = shape.x,
1867
- y = shape.y,
1868
- width = shape.width,
1869
- height = shape.height;
1870
-
1871
- var roundRectPath = [
1872
- ['M', x + borderRadius, y],
1873
- ['l', width - borderRadius * 2, 0],
1874
- ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
1875
- ['l', 0, height - borderRadius * 2],
1876
- ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
1877
- ['l', borderRadius * 2 - width, 0],
1878
- ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
1879
- ['l', 0, borderRadius * 2 - height],
1880
- ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
1881
- ['z']
1882
- ];
1883
-
1884
- return componentsToPath(roundRectPath);
1885
- }
1886
-
1887
- function getDiamondPath(shape) {
1888
-
1889
- var width = shape.width,
1890
- height = shape.height,
1891
- x = shape.x,
1892
- y = shape.y,
1893
- halfWidth = width / 2,
1894
- halfHeight = height / 2;
1895
-
1896
- var diamondPath = [
1897
- ['M', x + halfWidth, y],
1898
- ['l', halfWidth, halfHeight],
1899
- ['l', -halfWidth, halfHeight],
1900
- ['l', -halfWidth, -halfHeight],
1901
- ['z']
1902
- ];
1903
-
1904
- return componentsToPath(diamondPath);
1905
- }
1906
-
1907
- function getRectPath(shape) {
1908
- var x = shape.x,
1909
- y = shape.y,
1910
- width = shape.width,
1911
- height = shape.height;
1912
-
1913
- var rectPath = [
1914
- ['M', x, y],
1915
- ['l', width, 0],
1916
- ['l', 0, height],
1917
- ['l', -width, 0],
1918
- ['z']
1919
- ];
1920
-
1921
- return componentsToPath(rectPath);
1922
- }
1923
-
1924
- function getFillColor(element, defaultColor) {
1925
- var bo = getBusinessObject(element);
1926
-
1927
- return bo.di.get('fill') || defaultColor || 'white';
1928
- }
1929
-
1930
- function getStrokeColor(element, defaultColor) {
1931
- var bo = getBusinessObject(element);
1932
-
1933
- return bo.di.get('stroke') || defaultColor || 'black';
1934
- }
1
+ 'use strict';
2
+
3
+ var inherits = require('inherits'),
4
+ isObject = require('lodash/lang/isObject'),
5
+ assign = require('lodash/object/assign'),
6
+ forEach = require('lodash/collection/forEach'),
7
+ every = require('lodash/collection/every'),
8
+ some = require('lodash/collection/some');
9
+
10
+ var BaseRenderer = require('diagram-js/lib/draw/BaseRenderer'),
11
+ TextUtil = require('diagram-js/lib/util/Text'),
12
+ DiUtil = require('../util/DiUtil');
13
+
14
+ var getBusinessObject = require('../util/ModelUtil').getBusinessObject,
15
+ is = require('../util/ModelUtil').is;
16
+
17
+ var RenderUtil = require('diagram-js/lib/util/RenderUtil');
18
+
19
+ var componentsToPath = RenderUtil.componentsToPath,
20
+ createLine = RenderUtil.createLine;
21
+
22
+ var domQuery = require('min-dom/lib/query');
23
+
24
+ var svgAppend = require('tiny-svg/lib/append'),
25
+ svgAttr = require('tiny-svg/lib/attr'),
26
+ svgCreate = require('tiny-svg/lib/create'),
27
+ svgClasses = require('tiny-svg/lib/classes');
28
+
29
+ var rotate = require('diagram-js/lib/util/SvgTransformUtil').rotate,
30
+ transform = require('diagram-js/lib/util/SvgTransformUtil').transform,
31
+ translate = require('diagram-js/lib/util/SvgTransformUtil').translate;
32
+
33
+ var TASK_BORDER_RADIUS = 10;
34
+ var INNER_OUTER_DIST = 3;
35
+
36
+ var LABEL_STYLE = {
37
+ fontFamily: 'Arial, sans-serif',
38
+ fontSize: 12
39
+ };
40
+
41
+
42
+ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
43
+
44
+ BaseRenderer.call(this, eventBus, priority);
45
+
46
+ var textUtil = new TextUtil({
47
+ style: LABEL_STYLE,
48
+ size: { width: 100 }
49
+ });
50
+
51
+ var markers = {};
52
+
53
+ var computeStyle = styles.computeStyle;
54
+
55
+ function addMarker(id, options) {
56
+ var attrs = assign({
57
+ fill: 'black',
58
+ strokeWidth: 1,
59
+ strokeLinecap: 'round',
60
+ strokeDasharray: 'none'
61
+ }, options.attrs);
62
+
63
+ var ref = options.ref || { x: 0, y: 0 };
64
+
65
+ var scale = options.scale || 1;
66
+
67
+ // fix for safari / chrome / firefox bug not correctly
68
+ // resetting stroke dash array
69
+ if (attrs.strokeDasharray === 'none') {
70
+ attrs.strokeDasharray = [10000, 1];
71
+ }
72
+
73
+ var marker = svgCreate('marker');
74
+
75
+ svgAttr(options.element, attrs);
76
+
77
+ svgAppend(marker, options.element);
78
+
79
+ svgAttr(marker, {
80
+ id: id,
81
+ viewBox: '0 0 20 20',
82
+ refX: ref.x,
83
+ refY: ref.y,
84
+ markerWidth: 20 * scale,
85
+ markerHeight: 20 * scale,
86
+ orient: 'auto'
87
+ });
88
+
89
+ var defs = domQuery('defs', canvas._svg);
90
+
91
+ if (!defs) {
92
+ defs = svgCreate('defs');
93
+
94
+ svgAppend(canvas._svg, defs);
95
+ }
96
+
97
+ svgAppend(defs, marker);
98
+
99
+ markers[id] = marker;
100
+ }
101
+
102
+ function marker(type, fill, stroke) {
103
+ var id = type + '-' + fill + '-' + stroke;
104
+
105
+ if (!markers[id]) {
106
+ createMarker(type, fill, stroke);
107
+ }
108
+
109
+ return 'url(#' + id + ')';
110
+ }
111
+
112
+ function createMarker(type, fill, stroke) {
113
+ var id = type + '-' + fill + '-' + stroke;
114
+
115
+ if (type === 'sequenceflow-end') {
116
+ var sequenceflowEnd = svgCreate('path');
117
+ svgAttr(sequenceflowEnd, { d: 'M 1 5 L 11 10 L 1 15 Z' });
118
+
119
+ addMarker(id, {
120
+ element: sequenceflowEnd,
121
+ ref: { x: 11, y: 10 },
122
+ scale: 0.5,
123
+ attrs: {
124
+ fill: stroke,
125
+ stroke: stroke
126
+ }
127
+ });
128
+ }
129
+
130
+ if (type === 'messageflow-start') {
131
+ var messageflowStart = svgCreate('circle');
132
+ svgAttr(messageflowStart, { cx: 6, cy: 6, r: 3.5 });
133
+
134
+ addMarker(id, {
135
+ element: messageflowStart,
136
+ attrs: {
137
+ fill: fill,
138
+ stroke: stroke
139
+ },
140
+ ref: { x: 6, y: 6 }
141
+ });
142
+ }
143
+
144
+ if (type === 'messageflow-end') {
145
+ var messageflowEnd = svgCreate('path');
146
+ svgAttr(messageflowEnd, { d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z' });
147
+
148
+ addMarker(id, {
149
+ element: messageflowEnd,
150
+ attrs: {
151
+ fill: fill,
152
+ stroke: stroke,
153
+ strokeLinecap: 'butt'
154
+ },
155
+ ref: { x: 8.5, y: 5 }
156
+ });
157
+ }
158
+
159
+ if (type === 'association-start') {
160
+ var associationStart = svgCreate('path');
161
+ svgAttr(associationStart, { d: 'M 11 5 L 1 10 L 11 15' });
162
+
163
+ addMarker(id, {
164
+ element: associationStart,
165
+ attrs: {
166
+ fill: 'none',
167
+ stroke: stroke,
168
+ strokeWidth: 1.5
169
+ },
170
+ ref: { x: 1, y: 10 },
171
+ scale: 0.5
172
+ });
173
+ }
174
+
175
+ if (type === 'association-end') {
176
+ var associationEnd = svgCreate('path');
177
+ svgAttr(associationEnd, { d: 'M 1 5 L 11 10 L 1 15' });
178
+
179
+ addMarker(id, {
180
+ element: associationEnd,
181
+ attrs: {
182
+ fill: 'none',
183
+ stroke: stroke,
184
+ strokeWidth: 1.5
185
+ },
186
+ ref: { x: 12, y: 10 },
187
+ scale: 0.5
188
+ });
189
+ }
190
+
191
+ if (type === 'conditional-flow-marker') {
192
+ var conditionalflowMarker = svgCreate('path');
193
+ svgAttr(conditionalflowMarker, { d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z' });
194
+
195
+ addMarker(id, {
196
+ element: conditionalflowMarker,
197
+ attrs: {
198
+ fill: fill,
199
+ stroke: stroke
200
+ },
201
+ ref: { x: -1, y: 10 },
202
+ scale: 0.5
203
+ });
204
+ }
205
+
206
+ if (type === 'conditional-default-flow-marker') {
207
+ var conditionaldefaultflowMarker = svgCreate('path');
208
+ svgAttr(conditionaldefaultflowMarker, { d: 'M 6 4 L 10 16' });
209
+
210
+ addMarker(id, {
211
+ element: conditionaldefaultflowMarker,
212
+ attrs: {
213
+ stroke: stroke
214
+ },
215
+ ref: { x: 0, y: 10 },
216
+ scale: 0.5
217
+ });
218
+ }
219
+ }
220
+
221
+ function drawCircle(parentGfx, width, height, offset, attrs) {
222
+
223
+ if (isObject(offset)) {
224
+ attrs = offset;
225
+ offset = 0;
226
+ }
227
+
228
+ offset = offset || 0;
229
+
230
+ attrs = computeStyle(attrs, {
231
+ stroke: 'black',
232
+ strokeWidth: 2,
233
+ fill: 'white'
234
+ });
235
+
236
+ var cx = width / 2,
237
+ cy = height / 2;
238
+
239
+ var circle = svgCreate('circle');
240
+ svgAttr(circle, {
241
+ cx: cx,
242
+ cy: cy,
243
+ r: Math.round((width + height) / 4 - offset)
244
+ });
245
+ svgAttr(circle, attrs);
246
+
247
+ svgAppend(parentGfx, circle);
248
+
249
+ return circle;
250
+ }
251
+
252
+ function drawRect(parentGfx, width, height, r, offset, attrs) {
253
+
254
+ if (isObject(offset)) {
255
+ attrs = offset;
256
+ offset = 0;
257
+ }
258
+
259
+ offset = offset || 0;
260
+
261
+ attrs = computeStyle(attrs, {
262
+ stroke: 'black',
263
+ strokeWidth: 2,
264
+ fill: 'white'
265
+ });
266
+
267
+ var rect = svgCreate('rect');
268
+ svgAttr(rect, {
269
+ x: offset,
270
+ y: offset,
271
+ width: width - offset * 2,
272
+ height: height - offset * 2,
273
+ rx: r,
274
+ ry: r
275
+ });
276
+ svgAttr(rect, attrs);
277
+
278
+ svgAppend(parentGfx, rect);
279
+
280
+ return rect;
281
+ }
282
+
283
+ function drawDiamond(parentGfx, width, height, attrs) {
284
+
285
+ var x_2 = width / 2;
286
+ var y_2 = height / 2;
287
+
288
+ var points = [{ x: x_2, y: 0 }, { x: width, y: y_2 }, { x: x_2, y: height }, { x: 0, y: y_2 }];
289
+
290
+ var pointsString = points.map(function(point) {
291
+ return point.x + ',' + point.y;
292
+ }).join(' ');
293
+
294
+ attrs = computeStyle(attrs, {
295
+ stroke: 'black',
296
+ strokeWidth: 2,
297
+ fill: 'white'
298
+ });
299
+
300
+ var polygon = svgCreate('polygon');
301
+ svgAttr(polygon, {
302
+ points: pointsString
303
+ });
304
+ svgAttr(polygon, attrs);
305
+
306
+ svgAppend(parentGfx, polygon);
307
+
308
+ return polygon;
309
+ }
310
+
311
+ function drawLine(parentGfx, waypoints, attrs) {
312
+ attrs = computeStyle(attrs, [ 'no-fill' ], {
313
+ stroke: 'black',
314
+ strokeWidth: 2,
315
+ fill: 'none'
316
+ });
317
+
318
+ var line = createLine(waypoints, attrs);
319
+
320
+ svgAppend(parentGfx, line);
321
+
322
+ return line;
323
+ }
324
+
325
+ function drawPath(parentGfx, d, attrs) {
326
+
327
+ attrs = computeStyle(attrs, [ 'no-fill' ], {
328
+ strokeWidth: 2,
329
+ stroke: 'black'
330
+ });
331
+
332
+ var path = svgCreate('path');
333
+ svgAttr(path, { d: d });
334
+ svgAttr(path, attrs);
335
+
336
+ svgAppend(parentGfx, path);
337
+
338
+ return path;
339
+ }
340
+
341
+ function drawMarker(type, parentGfx, path, attrs) {
342
+ return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
343
+ }
344
+
345
+ function as(type) {
346
+ return function(parentGfx, element) {
347
+ return handlers[type](parentGfx, element);
348
+ };
349
+ }
350
+
351
+ function renderer(type) {
352
+ return handlers[type];
353
+ }
354
+
355
+ function renderEventContent(element, parentGfx) {
356
+
357
+ var event = getSemantic(element);
358
+ var isThrowing = isThrowEvent(event);
359
+
360
+ if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
361
+ return renderer('bpmn:MessageEventDefinition')(parentGfx, element, isThrowing);
362
+ }
363
+
364
+ if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
365
+ return renderer('bpmn:TimerEventDefinition')(parentGfx, element, isThrowing);
366
+ }
367
+
368
+ if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
369
+ return renderer('bpmn:ConditionalEventDefinition')(parentGfx, element);
370
+ }
371
+
372
+ if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
373
+ return renderer('bpmn:SignalEventDefinition')(parentGfx, element, isThrowing);
374
+ }
375
+
376
+ if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
377
+ isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
378
+ return renderer('bpmn:MultipleEventDefinition')(parentGfx, element, isThrowing);
379
+ }
380
+
381
+ if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
382
+ isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
383
+ return renderer('bpmn:ParallelMultipleEventDefinition')(parentGfx, element, isThrowing);
384
+ }
385
+
386
+ if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
387
+ return renderer('bpmn:EscalationEventDefinition')(parentGfx, element, isThrowing);
388
+ }
389
+
390
+ if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
391
+ return renderer('bpmn:LinkEventDefinition')(parentGfx, element, isThrowing);
392
+ }
393
+
394
+ if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
395
+ return renderer('bpmn:ErrorEventDefinition')(parentGfx, element, isThrowing);
396
+ }
397
+
398
+ if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
399
+ return renderer('bpmn:CancelEventDefinition')(parentGfx, element, isThrowing);
400
+ }
401
+
402
+ if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
403
+ return renderer('bpmn:CompensateEventDefinition')(parentGfx, element, isThrowing);
404
+ }
405
+
406
+ if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
407
+ return renderer('bpmn:TerminateEventDefinition')(parentGfx, element, isThrowing);
408
+ }
409
+
410
+ return null;
411
+ }
412
+
413
+ function renderLabel(parentGfx, label, options) {
414
+ var text = textUtil.createText(label || '', options);
415
+ svgClasses(text).add('djs-label');
416
+ svgAppend(parentGfx, text);
417
+
418
+ return text;
419
+ }
420
+
421
+ function renderEmbeddedLabel(parentGfx, element, align) {
422
+ var semantic = getSemantic(element);
423
+
424
+ return renderLabel(parentGfx, semantic.name, {
425
+ box: element,
426
+ align: align,
427
+ padding: 5,
428
+ style: {
429
+ fill: getStrokeColor(element)
430
+ }
431
+ });
432
+ }
433
+
434
+ function renderExternalLabel(parentGfx, element) {
435
+ var semantic = getSemantic(element);
436
+ var box = {
437
+ width: 90,
438
+ height: 30,
439
+ x: element.width / 2 + element.x,
440
+ y: element.height / 2 + element.y
441
+ };
442
+
443
+ return renderLabel(parentGfx, semantic.name, {
444
+ box: box,
445
+ fitBox: true,
446
+ style: { fontSize: '11px' }
447
+ });
448
+ }
449
+
450
+ function renderLaneLabel(parentGfx, text, element) {
451
+ var textBox = renderLabel(parentGfx, text, {
452
+ box: { height: 30, width: element.height },
453
+ align: 'center-middle',
454
+ style: {
455
+ fill: getStrokeColor(element)
456
+ }
457
+ });
458
+
459
+ var top = -1 * element.height;
460
+
461
+ transform(textBox, 0, -top, 270);
462
+ }
463
+
464
+ function createPathFromConnection(connection) {
465
+ var waypoints = connection.waypoints;
466
+
467
+ var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
468
+ for (var i = 1; i < waypoints.length; i++) {
469
+ pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
470
+ }
471
+ return pathData;
472
+ }
473
+
474
+ var handlers = this.handlers = {
475
+ 'bpmn:Event': function(parentGfx, element, attrs) {
476
+ return drawCircle(parentGfx, element.width, element.height, attrs);
477
+ },
478
+ 'bpmn:StartEvent': function(parentGfx, element) {
479
+ var attrs = {
480
+ fill: getFillColor(element),
481
+ stroke: getStrokeColor(element)
482
+ };
483
+
484
+ var semantic = getSemantic(element);
485
+
486
+ if (!semantic.isInterrupting) {
487
+ attrs = {
488
+ strokeDasharray: '6',
489
+ strokeLinecap: 'round'
490
+ };
491
+ }
492
+
493
+ var circle = renderer('bpmn:Event')(parentGfx, element, attrs);
494
+
495
+ renderEventContent(element, parentGfx);
496
+
497
+ return circle;
498
+ },
499
+ 'bpmn:MessageEventDefinition': function(parentGfx, element, isThrowing) {
500
+ var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
501
+ xScaleFactor: 0.9,
502
+ yScaleFactor: 0.9,
503
+ containerWidth: element.width,
504
+ containerHeight: element.height,
505
+ position: {
506
+ mx: 0.235,
507
+ my: 0.315
508
+ }
509
+ });
510
+
511
+ var fill = isThrowing ? getStrokeColor(element) : getFillColor(element);
512
+ var stroke = isThrowing ? getFillColor(element) : getStrokeColor(element);
513
+
514
+ var messagePath = drawPath(parentGfx, pathData, {
515
+ strokeWidth: 1,
516
+ fill: fill,
517
+ stroke: stroke
518
+ });
519
+
520
+ return messagePath;
521
+ },
522
+ 'bpmn:TimerEventDefinition': function(parentGfx, element) {
523
+ var circle = drawCircle(parentGfx, element.width, element.height, 0.2 * element.height, {
524
+ strokeWidth: 2,
525
+ fill: getFillColor(element),
526
+ stroke: getStrokeColor(element)
527
+ });
528
+
529
+ var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
530
+ xScaleFactor: 0.75,
531
+ yScaleFactor: 0.75,
532
+ containerWidth: element.width,
533
+ containerHeight: element.height,
534
+ position: {
535
+ mx: 0.5,
536
+ my: 0.5
537
+ }
538
+ });
539
+
540
+ drawPath(parentGfx, pathData, {
541
+ strokeWidth: 2,
542
+ strokeLinecap: 'square',
543
+ stroke: getStrokeColor(element)
544
+ });
545
+
546
+ for (var i = 0;i < 12;i++) {
547
+
548
+ var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
549
+ xScaleFactor: 0.75,
550
+ yScaleFactor: 0.75,
551
+ containerWidth: element.width,
552
+ containerHeight: element.height,
553
+ position: {
554
+ mx: 0.5,
555
+ my: 0.5
556
+ }
557
+ });
558
+
559
+ var width = element.width / 2;
560
+ var height = element.height / 2;
561
+
562
+ drawPath(parentGfx, linePathData, {
563
+ strokeWidth: 1,
564
+ strokeLinecap: 'square',
565
+ transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')',
566
+ stroke: getStrokeColor(element)
567
+ });
568
+ }
569
+
570
+ return circle;
571
+ },
572
+ 'bpmn:EscalationEventDefinition': function(parentGfx, event, isThrowing) {
573
+ var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
574
+ xScaleFactor: 1,
575
+ yScaleFactor: 1,
576
+ containerWidth: event.width,
577
+ containerHeight: event.height,
578
+ position: {
579
+ mx: 0.5,
580
+ my: 0.2
581
+ }
582
+ });
583
+
584
+ var fill = isThrowing ? getStrokeColor(event) : 'none';
585
+
586
+ return drawPath(parentGfx, pathData, {
587
+ strokeWidth: 1,
588
+ fill: fill,
589
+ stroke: getStrokeColor(event)
590
+ });
591
+ },
592
+ 'bpmn:ConditionalEventDefinition': function(parentGfx, event) {
593
+ var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
594
+ xScaleFactor: 1,
595
+ yScaleFactor: 1,
596
+ containerWidth: event.width,
597
+ containerHeight: event.height,
598
+ position: {
599
+ mx: 0.5,
600
+ my: 0.222
601
+ }
602
+ });
603
+
604
+ return drawPath(parentGfx, pathData, {
605
+ strokeWidth: 1,
606
+ stroke: getStrokeColor(event)
607
+ });
608
+ },
609
+ 'bpmn:LinkEventDefinition': function(parentGfx, event, isThrowing) {
610
+ var pathData = pathMap.getScaledPath('EVENT_LINK', {
611
+ xScaleFactor: 1,
612
+ yScaleFactor: 1,
613
+ containerWidth: event.width,
614
+ containerHeight: event.height,
615
+ position: {
616
+ mx: 0.57,
617
+ my: 0.263
618
+ }
619
+ });
620
+
621
+ var fill = isThrowing ? getStrokeColor(event) : 'none';
622
+
623
+ return drawPath(parentGfx, pathData, {
624
+ strokeWidth: 1,
625
+ fill: fill,
626
+ stroke: getStrokeColor(event)
627
+ });
628
+ },
629
+ 'bpmn:ErrorEventDefinition': function(parentGfx, event, isThrowing) {
630
+ var pathData = pathMap.getScaledPath('EVENT_ERROR', {
631
+ xScaleFactor: 1.1,
632
+ yScaleFactor: 1.1,
633
+ containerWidth: event.width,
634
+ containerHeight: event.height,
635
+ position: {
636
+ mx: 0.2,
637
+ my: 0.722
638
+ }
639
+ });
640
+
641
+ var fill = isThrowing ? getStrokeColor(event) : 'none';
642
+
643
+ return drawPath(parentGfx, pathData, {
644
+ strokeWidth: 1,
645
+ fill: fill,
646
+ stroke: getStrokeColor(event)
647
+ });
648
+ },
649
+ 'bpmn:CancelEventDefinition': function(parentGfx, event, isThrowing) {
650
+ var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
651
+ xScaleFactor: 1.0,
652
+ yScaleFactor: 1.0,
653
+ containerWidth: event.width,
654
+ containerHeight: event.height,
655
+ position: {
656
+ mx: 0.638,
657
+ my: -0.055
658
+ }
659
+ });
660
+
661
+ var fill = isThrowing ? 'black' : 'none';
662
+
663
+ var path = drawPath(parentGfx, pathData, {
664
+ strokeWidth: 1,
665
+ fill: fill
666
+ });
667
+
668
+ rotate(path, 45);
669
+
670
+ return path;
671
+ },
672
+ 'bpmn:CompensateEventDefinition': function(parentGfx, event, isThrowing) {
673
+ var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
674
+ xScaleFactor: 1,
675
+ yScaleFactor: 1,
676
+ containerWidth: event.width,
677
+ containerHeight: event.height,
678
+ position: {
679
+ mx: 0.22,
680
+ my: 0.5
681
+ }
682
+ });
683
+
684
+ var fill = isThrowing ? getStrokeColor(event) : 'none';
685
+
686
+ return drawPath(parentGfx, pathData, {
687
+ strokeWidth: 1,
688
+ fill: fill,
689
+ stroke: getStrokeColor(event)
690
+ });
691
+ },
692
+ 'bpmn:SignalEventDefinition': function(parentGfx, event, isThrowing) {
693
+ var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
694
+ xScaleFactor: 0.9,
695
+ yScaleFactor: 0.9,
696
+ containerWidth: event.width,
697
+ containerHeight: event.height,
698
+ position: {
699
+ mx: 0.5,
700
+ my: 0.2
701
+ }
702
+ });
703
+
704
+ var fill = isThrowing ? getStrokeColor(event) : 'none';
705
+
706
+ return drawPath(parentGfx, pathData, {
707
+ strokeWidth: 1,
708
+ fill: fill,
709
+ stroke: getStrokeColor(event)
710
+ });
711
+ },
712
+ 'bpmn:MultipleEventDefinition': function(parentGfx, event, isThrowing) {
713
+ var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
714
+ xScaleFactor: 1.1,
715
+ yScaleFactor: 1.1,
716
+ containerWidth: event.width,
717
+ containerHeight: event.height,
718
+ position: {
719
+ mx: 0.222,
720
+ my: 0.36
721
+ }
722
+ });
723
+
724
+ var fill = isThrowing ? 'black' : 'none';
725
+
726
+ return drawPath(parentGfx, pathData, {
727
+ strokeWidth: 1,
728
+ fill: fill
729
+ });
730
+ },
731
+ 'bpmn:ParallelMultipleEventDefinition': function(parentGfx, event) {
732
+ var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
733
+ xScaleFactor: 1.2,
734
+ yScaleFactor: 1.2,
735
+ containerWidth: event.width,
736
+ containerHeight: event.height,
737
+ position: {
738
+ mx: 0.458,
739
+ my: 0.194
740
+ }
741
+ });
742
+
743
+ return drawPath(parentGfx, pathData, {
744
+ strokeWidth: 1,
745
+ fill: getStrokeColor(event),
746
+ stroke: getStrokeColor(event)
747
+ });
748
+ },
749
+ 'bpmn:EndEvent': function(parentGfx, element) {
750
+ var circle = renderer('bpmn:Event')(parentGfx, element, {
751
+ strokeWidth: 4,
752
+ fill: getFillColor(element),
753
+ stroke: getStrokeColor(element)
754
+ });
755
+
756
+ renderEventContent(element, parentGfx, true);
757
+
758
+ return circle;
759
+ },
760
+ 'bpmn:TerminateEventDefinition': function(parentGfx, element) {
761
+ var circle = drawCircle(parentGfx, element.width, element.height, 8, {
762
+ strokeWidth: 4,
763
+ fill: getStrokeColor(element),
764
+ stroke: getStrokeColor(element)
765
+ });
766
+
767
+ return circle;
768
+ },
769
+ 'bpmn:IntermediateEvent': function(parentGfx, element) {
770
+ var outer = renderer('bpmn:Event')(parentGfx, element, {
771
+ strokeWidth: 1,
772
+ fill: getFillColor(element),
773
+ stroke: getStrokeColor(element)
774
+ });
775
+
776
+ /* inner */ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, {
777
+ strokeWidth: 1,
778
+ fill: getFillColor(element, 'none'),
779
+ stroke: getStrokeColor(element)
780
+ });
781
+
782
+ renderEventContent(element, parentGfx);
783
+
784
+ return outer;
785
+ },
786
+ 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
787
+ 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
788
+
789
+ 'bpmn:Activity': function(parentGfx, element, attrs) {
790
+ return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, attrs);
791
+ },
792
+
793
+ 'bpmn:Task': function(parentGfx, element) {
794
+ var attrs = {
795
+ fill: getFillColor(element),
796
+ stroke: getStrokeColor(element)
797
+ };
798
+
799
+ var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
800
+
801
+ renderEmbeddedLabel(parentGfx, element, 'center-middle');
802
+ attachTaskMarkers(parentGfx, element);
803
+
804
+ return rect;
805
+ },
806
+ 'bpmn:ServiceTask': function(parentGfx, element) {
807
+ var task = renderer('bpmn:Task')(parentGfx, element);
808
+
809
+ var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
810
+ abspos: {
811
+ x: 12,
812
+ y: 18
813
+ }
814
+ });
815
+
816
+ /* service bg */ drawPath(parentGfx, pathDataBG, {
817
+ strokeWidth: 1,
818
+ fill: getFillColor(element),
819
+ stroke: getStrokeColor(element)
820
+ });
821
+
822
+ var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
823
+ abspos: {
824
+ x: 17.2,
825
+ y: 18
826
+ }
827
+ });
828
+
829
+ /* service fill */ drawPath(parentGfx, fillPathData, {
830
+ strokeWidth: 0,
831
+ fill: getFillColor(element)
832
+ });
833
+
834
+ var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
835
+ abspos: {
836
+ x: 17,
837
+ y: 22
838
+ }
839
+ });
840
+
841
+ /* service */ drawPath(parentGfx, pathData, {
842
+ strokeWidth: 1,
843
+ fill: getFillColor(element),
844
+ stroke: getStrokeColor(element)
845
+ });
846
+
847
+ return task;
848
+ },
849
+ 'bpmn:UserTask': function(parentGfx, element) {
850
+ var task = renderer('bpmn:Task')(parentGfx, element);
851
+
852
+ var x = 15;
853
+ var y = 12;
854
+
855
+ var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
856
+ abspos: {
857
+ x: x,
858
+ y: y
859
+ }
860
+ });
861
+
862
+ /* user path */ drawPath(parentGfx, pathData, {
863
+ strokeWidth: 0.5,
864
+ fill: getFillColor(element),
865
+ stroke: getStrokeColor(element)
866
+ });
867
+
868
+ var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
869
+ abspos: {
870
+ x: x,
871
+ y: y
872
+ }
873
+ });
874
+
875
+ /* user2 path */ drawPath(parentGfx, pathData2, {
876
+ strokeWidth: 0.5,
877
+ fill: getFillColor(element),
878
+ stroke: getStrokeColor(element)
879
+ });
880
+
881
+ var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
882
+ abspos: {
883
+ x: x,
884
+ y: y
885
+ }
886
+ });
887
+
888
+ /* user3 path */ drawPath(parentGfx, pathData3, {
889
+ strokeWidth: 0.5,
890
+ fill: getStrokeColor(element),
891
+ stroke: getStrokeColor(element)
892
+ });
893
+
894
+ return task;
895
+ },
896
+ 'bpmn:ManualTask': function(parentGfx, element) {
897
+ var task = renderer('bpmn:Task')(parentGfx, element);
898
+
899
+ var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
900
+ abspos: {
901
+ x: 17,
902
+ y: 15
903
+ }
904
+ });
905
+
906
+ /* manual path */ drawPath(parentGfx, pathData, {
907
+ strokeWidth: 0.5, // 0.25,
908
+ fill: getFillColor(element),
909
+ stroke: getStrokeColor(element)
910
+ });
911
+
912
+ return task;
913
+ },
914
+ 'bpmn:SendTask': function(parentGfx, element) {
915
+ var task = renderer('bpmn:Task')(parentGfx, element);
916
+
917
+ var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
918
+ xScaleFactor: 1,
919
+ yScaleFactor: 1,
920
+ containerWidth: 21,
921
+ containerHeight: 14,
922
+ position: {
923
+ mx: 0.285,
924
+ my: 0.357
925
+ }
926
+ });
927
+
928
+ /* send path */ drawPath(parentGfx, pathData, {
929
+ strokeWidth: 1,
930
+ fill: getStrokeColor(element),
931
+ stroke: getFillColor(element)
932
+ });
933
+
934
+ return task;
935
+ },
936
+ 'bpmn:ReceiveTask' : function(parentGfx, element) {
937
+ var semantic = getSemantic(element);
938
+
939
+ var task = renderer('bpmn:Task')(parentGfx, element);
940
+ var pathData;
941
+
942
+ if (semantic.instantiate) {
943
+ drawCircle(parentGfx, 28, 28, 20 * 0.22, { strokeWidth: 1 });
944
+
945
+ pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
946
+ abspos: {
947
+ x: 7.77,
948
+ y: 9.52
949
+ }
950
+ });
951
+ } else {
952
+
953
+ pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
954
+ xScaleFactor: 0.9,
955
+ yScaleFactor: 0.9,
956
+ containerWidth: 21,
957
+ containerHeight: 14,
958
+ position: {
959
+ mx: 0.3,
960
+ my: 0.4
961
+ }
962
+ });
963
+ }
964
+
965
+ /* receive path */ drawPath(parentGfx, pathData, {
966
+ strokeWidth: 1,
967
+ fill: getFillColor(element),
968
+ stroke: getStrokeColor(element)
969
+ });
970
+
971
+ return task;
972
+ },
973
+ 'bpmn:ScriptTask': function(parentGfx, element) {
974
+ var task = renderer('bpmn:Task')(parentGfx, element);
975
+
976
+ var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
977
+ abspos: {
978
+ x: 15,
979
+ y: 20
980
+ }
981
+ });
982
+
983
+ /* script path */ drawPath(parentGfx, pathData, {
984
+ strokeWidth: 1,
985
+ stroke: getStrokeColor(element)
986
+ });
987
+
988
+ return task;
989
+ },
990
+ 'bpmn:BusinessRuleTask': function(parentGfx, element) {
991
+ var task = renderer('bpmn:Task')(parentGfx, element);
992
+
993
+ var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
994
+ abspos: {
995
+ x: 8,
996
+ y: 8
997
+ }
998
+ });
999
+
1000
+ var businessHeaderPath = drawPath(parentGfx, headerPathData);
1001
+ svgAttr(businessHeaderPath, {
1002
+ strokeWidth: 1,
1003
+ fill: getFillColor(element, '#aaaaaa'),
1004
+ stroke: getStrokeColor(element)
1005
+ });
1006
+
1007
+ var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
1008
+ abspos: {
1009
+ x: 8,
1010
+ y: 8
1011
+ }
1012
+ });
1013
+
1014
+ var businessPath = drawPath(parentGfx, headerData);
1015
+ svgAttr(businessPath, {
1016
+ strokeWidth: 1,
1017
+ stroke: getStrokeColor(element)
1018
+ });
1019
+
1020
+ return task;
1021
+ },
1022
+ 'bpmn:SubProcess': function(parentGfx, element, attrs) {
1023
+ attrs = assign({
1024
+ fillOpacity: 0.95,
1025
+ fill: getFillColor(element),
1026
+ stroke: getStrokeColor(element)
1027
+ }, attrs);
1028
+
1029
+ var rect = renderer('bpmn:Activity')(parentGfx, element, attrs);
1030
+
1031
+ var expanded = DiUtil.isExpanded(element);
1032
+
1033
+ var isEventSubProcess = DiUtil.isEventSubProcess(element);
1034
+
1035
+ if (isEventSubProcess) {
1036
+ svgAttr(rect, {
1037
+ strokeDasharray: '1,2'
1038
+ });
1039
+ }
1040
+
1041
+ renderEmbeddedLabel(parentGfx, element, expanded ? 'center-top' : 'center-middle');
1042
+
1043
+ if (expanded) {
1044
+ attachTaskMarkers(parentGfx, element);
1045
+ } else {
1046
+ attachTaskMarkers(parentGfx, element, ['SubProcessMarker']);
1047
+ }
1048
+
1049
+ return rect;
1050
+ },
1051
+ 'bpmn:AdHocSubProcess': function(parentGfx, element) {
1052
+ return renderer('bpmn:SubProcess')(parentGfx, element);
1053
+ },
1054
+ 'bpmn:Transaction': function(parentGfx, element) {
1055
+ var outer = renderer('bpmn:SubProcess')(parentGfx, element);
1056
+
1057
+ var innerAttrs = styles.style([ 'no-fill', 'no-events' ], {
1058
+ stroke: getStrokeColor(element)
1059
+ });
1060
+
1061
+ /* inner path */ drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
1062
+
1063
+ return outer;
1064
+ },
1065
+ 'bpmn:CallActivity': function(parentGfx, element) {
1066
+ return renderer('bpmn:SubProcess')(parentGfx, element, {
1067
+ strokeWidth: 5
1068
+ });
1069
+ },
1070
+ 'bpmn:Participant': function(parentGfx, element) {
1071
+
1072
+ var attrs = {
1073
+ fillOpacity: 0.95,
1074
+ fill: getFillColor(element),
1075
+ stroke: getStrokeColor(element)
1076
+ };
1077
+
1078
+ var lane = renderer('bpmn:Lane')(parentGfx, element, attrs);
1079
+
1080
+ var expandedPool = DiUtil.isExpanded(element);
1081
+
1082
+ if (expandedPool) {
1083
+ drawLine(parentGfx, [
1084
+ { x: 30, y: 0 },
1085
+ { x: 30, y: element.height }
1086
+ ], {
1087
+ stroke: getStrokeColor(element)
1088
+ });
1089
+ var text = getSemantic(element).name;
1090
+ renderLaneLabel(parentGfx, text, element);
1091
+ } else {
1092
+ // Collapsed pool draw text inline
1093
+ var text2 = getSemantic(element).name;
1094
+ renderLabel(parentGfx, text2, {
1095
+ box: element, align: 'center-middle',
1096
+ style: {
1097
+ fill: getStrokeColor(element)
1098
+ }
1099
+ });
1100
+ }
1101
+
1102
+ var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
1103
+
1104
+ if (participantMultiplicity) {
1105
+ renderer('ParticipantMultiplicityMarker')(parentGfx, element);
1106
+ }
1107
+
1108
+ return lane;
1109
+ },
1110
+ 'bpmn:Lane': function(parentGfx, element, attrs) {
1111
+ var rect = drawRect(parentGfx, element.width, element.height, 0, assign({
1112
+ fill: getFillColor(element),
1113
+ stroke: getStrokeColor(element)
1114
+ }, attrs));
1115
+
1116
+ var semantic = getSemantic(element);
1117
+
1118
+ if (semantic.$type === 'bpmn:Lane') {
1119
+ var text = semantic.name;
1120
+ renderLaneLabel(parentGfx, text, element);
1121
+ }
1122
+
1123
+ return rect;
1124
+ },
1125
+ 'bpmn:InclusiveGateway': function(parentGfx, element) {
1126
+ var attrs = {
1127
+ fill: getFillColor(element),
1128
+ stroke: getStrokeColor(element)
1129
+ };
1130
+
1131
+ var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1132
+
1133
+ /* circle path */
1134
+ drawCircle(parentGfx, element.width, element.height, element.height * 0.24, {
1135
+ strokeWidth: 2.5,
1136
+ fill: getFillColor(element),
1137
+ stroke: getStrokeColor(element)
1138
+ });
1139
+
1140
+ return diamond;
1141
+ },
1142
+ 'bpmn:ExclusiveGateway': function(parentGfx, element) {
1143
+ var attrs = {
1144
+ fill: getFillColor(element),
1145
+ stroke: getStrokeColor(element)
1146
+ };
1147
+
1148
+ var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1149
+
1150
+ var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
1151
+ xScaleFactor: 0.4,
1152
+ yScaleFactor: 0.4,
1153
+ containerWidth: element.width,
1154
+ containerHeight: element.height,
1155
+ position: {
1156
+ mx: 0.32,
1157
+ my: 0.3
1158
+ }
1159
+ });
1160
+
1161
+ if ((getDi(element).isMarkerVisible)) {
1162
+ drawPath(parentGfx, pathData, {
1163
+ strokeWidth: 1,
1164
+ fill: getStrokeColor(element),
1165
+ stroke: getStrokeColor(element)
1166
+ });
1167
+ }
1168
+
1169
+ return diamond;
1170
+ },
1171
+ 'bpmn:ComplexGateway': function(parentGfx, element) {
1172
+ var attrs = {
1173
+ fill: getFillColor(element),
1174
+ stroke: getStrokeColor(element)
1175
+ };
1176
+
1177
+ var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1178
+
1179
+ var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
1180
+ xScaleFactor: 0.5,
1181
+ yScaleFactor:0.5,
1182
+ containerWidth: element.width,
1183
+ containerHeight: element.height,
1184
+ position: {
1185
+ mx: 0.46,
1186
+ my: 0.26
1187
+ }
1188
+ });
1189
+
1190
+ /* complex path */ drawPath(parentGfx, pathData, {
1191
+ strokeWidth: 1,
1192
+ fill: getStrokeColor(element),
1193
+ stroke: getStrokeColor(element)
1194
+ });
1195
+
1196
+ return diamond;
1197
+ },
1198
+ 'bpmn:ParallelGateway': function(parentGfx, element) {
1199
+ var attrs = {
1200
+ fill: getFillColor(element),
1201
+ stroke: getStrokeColor(element)
1202
+ };
1203
+
1204
+ var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1205
+
1206
+ var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1207
+ xScaleFactor: 0.6,
1208
+ yScaleFactor:0.6,
1209
+ containerWidth: element.width,
1210
+ containerHeight: element.height,
1211
+ position: {
1212
+ mx: 0.46,
1213
+ my: 0.2
1214
+ }
1215
+ });
1216
+
1217
+ /* parallel path */ drawPath(parentGfx, pathData, {
1218
+ strokeWidth: 1,
1219
+ fill: getStrokeColor(element),
1220
+ stroke: getStrokeColor(element)
1221
+ });
1222
+
1223
+ return diamond;
1224
+ },
1225
+ 'bpmn:EventBasedGateway': function(parentGfx, element) {
1226
+
1227
+ var semantic = getSemantic(element);
1228
+
1229
+ var attrs = {
1230
+ fill: getFillColor(element),
1231
+ stroke: getStrokeColor(element)
1232
+ };
1233
+
1234
+ var diamond = drawDiamond(parentGfx, element.width, element.height, attrs);
1235
+
1236
+ /* outer circle path */ drawCircle(parentGfx, element.width, element.height, element.height * 0.20, {
1237
+ strokeWidth: 1,
1238
+ fill: 'none',
1239
+ stroke: getStrokeColor(element)
1240
+ });
1241
+
1242
+ var type = semantic.eventGatewayType;
1243
+ var instantiate = !!semantic.instantiate;
1244
+
1245
+ function drawEvent() {
1246
+
1247
+ var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
1248
+ xScaleFactor: 0.18,
1249
+ yScaleFactor: 0.18,
1250
+ containerWidth: element.width,
1251
+ containerHeight: element.height,
1252
+ position: {
1253
+ mx: 0.36,
1254
+ my: 0.44
1255
+ }
1256
+ });
1257
+
1258
+ var attrs = {
1259
+ strokeWidth: 2,
1260
+ fill: getFillColor(element, 'none'),
1261
+ stroke: getStrokeColor(element)
1262
+ };
1263
+
1264
+ /* event path */ drawPath(parentGfx, pathData, attrs);
1265
+ }
1266
+
1267
+ if (type === 'Parallel') {
1268
+
1269
+ var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
1270
+ xScaleFactor: 0.4,
1271
+ yScaleFactor:0.4,
1272
+ containerWidth: element.width,
1273
+ containerHeight: element.height,
1274
+ position: {
1275
+ mx: 0.474,
1276
+ my: 0.296
1277
+ }
1278
+ });
1279
+
1280
+ var parallelPath = drawPath(parentGfx, pathData);
1281
+ svgAttr(parallelPath, {
1282
+ strokeWidth: 1,
1283
+ fill: 'none'
1284
+ });
1285
+ } else if (type === 'Exclusive') {
1286
+
1287
+ if (!instantiate) {
1288
+ var innerCircle = drawCircle(parentGfx, element.width, element.height, element.height * 0.26);
1289
+ svgAttr(innerCircle, {
1290
+ strokeWidth: 1,
1291
+ fill: 'none',
1292
+ stroke: getStrokeColor(element)
1293
+ });
1294
+ }
1295
+
1296
+ drawEvent();
1297
+ }
1298
+
1299
+
1300
+ return diamond;
1301
+ },
1302
+ 'bpmn:Gateway': function(parentGfx, element) {
1303
+ return drawDiamond(parentGfx, element.width, element.height);
1304
+ },
1305
+ 'bpmn:SequenceFlow': function(parentGfx, element) {
1306
+ var pathData = createPathFromConnection(element);
1307
+
1308
+ var fill = getFillColor(element),
1309
+ stroke = getStrokeColor(element);
1310
+
1311
+ var attrs = {
1312
+ strokeLinejoin: 'round',
1313
+ markerEnd: marker('sequenceflow-end', fill, stroke),
1314
+ stroke: getStrokeColor(element)
1315
+ };
1316
+
1317
+ var path = drawPath(parentGfx, pathData, attrs);
1318
+
1319
+ var sequenceFlow = getSemantic(element);
1320
+ var source = element.source.businessObject;
1321
+
1322
+ // conditional flow marker
1323
+ if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Activity')) {
1324
+ svgAttr(path, {
1325
+ markerStart: marker('conditional-flow-marker', fill, stroke)
1326
+ });
1327
+ }
1328
+
1329
+ // default marker
1330
+ if (source.default && (source.$instanceOf('bpmn:Gateway') || source.$instanceOf('bpmn:Activity')) &&
1331
+ source.default === sequenceFlow) {
1332
+ svgAttr(path, {
1333
+ markerStart: marker('conditional-default-flow-marker', fill, stroke)
1334
+ });
1335
+ }
1336
+
1337
+ return path;
1338
+ },
1339
+ 'bpmn:Association': function(parentGfx, element, attrs) {
1340
+
1341
+ var semantic = getSemantic(element);
1342
+
1343
+ var fill = getFillColor(element),
1344
+ stroke = getStrokeColor(element);
1345
+
1346
+ attrs = assign({
1347
+ strokeDasharray: '0.5, 5',
1348
+ strokeLinecap: 'round',
1349
+ strokeLinejoin: 'round',
1350
+ stroke: getStrokeColor(element)
1351
+ }, attrs || {});
1352
+
1353
+ if (semantic.associationDirection === 'One' ||
1354
+ semantic.associationDirection === 'Both') {
1355
+ attrs.markerEnd = marker('association-end', fill, stroke);
1356
+ }
1357
+
1358
+ if (semantic.associationDirection === 'Both') {
1359
+ attrs.markerStart = marker('association-start', fill, stroke);
1360
+ }
1361
+
1362
+ return drawLine(parentGfx, element.waypoints, attrs);
1363
+ },
1364
+ 'bpmn:DataInputAssociation': function(parentGfx, element) {
1365
+ var fill = getFillColor(element),
1366
+ stroke = getStrokeColor(element);
1367
+
1368
+ return renderer('bpmn:Association')(parentGfx, element, {
1369
+ markerEnd: marker('association-end', fill, stroke)
1370
+ });
1371
+ },
1372
+ 'bpmn:DataOutputAssociation': function(parentGfx, element) {
1373
+ var fill = getFillColor(element),
1374
+ stroke = getStrokeColor(element);
1375
+
1376
+ return renderer('bpmn:Association')(parentGfx, element, {
1377
+ markerEnd: marker('association-end', fill, stroke)
1378
+ });
1379
+ },
1380
+ 'bpmn:MessageFlow': function(parentGfx, element) {
1381
+
1382
+ var semantic = getSemantic(element),
1383
+ di = getDi(element);
1384
+
1385
+ var fill = getFillColor(element),
1386
+ stroke = getStrokeColor(element);
1387
+
1388
+ var pathData = createPathFromConnection(element);
1389
+
1390
+ var attrs = {
1391
+ markerEnd: marker('messageflow-end', fill, stroke),
1392
+ markerStart: marker('messageflow-start', fill, stroke),
1393
+ strokeDasharray: '10, 12',
1394
+ strokeLinecap: 'round',
1395
+ strokeLinejoin: 'round',
1396
+ strokeWidth: '1.5px',
1397
+ stroke: getStrokeColor(element)
1398
+ };
1399
+
1400
+ var path = drawPath(parentGfx, pathData, attrs);
1401
+
1402
+ if (semantic.messageRef) {
1403
+ var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
1404
+
1405
+ var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
1406
+ abspos: {
1407
+ x: midPoint.x,
1408
+ y: midPoint.y
1409
+ }
1410
+ });
1411
+
1412
+ var messageAttrs = { strokeWidth: 1 };
1413
+
1414
+ if (di.messageVisibleKind === 'initiating') {
1415
+ messageAttrs.fill = 'white';
1416
+ messageAttrs.stroke = 'black';
1417
+ } else {
1418
+ messageAttrs.fill = '#888';
1419
+ messageAttrs.stroke = 'white';
1420
+ }
1421
+
1422
+ drawPath(parentGfx, markerPathData, messageAttrs);
1423
+ }
1424
+
1425
+ return path;
1426
+ },
1427
+ 'bpmn:DataObject': function(parentGfx, element) {
1428
+ var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
1429
+ xScaleFactor: 1,
1430
+ yScaleFactor: 1,
1431
+ containerWidth: element.width,
1432
+ containerHeight: element.height,
1433
+ position: {
1434
+ mx: 0.474,
1435
+ my: 0.296
1436
+ }
1437
+ });
1438
+
1439
+ var elementObject = drawPath(parentGfx, pathData, {
1440
+ fill: getFillColor(element),
1441
+ stroke: getStrokeColor(element)
1442
+ });
1443
+
1444
+ var semantic = getSemantic(element);
1445
+
1446
+ if (isCollection(semantic)) {
1447
+ renderDataItemCollection(parentGfx, element);
1448
+ }
1449
+
1450
+ return elementObject;
1451
+ },
1452
+ 'bpmn:DataObjectReference': as('bpmn:DataObject'),
1453
+ 'bpmn:DataInput': function(parentGfx, element) {
1454
+
1455
+ var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1456
+
1457
+ // page
1458
+ var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
1459
+
1460
+ /* input arrow path */ drawPath(parentGfx, arrowPathData, { strokeWidth: 1 });
1461
+
1462
+ return elementObject;
1463
+ },
1464
+ 'bpmn:DataOutput': function(parentGfx, element) {
1465
+ var arrowPathData = pathMap.getRawPath('DATA_ARROW');
1466
+
1467
+ // page
1468
+ var elementObject = renderer('bpmn:DataObject')(parentGfx, element);
1469
+
1470
+ /* output arrow path */ drawPath(parentGfx, arrowPathData, {
1471
+ strokeWidth: 1,
1472
+ fill: 'black'
1473
+ });
1474
+
1475
+ return elementObject;
1476
+ },
1477
+ 'bpmn:DataStoreReference': function(parentGfx, element) {
1478
+ var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
1479
+ xScaleFactor: 1,
1480
+ yScaleFactor: 1,
1481
+ containerWidth: element.width,
1482
+ containerHeight: element.height,
1483
+ position: {
1484
+ mx: 0,
1485
+ my: 0.133
1486
+ }
1487
+ });
1488
+
1489
+ var elementStore = drawPath(parentGfx, DATA_STORE_PATH, {
1490
+ strokeWidth: 2,
1491
+ fill: getFillColor(element),
1492
+ stroke: getStrokeColor(element)
1493
+ });
1494
+
1495
+ return elementStore;
1496
+ },
1497
+ 'bpmn:BoundaryEvent': function(parentGfx, element) {
1498
+
1499
+ var semantic = getSemantic(element),
1500
+ cancel = semantic.cancelActivity;
1501
+
1502
+ var attrs = {
1503
+ strokeWidth: 1,
1504
+ fill: getFillColor(element),
1505
+ stroke: getStrokeColor(element)
1506
+ };
1507
+
1508
+ if (!cancel) {
1509
+ attrs.strokeDasharray = '6';
1510
+ attrs.strokeLinecap = 'round';
1511
+ }
1512
+
1513
+ var outer = renderer('bpmn:Event')(parentGfx, element, attrs);
1514
+ /* inner path */ drawCircle(parentGfx, element.width, element.height, INNER_OUTER_DIST, assign(attrs, { fill: 'none' }));
1515
+
1516
+ renderEventContent(element, parentGfx);
1517
+
1518
+ return outer;
1519
+ },
1520
+ 'bpmn:Group': function(parentGfx, element) {
1521
+ return drawRect(parentGfx, element.width, element.height, TASK_BORDER_RADIUS, {
1522
+ strokeWidth: 1,
1523
+ strokeDasharray: '8,3,1,3',
1524
+ fill: 'none',
1525
+ pointerEvents: 'none'
1526
+ });
1527
+ },
1528
+ 'label': function(parentGfx, element) {
1529
+ return renderExternalLabel(parentGfx, element);
1530
+ },
1531
+ 'bpmn:TextAnnotation': function(parentGfx, element) {
1532
+ var style = {
1533
+ 'fill': 'none',
1534
+ 'stroke': 'none'
1535
+ };
1536
+
1537
+ var textElement = drawRect(parentGfx, element.width, element.height, 0, 0, style);
1538
+
1539
+ var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
1540
+ xScaleFactor: 1,
1541
+ yScaleFactor: 1,
1542
+ containerWidth: element.width,
1543
+ containerHeight: element.height,
1544
+ position: {
1545
+ mx: 0.0,
1546
+ my: 0.0
1547
+ }
1548
+ });
1549
+ drawPath(parentGfx, textPathData, {
1550
+ stroke: getStrokeColor(element)
1551
+ });
1552
+
1553
+ var text = getSemantic(element).text || '';
1554
+ renderLabel(parentGfx, text, { box: element, align: 'left-top', padding: 5 });
1555
+
1556
+ return textElement;
1557
+ },
1558
+ 'ParticipantMultiplicityMarker': function(parentGfx, element) {
1559
+ var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
1560
+ xScaleFactor: 1,
1561
+ yScaleFactor: 1,
1562
+ containerWidth: element.width,
1563
+ containerHeight: element.height,
1564
+ position: {
1565
+ mx: ((element.width / 2) / element.width),
1566
+ my: (element.height - 15) / element.height
1567
+ }
1568
+ });
1569
+
1570
+ drawMarker('participant-multiplicity', parentGfx, markerPath);
1571
+ },
1572
+ 'SubProcessMarker': function(parentGfx, element) {
1573
+ var markerRect = drawRect(parentGfx, 14, 14, 0, {
1574
+ strokeWidth: 1,
1575
+ fill: getFillColor(element),
1576
+ stroke: getStrokeColor(element)
1577
+ });
1578
+
1579
+ // Process marker is placed in the middle of the box
1580
+ // therefore fixed values can be used here
1581
+ translate(markerRect, element.width / 2 - 7.5, element.height - 20);
1582
+
1583
+ var markerPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
1584
+ xScaleFactor: 1.5,
1585
+ yScaleFactor: 1.5,
1586
+ containerWidth: element.width,
1587
+ containerHeight: element.height,
1588
+ position: {
1589
+ mx: (element.width / 2 - 7.5) / element.width,
1590
+ my: (element.height - 20) / element.height
1591
+ }
1592
+ });
1593
+
1594
+ drawMarker('sub-process', parentGfx, markerPath, {
1595
+ fill: getFillColor(element),
1596
+ stroke: getStrokeColor(element)
1597
+ });
1598
+ },
1599
+ 'ParallelMarker': function(parentGfx, element, position) {
1600
+ var markerPath = pathMap.getScaledPath('MARKER_PARALLEL', {
1601
+ xScaleFactor: 1,
1602
+ yScaleFactor: 1,
1603
+ containerWidth: element.width,
1604
+ containerHeight: element.height,
1605
+ position: {
1606
+ mx: ((element.width / 2 + position.parallel) / element.width),
1607
+ my: (element.height - 20) / element.height
1608
+ }
1609
+ });
1610
+
1611
+ drawMarker('parallel', parentGfx, markerPath);
1612
+ },
1613
+ 'SequentialMarker': function(parentGfx, element, position) {
1614
+ var markerPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
1615
+ xScaleFactor: 1,
1616
+ yScaleFactor: 1,
1617
+ containerWidth: element.width,
1618
+ containerHeight: element.height,
1619
+ position: {
1620
+ mx: ((element.width / 2 + position.seq) / element.width),
1621
+ my: (element.height - 19) / element.height
1622
+ }
1623
+ });
1624
+
1625
+ drawMarker('sequential', parentGfx, markerPath);
1626
+ },
1627
+ 'CompensationMarker': function(parentGfx, element, position) {
1628
+ var markerMath = pathMap.getScaledPath('MARKER_COMPENSATION', {
1629
+ xScaleFactor: 1,
1630
+ yScaleFactor: 1,
1631
+ containerWidth: element.width,
1632
+ containerHeight: element.height,
1633
+ position: {
1634
+ mx: ((element.width / 2 + position.compensation) / element.width),
1635
+ my: (element.height - 13) / element.height
1636
+ }
1637
+ });
1638
+
1639
+ drawMarker('compensation', parentGfx, markerMath, { strokeWidth: 1 });
1640
+ },
1641
+ 'LoopMarker': function(parentGfx, element, position) {
1642
+ var markerPath = pathMap.getScaledPath('MARKER_LOOP', {
1643
+ xScaleFactor: 1,
1644
+ yScaleFactor: 1,
1645
+ containerWidth: element.width,
1646
+ containerHeight: element.height,
1647
+ position: {
1648
+ mx: ((element.width / 2 + position.loop) / element.width),
1649
+ my: (element.height - 7) / element.height
1650
+ }
1651
+ });
1652
+
1653
+ drawMarker('loop', parentGfx, markerPath, {
1654
+ strokeWidth: 1,
1655
+ fill: 'none',
1656
+ strokeLinecap: 'round',
1657
+ strokeMiterlimit: 0.5
1658
+ });
1659
+ },
1660
+ 'AdhocMarker': function(parentGfx, element, position) {
1661
+ var markerPath = pathMap.getScaledPath('MARKER_ADHOC', {
1662
+ xScaleFactor: 1,
1663
+ yScaleFactor: 1,
1664
+ containerWidth: element.width,
1665
+ containerHeight: element.height,
1666
+ position: {
1667
+ mx: ((element.width / 2 + position.adhoc) / element.width),
1668
+ my: (element.height - 15) / element.height
1669
+ }
1670
+ });
1671
+
1672
+ drawMarker('adhoc', parentGfx, markerPath, {
1673
+ strokeWidth: 1,
1674
+ fill: 'black'
1675
+ });
1676
+ }
1677
+ };
1678
+
1679
+ function attachTaskMarkers(parentGfx, element, taskMarkers) {
1680
+ var obj = getSemantic(element);
1681
+
1682
+ var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1;
1683
+ var position;
1684
+
1685
+ if (subprocess) {
1686
+ position = {
1687
+ seq: -21,
1688
+ parallel: -22,
1689
+ compensation: -42,
1690
+ loop: -18,
1691
+ adhoc: 10
1692
+ };
1693
+ } else {
1694
+ position = {
1695
+ seq: -3,
1696
+ parallel: -6,
1697
+ compensation: -27,
1698
+ loop: 0,
1699
+ adhoc: 10
1700
+ };
1701
+ }
1702
+
1703
+ forEach(taskMarkers, function(marker) {
1704
+ renderer(marker)(parentGfx, element, position);
1705
+ });
1706
+
1707
+ if (obj.isForCompensation) {
1708
+ renderer('CompensationMarker')(parentGfx, element, position);
1709
+ }
1710
+
1711
+ if (obj.$type === 'bpmn:AdHocSubProcess') {
1712
+ renderer('AdhocMarker')(parentGfx, element, position);
1713
+ }
1714
+
1715
+ var loopCharacteristics = obj.loopCharacteristics,
1716
+ isSequential = loopCharacteristics && loopCharacteristics.isSequential;
1717
+
1718
+ if (loopCharacteristics) {
1719
+
1720
+ if (isSequential === undefined) {
1721
+ renderer('LoopMarker')(parentGfx, element, position);
1722
+ }
1723
+
1724
+ if (isSequential === false) {
1725
+ renderer('ParallelMarker')(parentGfx, element, position);
1726
+ }
1727
+
1728
+ if (isSequential === true) {
1729
+ renderer('SequentialMarker')(parentGfx, element, position);
1730
+ }
1731
+ }
1732
+ }
1733
+
1734
+ function renderDataItemCollection(parentGfx, element) {
1735
+
1736
+ var yPosition = (element.height - 16) / element.height;
1737
+
1738
+ var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
1739
+ xScaleFactor: 1,
1740
+ yScaleFactor: 1,
1741
+ containerWidth: element.width,
1742
+ containerHeight: element.height,
1743
+ position: {
1744
+ mx: 0.451,
1745
+ my: yPosition
1746
+ }
1747
+ });
1748
+
1749
+ /* collection path */ drawPath(parentGfx, pathData, {
1750
+ strokeWidth: 2
1751
+ });
1752
+ }
1753
+ }
1754
+
1755
+
1756
+ inherits(BpmnRenderer, BaseRenderer);
1757
+
1758
+ BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap', 'canvas' ];
1759
+
1760
+ module.exports = BpmnRenderer;
1761
+
1762
+
1763
+ BpmnRenderer.prototype.canRender = function(element) {
1764
+ return is(element, 'bpmn:BaseElement');
1765
+ };
1766
+
1767
+ BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
1768
+ var type = element.type;
1769
+ var h = this.handlers[type];
1770
+
1771
+ /* jshint -W040 */
1772
+ return h(parentGfx, element);
1773
+ };
1774
+
1775
+ BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
1776
+ var type = element.type;
1777
+ var h = this.handlers[type];
1778
+
1779
+ /* jshint -W040 */
1780
+ return h(parentGfx, element);
1781
+ };
1782
+
1783
+ BpmnRenderer.prototype.getShapePath = function(element) {
1784
+
1785
+ if (is(element, 'bpmn:Event')) {
1786
+ return getCirclePath(element);
1787
+ }
1788
+
1789
+ if (is(element, 'bpmn:Activity')) {
1790
+ return getRoundRectPath(element, TASK_BORDER_RADIUS);
1791
+ }
1792
+
1793
+ if (is(element, 'bpmn:Gateway')) {
1794
+ return getDiamondPath(element);
1795
+ }
1796
+
1797
+ return getRectPath(element);
1798
+ };
1799
+
1800
+
1801
+ ///////// helper functions /////////////////////////////
1802
+
1803
+ /**
1804
+ * Checks if eventDefinition of the given element matches with semantic type.
1805
+ *
1806
+ * @return {boolean} true if element is of the given semantic type
1807
+ */
1808
+ function isTypedEvent(event, eventDefinitionType, filter) {
1809
+
1810
+ function matches(definition, filter) {
1811
+ return every(filter, function(val, key) {
1812
+
1813
+ // we want a == conversion here, to be able to catch
1814
+ // undefined == false and friends
1815
+ /* jshint -W116 */
1816
+ return definition[key] == val;
1817
+ });
1818
+ }
1819
+
1820
+ return some(event.eventDefinitions, function(definition) {
1821
+ return definition.$type === eventDefinitionType && matches(event, filter);
1822
+ });
1823
+ }
1824
+
1825
+ function isThrowEvent(event) {
1826
+ return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
1827
+ }
1828
+
1829
+ function isCollection(element) {
1830
+ var dataObject = element.dataObjectRef;
1831
+
1832
+ return element.isCollection || (dataObject && dataObject.isCollection);
1833
+ }
1834
+
1835
+ function getDi(element) {
1836
+ return element.businessObject.di;
1837
+ }
1838
+
1839
+ function getSemantic(element) {
1840
+ return element.businessObject;
1841
+ }
1842
+
1843
+
1844
+
1845
+ /////// cropping path customizations /////////////////////////
1846
+
1847
+ function getCirclePath(shape) {
1848
+
1849
+ var cx = shape.x + shape.width / 2,
1850
+ cy = shape.y + shape.height / 2,
1851
+ radius = shape.width / 2;
1852
+
1853
+ var circlePath = [
1854
+ ['M', cx, cy],
1855
+ ['m', 0, -radius],
1856
+ ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
1857
+ ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
1858
+ ['z']
1859
+ ];
1860
+
1861
+ return componentsToPath(circlePath);
1862
+ }
1863
+
1864
+ function getRoundRectPath(shape, borderRadius) {
1865
+
1866
+ var x = shape.x,
1867
+ y = shape.y,
1868
+ width = shape.width,
1869
+ height = shape.height;
1870
+
1871
+ var roundRectPath = [
1872
+ ['M', x + borderRadius, y],
1873
+ ['l', width - borderRadius * 2, 0],
1874
+ ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
1875
+ ['l', 0, height - borderRadius * 2],
1876
+ ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
1877
+ ['l', borderRadius * 2 - width, 0],
1878
+ ['a', borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
1879
+ ['l', 0, borderRadius * 2 - height],
1880
+ ['a', borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
1881
+ ['z']
1882
+ ];
1883
+
1884
+ return componentsToPath(roundRectPath);
1885
+ }
1886
+
1887
+ function getDiamondPath(shape) {
1888
+
1889
+ var width = shape.width,
1890
+ height = shape.height,
1891
+ x = shape.x,
1892
+ y = shape.y,
1893
+ halfWidth = width / 2,
1894
+ halfHeight = height / 2;
1895
+
1896
+ var diamondPath = [
1897
+ ['M', x + halfWidth, y],
1898
+ ['l', halfWidth, halfHeight],
1899
+ ['l', -halfWidth, halfHeight],
1900
+ ['l', -halfWidth, -halfHeight],
1901
+ ['z']
1902
+ ];
1903
+
1904
+ return componentsToPath(diamondPath);
1905
+ }
1906
+
1907
+ function getRectPath(shape) {
1908
+ var x = shape.x,
1909
+ y = shape.y,
1910
+ width = shape.width,
1911
+ height = shape.height;
1912
+
1913
+ var rectPath = [
1914
+ ['M', x, y],
1915
+ ['l', width, 0],
1916
+ ['l', 0, height],
1917
+ ['l', -width, 0],
1918
+ ['z']
1919
+ ];
1920
+
1921
+ return componentsToPath(rectPath);
1922
+ }
1923
+
1924
+ function getFillColor(element, defaultColor) {
1925
+ var bo = getBusinessObject(element);
1926
+
1927
+ return bo.di.get('fill') || defaultColor || 'white';
1928
+ }
1929
+
1930
+ function getStrokeColor(element, defaultColor) {
1931
+ var bo = getBusinessObject(element);
1932
+
1933
+ return bo.di.get('stroke') || defaultColor || 'black';
1934
+ }