diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index f4015de6..e8536540 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -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 }; + } }; \ No newline at end of file