fix(BpmnRenderer): revert text annotations automatic content fitting

This reverts commit a53562e1d5.

Closes #635
This commit is contained in:
Nico Rehwaldt 2016-12-01 13:17:44 +01:00
parent eda7f9afeb
commit 404c35c97f
8 changed files with 54 additions and 45 deletions

View File

@ -1402,27 +1402,13 @@ function BpmnRenderer(eventBus, styles, pathMap, priority) {
'stroke': 'none'
};
var minHeight = 32,
minWidth = 100;
var text = getSemantic(element).text || '';
// provide pseudo infinite max width, which is necessary to
// avoid automatic line breaks in createText
var box = { width: 9000, height: element.height, x: element.x, y: element.y };
var label = renderLabel(parentGfx, text, { box: box, align: 'left', padding: 5 });
var bbox = label.getBBox();
var height = Math.max(bbox.height + 18, minHeight),
width = Math.max(bbox.width, minWidth);
var textElement = drawRect(parentGfx, element.width, element.height, 0, 0, style);
var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
xScaleFactor: 1,
yScaleFactor: 1,
containerWidth: width,
containerHeight: height,
containerWidth: element.width,
containerHeight: element.height,
position: {
mx: 0.0,
my: 0.0
@ -1430,16 +1416,8 @@ function BpmnRenderer(eventBus, styles, pathMap, priority) {
});
drawPath(parentGfx, textPathData);
var dy = -((height - element.height) / 2);
// adjust dimension and vertical position
assign(element, {
width: width,
height: height,
y: element.y + dy
});
var textElement = drawRect(parentGfx, element.width, element.height, 0, 0, style);
var text = getSemantic(element).text || '';
renderLabel(parentGfx, text, { box: element, align: 'left-middle', padding: 5 });
return textElement;
},

View File

@ -175,12 +175,10 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
// text annotations
if (is(element, 'bpmn:TextAnnotation')) {
bounds.minWidth = element.width + PADDING;
bounds.minHeight = element.height;
bounds.minWidth = 100;
bounds.height = element.height;
style.textAlign = 'left';
style.paddingLeft = '4px';
style.paddingTop = '7px';
}
return { bounds: bounds, style: style };

View File

@ -679,6 +679,10 @@ function canResize(shape, newBounds) {
return !newBounds || (newBounds.width >= 250 && newBounds.height >= 50);
}
if (isTextAnnotation(shape)) {
return true;
}
return false;
}

View File

@ -274,7 +274,7 @@ describe('draw - bpmn renderer', function() {
var TextAnnotationPath = graphicsFactory.getShapePath(TextAnnotationElement);
// then
expect(TextAnnotationPath).to.equal('M368,180l100,0l0,32l-100,0z');
expect(TextAnnotationPath).to.equal('M368,156l100,0l0,80l-100,0z');
}));
});

View File

@ -441,13 +441,13 @@ describe('features - label-editing', function() {
describe('text annotation', function() {
it('[no text] should have element height', testTextboxSizing('text-annotation', 1, 106, 'auto'));
it('[no text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98));
it('[1 line text] should have element height', testTextboxSizing('text-annotation', 1, 106, 'auto', oneLineText));
it('[1 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, oneLineText));
it('[2 line text] should have extended height', testTextboxSizing('text-annotation', 1, 106, { min: 38 }, twoLineText));
it('[2 line text] should have element height', testTextboxSizing('text-annotation', 1, 100, 98, twoLineText));
it('[10 line text] should have extended height', testTextboxSizing('text-annotation', 1, 106, { min: 140 }, tenLineText));
it('[10 line text] should have element height', testTextboxSizing('text-annotation', 1, { min: 100 }, 98, tenLineText));
});
@ -556,13 +556,13 @@ describe('features - label-editing', function() {
describe('text annotation', function() {
it('[no text] should have min width', testTextboxSizing('text-annotation', 1, 106, { min: 32 }));
it('[no text] should have min width', testTextboxSizing('text-annotation', 1, 100, 98));
it('[one word] should have min width', testTextboxSizing('text-annotation', 1, 106, { min: 32 }, oneWord));
it('[one word] should have min width', testTextboxSizing('text-annotation', 1, 100, 98, oneWord));
it('[five words] should expand width', testTextboxSizing('text-annotation', 1, { min: 176 }, { min: 32 }, fiveWords));
it('[five words] should expand width', testTextboxSizing('text-annotation', 1, { min: 176 }, 98, fiveWords));
it('[long word] should expand width', testTextboxSizing('text-annotation', 1, { min: 129 }, { min: 32 }, longWord));
it('[long word] should expand width', testTextboxSizing('text-annotation', 1, { min: 129 }, 98, longWord));
});

View File

@ -95,7 +95,7 @@ describe('features/modeling - append text-annotation', function() {
//then
expect(annotationShape.width).to.eql(100);
expect(annotationShape.height).to.eql(32);
expect(annotationShape.height).to.eql(30);
}));
});

View File

@ -41,7 +41,7 @@ describe('features/modeling - layout association', function() {
// then
expect(waypoints).to.eql([
{ original: { x: 400, y: 400 }, x: 388, y: 384 },
{ original: { x: 400, y: 400 }, x: 389, y: 385 },
{ original: { x: 191, y: 120 }, x: 202, y: 134 }
]);
@ -63,7 +63,7 @@ describe('features/modeling - layout association', function() {
// then
expect(waypoints).to.eql([
{ original: { x: 420, y: 400 }, x: 407, y: 384 },
{ original: { x: 420, y: 400 }, x: 408, y: 385 },
{ original: { x: 191, y: 120 }, x: 202, y: 134 }
]);
@ -91,7 +91,7 @@ describe('features/modeling - layout association', function() {
// then
expect(waypoints).to.eql([
{ original: { x: 420, y: 400 }, x: 417, y: 384 },
{ original: { x: 420, y: 400 }, x: 417, y: 385 },
{ x: 400, y: 300 },
{ original: { x: 191, y: 120 }, x: 204, y: 131 }
]);

View File

@ -302,7 +302,7 @@ describe('features/snapping - BpmnSnapping', function() {
dragging.end();
expect(participant.width).to.equal(467);
expect(participant.height).to.equal(263);
expect(participant.height).to.equal(287);
}));
@ -437,6 +437,35 @@ describe('features/snapping - BpmnSnapping', function() {
});
describe('on TextAnnotation resize', function() {
var diagramXML = require('./BpmnSnapping.textAnnotation-resize.bpmn');
var testResizeModules = [
coreModule,
modelingModule,
resizeModule,
rulesModule,
snappingModule
];
beforeEach(bootstrapModeler(diagramXML, { modules: testResizeModules }));
it('should snap to minimum bounds', inject(function(elementRegistry, resize, dragging) {
var textAnnotation = elementRegistry.get('TextAnnotation');
resize.activate(canvasEvent({ x: 0, y: 0 }), textAnnotation, 'se');
dragging.move(canvasEvent({ x: -400, y: -400 }));
dragging.end();
expect(textAnnotation.width).to.equal(50);
expect(textAnnotation.height).to.equal(30);
}));
});
describe('labels', function() {
var diagramXML = require('./BpmnSnapping.labels.bpmn');