@@ -26,17 +26,18 @@ import {
26
26
} from './Util' ;
27
27
28
28
29
- function elementData ( semantic , attrs ) {
29
+ function elementData ( semantic , di , attrs ) {
30
30
return assign ( {
31
31
id : semantic . id ,
32
32
type : semantic . $type ,
33
- businessObject : semantic
33
+ businessObject : semantic ,
34
+ di : di
34
35
} , attrs ) ;
35
36
}
36
37
37
- function getWaypoints ( bo , source , target ) {
38
+ function getWaypoints ( di , source , target ) {
38
39
39
- var waypoints = bo . di . waypoint ;
40
+ var waypoints = di . waypoint ;
40
41
41
42
if ( ! waypoints || waypoints . length < 2 ) {
42
43
return [ getMid ( source ) , getMid ( target ) ] ;
@@ -92,12 +93,12 @@ BpmnImporter.$inject = [
92
93
* Add bpmn element (semantic) to the canvas onto the
93
94
* specified parent shape.
94
95
*/
95
- BpmnImporter . prototype . add = function ( semantic , parentElement ) {
96
-
97
- var di = semantic . di ,
98
- element ,
96
+ BpmnImporter . prototype . add = function ( context , parentElement ) {
97
+ var element ,
99
98
translate = this . _translate ,
100
- hidden ;
99
+ hidden ,
100
+ semantic = context . element ,
101
+ di = context . di ;
101
102
102
103
var parentIndex ;
103
104
@@ -107,21 +108,21 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
107
108
if ( is ( di , 'bpmndi:BPMNPlane' ) ) {
108
109
109
110
// add a virtual element (not being drawn)
110
- element = this . _elementFactory . createRoot ( elementData ( semantic ) ) ;
111
+ element = this . _elementFactory . createRoot ( elementData ( semantic , di ) ) ;
111
112
112
113
this . _canvas . setRootElement ( element ) ;
113
114
}
114
115
115
116
// SHAPE
116
117
else if ( is ( di , 'bpmndi:BPMNShape' ) ) {
117
118
118
- var collapsed = ! isExpanded ( semantic ) ,
119
+ var collapsed = ! isExpanded ( semantic , di ) ,
119
120
isFrame = isFrameElement ( semantic ) ;
120
121
hidden = parentElement && ( parentElement . hidden || parentElement . collapsed ) ;
121
122
122
- var bounds = semantic . di . bounds ;
123
+ var bounds = di . bounds ;
123
124
124
- element = this . _elementFactory . createShape ( elementData ( semantic , {
125
+ element = this . _elementFactory . createShape ( elementData ( semantic , di , {
125
126
collapsed : collapsed ,
126
127
hidden : hidden ,
127
128
x : Math . round ( bounds . x ) ,
@@ -159,11 +160,11 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
159
160
160
161
hidden = parentElement && ( parentElement . hidden || parentElement . collapsed ) ;
161
162
162
- element = this . _elementFactory . createConnection ( elementData ( semantic , {
163
+ element = this . _elementFactory . createConnection ( elementData ( semantic , di , {
163
164
hidden : hidden ,
164
165
source : source ,
165
166
target : target ,
166
- waypoints : getWaypoints ( semantic , source , target )
167
+ waypoints : getWaypoints ( di , source , target )
167
168
} ) ) ;
168
169
169
170
if ( is ( semantic , 'bpmn:DataAssociation' ) ) {
@@ -190,7 +191,7 @@ BpmnImporter.prototype.add = function(semantic, parentElement) {
190
191
191
192
// (optional) LABEL
192
193
if ( isLabelExternal ( semantic ) && getLabel ( element ) ) {
193
- this . addLabel ( semantic , element ) ;
194
+ this . addLabel ( semantic , di , element ) ;
194
195
}
195
196
196
197
@@ -239,12 +240,12 @@ BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElem
239
240
/**
240
241
* add label for an element
241
242
*/
242
- BpmnImporter . prototype . addLabel = function ( semantic , element ) {
243
+ BpmnImporter . prototype . addLabel = function ( semantic , di , element ) {
243
244
var bounds ,
244
245
text ,
245
246
label ;
246
247
247
- bounds = getExternalLabelBounds ( semantic , element ) ;
248
+ bounds = getExternalLabelBounds ( di , element ) ;
248
249
249
250
text = getLabel ( element ) ;
250
251
@@ -254,7 +255,7 @@ BpmnImporter.prototype.addLabel = function(semantic, element) {
254
255
bounds = this . _textRenderer . getExternalLabelBounds ( bounds , text ) ;
255
256
}
256
257
257
- label = this . _elementFactory . createLabel ( elementData ( semantic , {
258
+ label = this . _elementFactory . createLabel ( elementData ( semantic , di , {
258
259
id : semantic . id + '_label' ,
259
260
labelTarget : element ,
260
261
type : 'label' ,
0 commit comments