From 00bd2712e2bbf80cf8f1fd70cfbea0721b0d05fb Mon Sep 17 00:00:00 2001 From: jdotzki Date: Fri, 2 May 2014 11:17:25 +0200 Subject: [PATCH] feat(bpmnrenderer): add text annotation rendering --- lib/draw/BpmnRenderer.js | 23 +++++- lib/draw/PathMap.js | 7 ++ .../fixtures/bpmn/render/text-annotation.bpmn | 71 +++++++++++++++++++ test/spec/browser/draw/BpmnRendererSpec.js | 11 +++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/bpmn/render/text-annotation.bpmn diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index af65b1a4..c670f481 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -916,8 +916,29 @@ function BpmnRenderer(events, styles, bpmnRegistry, pathMap) { return group; }, 'label': function(p, data) { - return renderExternalLabel(p, data, 'center-top'); + return renderExternalLabel(p, data, ''); + }, + 'bpmn:TextAnnotation': function(p, data) { + console.log(data); + console.log(bpmnRegistry.getSemantic(data.id)); + 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 || ''; + renderLabel(p, text, data, 'left-middle'); + + return textPath; } + }; function drawShape(parent, data) { diff --git a/lib/draw/PathMap.js b/lib/draw/PathMap.js index 5cb8b368..243bda69 100644 --- a/lib/draw/PathMap.js +++ b/lib/draw/PathMap.js @@ -197,6 +197,13 @@ function PathMap(Snap) { width: 61, heightElements: [7, 10, 45], widthElements: [2, 58, 60] + }, + 'TEXT_ANNOTATION': { + d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0', + height: 30, + width: 10, + heightElements: [30], + widthElements: [10] } }; diff --git a/test/fixtures/bpmn/render/text-annotation.bpmn b/test/fixtures/bpmn/render/text-annotation.bpmn new file mode 100644 index 00000000..a666cfdf --- /dev/null +++ b/test/fixtures/bpmn/render/text-annotation.bpmn @@ -0,0 +1,71 @@ + + + + + + + Test test consetetursadipscingelitrametamet nonumy + + + + + + + + + + + + + + Lorem ipsum dolor sit amet, consetetursadipscingelitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor s + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/browser/draw/BpmnRendererSpec.js b/test/spec/browser/draw/BpmnRendererSpec.js index af216ab6..f119c4ce 100644 --- a/test/spec/browser/draw/BpmnRendererSpec.js +++ b/test/spec/browser/draw/BpmnRendererSpec.js @@ -16,6 +16,17 @@ describe('draw/BpmnRenderer', function() { document.getElementsByTagName('body')[0].appendChild(container); }); + it('should render text annotations', function(done) { + + var xml = fs.readFileSync('test/fixtures/bpmn/render/text-annotation.bpmn', 'utf8'); + + var renderer = new Viewer(container); + + renderer.importXML(xml, function(err) { + done(err); + }); + }); + it('should render data objects', function(done) { var xml = fs.readFileSync('test/fixtures/bpmn/render/data-objects.bpmn', 'utf8');