diff --git a/lib/draw/BpmnRenderUtil.js b/lib/draw/BpmnRenderUtil.js index d5c9443a..aef898b3 100644 --- a/lib/draw/BpmnRenderUtil.js +++ b/lib/draw/BpmnRenderUtil.js @@ -54,13 +54,24 @@ export function getSemantic(element) { // color access ////////////////////// export function getFillColor(element, defaultColor) { - return getDi(element).get('bioc:fill') || defaultColor || 'white'; + var di = getDi(element); + + return di.get('color:background-color') || di.get('bioc:fill') || defaultColor || 'white'; } export function getStrokeColor(element, defaultColor) { - return getDi(element).get('bioc:stroke') || defaultColor || 'black'; + var di = getDi(element); + + return di.get('color:border-color') || di.get('bioc:stroke') || defaultColor || 'black'; } +export function getLabelColor(element, defaultColor, defaultStrokeColor) { + var di = getDi(element), + label = di.get('label'); + + return label && label.get('color:color') || defaultColor || + getStrokeColor(element, defaultStrokeColor); +} // cropping path customizations ////////////////////// diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index 1b4635ba..ce652332 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -34,7 +34,8 @@ import { getDiamondPath, getRectPath, getFillColor, - getStrokeColor + getStrokeColor, + getLabelColor } from './BpmnRenderUtil'; import { @@ -73,7 +74,8 @@ export default function BpmnRenderer( BaseRenderer.call(this, eventBus, priority); var defaultFillColor = config && config.defaultFillColor, - defaultStrokeColor = config && config.defaultStrokeColor; + defaultStrokeColor = config && config.defaultStrokeColor, + defaultLabelColor = config && config.defaultLabelColor; var rendererId = RENDERER_IDS.next(); @@ -472,7 +474,7 @@ export default function BpmnRenderer( align: align, padding: 5, style: { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor) } }); } @@ -493,7 +495,7 @@ export default function BpmnRenderer( {}, textRenderer.getExternalStyle(), { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor) } ) }); @@ -507,7 +509,7 @@ export default function BpmnRenderer( }, align: 'center-middle', style: { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor) } }); @@ -1163,7 +1165,7 @@ export default function BpmnRenderer( renderLabel(parentGfx, text2, { box: element, align: 'center-middle', style: { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor) } }); } @@ -1482,7 +1484,7 @@ export default function BpmnRenderer( align: 'center-top', fitBox: true, style: { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getStrokeColor(element, defaultLabelColor, defaultStrokeColor) } }); @@ -1648,7 +1650,7 @@ export default function BpmnRenderer( align: 'left-top', padding: 5, style: { - fill: getStrokeColor(element, defaultStrokeColor) + fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor) } }); diff --git a/test/spec/draw/BpmnRenderUtilSpec.js b/test/spec/draw/BpmnRenderUtilSpec.js index 959b56c8..7a9b67da 100644 --- a/test/spec/draw/BpmnRenderUtilSpec.js +++ b/test/spec/draw/BpmnRenderUtilSpec.js @@ -9,7 +9,8 @@ import { getDiamondPath, getRectPath, getFillColor, - getStrokeColor + getStrokeColor, + getLabelColor } from 'lib/draw/BpmnRenderUtil'; @@ -83,4 +84,10 @@ describe('BpmnRenderUtil', function() { }); + + it('should expose getLabelColor', function() { + + expect(getLabelColor).to.be.a('function'); + + }); }); diff --git a/test/spec/draw/BpmnRenderer.colors.bpmn b/test/spec/draw/BpmnRenderer.colors.bpmn index 25604f0a..4fa557d4 100644 --- a/test/spec/draw/BpmnRenderer.colors.bpmn +++ b/test/spec/draw/BpmnRenderer.colors.bpmn @@ -1,5 +1,5 @@ - + @@ -84,14 +84,14 @@ - + - + - + @@ -132,7 +132,7 @@ - + diff --git a/test/spec/draw/BpmnRendererSpec.js b/test/spec/draw/BpmnRendererSpec.js index 992ea7b2..36872c38 100644 --- a/test/spec/draw/BpmnRendererSpec.js +++ b/test/spec/draw/BpmnRendererSpec.js @@ -355,7 +355,7 @@ describe('draw - bpmn renderer', function() { expect(markers).to.have.length(7); expect(markers[0].id).to.match(/^sequenceflow-end-rgb_255_224_178_-rgb_251_140_0_-[A-Za-z0-9]{25}$/); expect(markers[1].id).to.match(/^sequenceflow-end-yellow-blue-[A-Za-z0-9]{25}$/); - expect(markers[2].id).to.match(/^sequenceflow-end-white-_3399aa-[A-Za-z0-9]{25}$/); + expect(markers[2].id).to.match(/^sequenceflow-end-white-_FB8C00-[A-Za-z0-9]{25}$/); expect(markers[3].id).to.match(/^sequenceflow-end-white-rgba_255_0_0_0_9_-[A-Za-z0-9]{25}$/); expect(markers[4].id).to.match(/^association-end-_FFE0B2-_FB8C00-[A-Za-z0-9]{25}$/); expect(markers[5].id).to.match(/^messageflow-end-_FFE0B2-_FB8C00-[A-Za-z0-9]{25}$/); @@ -450,7 +450,8 @@ describe('draw - bpmn renderer', function() { describe('default colors', function() { var defaultFillColor = 'red', - defaultStrokeColor = 'lime'; + defaultStrokeColor = 'lime', + defaultLabelColor = 'blue'; // TODO(philippfromme): remove once we drop PhantomJS function expectedColors(color) { @@ -478,7 +479,8 @@ describe('draw - bpmn renderer', function() { beforeEach(bootstrapViewer(xml,{ bpmnRenderer: { defaultFillColor: defaultFillColor, - defaultStrokeColor: defaultStrokeColor + defaultStrokeColor: defaultStrokeColor, + defaultLabelColor: defaultLabelColor } })); @@ -528,7 +530,7 @@ describe('draw - bpmn renderer', function() { * @param {string} fillColor - Fill color to expect. * @param {string} strokeColor - Stroke color to expect. */ - function expectColors(element, gfx, fillColor, strokeColor) { + function expectColors(element, gfx, fillColor, strokeColor, labelColor) { var djsVisual = domQuery('.djs-visual', gfx); var circle, path, polygon, polyline, rect, text; @@ -536,7 +538,7 @@ describe('draw - bpmn renderer', function() { if (element.labelTarget) { text = domQuery('text', djsVisual); - expectFillColor(text, strokeColor); + expectFillColor(text, labelColor); } else if (element.waypoints) { path = domQuery('path', djsVisual); polyline = domQuery('polyline', djsVisual); @@ -547,13 +549,13 @@ describe('draw - bpmn renderer', function() { expectFillColor(circle, fillColor); expectStrokeColor(circle, strokeColor); - } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Particpant' ])) { + } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Participant' ])) { rect = domQuery('rect', djsVisual); text = domQuery('text', djsVisual); expectFillColor(rect, fillColor); expectStrokeColor(rect, strokeColor); - expectFillColor(text, strokeColor); + expectFillColor(text, labelColor); } else if (isAny(element, [ 'bpmn:Gateway' ])) { polygon = domQuery('polygon', djsVisual); @@ -573,14 +575,12 @@ describe('draw - bpmn renderer', function() { var gfx = elementRegistry.getGraphics(element), di = getDi(element), - fillColor = di.get('bioc:fill'), - strokeColor = di.get('bioc:stroke'); + fillColor = di.get('color:background-color') || di.get('bioc:fill') || defaultFillColor, + strokeColor = di.get('color:border-color') || di.get('bioc:stroke') || defaultStrokeColor, + labelDi = di.get('label'), + labelColor = labelDi && labelDi.get('color:color') || defaultLabelColor; - if (fillColor || strokeColor) { - expectColors(element, gfx, fillColor, strokeColor); - } else { - expectColors(element, gfx, defaultFillColor, defaultStrokeColor); - } + expectColors(element, gfx, fillColor, strokeColor, labelColor); }); }));