Skip to content

Commit

Permalink
feat: allow overriding fill and stroke color
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Jul 13, 2023
1 parent 3d7fb25 commit a2b8ea5
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions lib/draw/BpmnRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,13 +1408,13 @@ export default function BpmnRenderer(
stroke: getStrokeColor(element, defaultStrokeColor)
});
},
'bpmn:SequenceFlow': function(parentGfx, element) {
var fill = getFillColor(element, defaultFillColor),
stroke = getStrokeColor(element, defaultStrokeColor);
'bpmn:SequenceFlow': function(parentGfx, element, attrs) {
var fill = attrs.fill || getFillColor(element, defaultFillColor),
stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);

var path = drawConnectionSegments(parentGfx, element.waypoints, {
markerEnd: marker('sequenceflow-end', fill, stroke),
stroke: getStrokeColor(element, defaultStrokeColor)
stroke: stroke
});

var sequenceFlow = getSemantic(element);
Expand Down Expand Up @@ -1443,16 +1443,14 @@ export default function BpmnRenderer(
return path;
},
'bpmn:Association': function(parentGfx, element, attrs) {

var semantic = getSemantic(element);

var fill = getFillColor(element, defaultFillColor),
stroke = getStrokeColor(element, defaultStrokeColor);
var fill = attrs.fill || getFillColor(element, defaultFillColor),
stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);

attrs = {
strokeDasharray: '0, 5',
stroke: getStrokeColor(element, defaultStrokeColor),
...attrs
stroke: stroke
};

if (semantic.associationDirection === 'One' ||
Expand All @@ -1466,36 +1464,35 @@ export default function BpmnRenderer(

return drawConnectionSegments(parentGfx, element.waypoints, attrs);
},
'bpmn:DataInputAssociation': function(parentGfx, element) {
var fill = getFillColor(element, defaultFillColor),
stroke = getStrokeColor(element, defaultStrokeColor);
'bpmn:DataInputAssociation': function(parentGfx, element, attrs) {
var fill = attrs.fill || getFillColor(element, defaultFillColor),
stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);

return renderer('bpmn:Association')(parentGfx, element, {
markerEnd: marker('association-end', fill, stroke)
});
},
'bpmn:DataOutputAssociation': function(parentGfx, element) {
var fill = getFillColor(element, defaultFillColor),
stroke = getStrokeColor(element, defaultStrokeColor);
'bpmn:DataOutputAssociation': function(parentGfx, element, attrs) {
var fill = attrs.fill || getFillColor(element, defaultFillColor),
stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);

return renderer('bpmn:Association')(parentGfx, element, {
markerEnd: marker('association-end', fill, stroke)
});
},
'bpmn:MessageFlow': function(parentGfx, element) {

'bpmn:MessageFlow': function(parentGfx, element, attrs) {
var semantic = getSemantic(element),
di = getDi(element);

var fill = getFillColor(element, defaultFillColor),
stroke = getStrokeColor(element, defaultStrokeColor);
var fill = attrs.fill || getFillColor(element, defaultFillColor),
stroke = attrs.stroke || getStrokeColor(element, defaultStrokeColor);

var path = drawConnectionSegments(parentGfx, element.waypoints, {
markerEnd: marker('messageflow-end', fill, stroke),
markerStart: marker('messageflow-start', fill, stroke),
strokeDasharray: '10, 11',
strokeWidth: 1.5,
stroke: getStrokeColor(element, defaultStrokeColor)
stroke: stroke
});

if (semantic.messageRef) {
Expand Down Expand Up @@ -1525,7 +1522,7 @@ export default function BpmnRenderer(
align: 'center-top',
fitBox: true,
style: {
fill: getStrokeColor(element, defaultLabelColor, defaultStrokeColor)
fill: stroke
}
});

Expand Down Expand Up @@ -1940,31 +1937,33 @@ BpmnRenderer.prototype.canRender = function(element) {
*
* @param {SVGElement} parentGfx
* @param {Element} element
* @param {Object} [attrs]
*
* @return {SVGElement} mainGfx
*/
BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
BpmnRenderer.prototype.drawShape = function(parentGfx, element, attrs) {
var type = element.type;
var h = this._renderer(type);

/* jshint -W040 */
return h(parentGfx, element);
return h(parentGfx, element, attrs || {});
};

/**
* Draw connection into parentGfx.
*
* @param {SVGElement} parentGfx
* @param {Element} element
* @param {Object} [attrs]
*
* @return {SVGElement} mainGfx
*/
BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
BpmnRenderer.prototype.drawConnection = function(parentGfx, element, attrs) {
var type = element.type;
var h = this._renderer(type);

/* jshint -W040 */
return h(parentGfx, element);
return h(parentGfx, element, attrs || {});
};

/**
Expand Down

0 comments on commit a2b8ea5

Please sign in to comment.