@@ -44,50 +44,50 @@ import { isDirectionHorizontal } from './util/ModelingUtil';
4444 */
4545
4646var ATTACH_ORIENTATION_PADDING = - 10 ,
47- BOUNDARY_TO_HOST_THRESHOLD = 40 ;
47+ BOUNDARY_TO_HOST_THRESHOLD = 40 ;
4848
4949// layout all connection between flow elements h:h, except for
5050// (1) outgoing of boundary events -> layout based on attach orientation and target orientation
5151// (2) incoming/outgoing of gateways -> v:h for outgoing, h:v for incoming
5252// (3) loops connect sides clockwise
5353var PREFERRED_LAYOUTS_HORIZONTAL = {
54- default : [ 'h:h' ] ,
55- fromGateway : [ 'v:h' ] ,
56- toGateway : [ 'h:v' ] ,
54+ default : [ 'h:h' ] ,
55+ fromGateway : [ 'v:h' ] ,
56+ toGateway : [ 'h:v' ] ,
5757 loop : {
58- fromTop : [ 't:r' ] ,
59- fromRight : [ 'r:b' ] ,
60- fromLeft : [ 'l:t' ] ,
61- fromBottom : [ 'b:l' ]
58+ fromTop : [ 't:r' ] ,
59+ fromRight : [ 'r:b' ] ,
60+ fromLeft : [ 'l:t' ] ,
61+ fromBottom : [ 'b:l' ]
6262 } ,
6363 boundaryLoop : {
6464 alternateHorizontalSide : 'b' ,
6565 alternateVerticalSide : 'l' ,
6666 default : 'v'
6767 } ,
68- messageFlow : [ 'straight' , 'v:v' ] ,
69- subProcess : [ 'straight' , 'h:h' ] ,
68+ messageFlow : [ 'straight' , 'v:v' ] ,
69+ subProcess : [ 'straight' , 'h:h' ] ,
7070 isHorizontal : true
7171} ;
7272
7373// for vertical layouts, switch h and v and loop counter-clockwise
7474var PREFERRED_LAYOUTS_VERTICAL = {
75- default : [ 'v:v' ] ,
76- fromGateway : [ 'h:v' ] ,
77- toGateway : [ 'v:h' ] ,
75+ default : [ 'v:v' ] ,
76+ fromGateway : [ 'h:v' ] ,
77+ toGateway : [ 'v:h' ] ,
7878 loop : {
79- fromTop : [ 't:l' ] ,
80- fromRight : [ 'r:t' ] ,
81- fromLeft : [ 'l:b' ] ,
82- fromBottom : [ 'b:r' ]
79+ fromTop : [ 't:l' ] ,
80+ fromRight : [ 'r:t' ] ,
81+ fromLeft : [ 'l:b' ] ,
82+ fromBottom : [ 'b:r' ]
8383 } ,
8484 boundaryLoop : {
8585 alternateHorizontalSide : 't' ,
8686 alternateVerticalSide : 'r' ,
8787 default : 'h'
8888 } ,
89- messageFlow : [ 'straight' , 'h:h' ] ,
90- subProcess : [ 'straight' , 'v:v' ] ,
89+ messageFlow : [ 'straight' , 'h:h' ] ,
90+ subProcess : [ 'straight' , 'v:v' ] ,
9191 isHorizontal : false
9292} ;
9393
@@ -123,34 +123,34 @@ inherits(BpmnLayouter, BaseLayouter);
123123 *
124124 * @return {Point[] }
125125 */
126- BpmnLayouter . prototype . layoutConnection = function ( connection , hints ) {
126+ BpmnLayouter . prototype . layoutConnection = function ( connection , hints ) {
127127 if ( ! hints ) {
128128 hints = { } ;
129129 }
130130
131131 var source = hints . source || connection . source ,
132- target = hints . target || connection . target ,
133- waypoints = hints . waypoints || connection . waypoints ,
134- connectionStart = hints . connectionStart ,
135- connectionEnd = hints . connectionEnd ,
136- elementRegistry = this . _elementRegistry ;
132+ target = hints . target || connection . target ,
133+ waypoints = hints . waypoints || connection . waypoints ,
134+ connectionStart = hints . connectionStart ,
135+ connectionEnd = hints . connectionEnd ,
136+ elementRegistry = this . _elementRegistry ;
137137
138138 var manhattanOptions ,
139- updatedWaypoints ;
139+ updatedWaypoints ;
140140
141141 if ( ! connectionStart ) {
142- connectionStart = getConnectionDocking ( waypoints && waypoints [ 0 ] , source ) ;
142+ connectionStart = getConnectionDocking ( waypoints && waypoints [ 0 ] , source ) ;
143143 }
144144
145145 if ( ! connectionEnd ) {
146- connectionEnd = getConnectionDocking ( waypoints && waypoints [ waypoints . length - 1 ] , target ) ;
146+ connectionEnd = getConnectionDocking ( waypoints && waypoints [ waypoints . length - 1 ] , target ) ;
147147 }
148148
149149 if ( is ( connection , 'bpmn:Association' ) ||
150- is ( connection , 'bpmn:DataAssociation' ) ) {
150+ is ( connection , 'bpmn:DataAssociation' ) ) {
151151
152152 if ( waypoints && ! isCompensationAssociation ( source , target ) ) {
153- return [ ] . concat ( [ connectionStart ] , waypoints . slice ( 1 , - 1 ) , [ connectionEnd ] ) ;
153+ return [ ] . concat ( [ connectionStart ] , waypoints . slice ( 1 , - 1 ) , [ connectionEnd ] ) ;
154154 }
155155 }
156156
@@ -201,7 +201,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
201201 ) ) ;
202202 }
203203
204- return updatedWaypoints || [ connectionStart , connectionEnd ] ;
204+ return updatedWaypoints || [ connectionStart , connectionEnd ] ;
205205} ;
206206
207207
@@ -332,14 +332,14 @@ function getLoopPreferredLayout(source, connection, layout) {
332332
333333function getBoundaryEventPreferredLayouts ( source , target , end , layout ) {
334334 var sourceMid = getMid ( source ) ,
335- targetMid = getMid ( target ) ,
336- attachOrientation = getAttachOrientation ( source ) ,
337- sourceLayout ,
338- targetLayout ;
335+ targetMid = getMid ( target ) ,
336+ attachOrientation = getAttachOrientation ( source ) ,
337+ sourceLayout ,
338+ targetLayout ;
339339
340340 var isLoop = isSame ( source . host , target ) ;
341341
342- var attachedToSide = isAnyOrientation ( attachOrientation , [ 'top' , 'right' , 'bottom' , 'left' ] ) ;
342+ var attachedToSide = isAnyOrientation ( attachOrientation , [ 'top' , 'right' , 'bottom' , 'left' ] ) ;
343343
344344 var targetOrientation = getOrientation ( targetMid , sourceMid , {
345345 x : source . width / 2 + target . width / 2 ,
@@ -356,13 +356,13 @@ function getBoundaryEventPreferredLayouts(source, target, end, layout) {
356356 // target layout
357357 targetLayout = getBoundaryEventTargetLayout ( attachOrientation , targetOrientation , attachedToSide , layout . isHorizontal ) ;
358358
359- return [ sourceLayout + ':' + targetLayout ] ;
359+ return [ sourceLayout + ':' + targetLayout ] ;
360360}
361361
362362function getBoundaryEventLoopLayout ( attachOrientation , attachedToSide , source , target , end , layout ) {
363363 var orientation = attachedToSide ? attachOrientation : layout . isHorizontal ? getVerticalOrientation ( attachOrientation ) : getHorizontalOrientation ( attachOrientation ) ,
364- sourceLayout = orientationDirectionMapping [ orientation ] ,
365- targetLayout ;
364+ sourceLayout = orientationDirectionMapping [ orientation ] ,
365+ targetLayout ;
366366
367367 if ( attachedToSide ) {
368368 if ( isHorizontalOrientation ( attachOrientation ) ) {
@@ -374,7 +374,7 @@ function getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, t
374374 targetLayout = layout . boundaryLoop . default ;
375375 }
376376
377- return [ sourceLayout + ':' + targetLayout ] ;
377+ return [ sourceLayout + ':' + targetLayout ] ;
378378}
379379
380380function shouldConnectToSameSide ( axis , source , target , end ) {
@@ -391,22 +391,22 @@ function shouldConnectToSameSide(axis, source, target, end) {
391391}
392392
393393function areCloseOnAxis ( axis , a , b , threshold ) {
394- return Math . abs ( a [ axis ] - b [ axis ] ) < threshold ;
394+ return Math . abs ( a [ axis ] - b [ axis ] ) < threshold ;
395395}
396396
397397function getBoundaryEventSourceLayout ( attachOrientation , targetOrientation , attachedToSide , isHorizontal ) {
398398
399399 // attached to either top, right, bottom or left side
400400 if ( attachedToSide ) {
401- return orientationDirectionMapping [ attachOrientation ] ;
401+ return orientationDirectionMapping [ attachOrientation ] ;
402402 }
403403
404404 // attached to either top-right, top-left, bottom-right or bottom-left corner
405405
406406 var verticalAttachOrientation = getVerticalOrientation ( attachOrientation ) ,
407- horizontalAttachOrientation = getHorizontalOrientation ( attachOrientation ) ,
408- verticalTargetOrientation = getVerticalOrientation ( targetOrientation ) ,
409- horizontalTargetOrientation = getHorizontalOrientation ( targetOrientation ) ;
407+ horizontalAttachOrientation = getHorizontalOrientation ( attachOrientation ) ,
408+ verticalTargetOrientation = getVerticalOrientation ( targetOrientation ) ,
409+ horizontalTargetOrientation = getHorizontalOrientation ( targetOrientation ) ;
410410
411411 if ( isHorizontal ) {
412412
@@ -415,7 +415,7 @@ function getBoundaryEventSourceLayout(attachOrientation, targetOrientation, atta
415415 isSame ( verticalAttachOrientation , verticalTargetOrientation ) ||
416416 isOppositeOrientation ( horizontalAttachOrientation , horizontalTargetOrientation )
417417 ) {
418- return orientationDirectionMapping [ verticalAttachOrientation ] ;
418+ return orientationDirectionMapping [ verticalAttachOrientation ] ;
419419 }
420420 } else {
421421
@@ -424,12 +424,12 @@ function getBoundaryEventSourceLayout(attachOrientation, targetOrientation, atta
424424 isSame ( horizontalAttachOrientation , horizontalTargetOrientation ) ||
425425 isOppositeOrientation ( verticalAttachOrientation , verticalTargetOrientation )
426426 ) {
427- return orientationDirectionMapping [ horizontalAttachOrientation ] ;
427+ return orientationDirectionMapping [ horizontalAttachOrientation ] ;
428428 }
429429 }
430430
431431 // fallback
432- return orientationDirectionMapping [ isHorizontal ? horizontalAttachOrientation : verticalAttachOrientation ] ;
432+ return orientationDirectionMapping [ isHorizontal ? horizontalAttachOrientation : verticalAttachOrientation ] ;
433433}
434434
435435function getBoundaryEventTargetLayout ( attachOrientation , targetOrientation , attachedToSide , isHorizontal ) {
@@ -467,22 +467,38 @@ function getBoundaryEventTargetLayout(attachOrientation, targetOrientation, atta
467467 }
468468 }
469469
470- // attached to either top-right, top-left, bottom-right or bottom-left corner
471- // and orientation is same on the counter-axis
470+ // attached to either top-right, top-left, bottom-right or bottom-left corner,
471+ // or strictly above/below or left/right of the target. In the corner case,
472+ // the orientation is compared on the counter-axis to decide the layout.
473+
474+ var verticalAttachOrientation = getVerticalOrientation ( attachOrientation ) ,
475+ horizontalAttachOrientation = getHorizontalOrientation ( attachOrientation ) ,
476+ verticalTargetOrientation = getVerticalOrientation ( targetOrientation ) ,
477+ horizontalTargetOrientation = getHorizontalOrientation ( targetOrientation ) ;
478+
479+ // If the target is strictly above/below (no horizontal orientation)
480+ if ( verticalTargetOrientation && ! horizontalTargetOrientation ) {
481+ return 'v' ;
482+ }
483+
484+ // If the target is strictly left/right (no vertical orientation)
485+ if ( horizontalTargetOrientation && ! verticalTargetOrientation ) {
486+ return 'h' ;
487+ }
472488
473489 if ( isHorizontal ) {
474- if ( isSame ( getVerticalOrientation ( attachOrientation ) , getVerticalOrientation ( targetOrientation ) ) ) {
490+ if ( isSame ( verticalAttachOrientation , verticalTargetOrientation ) ) {
475491 return 'h' ;
476492 } else {
477493 return 'v' ;
478494 }
479495 } else {
480- if ( isSame ( getHorizontalOrientation ( attachOrientation ) , getHorizontalOrientation ( targetOrientation ) ) ) {
496+ if ( isSame ( horizontalAttachOrientation , horizontalTargetOrientation ) ) {
481497 return 'v' ;
482498 } else {
483499 return 'h' ;
484500 }
485501 }
486502}
487503
488- BpmnLayouter . $inject = [ 'elementRegistry' ] ;
504+ BpmnLayouter . $inject = [ 'elementRegistry' ] ;
0 commit comments