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 || {};
var businessObject = attrs.businessObject;
var businessObject = attrs.businessObject,
size;
if (!businessObject) {
if (!attrs.type) {
@ -31,13 +32,15 @@ ElementFactory.prototype.createWithBpmn = function(elementType, attrs) {
}
businessObject = this._bpmnFactory.create(attrs.type);
_.extend(attrs, {
businessObject: businessObject,
id: businessObject.id
});
}
size = this._getDefaultSize(businessObject);
attrs = _.extend({
businessObject: businessObject,
id: businessObject.id
}, size, attrs);
return this.create(elementType, attrs);
};
@ -55,4 +58,19 @@ ElementFactory.prototype.createShape = function(attrs) {
ElementFactory.prototype.createConnection = function(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 };
}
};