2014-03-20 15:18:23 +00:00
|
|
|
var bpmnModule = require('../di').defaultModule;
|
2014-04-03 12:01:56 +00:00
|
|
|
var _ = require('lodash');
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
require('diagram-js/lib/core/EventBus');
|
|
|
|
require('diagram-js/lib/draw/Styles');
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-04-09 08:50:20 +00:00
|
|
|
require('../core/BpmnRegistry');
|
2014-04-30 12:41:59 +00:00
|
|
|
require('./PathMap');
|
2014-04-09 08:50:20 +00:00
|
|
|
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
var DefaultRenderer = require('diagram-js/lib/draw/Renderer');
|
2014-04-25 14:14:36 +00:00
|
|
|
var LabelUtil = require('diagram-js/lib/util/LabelUtil');
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
|
|
|
|
var flattenPoints = DefaultRenderer.flattenPoints;
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
function BpmnRenderer(events, styles, bpmnRegistry, pathMap) {
|
2014-03-25 13:08:11 +00:00
|
|
|
|
|
|
|
DefaultRenderer.apply(this, [ events, 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 = {
|
|
|
|
fontFamily: '"Helvetica Neue", Helvetica, Arial, sans-serif',
|
2014-05-02 16:20:36 +00:00
|
|
|
fontSize: '10pt'
|
2014-04-25 14:14:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var labelUtil = new LabelUtil({
|
|
|
|
style: LABEL_STYLE
|
|
|
|
});
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
var markers = {};
|
|
|
|
|
|
|
|
function addMarker(id, element) {
|
|
|
|
markers[id] = element;
|
|
|
|
}
|
|
|
|
|
|
|
|
function marker(id) {
|
|
|
|
return markers[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMarkers(paper) {
|
|
|
|
|
|
|
|
addMarker('sequenceflow-end',
|
|
|
|
paper
|
|
|
|
.path('M 0 0 L 10 5 L 0 10 Z')
|
|
|
|
.attr({
|
|
|
|
'fill': 'black',
|
|
|
|
'stroke': 'none'
|
|
|
|
})
|
|
|
|
.marker(0, 0, 10, 10, 10, 5)
|
|
|
|
.attr({
|
|
|
|
markerUnits: 'strokeWidth',
|
|
|
|
markerWidth: 10,
|
|
|
|
markerHeight: 6,
|
|
|
|
orient: 'auto',
|
|
|
|
overflow: 'visible'
|
|
|
|
}));
|
|
|
|
|
|
|
|
addMarker('messageflow-start',
|
|
|
|
paper
|
|
|
|
.circle(4, 4, 4)
|
|
|
|
.attr({
|
|
|
|
fill: 'white',
|
|
|
|
stroke: 'black',
|
2014-03-21 15:54:34 +00:00
|
|
|
'stroke-width': 1,
|
2014-03-20 16:51:05 +00:00
|
|
|
'stroke-dasharray': '1,0'
|
|
|
|
})
|
|
|
|
.marker(0, 0, 10, 10, 4, 4)
|
|
|
|
.attr({
|
|
|
|
markerUnits: 'strokeWidth',
|
2014-03-21 15:54:34 +00:00
|
|
|
markerWidth: 7,
|
|
|
|
markerHeight: 7,
|
2014-03-20 16:51:05 +00:00
|
|
|
orient: 'auto',
|
|
|
|
overflow: 'visible'
|
|
|
|
}));
|
|
|
|
|
|
|
|
addMarker('messageflow-end',
|
|
|
|
paper
|
2014-03-22 00:45:38 +00:00
|
|
|
.path('M 0 0 L 10 5 L 0 10 Z')
|
2014-03-20 16:51:05 +00:00
|
|
|
.attr({
|
|
|
|
stroke: 'black',
|
2014-03-21 15:54:34 +00:00
|
|
|
fill: 'white',
|
|
|
|
'stroke-width': 1,
|
2014-03-20 16:51:05 +00:00
|
|
|
'stroke-linecap': 'round',
|
|
|
|
'stroke-dasharray': '1,0'
|
|
|
|
})
|
2014-03-25 13:08:11 +00:00
|
|
|
.marker(0, 0, 10, 10, 11, 5)
|
2014-03-20 16:51:05 +00:00
|
|
|
.attr({
|
|
|
|
markerUnits: 'strokeWidth',
|
2014-03-25 13:08:11 +00:00
|
|
|
markerWidth: 6,
|
|
|
|
markerHeight: 6,
|
2014-03-20 16:51:05 +00:00
|
|
|
orient: 'auto',
|
|
|
|
overflow: 'visible'
|
|
|
|
}));
|
|
|
|
|
|
|
|
addMarker('directed-association-end',
|
|
|
|
paper
|
|
|
|
.path('M 0 0 L 10 5 L 0 10 Z')
|
|
|
|
.attr('class', 'djs-connection-marker')
|
|
|
|
.marker(0, 0, 10, 10, 10, 5)
|
|
|
|
.attr({
|
|
|
|
stroke: 'black',
|
|
|
|
fill: 'none',
|
|
|
|
'stroke-width': 1.5,
|
|
|
|
'stroke-linecap': 'round',
|
|
|
|
'stroke-dasharray': '1,0'
|
|
|
|
}));
|
2014-04-02 10:55:18 +00:00
|
|
|
addMarker('data-association-end',
|
|
|
|
paper
|
|
|
|
.path('M 0 0 L 10 5 L 0 10')
|
|
|
|
.attr({
|
|
|
|
'fill': 'white',
|
|
|
|
'stroke': 'Black'
|
|
|
|
})
|
|
|
|
.marker(0, 0, 10, 10, 10, 5)
|
|
|
|
.attr({
|
|
|
|
markerUnits: 'strokeWidth',
|
|
|
|
markerWidth: 10,
|
|
|
|
markerHeight: 6,
|
|
|
|
orient: 'auto',
|
|
|
|
overflow: 'visible'
|
|
|
|
}));
|
2014-03-20 16:51:05 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
function drawCircle(p, width, height, offset) {
|
|
|
|
|
|
|
|
offset = offset || 0;
|
|
|
|
|
|
|
|
var cx = width / 2,
|
|
|
|
cy = height / 2;
|
|
|
|
|
|
|
|
return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr({
|
|
|
|
'stroke': 'Black',
|
2014-04-03 12:01:56 +00:00
|
|
|
'stroke-width': 1,
|
2014-03-20 15:18:23 +00:00
|
|
|
'fill': 'White'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawRect(p, width, height, r, offset) {
|
|
|
|
offset = offset || 0;
|
|
|
|
|
|
|
|
var x, y;
|
|
|
|
|
|
|
|
x = y = offset;
|
|
|
|
|
|
|
|
return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr({
|
|
|
|
'stroke': 'Black',
|
|
|
|
'stroke-width': 2,
|
|
|
|
'fill': 'White'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
function drawDiamond(p, width, height) {
|
|
|
|
|
|
|
|
var x_2 = width / 2;
|
|
|
|
var y_2 = height / 2;
|
|
|
|
|
|
|
|
var points = [x_2, 0, width, y_2, x_2, height, 0, y_2 ];
|
|
|
|
|
|
|
|
return p.polygon(points).attr({
|
|
|
|
'stroke': 'Black',
|
|
|
|
'stroke-width': 2,
|
|
|
|
'fill': 'White'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawLine(p, waypoints) {
|
|
|
|
var points = flattenPoints(waypoints);
|
|
|
|
|
2014-03-25 13:08:11 +00:00
|
|
|
return p.polyline(points).attr(styles.style([ 'no-fill' ], {
|
2014-03-20 16:51:05 +00:00
|
|
|
'stroke-width': 2,
|
|
|
|
'stroke': 'Black'
|
2014-03-25 13:08:11 +00:00
|
|
|
}));
|
2014-03-20 16:51:05 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
function drawPath(p, d, fill) {
|
|
|
|
|
|
|
|
var fillColor = fill ? 'Black' : 'None';
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
var path = p.path(d).attr(styles.style([ 'no-fill' ],{
|
|
|
|
'stroke-width': 2,
|
2014-04-03 12:01:56 +00:00
|
|
|
'stroke': 'Black',
|
|
|
|
'fill': fillColor
|
2014-04-02 10:55:18 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
function as(type) {
|
|
|
|
return function(p, data) {
|
|
|
|
return handlers[type](p, data);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderer(type) {
|
|
|
|
return handlers[type];
|
|
|
|
}
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
function renderEventContent(data, p) {
|
|
|
|
|
|
|
|
var path;
|
|
|
|
|
2014-04-25 11:50:53 +00:00
|
|
|
var event = bpmnRegistry.getSemantic(data);
|
|
|
|
var isThrowing = isThrowEvent(event);
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
|
|
|
|
return renderer('bpmn:MessageEventDefinition')(p, data, isThrowing);
|
2014-04-03 12:01:56 +00:00
|
|
|
}
|
2014-04-25 11:50:53 +00:00
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
|
|
|
|
return renderer('bpmn:TimerEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
|
|
|
|
return renderer('bpmn:ConditionalEventDefinition')(p, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
|
|
|
|
return renderer('bpmn:SignalEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
2014-05-02 16:20:36 +00:00
|
|
|
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
|
2014-04-25 11:50:53 +00:00
|
|
|
return renderer('bpmn:MultipleEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
|
2014-05-02 16:20:36 +00:00
|
|
|
isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
|
2014-04-25 11:50:53 +00:00
|
|
|
return renderer('bpmn:ParallelMultipleEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
|
|
|
|
return renderer('bpmn:EscalationEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
|
|
|
|
return renderer('bpmn:LinkEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
|
|
|
|
return renderer('bpmn:ErrorEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
|
|
|
|
return renderer('bpmn:CancelEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
|
|
|
|
return renderer('bpmn:CompensateEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
|
|
|
|
return renderer('bpmn:TerminateEventDefinition')(p, data, isThrowing);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2014-04-03 12:01:56 +00:00
|
|
|
}
|
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
function renderLabel(p, label, box, align) {
|
|
|
|
return labelUtil.createLabel(p, label || '', { box: box, align: align }).addClass('djs-label');
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderEmbeddedLabel(p, data, align) {
|
|
|
|
var element = bpmnRegistry.getSemantic(data);
|
|
|
|
|
|
|
|
return renderLabel(p, element.name, data, align);
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderExternalLabel(p, data, align) {
|
|
|
|
var element = bpmnRegistry.getSemantic(data.attachedId);
|
|
|
|
return renderLabel(p, element.name, data, align);
|
|
|
|
}
|
|
|
|
|
2014-05-02 15:03:03 +00:00
|
|
|
function renderLaneLabel(p, text, data) {
|
|
|
|
// position text left top
|
|
|
|
var textBox = renderLabel(p, text, {height: data.width, width: data.height}, 'left-top');
|
|
|
|
// rotate text and center it on the middle of the lane height
|
|
|
|
var bbox = textBox.getBBox();
|
|
|
|
var top = (data.height / 2) + (bbox.width / 2);
|
|
|
|
textBox.transform('translate(0,' + top + ') rotate(270)');
|
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
var handlers = {
|
|
|
|
'bpmn:Event': function(p, data) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var circle = drawCircle(p, data.width, data.height);
|
2014-03-20 15:18:23 +00:00
|
|
|
return circle;
|
|
|
|
},
|
2014-04-03 12:01:56 +00:00
|
|
|
'bpmn:StartEvent': function(p, data) {
|
|
|
|
var circle = renderer('bpmn:Event')(p, data);
|
|
|
|
|
|
|
|
renderEventContent(data, p);
|
|
|
|
|
|
|
|
return circle;
|
|
|
|
},
|
2014-04-25 11:50:53 +00:00
|
|
|
'bpmn:MessageEventDefinition': function(p, data, isThrowing) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
|
|
|
|
xScaleFactor: 0.9,
|
|
|
|
yScaleFactor: 0.9,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.235,
|
|
|
|
my: 0.315
|
|
|
|
}
|
|
|
|
});
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
|
|
|
var stroke = isThrowing ? 'White' : 'Black';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var messagePath = drawPath(p, pathData);
|
|
|
|
messagePath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill,
|
|
|
|
'stroke': stroke
|
|
|
|
});
|
|
|
|
|
|
|
|
return messagePath;
|
|
|
|
},
|
2014-04-28 13:32:55 +00:00
|
|
|
'bpmn:TimerEventDefinition': function(p, data) {
|
2014-04-03 12:01:56 +00:00
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var circle = drawCircle(p, data.width, data.height, 0.2 * data.height);
|
|
|
|
circle.attr({
|
|
|
|
'stroke-width': 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,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.5,
|
|
|
|
my: 0.5
|
|
|
|
}
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var timerPathWh = drawPath(p, pathData);
|
2014-04-03 12:01:56 +00:00
|
|
|
timerPathWh.attr({
|
2014-04-28 13:32:55 +00:00
|
|
|
'stroke-width': 2
|
2014-04-03 12:01:56 +00:00
|
|
|
});
|
|
|
|
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var escalationPath = drawPath(p, pathData);
|
|
|
|
escalationPath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
|
|
|
return escalationPath;
|
|
|
|
},
|
|
|
|
'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
|
|
|
|
|
|
|
var conditionalPath = drawPath(p, pathData);
|
|
|
|
conditionalPath.attr({
|
|
|
|
'stroke-width': 1
|
|
|
|
});
|
|
|
|
|
|
|
|
return conditionalPath;
|
|
|
|
},
|
|
|
|
'bpmn:LinkEventDefinition': function(p, event) {
|
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
|
|
|
|
|
|
|
var linkPath = drawPath(p, pathData);
|
|
|
|
linkPath.attr({
|
|
|
|
'stroke-width': 1
|
|
|
|
});
|
|
|
|
|
|
|
|
return linkPath;
|
|
|
|
},
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var errorPath = drawPath(p, pathData);
|
|
|
|
errorPath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
|
|
|
return errorPath;
|
|
|
|
},
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var cancelPath = drawPath(p, pathData);
|
|
|
|
cancelPath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
cancelPath.transform('rotate(45)');
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
return cancelPath;
|
|
|
|
},
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var compensationPath = drawPath(p, pathData);
|
|
|
|
compensationPath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
|
|
|
return compensationPath;
|
|
|
|
},
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var signalPath = drawPath(p, pathData);
|
|
|
|
signalPath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
|
|
|
return signalPath;
|
|
|
|
},
|
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-04-25 11:50:53 +00:00
|
|
|
var fill = isThrowing ? 'Black' : 'None';
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
var multiplePath = drawPath(p, pathData);
|
|
|
|
multiplePath.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': fill
|
|
|
|
});
|
|
|
|
|
|
|
|
return multiplePath;
|
|
|
|
},
|
|
|
|
'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-04-03 12:01:56 +00:00
|
|
|
var multiplePath = drawPath(p, pathData);
|
2014-04-28 13:32:55 +00:00
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
multiplePath.attr({
|
|
|
|
'stroke-width': 1
|
|
|
|
});
|
|
|
|
|
|
|
|
return multiplePath;
|
|
|
|
},
|
2014-03-20 15:18:23 +00:00
|
|
|
'bpmn:EndEvent': function(p, data) {
|
|
|
|
var circle = renderer('bpmn:Event')(p, data);
|
|
|
|
|
|
|
|
circle.attr({
|
|
|
|
'stroke-width': 4
|
|
|
|
});
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
renderEventContent(data, p, true);
|
|
|
|
|
|
|
|
return circle;
|
|
|
|
},
|
|
|
|
'bpmn:TerminateEventDefinition': function(p, data) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var circle = drawCircle(p, data.width, data.height, 7);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
circle.attr({
|
|
|
|
'stroke-width': 4,
|
|
|
|
'fill': 'Black'
|
|
|
|
});
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
return circle;
|
|
|
|
},
|
|
|
|
'bpmn:IntermediateEvent': function(p, data) {
|
|
|
|
var outer = renderer('bpmn:Event')(p, data);
|
|
|
|
var inner = drawCircle(p, data.width, data.height, INNER_OUTER_DIST);
|
|
|
|
|
|
|
|
outer.attr('stroke-width', 1);
|
|
|
|
inner.attr('stroke-width', 1);
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
renderEventContent(data, p);
|
|
|
|
|
|
|
|
return outer;
|
|
|
|
},
|
2014-04-30 12:41:59 +00:00
|
|
|
'bpmn:IntermediateNonInterruptingEvent': function(p, data) {
|
2014-04-03 12:01:56 +00:00
|
|
|
var outer = renderer('bpmn:Event')(p, data);
|
2014-04-28 13:32:55 +00:00
|
|
|
var inner = drawCircle(p, data.width, data.height, INNER_OUTER_DIST);
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
outer.attr('stroke-width', 1);
|
2014-04-30 12:41:59 +00:00
|
|
|
outer.attr('stroke-dasharray', '4');
|
2014-04-03 12:01:56 +00:00
|
|
|
inner.attr('stroke-width', 1);
|
2014-04-30 12:41:59 +00:00
|
|
|
inner.attr('stroke-dasharray', '5');
|
2014-04-03 12:01:56 +00:00
|
|
|
|
|
|
|
renderEventContent(data, p);
|
|
|
|
|
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
|
|
|
|
|
|
|
'bpmn:Activity': function(p, data) {
|
|
|
|
var rect = drawRect(p, data.width, data.height, TASK_BORDER_RADIUS);
|
2014-04-25 14:14:36 +00:00
|
|
|
|
|
|
|
return rect;
|
|
|
|
},
|
|
|
|
|
|
|
|
'bpmn:Task': function(p, data) {
|
|
|
|
var rect = renderer('bpmn:Activity')(p, data);
|
|
|
|
renderEmbeddedLabel(p, data, 'center-middle');
|
2014-03-20 15:18:23 +00:00
|
|
|
return rect;
|
|
|
|
},
|
2014-04-25 14:14:36 +00:00
|
|
|
'bpmn:ServiceTask': as('bpmn:Task'),
|
|
|
|
'bpmn:UserTask': as('bpmn:Task'),
|
|
|
|
'bpmn:ManualTask': as('bpmn:Task'),
|
|
|
|
'bpmn:SendTask': as('bpmn:Task'),
|
|
|
|
'bpmn:ReceiveTask': as('bpmn:Task'),
|
|
|
|
'bpmn:ScriptTask': as('bpmn:Task'),
|
|
|
|
'bpmn:BusinessRuleTask': as('bpmn:Task'),
|
|
|
|
'bpmn:SubProcess': function(p, data) {
|
|
|
|
var rect = renderer('bpmn:Activity')(p, data);
|
|
|
|
|
|
|
|
var di = bpmnRegistry.getDi(data);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
renderEmbeddedLabel(p, data, di.isExpanded ? 'center-top' : 'center-middle');
|
|
|
|
return rect;
|
|
|
|
},
|
|
|
|
'bpmn:AdHocSubProcess': as('bpmn:SubProcess'),
|
2014-03-20 15:18:23 +00:00
|
|
|
'bpmn:Transaction': function(p, data) {
|
2014-04-25 14:14:36 +00:00
|
|
|
var outer = renderer('bpmn:SubProcess')(p, data);
|
|
|
|
var inner = drawRect(p, data.width, data.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST)
|
|
|
|
.attr(styles.style([ 'no-fill', 'no-events' ]));
|
2014-03-20 15:18:23 +00:00
|
|
|
|
2014-04-25 14:14:36 +00:00
|
|
|
outer.attr('stroke-width', 1);
|
|
|
|
inner.attr('stroke-width', 1);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
return outer;
|
|
|
|
},
|
|
|
|
'bpmn:CallActivity': function(p, data) {
|
2014-04-25 14:14:36 +00:00
|
|
|
var rect = renderer('bpmn:SubProcess')(p, data);
|
2014-03-20 15:18:23 +00:00
|
|
|
rect.attr('stroke-width', 4);
|
|
|
|
return rect;
|
|
|
|
},
|
|
|
|
|
2014-05-02 15:03:03 +00:00
|
|
|
'bpmn:Participant': function(p, data) {
|
|
|
|
|
|
|
|
var lane = renderer('bpmn:Lane')(p, data);
|
|
|
|
|
|
|
|
var expandedPool = !!(bpmnRegistry.getSemantic(data.id).processRef);
|
|
|
|
|
|
|
|
if (expandedPool) {
|
|
|
|
drawLine(p, [
|
|
|
|
{x: 30, y: 0},
|
|
|
|
{x: 30, y: data.height}
|
|
|
|
]);
|
|
|
|
var text = bpmnRegistry.getSemantic(data.id).name;
|
|
|
|
renderLaneLabel(p, text, data);
|
|
|
|
} else {
|
|
|
|
// Collapsed pool draw text inline
|
|
|
|
var text2 = bpmnRegistry.getSemantic(data.id).name;
|
|
|
|
renderLabel(p, text2, data, 'center-middle');
|
|
|
|
}
|
|
|
|
|
|
|
|
return lane;
|
|
|
|
},
|
2014-03-20 15:18:23 +00:00
|
|
|
'bpmn:Lane': function(p, data) {
|
|
|
|
var rect = drawRect(p, data.width, data.height, 0);
|
2014-05-02 15:03:03 +00:00
|
|
|
|
|
|
|
if(bpmnRegistry.getSemantic(data.id).$type === 'bpmn:Lane') {
|
|
|
|
var text = bpmnRegistry.getSemantic(data.id).name;
|
|
|
|
renderLaneLabel(p, text, data);
|
|
|
|
}
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
return rect;
|
2014-03-20 16:51:05 +00:00
|
|
|
},
|
2014-04-24 10:25:04 +00:00
|
|
|
'bpmn:InclusiveGateway': function(p, data) {
|
|
|
|
var diamond = drawDiamond(p, data.width, data.height);
|
2014-03-20 16:51:05 +00:00
|
|
|
|
2014-04-24 10:25:04 +00:00
|
|
|
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', {
|
2014-04-28 09:48:19 +00:00
|
|
|
xScaleFactor: 0.4,
|
|
|
|
yScaleFactor: 0.4,
|
2014-04-24 10:25:04 +00:00
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
2014-04-28 09:48:19 +00:00
|
|
|
mx: 0.32,
|
|
|
|
my: 0.3
|
2014-04-24 10:25:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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: {
|
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({
|
|
|
|
'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();
|
|
|
|
}
|
2014-04-25 14:14:36 +00:00
|
|
|
|
2014-04-24 10:25:04 +00:00
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
2014-03-20 16:51:05 +00:00
|
|
|
'bpmn:Gateway': function(p, data) {
|
|
|
|
|
|
|
|
var diamond = drawDiamond(p, data.width, data.height);
|
|
|
|
|
|
|
|
return diamond;
|
|
|
|
},
|
|
|
|
'bpmn:SequenceFlow': function(p, data) {
|
|
|
|
var polyline = drawLine(p, data.waypoints);
|
|
|
|
|
|
|
|
return polyline.attr({
|
|
|
|
'marker-end': marker('sequenceflow-end')
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'bpmn:Association': function(p, data) {
|
|
|
|
var polyline = drawLine(p, data.waypoints);
|
|
|
|
|
|
|
|
// TODO(nre): style according to directed state
|
|
|
|
return polyline.attr({
|
|
|
|
'stroke-dasharray': '3,3'
|
|
|
|
});
|
|
|
|
},
|
2014-04-02 10:55:18 +00:00
|
|
|
'bpmn:DataInputAssociation': function(p, data) {
|
|
|
|
var polyline = drawLine(p, data.waypoints);
|
|
|
|
|
|
|
|
return polyline.attr({
|
|
|
|
'stroke-dasharray': '2,4',
|
|
|
|
'marker-end': marker('data-association-end')
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'bpmn:DataOutputAssociation': function(p, data) {
|
|
|
|
var polyline = drawLine(p, data.waypoints);
|
|
|
|
|
|
|
|
return polyline.attr({
|
|
|
|
'stroke-dasharray': '2,4',
|
|
|
|
'marker-end': marker('data-association-end')
|
|
|
|
});
|
|
|
|
},
|
2014-03-20 16:51:05 +00:00
|
|
|
'bpmn:MessageFlow': function(p, data) {
|
|
|
|
var polyline = drawLine(p, data.waypoints);
|
|
|
|
|
|
|
|
return polyline.attr({
|
|
|
|
'marker-end': marker('messageflow-end'),
|
|
|
|
'marker-start': marker('messageflow-start'),
|
2014-04-02 10:55:18 +00:00
|
|
|
'stroke-dasharray': '1,3'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'bpmn:DataObjectReference': function(p, data) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.474,
|
|
|
|
my: 0.296
|
|
|
|
}
|
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var dataObject = drawPath(p, pathData);
|
2014-04-06 22:16:57 +00:00
|
|
|
if(getObjectRef(data.id, 'isCollection') === true ||
|
|
|
|
bpmnRegistry.getSemantic(data.id).isCollection === true) {
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var yPosition = (data.height - 16) / data.height;
|
|
|
|
|
|
|
|
var collectionPathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.451,
|
|
|
|
my: yPosition
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var collectionPath = drawPath(p, collectionPathData);
|
|
|
|
collectionPath.attr({
|
|
|
|
'stroke-width': 2
|
|
|
|
});
|
2014-04-04 10:01:42 +00:00
|
|
|
}
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
},
|
|
|
|
'bpmn:DataInput': function(p, data) {
|
|
|
|
|
2014-04-28 13:32:55 +00:00
|
|
|
var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
//page
|
|
|
|
var dataObject = renderer('bpmn:DataObjectReference')(p, data);
|
|
|
|
//arrow
|
2014-04-28 13:32:55 +00:00
|
|
|
var dataInput = drawPath(p, arrowPathData);
|
2014-04-02 10:55:18 +00:00
|
|
|
dataInput.attr('stroke-width', 1);
|
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
},
|
|
|
|
'bpmn:DataOutput': function(p, data) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var arrowPathData = pathMap.getRawPath('DATA_ARROW');
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
//page
|
|
|
|
var dataObject = renderer('bpmn:DataObjectReference')(p, data);
|
|
|
|
//arrow
|
2014-04-28 13:32:55 +00:00
|
|
|
var dataInput = drawPath(p, arrowPathData);
|
2014-04-02 10:55:18 +00:00
|
|
|
dataInput.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': 'Black'
|
|
|
|
});
|
|
|
|
|
|
|
|
return dataObject;
|
|
|
|
},
|
|
|
|
'bpmn:DataStoreReference': function(p, data) {
|
2014-04-28 13:32:55 +00:00
|
|
|
var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0,
|
|
|
|
my: 0.133
|
|
|
|
}
|
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
var dataStore = drawPath(p, DATA_STORE_PATH);
|
|
|
|
dataStore.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'fill': 'Black',
|
|
|
|
'stroke-miterlimit': 4,
|
|
|
|
'stroke-linejoin': 'miter',
|
|
|
|
'stroke-linecap': 'butt',
|
|
|
|
'stroke-opacity': 1,
|
|
|
|
'stroke': 'rgb(34, 34, 34)',
|
|
|
|
'stroke-dasharray': 'none',
|
|
|
|
'fill-opacity': 0
|
2014-03-20 16:51:05 +00:00
|
|
|
});
|
2014-04-02 10:55:18 +00:00
|
|
|
|
|
|
|
return dataStore;
|
2014-04-03 12:01:56 +00:00
|
|
|
},
|
|
|
|
'bpmn:BoundaryEvent': function(p, data) {
|
2014-04-30 12:41:59 +00:00
|
|
|
return renderer('bpmn:IntermediateNonInterruptingEvent')(p, data);
|
2014-04-25 11:50:53 +00:00
|
|
|
},
|
2014-04-29 13:39:26 +00:00
|
|
|
'bpmn:Group': function(p, data) {
|
|
|
|
var group = drawRect(p, data.width, data.height, TASK_BORDER_RADIUS);
|
|
|
|
group.attr({
|
|
|
|
'stroke-width': 1,
|
|
|
|
'stroke-dasharray': '8,3,1,3',
|
2014-04-30 13:20:59 +00:00
|
|
|
'fill': 'None',
|
|
|
|
'pointer-events': 'none'
|
2014-04-29 13:39:26 +00:00
|
|
|
});
|
2014-04-25 11:50:53 +00:00
|
|
|
|
2014-04-29 13:39:26 +00:00
|
|
|
return group;
|
2014-04-25 14:14:36 +00:00
|
|
|
},
|
|
|
|
'label': function(p, data) {
|
2014-05-02 09:17:25 +00:00
|
|
|
return renderExternalLabel(p, data, '');
|
|
|
|
},
|
|
|
|
'bpmn:TextAnnotation': function(p, data) {
|
|
|
|
var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
|
|
|
|
xScaleFactor: 1,
|
|
|
|
yScaleFactor: 1,
|
|
|
|
containerWidth: data.width,
|
|
|
|
containerHeight: data.height,
|
|
|
|
position: {
|
|
|
|
mx: 0.0,
|
|
|
|
my: 0.0
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var textPath = drawPath(p, textPathData);
|
|
|
|
|
|
|
|
var text = bpmnRegistry.getSemantic(data.id).text || '';
|
2014-05-05 12:26:17 +00:00
|
|
|
var label = renderLabel(p, text, data, 'left-middle');
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-05-05 12:26:17 +00:00
|
|
|
return label;
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function drawShape(parent, data) {
|
|
|
|
var type = data.type;
|
|
|
|
var h = handlers[type];
|
|
|
|
|
|
|
|
if (!h) {
|
2014-03-25 13:08:11 +00:00
|
|
|
return DefaultRenderer.prototype.drawShape.apply(this, [ parent, data ]);
|
2014-03-20 15:18:23 +00:00
|
|
|
} else {
|
|
|
|
return h(parent, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
function drawConnection(parent, data) {
|
|
|
|
var type = data.type;
|
|
|
|
var h = handlers[type];
|
|
|
|
|
|
|
|
if (!h) {
|
2014-03-25 13:08:11 +00:00
|
|
|
return DefaultRenderer.prototype.drawConnection.apply(this, [ parent, data ]);
|
2014-03-20 16:51:05 +00:00
|
|
|
} else {
|
|
|
|
return h(parent, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
return _.all(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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-04-25 11:50:53 +00:00
|
|
|
return _.any(event.eventDefinitions, function(definition) {
|
2014-05-02 16:20:36 +00:00
|
|
|
return definition.$type === eventDefinitionType && matches(definition, 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
|
|
|
}
|
|
|
|
|
2014-04-04 10:01:42 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return {Object} returns a specified objectRef
|
|
|
|
*/
|
|
|
|
function getObjectRef(id, refName) {
|
|
|
|
var semantic = bpmnRegistry.getSemantic(id);
|
|
|
|
|
|
|
|
if(!semantic || !semantic.dataObjectRef) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return semantic.dataObjectRef[refName];
|
|
|
|
}
|
|
|
|
|
2014-03-20 16:51:05 +00:00
|
|
|
// hook onto canvas init event to initialize
|
|
|
|
// connection start/end markers on paper
|
|
|
|
events.on('canvas.init', function(event) {
|
|
|
|
var paper = event.paper;
|
|
|
|
|
|
|
|
initMarkers(paper);
|
|
|
|
});
|
|
|
|
|
2014-03-20 15:18:23 +00:00
|
|
|
this.drawShape = drawShape;
|
2014-03-20 16:51:05 +00:00
|
|
|
this.drawConnection = drawConnection;
|
2014-03-20 15:18:23 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 13:08:11 +00:00
|
|
|
BpmnRenderer.prototype = Object.create(DefaultRenderer.prototype);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
|
2014-04-03 12:01:56 +00:00
|
|
|
bpmnModule.type('renderer', [ 'eventBus', 'styles', 'bpmnRegistry', 'pathMap', BpmnRenderer ]);
|
2014-03-20 15:18:23 +00:00
|
|
|
|
|
|
|
module.exports = BpmnRenderer;
|