2014-05-27 15:51:16 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-23 14:15:32 +00:00
|
|
|
var inherits = require('inherits'),
|
|
|
|
isArray = require('lodash/lang/isArray'),
|
2015-02-02 13:46:21 +00:00
|
|
|
isObject = require('lodash/lang/isObject'),
|
|
|
|
assign = require('lodash/object/assign'),
|
|
|
|
forEach = require('lodash/collection/forEach'),
|
|
|
|
every = require('lodash/collection/every'),
|
|
|
|
includes = require('lodash/collection/includes'),
|
|
|
|
some = require('lodash/collection/some');
|
|
|
|
|
|
|
|
var DefaultRenderer = require('diagram-js/lib/draw/Renderer'),
|
|
|
|
TextUtil = require('diagram-js/lib/util/Text'),
|
2015-04-27 14:50:09 +00:00
|
|
|
DiUtil = require('../util/DiUtil');
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-09-08 17:03:39 +00:00
|
|
|
var createLine = DefaultRenderer.createLine;
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function BpmnRenderer(events, styles, pathMap) {
|
2014-03-25 13:08:11 +00:00
|
|
|
|
2014-06-11 12:41:55 +00:00
|
|
|
DefaultRenderer.call(this, styles);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
var TASK_BORDER_RADIUS = 10;
|
2014-03-20 15:18:23 +00:00
|
|
|
var INNER_OUTER_DIST = 3;
|
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
var LABEL_STYLE = {
|
2014-05-06 15:22:39 +00:00
|
|
|
fontFamily: 'Arial, sans-serif',
|
|
|
|
fontSize: '12px'
|
2014-04-25 14:14:36 +00:00
|
|
|
};
|
|
|
|
|
2014-09-09 13:20:30 +00:00
|
|
|
var textUtil = new TextUtil({
|
2014-05-06 08:15:38 +00:00
|
|
|
style: LABEL_STYLE,
|
|
|
|
size: { width: 100 }
|
2014-04-25 14:14:36 +00:00
|
|
|
});
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
var markers = {};
|
|
|
|
|
|
|
|
function addMarker(id, element) {
|
|
|
|
markers[id] = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
function marker(id) {
|
|
|
|
return markers[id];
|
|
|
|
}
|
|
|
|
|
2014-11-26 10:31:23 +00:00
|
|
|
function initMarkers(svg) {
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-06-02 13:37:14 +00:00
|
|
|
function createMarker(id, options) {
|
2015-02-02 13:46:21 +00:00
|
|
|
var attrs = assign({
|
2014-06-02 13:37:14 +00:00
|
|
|
fill: 'black',
|
|
|
|
strokeWidth: 1,
|
|
|
|
strokeLinecap: 'round',
|
|
|
|
strokeDasharray: 'none'
|
|
|
|
}, options.attrs);
|
|
|
|
|
|
|
|
var ref = options.ref || { x: 0, y: 0 };
|
|
|
|
|
|
|
|
var scale = options.scale || 1;
|
|
|
|
|
|
|
|
// fix for safari / chrome / firefox bug not correctly
|
|
|
|
// resetting stroke dash array
|
|
|
|
if (attrs.strokeDasharray === 'none') {
|
|
|
|
attrs.strokeDasharray = [10000, 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
var marker = options.element
|
|
|
|
.attr(attrs)
|
|
|
|
.marker(0, 0, 20, 20, ref.x, ref.y)
|
|
|
|
.attr({
|
|
|
|
markerWidth: 20 * scale,
|
|
|
|
markerHeight: 20 * scale
|
|
|
|
});
|
|
|
|
|
|
|
|
return addMarker(id, marker);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createMarker('sequenceflow-end', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.path('M 1 5 L 11 10 L 1 15 Z'),
|
2014-06-02 13:37:14 +00:00
|
|
|
ref: { x: 11, y: 10 },
|
|
|
|
scale: 0.5
|
|
|
|
});
|
|
|
|
|
|
|
|
createMarker('messageflow-start', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.circle(6, 6, 5),
|
2014-06-02 13:37:14 +00:00
|
|
|
attrs: {
|
|
|
|
fill: 'white',
|
|
|
|
stroke: 'black'
|
|
|
|
},
|
|
|
|
ref: { x: 6, y: 6 }
|
|
|
|
});
|
|
|
|
|
|
|
|
createMarker('messageflow-end', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.path('M 1 5 L 11 10 L 1 15 Z'),
|
2014-06-02 13:37:14 +00:00
|
|
|
attrs: {
|
|
|
|
fill: 'white',
|
|
|
|
stroke: 'black'
|
|
|
|
},
|
|
|
|
ref: { x: 11, y: 10 }
|
|
|
|
});
|
|
|
|
|
|
|
|
createMarker('data-association-end', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.path('M 1 5 L 11 10 L 1 15'),
|
2014-06-02 13:37:14 +00:00
|
|
|
attrs: {
|
|
|
|
fill: 'white',
|
|
|
|
stroke: 'black'
|
|
|
|
},
|
|
|
|
ref: { x: 11, y: 10 },
|
|
|
|
scale: 0.5
|
|
|
|
});
|
|
|
|
|
|
|
|
createMarker('conditional-flow-marker', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'),
|
2014-06-02 13:37:14 +00:00
|
|
|
attrs: {
|
|
|
|
fill: 'white',
|
|
|
|
stroke: 'black'
|
|
|
|
},
|
|
|
|
ref: { x: -1, y: 10 },
|
|
|
|
scale: 0.5
|
|
|
|
});
|
|
|
|
|
|
|
|
createMarker('conditional-default-flow-marker', {
|
2014-11-26 10:31:23 +00:00
|
|
|
element: svg.path('M 1 4 L 5 16'),
|
2014-06-02 13:37:14 +00:00
|
|
|
attrs: {
|
|
|
|
stroke: 'black'
|
|
|
|
},
|
|
|
|
ref: { x: -5, y: 10 },
|
|
|
|
scale: 0.5
|
|
|
|
});
|
2014-03-20 16:51:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
function computeStyle(custom, traits, defaultStyles) {
|
2015-02-02 13:46:21 +00:00
|
|
|
if (!isArray(traits)) {
|
2014-05-27 15:51:16 +00:00
|
|
|
defaultStyles = traits;
|
|
|
|
traits = [];
|
|
|
|
}
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
return styles.style(traits || [], assign(defaultStyles, custom || {}));
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function drawCircle(p, width, height, offset, attrs) {
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
if (isObject(offset)) {
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = offset;
|
|
|
|
offset = 0;
|
|
|
|
}
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
offset = offset || 0;
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = computeStyle(attrs, {
|
2014-05-27 16:48:38 +00:00
|
|
|
stroke: 'black',
|
|
|
|
strokeWidth: 2,
|
|
|
|
fill: 'white'
|
2014-05-27 15:51:16 +00:00
|
|
|
});
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
var cx = width / 2,
|
|
|
|
cy = height / 2;
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs);
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
function drawRect(p, width, height, r, offset, attrs) {
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
if (isObject(offset)) {
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = offset;
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
offset = offset || 0;
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = computeStyle(attrs, {
|
2014-05-27 16:48:38 +00:00
|
|
|
stroke: 'black',
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'white'
|
2014-03-20 15:18:23 +00:00
|
|
|
});
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs);
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
function drawDiamond(p, width, height, attrs) {
|
2014-03-20 16:51:05 +00:00
|
|
|
|
|
|
|
var x_2 = width / 2;
|
|
|
|
var y_2 = height / 2;
|
|
|
|
|
|
|
|
var points = [x_2, 0, width, y_2, x_2, height, 0, y_2 ];
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = computeStyle(attrs, {
|
2014-05-27 16:48:38 +00:00
|
|
|
stroke: 'black',
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'white'
|
2014-03-20 16:51:05 +00:00
|
|
|
});
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
return p.polygon(points).attr(attrs);
|
2014-03-20 16:51:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
function drawLine(p, waypoints, attrs) {
|
|
|
|
attrs = computeStyle(attrs, [ 'no-fill' ], {
|
2014-05-27 16:48:38 +00:00
|
|
|
stroke: 'black',
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2,
|
2014-05-28 20:48:11 +00:00
|
|
|
fill: 'none'
|
2014-05-27 15:51:16 +00:00
|
|
|
});
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-09-08 17:03:39 +00:00
|
|
|
return createLine(waypoints, attrs).appendTo(p);
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
function drawPath(p, d, attrs) {
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
attrs = computeStyle(attrs, [ 'no-fill' ], {
|
2014-05-27 16:48:38 +00:00
|
|
|
strokeWidth: 2,
|
|
|
|
stroke: 'black'
|
2014-05-27 15:51:16 +00:00
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return p.path(d).attr(attrs);
|
2014-04-02 10:55:18 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
function as(type) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return function(p, element) {
|
|
|
|
return handlers[type](p, element);
|
2014-03-20 15:18:23 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderer(type) {
|
|
|
|
return handlers[type];
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function renderEventContent(element, p) {
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var event = getSemantic(element);
|
2014-04-25 11:50:53 +00:00
|
|
|
var isThrowing = isThrowEvent(event);
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing);
|
2014-04-03 12:01:56 +00:00
|
|
|
}
|
2014-04-25 11:50:53 +00:00
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:ConditionalEventDefinition')(p, element);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
2014-05-21 14:14:17 +00:00
|
|
|
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
2014-05-21 14:14:17 +00:00
|
|
|
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing);
|
2014-04-25 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2014-04-03 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
2014-05-06 15:22:39 +00:00
|
|
|
function renderLabel(p, label, options) {
|
2014-09-09 13:20:30 +00:00
|
|
|
return textUtil.createText(p, label || '', options).addClass('djs-label');
|
2014-04-25 14:14:36 +00:00
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function renderEmbeddedLabel(p, element, align) {
|
|
|
|
var semantic = getSemantic(element);
|
2014-09-15 12:41:26 +00:00
|
|
|
return renderLabel(p, semantic.name, { box: element, align: align, padding: 5 });
|
2014-04-25 14:14:36 +00:00
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function renderExternalLabel(p, element, align) {
|
|
|
|
var semantic = getSemantic(element);
|
2014-09-09 13:20:30 +00:00
|
|
|
|
|
|
|
if (!semantic.name) {
|
|
|
|
element.hidden = true;
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
return renderLabel(p, semantic.name, { box: element, align: align, style: { fontSize: '11px' } });
|
2014-04-25 14:14:36 +00:00
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function renderLaneLabel(p, text, element) {
|
2014-05-06 15:22:39 +00:00
|
|
|
var textBox = renderLabel(p, text, {
|
2014-07-16 14:15:23 +00:00
|
|
|
box: { height: 30, width: element.height },
|
2014-05-06 15:22:39 +00:00
|
|
|
align: 'center-middle'
|
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var top = -1 * element.height;
|
2014-05-06 14:21:53 +00:00
|
|
|
textBox.transform(
|
2014-05-27 15:51:16 +00:00
|
|
|
'rotate(270) ' +
|
|
|
|
'translate(' + top + ',' + 0 + ')'
|
2014-05-06 14:21:53 +00:00
|
|
|
);
|
2014-05-02 15:03:03 +00:00
|
|
|
}
|
|
|
|
|
2014-07-30 14:06:32 +00:00
|
|
|
function createPathFromConnection(connection) {
|
|
|
|
var waypoints = connection.waypoints;
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
|
2014-05-21 11:51:59 +00:00
|
|
|
for (var i = 1; i < waypoints.length; i++) {
|
2014-05-27 15:51:16 +00:00
|
|
|
pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
|
2014-05-21 11:51:59 +00:00
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
return pathData;
|
2014-05-21 11:51:59 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
var handlers = {
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Event': function(p, element, attrs) {
|
|
|
|
return drawCircle(p, element.width, element.height, attrs);
|
2014-03-20 15:18:23 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:StartEvent': function(p, element) {
|
2014-05-27 15:51:16 +00:00
|
|
|
var attrs = {};
|
2014-07-16 14:15:23 +00:00
|
|
|
var semantic = getSemantic(element);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (!semantic.isInterrupting) {
|
2014-05-28 21:19:41 +00:00
|
|
|
attrs = {
|
|
|
|
strokeDasharray: '6',
|
|
|
|
strokeLinecap: 'round'
|
|
|
|
};
|
2014-05-15 08:09:07 +00:00
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var circle = renderer('bpmn:Event')(p, element, attrs);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEventContent(element, p);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
return circle;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:MessageEventDefinition': function(p, element, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
|
|
|
|
xScaleFactor: 0.9,
|
|
|
|
yScaleFactor: 0.9,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-28 13:32:55 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.235,
|
|
|
|
my: 0.315
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-08-17 16:33:41 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'white';
|
2014-05-27 16:48:38 +00:00
|
|
|
var stroke = isThrowing ? 'white' : 'black';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
var messagePath = drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill,
|
|
|
|
stroke: stroke
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return messagePath;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:TimerEventDefinition': function(p, element) {
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
|
|
|
|
xScaleFactor: 0.75,
|
|
|
|
yScaleFactor: 0.75,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-28 13:32:55 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.5
|
|
|
|
}
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
drawPath(p, pathData, {
|
2014-09-17 14:05:24 +00:00
|
|
|
strokeWidth: 2,
|
|
|
|
strokeLinecap: 'square'
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
2014-09-17 14:05:24 +00:00
|
|
|
for(var i = 0;i < 12;i++) {
|
|
|
|
|
|
|
|
var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
|
|
|
|
xScaleFactor: 0.75,
|
|
|
|
yScaleFactor: 0.75,
|
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.5
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var width = element.width / 2;
|
|
|
|
var height = element.height / 2;
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
drawPath(p, linePathData, {
|
2014-09-17 14:05:24 +00:00
|
|
|
strokeWidth: 1,
|
|
|
|
strokeLinecap: 'square',
|
|
|
|
transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
return circle;
|
2014-04-03 12:01:56 +00:00
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:EscalationEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.555
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
'bpmn:ConditionalEventDefinition': function(p, event) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.222
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2015-03-04 12:29:46 +00:00
|
|
|
'bpmn:LinkEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_LINK', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.57,
|
|
|
|
my: 0.263
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2015-03-04 12:29:46 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
2015-03-04 12:29:46 +00:00
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:ErrorEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_ERROR', {
|
|
|
|
xScaleFactor: 1.1,
|
|
|
|
yScaleFactor: 1.1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.2,
|
|
|
|
my: 0.722
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:CancelEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
|
|
|
|
xScaleFactor: 1.0,
|
|
|
|
yScaleFactor: 1.0,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.638,
|
|
|
|
my: -0.055
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
|
|
|
}).transform('rotate(45)');
|
2014-04-03 12:01:56 +00:00
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:CompensateEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.201,
|
|
|
|
my: 0.472
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:SignalEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
|
|
|
|
xScaleFactor: 0.9,
|
|
|
|
yScaleFactor: 0.9,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.2
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:MultipleEventDefinition': function(p, event, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
|
|
|
|
xScaleFactor: 1.1,
|
|
|
|
yScaleFactor: 1.1,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.222,
|
|
|
|
my: 0.36
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 16:48:38 +00:00
|
|
|
var fill = isThrowing ? 'black' : 'none';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: fill
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
'bpmn:ParallelMultipleEventDefinition': function(p, event) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
|
|
|
|
xScaleFactor: 1.2,
|
|
|
|
yScaleFactor: 1.2,
|
|
|
|
containerWidth: event.width,
|
|
|
|
containerHeight: event.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.458,
|
|
|
|
my: 0.194
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:EndEvent': function(p, element) {
|
|
|
|
var circle = renderer('bpmn:Event')(p, element, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 4
|
2014-03-20 15:18:23 +00:00
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEventContent(element, p, true);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
return circle;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:TerminateEventDefinition': function(p, element) {
|
|
|
|
var circle = drawCircle(p, element.width, element.height, 8, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 4,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
return circle;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:IntermediateEvent': function(p, element) {
|
|
|
|
var outer = renderer('bpmn:Event')(p, element, { strokeWidth: 1 });
|
2015-02-02 13:46:21 +00:00
|
|
|
/* inner */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEventContent(element, p);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
return outer;
|
|
|
|
},
|
|
|
|
'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
|
2014-04-03 12:01:56 +00:00
|
|
|
'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Activity': function(p, element, attrs) {
|
|
|
|
return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs);
|
2014-04-25 14:14:36 +00:00
|
|
|
},
|
|
|
|
|
2015-05-05 10:01:53 +00:00
|
|
|
'bpmn:Task': function(p, element, attrs) {
|
|
|
|
var rect = renderer('bpmn:Activity')(p, element, attrs);
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEmbeddedLabel(p, element, 'center-middle');
|
|
|
|
attachTaskMarkers(p, element);
|
2014-03-20 15:18:23 +00:00
|
|
|
return rect;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ServiceTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
|
|
|
|
abspos: {
|
|
|
|
x: 12,
|
|
|
|
y: 18
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* service bg */ drawPath(p, pathDataBG, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
|
|
|
|
abspos: {
|
|
|
|
x: 17.2,
|
|
|
|
y: 18
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* service fill */ drawPath(p, fillPathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 0,
|
|
|
|
stroke: 'none',
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'white'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
|
|
|
|
abspos: {
|
|
|
|
x: 17,
|
|
|
|
y: 22
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* service */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'white'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:UserTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var x = 15;
|
|
|
|
var y = 12;
|
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
|
|
|
|
abspos: {
|
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* user path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 0.5,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
|
|
|
|
abspos: {
|
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* user2 path */ drawPath(p, pathData2, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 0.5,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
|
|
|
|
abspos: {
|
|
|
|
x: x,
|
|
|
|
y: y
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* user3 path */ drawPath(p, pathData3, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 0.5,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ManualTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
|
|
|
|
abspos: {
|
|
|
|
x: 17,
|
|
|
|
y: 15
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* manual path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 0.25,
|
2014-08-17 16:33:41 +00:00
|
|
|
fill: 'white',
|
2014-05-27 16:48:38 +00:00
|
|
|
stroke: 'black'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:SendTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: 21,
|
|
|
|
containerHeight: 14,
|
|
|
|
position: {
|
|
|
|
mx: 0.285,
|
|
|
|
my: 0.357
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* send path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black',
|
|
|
|
stroke: 'white'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ReceiveTask' : function(p, element) {
|
|
|
|
var semantic = getSemantic(element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
var pathData;
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-05-28 21:19:41 +00:00
|
|
|
if (semantic.instantiate) {
|
|
|
|
drawCircle(p, 28, 28, 20 * 0.22, { strokeWidth: 1 });
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
|
|
|
|
abspos: {
|
|
|
|
x: 7.77,
|
|
|
|
y: 9.52
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
|
|
|
|
xScaleFactor: 0.9,
|
|
|
|
yScaleFactor: 0.9,
|
|
|
|
containerWidth: 21,
|
|
|
|
containerHeight: 14,
|
|
|
|
position: {
|
|
|
|
mx: 0.3,
|
|
|
|
my: 0.4
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* receive path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ScriptTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
|
|
|
|
abspos: {
|
|
|
|
x: 15,
|
|
|
|
y: 20
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* script path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:BusinessRuleTask': function(p, element) {
|
|
|
|
var task = renderer('bpmn:Task')(p, element);
|
2014-05-12 09:48:24 +00:00
|
|
|
|
|
|
|
var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
|
|
|
|
abspos: {
|
|
|
|
x: 8,
|
|
|
|
y: 8
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var businessHeaderPath = drawPath(p, headerPathData);
|
|
|
|
businessHeaderPath.attr({
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
|
|
|
fill: 'AAA'
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
|
|
|
|
abspos: {
|
|
|
|
x: 8,
|
|
|
|
y: 8
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var businessPath = drawPath(p, headerData);
|
|
|
|
businessPath.attr({
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
2014-05-23 08:59:00 +00:00
|
|
|
|
2014-05-12 09:48:24 +00:00
|
|
|
return task;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:SubProcess': function(p, element, attrs) {
|
|
|
|
var rect = renderer('bpmn:Activity')(p, element, attrs);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var semantic = getSemantic(element);
|
2014-04-25 14:14:36 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var expanded = DiUtil.isExpanded(semantic);
|
2014-06-17 09:48:23 +00:00
|
|
|
|
2014-09-15 12:41:26 +00:00
|
|
|
var isEventSubProcess = !!semantic.triggeredByEvent;
|
2014-05-27 15:51:16 +00:00
|
|
|
if (isEventSubProcess) {
|
2014-05-15 06:37:45 +00:00
|
|
|
rect.attr({
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeDasharray: '1,2'
|
2014-05-15 06:37:45 +00:00
|
|
|
});
|
|
|
|
}
|
2014-05-05 15:22:43 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle');
|
2014-05-05 15:22:43 +00:00
|
|
|
|
2014-06-17 09:48:23 +00:00
|
|
|
if (expanded) {
|
2014-07-16 14:15:23 +00:00
|
|
|
attachTaskMarkers(p, element);
|
2014-05-05 15:22:43 +00:00
|
|
|
} else {
|
2014-07-16 14:15:23 +00:00
|
|
|
attachTaskMarkers(p, element, ['SubProcessMarker']);
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
2014-05-21 11:51:59 +00:00
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
return rect;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:AdHocSubProcess': function(p, element) {
|
|
|
|
return renderer('bpmn:SubProcess')(p, element);
|
2014-05-05 15:22:43 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Transaction': function(p, element) {
|
|
|
|
var outer = renderer('bpmn:SubProcess')(p, element);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
var innerAttrs = styles.style([ 'no-fill', 'no-events' ]);
|
2015-02-02 13:46:21 +00:00
|
|
|
|
|
|
|
/* inner path */ drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
return outer;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:CallActivity': function(p, element) {
|
2015-05-05 10:01:53 +00:00
|
|
|
return renderer('bpmn:Task')(p, element, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 5
|
|
|
|
});
|
2014-03-20 15:18:23 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Participant': function(p, element) {
|
2014-05-02 15:03:03 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var lane = renderer('bpmn:Lane')(p, element);
|
2014-05-02 15:03:03 +00:00
|
|
|
|
2015-04-27 14:50:09 +00:00
|
|
|
var expandedPool = DiUtil.isExpanded(element);
|
2014-05-02 15:03:03 +00:00
|
|
|
|
|
|
|
if (expandedPool) {
|
|
|
|
drawLine(p, [
|
2014-09-08 17:03:39 +00:00
|
|
|
{ x: 30, y: 0 },
|
|
|
|
{ x: 30, y: element.height }
|
2014-05-02 15:03:03 +00:00
|
|
|
]);
|
2014-07-16 14:15:23 +00:00
|
|
|
var text = getSemantic(element).name;
|
|
|
|
renderLaneLabel(p, text, element);
|
2014-05-02 15:03:03 +00:00
|
|
|
} else {
|
|
|
|
// Collapsed pool draw text inline
|
2014-07-16 14:15:23 +00:00
|
|
|
var text2 = getSemantic(element).name;
|
|
|
|
renderLabel(p, text2, { box: element, align: 'center-middle' });
|
2014-05-02 15:03:03 +00:00
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
|
2014-05-18 10:20:11 +00:00
|
|
|
|
|
|
|
if(participantMultiplicity) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('ParticipantMultiplicityMarker')(p, element);
|
2014-05-18 10:20:11 +00:00
|
|
|
}
|
|
|
|
|
2014-05-02 15:03:03 +00:00
|
|
|
return lane;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Lane': function(p, element) {
|
|
|
|
var rect = drawRect(p, element.width, element.height, 0, {
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-05-27 15:51:16 +00:00
|
|
|
});
|
2014-05-02 15:03:03 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var semantic = getSemantic(element);
|
2014-05-21 13:35:26 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (semantic.$type === 'bpmn:Lane') {
|
|
|
|
var text = semantic.name;
|
2014-07-16 14:15:23 +00:00
|
|
|
renderLaneLabel(p, text, element);
|
2014-05-02 15:03:03 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
return rect;
|
2014-03-20 16:51:05 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:InclusiveGateway': function(p, element) {
|
|
|
|
var diamond = drawDiamond(p, element.width, element.height);
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2015-03-05 13:18:53 +00:00
|
|
|
/* circle path */
|
|
|
|
drawCircle(p, element.width, element.height, element.height * 0.24, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2.5,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ExclusiveGateway': function(p, element) {
|
|
|
|
var diamond = drawDiamond(p, element.width, element.height);
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
|
2014-04-28 09:48:19 +00:00
|
|
|
xScaleFactor: 0.4,
|
|
|
|
yScaleFactor: 0.4,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-24 10:25:04 +00:00
|
|
|
position: {
|
2014-04-28 09:48:19 +00:00
|
|
|
mx: 0.32,
|
|
|
|
my: 0.3
|
2014-04-24 10:25:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
if (!!(getDi(element).isMarkerVisible)) {
|
2014-07-09 08:02:34 +00:00
|
|
|
drawPath(p, pathData, {
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: 'black'
|
|
|
|
});
|
|
|
|
}
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ComplexGateway': function(p, element) {
|
|
|
|
var diamond = drawDiamond(p, element.width, element.height);
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
|
|
|
|
xScaleFactor: 0.5,
|
|
|
|
yScaleFactor:0.5,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-24 10:25:04 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.46,
|
|
|
|
my: 0.26
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* complex path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:ParallelGateway': function(p, element) {
|
|
|
|
var diamond = drawDiamond(p, element.width, element.height);
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
|
|
|
|
xScaleFactor: 0.6,
|
|
|
|
yScaleFactor:0.6,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-24 10:25:04 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.46,
|
|
|
|
my: 0.2
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* parallel path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:EventBasedGateway': function(p, element) {
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var semantic = getSemantic(element);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var diamond = drawDiamond(p, element.width, element.height);
|
2014-04-24 10:25:04 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* outer circle path */ drawCircle(p, element.width, element.height, element.height * 0.20, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
var type = semantic.eventGatewayType;
|
|
|
|
var instantiate = !!semantic.instantiate;
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
function drawEvent() {
|
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
|
2014-05-06 09:30:03 +00:00
|
|
|
xScaleFactor: 0.18,
|
|
|
|
yScaleFactor: 0.18,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-24 10:25:04 +00:00
|
|
|
position: {
|
2014-05-06 09:30:03 +00:00
|
|
|
mx: 0.36,
|
|
|
|
my: 0.44
|
2014-04-24 10:25:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* event path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (type === 'Parallel') {
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
|
|
|
|
xScaleFactor: 0.4,
|
|
|
|
yScaleFactor:0.4,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-24 10:25:04 +00:00
|
|
|
position: {
|
2014-04-28 09:48:19 +00:00
|
|
|
mx: 0.474,
|
|
|
|
my: 0.296
|
2014-04-24 10:25:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var parallelPath = drawPath(p, pathData);
|
|
|
|
parallelPath.attr({
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none'
|
2014-04-24 10:25:04 +00:00
|
|
|
});
|
2014-05-28 21:19:41 +00:00
|
|
|
} else if (type === 'Exclusive') {
|
2014-04-24 10:25:04 +00:00
|
|
|
|
2014-05-28 21:19:41 +00:00
|
|
|
if (!instantiate) {
|
2014-07-16 14:15:23 +00:00
|
|
|
var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26);
|
2014-05-28 21:19:41 +00:00
|
|
|
innerCircle.attr({
|
|
|
|
strokeWidth: 1,
|
|
|
|
fill: 'none'
|
|
|
|
});
|
|
|
|
}
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
drawEvent();
|
|
|
|
}
|
2014-04-25 14:14:36 +00:00
|
|
|
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Gateway': function(p, element) {
|
|
|
|
return drawDiamond(p, element.width, element.height);
|
2014-03-20 16:51:05 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:SequenceFlow': function(p, element) {
|
2014-07-30 14:06:32 +00:00
|
|
|
var pathData = createPathFromConnection(element);
|
2014-05-27 15:51:16 +00:00
|
|
|
var path = drawPath(p, pathData, {
|
|
|
|
markerEnd: marker('sequenceflow-end')
|
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var sequenceFlow = getSemantic(element);
|
2014-07-23 16:53:33 +00:00
|
|
|
var source = element.source.businessObject;
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
// conditional flow marker
|
|
|
|
if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) {
|
|
|
|
path.attr({
|
|
|
|
markerStart: marker('conditional-flow-marker')
|
2014-05-17 08:54:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
// default marker
|
|
|
|
if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) {
|
|
|
|
path.attr({
|
|
|
|
markerStart: marker('conditional-default-flow-marker')
|
|
|
|
});
|
2014-05-19 14:22:55 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return path;
|
2014-03-20 16:51:05 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Association': function(p, element, attrs) {
|
2014-05-28 20:48:11 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
attrs = assign({
|
2014-05-28 20:48:11 +00:00
|
|
|
strokeDasharray: '1,6',
|
|
|
|
strokeLinecap: 'round'
|
|
|
|
}, attrs || {});
|
2014-03-20 16:51:05 +00:00
|
|
|
|
|
|
|
// TODO(nre): style according to directed state
|
2014-07-16 14:15:23 +00:00
|
|
|
return drawLine(p, element.waypoints, attrs);
|
2014-03-20 16:51:05 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataInputAssociation': function(p, element) {
|
|
|
|
return renderer('bpmn:Association')(p, element, {
|
2014-07-24 09:02:52 +00:00
|
|
|
markerEnd: marker('data-association-end')
|
2014-04-02 10:55:18 +00:00
|
|
|
});
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataOutputAssociation': function(p, element) {
|
|
|
|
return renderer('bpmn:Association')(p, element, {
|
2014-07-24 09:02:52 +00:00
|
|
|
markerEnd: marker('data-association-end')
|
2014-04-02 10:55:18 +00:00
|
|
|
});
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:MessageFlow': function(p, element) {
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2015-02-25 17:30:16 +00:00
|
|
|
var semantic = getSemantic(element),
|
|
|
|
di = getDi(element);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-30 14:06:32 +00:00
|
|
|
var pathData = createPathFromConnection(element);
|
2014-05-27 15:51:16 +00:00
|
|
|
var path = drawPath(p, pathData, {
|
|
|
|
markerEnd: marker('messageflow-end'),
|
|
|
|
markerStart: marker('messageflow-start'),
|
2014-05-27 16:48:38 +00:00
|
|
|
strokeDasharray: '10',
|
|
|
|
strokeLinecap: 'round',
|
|
|
|
strokeWidth: 1
|
2014-05-27 15:51:16 +00:00
|
|
|
});
|
2014-05-21 11:51:59 +00:00
|
|
|
|
2015-02-25 17:30:16 +00:00
|
|
|
if (semantic.messageRef) {
|
2014-05-27 15:51:16 +00:00
|
|
|
var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
|
2014-05-21 11:51:59 +00:00
|
|
|
|
|
|
|
var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
|
|
|
|
abspos: {
|
|
|
|
x: midPoint.x,
|
|
|
|
y: midPoint.y
|
|
|
|
}
|
|
|
|
});
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
var messageAttrs = { strokeWidth: 1 };
|
|
|
|
|
|
|
|
if (di.messageVisibleKind === 'initiating') {
|
2014-05-27 16:48:38 +00:00
|
|
|
messageAttrs.fill = 'white';
|
|
|
|
messageAttrs.stroke = 'black';
|
2014-05-27 15:51:16 +00:00
|
|
|
} else {
|
|
|
|
messageAttrs.fill = '#888';
|
2014-05-27 16:48:38 +00:00
|
|
|
messageAttrs.stroke = 'white';
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
drawPath(p, markerPathData, messageAttrs);
|
2014-05-21 11:51:59 +00:00
|
|
|
}
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
return path;
|
2014-04-02 10:55:18 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataObject': function(p, element) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-28 13:32:55 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.474,
|
|
|
|
my: 0.296
|
|
|
|
}
|
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var elementObject = drawPath(p, pathData, { fill: 'white' });
|
2014-04-06 22:16:57 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var semantic = getSemantic(element);
|
2014-04-28 13:32:55 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (isCollection(semantic)) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderDataItemCollection(p, element);
|
2014-04-04 10:01:42 +00:00
|
|
|
}
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
return elementObject;
|
2014-04-02 10:55:18 +00:00
|
|
|
},
|
2014-05-27 15:51:16 +00:00
|
|
|
'bpmn:DataObjectReference': as('bpmn:DataObject'),
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataInput': function(p, element) {
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
// page
|
2014-07-16 14:15:23 +00:00
|
|
|
var elementObject = renderer('bpmn:DataObject')(p, element);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* input arrow path */ drawPath(p, arrowPathData, { strokeWidth: 1 });
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
return elementObject;
|
2014-04-02 10:55:18 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataOutput': function(p, element) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
// page
|
2014-07-16 14:15:23 +00:00
|
|
|
var elementObject = renderer('bpmn:DataObject')(p, element);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* output arrow path */ drawPath(p, arrowPathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-04-02 10:55:18 +00:00
|
|
|
});
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
return elementObject;
|
2014-04-02 10:55:18 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:DataStoreReference': function(p, element) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-04-28 13:32:55 +00:00
|
|
|
position: {
|
|
|
|
mx: 0,
|
|
|
|
my: 0.133
|
|
|
|
}
|
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var elementStore = drawPath(p, DATA_STORE_PATH, {
|
2014-05-27 16:48:38 +00:00
|
|
|
strokeWidth: 2,
|
2014-05-28 20:48:11 +00:00
|
|
|
fill: 'white'
|
2014-03-20 16:51:05 +00:00
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
return elementStore;
|
2014-04-03 12:01:56 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:BoundaryEvent': function(p, element) {
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var semantic = getSemantic(element),
|
2014-05-27 15:51:16 +00:00
|
|
|
cancel = semantic.cancelActivity;
|
|
|
|
|
2014-05-28 21:19:41 +00:00
|
|
|
var attrs = {
|
2014-05-27 16:48:38 +00:00
|
|
|
strokeLinecap: 'round',
|
2014-05-28 21:19:41 +00:00
|
|
|
strokeWidth: 1
|
|
|
|
};
|
2014-05-27 16:48:38 +00:00
|
|
|
|
2014-05-28 21:19:41 +00:00
|
|
|
if (!cancel) {
|
|
|
|
attrs.strokeDasharray = '6';
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var outer = renderer('bpmn:Event')(p, element, attrs);
|
2015-02-02 13:46:21 +00:00
|
|
|
/* inner path */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, attrs);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
renderEventContent(element, p);
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
return outer;
|
2014-04-25 11:50:53 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:Group': function(p, element) {
|
|
|
|
return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1,
|
|
|
|
strokeDasharray: '8,3,1,3',
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none',
|
2014-05-27 15:51:16 +00:00
|
|
|
pointerEvents: 'none'
|
2014-04-29 13:39:26 +00:00
|
|
|
});
|
2014-04-25 14:14:36 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'label': function(p, element) {
|
|
|
|
return renderExternalLabel(p, element, '');
|
2014-05-02 09:17:25 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'bpmn:TextAnnotation': function(p, element) {
|
2014-08-05 11:57:32 +00:00
|
|
|
var style = {
|
|
|
|
'fill': 'none',
|
|
|
|
'stroke': 'none'
|
|
|
|
};
|
2014-12-07 12:06:32 +00:00
|
|
|
var textElement = drawRect(p, element.width, element.height, 0, 0, style);
|
2014-05-02 09:17:25 +00:00
|
|
|
var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-02 09:17:25 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.0,
|
|
|
|
my: 0.0
|
|
|
|
}
|
|
|
|
});
|
2014-05-05 15:22:43 +00:00
|
|
|
drawPath(p, textPathData);
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var text = getSemantic(element).text || '';
|
2014-09-15 12:41:26 +00:00
|
|
|
renderLabel(p, text, { box: element, align: 'left-middle', padding: 5 });
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-08-05 11:57:32 +00:00
|
|
|
return textElement;
|
2014-05-05 15:22:43 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'ParticipantMultiplicityMarker': function(p, element) {
|
2014-05-18 10:20:11 +00:00
|
|
|
var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-18 10:20:11 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2) / element.width),
|
|
|
|
my: (element.height - 15) / element.height
|
2014-05-18 10:20:11 +00:00
|
|
|
}
|
|
|
|
});
|
2014-05-28 20:48:11 +00:00
|
|
|
|
|
|
|
drawPath(p, subProcessPath);
|
2014-05-18 10:20:11 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'SubProcessMarker': function(p, element) {
|
2014-05-28 20:48:11 +00:00
|
|
|
var markerRect = drawRect(p, 14, 14, 0, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 1
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-05-28 20:48:11 +00:00
|
|
|
// Process marker is placed in the middle of the box
|
|
|
|
// therefore fixed values can be used here
|
2014-07-16 14:15:23 +00:00
|
|
|
markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')');
|
2014-05-28 20:48:11 +00:00
|
|
|
|
2014-05-05 15:22:43 +00:00
|
|
|
var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
|
|
|
|
xScaleFactor: 1.5,
|
|
|
|
yScaleFactor: 1.5,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: (element.width / 2 - 7.5) / element.width,
|
|
|
|
my: (element.height - 20) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
2014-05-28 20:48:11 +00:00
|
|
|
|
2014-05-05 15:22:43 +00:00
|
|
|
drawPath(p, subProcessPath);
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'ParallelMarker': function(p, element, position) {
|
2014-05-05 15:22:43 +00:00
|
|
|
var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2 + position.parallel) / element.width),
|
|
|
|
my: (element.height - 20) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
drawPath(p, subProcessPath);
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'SequentialMarker': function(p, element, position) {
|
2014-05-05 15:22:43 +00:00
|
|
|
var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2 + position.seq) / element.width),
|
|
|
|
my: (element.height - 19) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
drawPath(p, sequentialPath);
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'CompensationMarker': function(p, element, position) {
|
2014-05-05 15:22:43 +00:00
|
|
|
var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2 + position.compensation) / element.width),
|
|
|
|
my: (element.height - 13) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
2014-05-27 16:48:38 +00:00
|
|
|
drawPath(p, compensationPath, { strokeWidth: 1 });
|
2014-05-05 15:22:43 +00:00
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'LoopMarker': function(p, element, position) {
|
2014-05-05 15:22:43 +00:00
|
|
|
var loopPath = pathMap.getScaledPath('MARKER_LOOP', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2 + position.loop) / element.width),
|
|
|
|
my: (element.height - 7) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
drawPath(p, loopPath, {
|
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'none',
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeLinecap: 'round',
|
|
|
|
strokeMiterlimit: 0.5
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
|
|
|
},
|
2014-07-16 14:15:23 +00:00
|
|
|
'AdhocMarker': function(p, element, position) {
|
2014-05-05 15:22:43 +00:00
|
|
|
var loopPath = pathMap.getScaledPath('MARKER_ADHOC', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-05 15:22:43 +00:00
|
|
|
position: {
|
2014-07-16 14:15:23 +00:00
|
|
|
mx: ((element.width / 2 + position.adhoc) / element.width),
|
|
|
|
my: (element.height - 15) / element.height
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
});
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
drawPath(p, loopPath, {
|
|
|
|
strokeWidth: 1,
|
2014-05-27 16:48:38 +00:00
|
|
|
fill: 'black'
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
|
|
|
}
|
2014-03-20 15:18:23 +00:00
|
|
|
};
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function attachTaskMarkers(p, element, taskMarkers) {
|
|
|
|
var obj = getSemantic(element);
|
2014-05-05 15:22:43 +00:00
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
var subprocess = includes(taskMarkers, 'SubProcessMarker');
|
2014-05-05 15:22:43 +00:00
|
|
|
var position;
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (subprocess) {
|
2014-05-05 15:22:43 +00:00
|
|
|
position = {
|
|
|
|
seq: -21,
|
|
|
|
parallel: -22,
|
|
|
|
compensation: -42,
|
|
|
|
loop: -18,
|
|
|
|
adhoc: 10
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
position = {
|
|
|
|
seq: -3,
|
|
|
|
parallel: -6,
|
|
|
|
compensation: -27,
|
|
|
|
loop: 0,
|
|
|
|
adhoc: 10
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
forEach(taskMarkers, function(marker) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer(marker)(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
if (obj.$type === 'bpmn:AdHocSubProcess') {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('AdhocMarker')(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('LoopMarker')(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
if (obj.loopCharacteristics &&
|
2014-05-05 15:22:43 +00:00
|
|
|
obj.loopCharacteristics.isSequential !== undefined &&
|
|
|
|
!obj.loopCharacteristics.isSequential) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('ParallelMarker')(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('SequentialMarker')(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
2014-05-27 15:51:16 +00:00
|
|
|
if (!!obj.isForCompensation) {
|
2014-07-16 14:15:23 +00:00
|
|
|
renderer('CompensationMarker')(p, element, position);
|
2014-05-05 15:22:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function drawShape(parent, element) {
|
|
|
|
var type = element.type;
|
2014-03-20 15:18:23 +00:00
|
|
|
var h = handlers[type];
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
/* jshint -W040 */
|
2014-03-20 15:18:23 +00:00
|
|
|
if (!h) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return DefaultRenderer.prototype.drawShape.apply(this, [ parent, element ]);
|
2014-03-20 15:18:23 +00:00
|
|
|
} else {
|
2014-07-16 14:15:23 +00:00
|
|
|
return h(parent, element);
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function drawConnection(parent, element) {
|
|
|
|
var type = element.type;
|
2014-03-20 16:51:05 +00:00
|
|
|
var h = handlers[type];
|
|
|
|
|
2014-05-27 15:51:16 +00:00
|
|
|
/* jshint -W040 */
|
2014-03-20 16:51:05 +00:00
|
|
|
if (!h) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return DefaultRenderer.prototype.drawConnection.apply(this, [ parent, element ]);
|
2014-03-20 16:51:05 +00:00
|
|
|
} else {
|
2014-07-16 14:15:23 +00:00
|
|
|
return h(parent, element);
|
2014-03-20 16:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
function renderDataItemCollection(p, element) {
|
2014-05-27 15:51:16 +00:00
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
var yPosition = (element.height - 16) / element.height;
|
2014-05-27 15:51:16 +00:00
|
|
|
|
|
|
|
var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
2014-07-16 14:15:23 +00:00
|
|
|
containerWidth: element.width,
|
|
|
|
containerHeight: element.height,
|
2014-05-27 15:51:16 +00:00
|
|
|
position: {
|
|
|
|
mx: 0.451,
|
|
|
|
my: yPosition
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
/* collection path */ drawPath(p, pathData, {
|
2014-05-27 15:51:16 +00:00
|
|
|
strokeWidth: 2
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function isCollection(element, filter) {
|
|
|
|
return element.isCollection ||
|
2014-07-16 14:15:23 +00:00
|
|
|
(element.elementObjectRef && element.elementObjectRef.isCollection);
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getDi(element) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return element.businessObject.di;
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSemantic(element) {
|
2014-07-16 14:15:23 +00:00
|
|
|
return element.businessObject;
|
2014-05-27 15:51:16 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
/**
|
|
|
|
* Checks if eventDefinition of the given element matches with semantic type.
|
|
|
|
*
|
|
|
|
* @return {boolean} true if element is of the given semantic type
|
|
|
|
*/
|
2014-04-25 11:50:53 +00:00
|
|
|
function isTypedEvent(event, eventDefinitionType, filter) {
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-05-02 16:20:36 +00:00
|
|
|
function matches(definition, filter) {
|
2015-02-02 13:46:21 +00:00
|
|
|
return every(filter, function(val, key) {
|
2014-05-05 07:18:46 +00:00
|
|
|
|
|
|
|
// we want a == conversion here, to be able to catch
|
|
|
|
// undefined == false and friends
|
|
|
|
/* jshint -W116 */
|
2014-05-02 16:20:36 +00:00
|
|
|
return definition[key] == val;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-02-02 13:46:21 +00:00
|
|
|
return some(event.eventDefinitions, function(definition) {
|
2014-05-21 14:14:17 +00:00
|
|
|
return definition.$type === eventDefinitionType && matches(event, filter);
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-04-25 11:50:53 +00:00
|
|
|
function isThrowEvent(event) {
|
|
|
|
return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
|
2014-04-03 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
/////// cropping path customizations /////////////////////////
|
|
|
|
|
|
|
|
function componentsToPath(elements) {
|
|
|
|
return elements.join(',').replace(/,?([A-z]),?/g, '$1');
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCirclePath(shape) {
|
|
|
|
|
|
|
|
var cx = shape.x + shape.width / 2,
|
|
|
|
cy = shape.y + shape.height / 2,
|
|
|
|
radius = shape.width / 2;
|
|
|
|
|
|
|
|
var circlePath = [
|
|
|
|
['M', cx, cy],
|
|
|
|
['m', 0, -radius],
|
|
|
|
['a', radius, radius, 0, 1, 1, 0, 2 * radius],
|
|
|
|
['a', radius, radius, 0, 1, 1, 0, -2 * radius],
|
|
|
|
['z']
|
|
|
|
];
|
|
|
|
|
|
|
|
return componentsToPath(circlePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRoundRectPath(shape) {
|
|
|
|
|
|
|
|
var radius = TASK_BORDER_RADIUS,
|
|
|
|
x = shape.x,
|
|
|
|
y = shape.y,
|
|
|
|
width = shape.width,
|
|
|
|
height = shape.height;
|
|
|
|
|
|
|
|
var roundRectPath = [
|
|
|
|
['M', x + radius, y],
|
|
|
|
['l', width - radius * 2, 0],
|
|
|
|
['a', radius, radius, 0, 0, 1, radius, radius],
|
|
|
|
['l', 0, height - radius * 2],
|
|
|
|
['a', radius, radius, 0, 0, 1, -radius, radius],
|
|
|
|
['l', radius * 2 - width, 0],
|
|
|
|
['a', radius, radius, 0, 0, 1, -radius, -radius],
|
|
|
|
['l', 0, radius * 2 - height],
|
|
|
|
['a', radius, radius, 0, 0, 1, radius, -radius],
|
|
|
|
['z']
|
|
|
|
];
|
|
|
|
|
|
|
|
return componentsToPath(roundRectPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDiamondPath(shape) {
|
|
|
|
|
|
|
|
var width = shape.width,
|
|
|
|
height = shape.height,
|
|
|
|
x = shape.x,
|
|
|
|
y = shape.y,
|
|
|
|
halfWidth = width / 2,
|
|
|
|
halfHeight = height / 2;
|
|
|
|
|
|
|
|
var diamondPath = [
|
|
|
|
['M', x + halfWidth, y],
|
|
|
|
['l', halfWidth, halfHeight],
|
|
|
|
['l', -halfWidth, halfHeight],
|
|
|
|
['l', -halfWidth, -halfHeight],
|
|
|
|
['z']
|
|
|
|
];
|
|
|
|
|
|
|
|
return componentsToPath(diamondPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRectPath(shape) {
|
|
|
|
var x = shape.x,
|
|
|
|
y = shape.y,
|
|
|
|
width = shape.width,
|
|
|
|
height = shape.height;
|
|
|
|
|
|
|
|
var rectPath = [
|
|
|
|
['M', x, y],
|
|
|
|
['l', width, 0],
|
|
|
|
['l', 0, height],
|
|
|
|
['l', -width, 0],
|
|
|
|
['z']
|
|
|
|
];
|
|
|
|
|
|
|
|
return componentsToPath(rectPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getShapePath(element) {
|
|
|
|
var obj = getSemantic(element);
|
|
|
|
|
|
|
|
if (obj.$instanceOf('bpmn:Event')) {
|
|
|
|
return getCirclePath(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.$instanceOf('bpmn:Activity')) {
|
|
|
|
return getRoundRectPath(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.$instanceOf('bpmn:Gateway')) {
|
|
|
|
return getDiamondPath(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
return getRectPath(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
// hook onto canvas init event to initialize
|
2014-11-26 10:31:23 +00:00
|
|
|
// connection start/end markers on svg
|
2014-03-20 16:51:05 +00:00
|
|
|
events.on('canvas.init', function(event) {
|
2014-11-26 10:31:23 +00:00
|
|
|
initMarkers(event.svg);
|
2014-03-20 16:51:05 +00:00
|
|
|
});
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
this.drawShape = drawShape;
|
2014-03-20 16:51:05 +00:00
|
|
|
this.drawConnection = drawConnection;
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
this.getShapePath = getShapePath;
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 14:15:32 +00:00
|
|
|
inherits(BpmnRenderer, DefaultRenderer);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
|
2014-07-16 14:15:23 +00:00
|
|
|
BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap' ];
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2015-03-04 12:29:46 +00:00
|
|
|
module.exports = BpmnRenderer;
|