feat(features/modeling): assign default size for elements

This commit is contained in:
Nico Rehwaldt 2014-07-26 14:21:54 +02:00
parent d729818b94
commit 9456ca9098
1 changed files with 24 additions and 6 deletions

View File

@ -23,7 +23,8 @@ ElementFactory.prototype.createWithBpmn = function(elementType, attrs) {
attrs = attrs || {}; attrs = attrs || {};
var businessObject = attrs.businessObject; var businessObject = attrs.businessObject,
size;
if (!businessObject) { if (!businessObject) {
if (!attrs.type) { if (!attrs.type) {
@ -31,12 +32,14 @@ ElementFactory.prototype.createWithBpmn = function(elementType, attrs) {
} }
businessObject = this._bpmnFactory.create(attrs.type); businessObject = this._bpmnFactory.create(attrs.type);
}
_.extend(attrs, { size = this._getDefaultSize(businessObject);
attrs = _.extend({
businessObject: businessObject, businessObject: businessObject,
id: businessObject.id id: businessObject.id
}); }, size, attrs);
}
return this.create(elementType, attrs); return this.create(elementType, attrs);
}; };
@ -56,3 +59,18 @@ ElementFactory.prototype.createShape = function(attrs) {
ElementFactory.prototype.createConnection = function(attrs) { ElementFactory.prototype.createConnection = function(attrs) {
return this.createWithBpmn('connection', attrs); return this.createWithBpmn('connection', attrs);
}; };
ElementFactory.prototype._getDefaultSize = function(semantic) {
if (semantic.$instanceOf('bpmn:Task')) {
return { width: 100, height: 80 };
}
if (semantic.$instanceOf('bpmn:Gateway')) {
return { width: 36, height: 36 };
}
if (semantic.$instanceOf('bpmn:Event')) {
return { width: 36, height: 36 };
}
};