diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index 6b80bdd6..21b4c1a5 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -494,12 +494,148 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) { var rect = drawRect(p, data.width, data.height, 0); return rect; }, + 'bpmn:InclusiveGateway': function(p, data) { + var diamond = drawDiamond(p, data.width, data.height); - 'bpmn:InclusiveGateway': as('bpmn:Gateway'), - 'bpmn:ExclusiveGateway': as('bpmn:Gateway'), - 'bpmn:ComplexGateway': as('bpmn:Gateway'), - 'bpmn:ParallelGateway': as('bpmn:Gateway'), - 'bpmn:EventBasedGateway': as('bpmn:Gateway'), + var circle = drawCircle(p, data.width, data.height, data.height * 0.24); + circle.attr({ + 'stroke-width': 2.5, + 'fill': 'None' + }); + + return diamond; + }, + 'bpmn:ExclusiveGateway': function(p, data) { + var diamond = drawDiamond(p, data.width, data.height); + + var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', { + xScaleFactor: 0.45, + yScaleFactor: 0.45, + containerWidth: data.width, + containerHeight: data.height, + position: { + mx: 0.3, + my: 0.28 + } + }); + + var exclusivePath = drawPath(p, pathData); + exclusivePath.attr({ + 'stroke-width': 1, + 'fill': 'Black' + }); + + return diamond; + }, + 'bpmn:ComplexGateway': function(p, data) { + var diamond = drawDiamond(p, data.width, data.height); + + var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', { + xScaleFactor: 0.5, + yScaleFactor:0.5, + containerWidth: data.width, + containerHeight: data.height, + position: { + mx: 0.46, + my: 0.26 + } + }); + + var complexPath = drawPath(p, pathData); + complexPath.attr({ + 'stroke-width': 1, + 'fill': 'Black' + }); + + return diamond; + }, + 'bpmn:ParallelGateway': function(p, data) { + var diamond = drawDiamond(p, data.width, data.height); + + var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { + xScaleFactor: 0.6, + yScaleFactor:0.6, + containerWidth: data.width, + containerHeight: data.height, + position: { + mx: 0.46, + my: 0.2 + } + }); + + var parallelPath = drawPath(p, pathData); + parallelPath.attr({ + 'stroke-width': 1, + 'fill': 'Black' + }); + + return diamond; + }, + 'bpmn:EventBasedGateway': function(p, data) { + var diamond = drawDiamond(p, data.width, data.height); + + var outerCircle = drawCircle(p, data.width, data.height, data.height * 0.21); + outerCircle.attr({ + 'stroke-width': 1, + 'fill': 'None' + }); + + var type = bpmnRegistry.getSemantic(data.id).eventGatewayType; + + function drawEvent() { + + var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', { + xScaleFactor: 0.20, + yScaleFactor: 0.20, + containerWidth: data.width, + containerHeight: data.height, + position: { + mx: 0.34, + my: 0.43 + } + }); + + var eventPath = drawPath(p, pathData); + eventPath.attr({ + 'stroke-width': 2, + 'fill': 'None' + }); + } + + if(type === 'Parallel') { + + var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', { + xScaleFactor: 0.4, + yScaleFactor:0.4, + containerWidth: data.width, + containerHeight: data.height, + position: { + mx: 0.46, + my: 0.29 + } + }); + + var parallelPath = drawPath(p, pathData); + parallelPath.attr({ + 'stroke-width': 1, + 'fill': 'None' + }); + } else if(type === 'Exclusive') { + + drawEvent(); + } else { + + var innerCircle = drawCircle(p, data.width, data.height, data.height * 0.24); + innerCircle.attr({ + 'stroke-width': 1, + 'fill': 'None' + }); + drawEvent(); + } + + + return diamond; + }, 'bpmn:Gateway': function(p, data) { var diamond = drawDiamond(p, data.width, data.height); diff --git a/lib/draw/PathMap.js b/lib/draw/PathMap.js index 590df30a..9dc440e2 100644 --- a/lib/draw/PathMap.js +++ b/lib/draw/PathMap.js @@ -8,6 +8,34 @@ function PathMap(Snap) { /** * Contains a map of path elements + * + *
+ * 'GATEWAY_PARALLEL': { + * d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' + + '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z', + * height: 17.5, + * width: 17.5, + * heightElements: [2.5, 7.5], + * widthElements: [2.5, 7.5] + * } + *+ *
It's important to specify a correct height and width for the path as the scaling + * is based on the ratio between the specified height and width in this object and the + * height and width that is set as scale target (Note x,y coordinates will be scaled with + * individual ratios).
+ *The 'heightElements' and 'widthElements' array must contain the values that will be scaled. + * The scaling is based on the computed ratios. + * Coordinates on the y axis should be in the heightElement's array, they will be scaled using + * the computed ratio coefficient. + * In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets. + *
Use case is to scale the content of elements (event, gateways) based + * on the element bounding box's size. + *
+ *Scaling a path with transform() will also scale the stroke and IE does not support + * the option 'non-scaling-stroke' to prevent this. + * Also there are use cases where only some parts of a path should be + * scaled.
+ * + * @param {String} pathId The ID of the path. + * @param {Object} param+ * Example param object scales the path to 60% size of the container (data.width, data.height). + *
+ * { + * xScaleFactor: 0.6, + * yScaleFactor:0.6, + * containerWidth: data.width, + * containerHeight: data.height, + * position: { + * mx: 0.46, + * my: 0.2, + * } + * } + *+ *
position: { + * mx: 0.5, + * my: 0.5, + * }+ * Upper left corner of the container + *
position: { + * mx: 0.0, + * my: 0.0, + * }+ *