From 4428be4227be55e9f7e64b7caabe42455b93ffc1 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 15 Sep 2014 14:41:26 +0200 Subject: [PATCH] fix(draw): render labels as one-liner per default This is a temporary fix for #113 --- lib/draw/BpmnRenderer.js | 6 +++--- lib/util/Label.js | 6 +++--- test/spec/features/modeling/AppendShapeSpec.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index 0adb77a4..1d069fdf 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -281,7 +281,7 @@ function BpmnRenderer(events, styles, pathMap) { function renderEmbeddedLabel(p, element, align) { var semantic = getSemantic(element); - return renderLabel(p, semantic.name, { box: element, align: align }); + return renderLabel(p, semantic.name, { box: element, align: align, padding: 5 }); } function renderExternalLabel(p, element, align) { @@ -799,7 +799,7 @@ function BpmnRenderer(events, styles, pathMap) { var expanded = DiUtil.isExpanded(semantic); - var isEventSubProcess = !!getSemantic(element).triggeredByEvent; + var isEventSubProcess = !!semantic.triggeredByEvent; if (isEventSubProcess) { rect.attr({ strokeDasharray: '1,2' @@ -1220,7 +1220,7 @@ function BpmnRenderer(events, styles, pathMap) { drawPath(p, textPathData); var text = getSemantic(element).text || ''; - renderLabel(p, text, { box: element, align: 'left-middle' }); + renderLabel(p, text, { box: element, align: 'left-middle', padding: 5 }); return textElement; }, diff --git a/lib/util/Label.js b/lib/util/Label.js index 8271ba68..97d3e7f1 100644 --- a/lib/util/Label.js +++ b/lib/util/Label.js @@ -5,7 +5,7 @@ var _ = require('lodash'); var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = { width: 90, - height: 50 + height: 20 }; @@ -53,7 +53,7 @@ var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) } else { return { x: element.x + element.width / 2, - y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2 - 5 + y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2 }; } }; @@ -77,7 +77,7 @@ module.exports.getExternalLabelBounds = function(semantic, element) { bounds = label.bounds; size = { - width: Math.max(150, bounds.width), + width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width), height: bounds.height }; diff --git a/test/spec/features/modeling/AppendShapeSpec.js b/test/spec/features/modeling/AppendShapeSpec.js index 12a90270..1c31fdba 100644 --- a/test/spec/features/modeling/AppendShapeSpec.js +++ b/test/spec/features/modeling/AppendShapeSpec.js @@ -109,7 +109,7 @@ describe('features/modeling - append shape', function() { expect(elementRegistry.getById(label.id)).toBeDefined(); expect(label.x).toBe(443); - expect(label.y).toBe(273); + expect(label.y).toBe(278); expect(label.width).toBe(LabelUtil.DEFAULT_LABEL_SIZE.width); expect(label.height).toBe(LabelUtil.DEFAULT_LABEL_SIZE.height); }));