chore(autp-place): move helper function to util

This commit is contained in:
Philipp Fromme 2019-04-29 16:03:07 +02:00 committed by merge-me[bot]
parent d73ffd5991
commit 4388359fb1
2 changed files with 28 additions and 39 deletions

View File

@ -1,12 +1,4 @@
import { is } from '../../util/ModelUtil';
import { isAny } from '../modeling/util/ModelingUtil';
import {
getTextAnnotationPosition,
getDataElementPosition,
getFlowNodePosition,
getDefaultPosition
} from './AutoPlaceUtil';
import { getNewShapePosition } from './AutoPlaceUtil';
/**
@ -59,32 +51,3 @@ AutoPlace.$inject = [
'eventBus',
'modeling'
];
// helpers //////////////////////
/**
* Find the new position for the target element to
* connect to source.
*
* @param {djs.model.Shape} source
* @param {djs.model.Shape} element
*
* @return {Point}
*/
function getNewShapePosition(source, element) {
if (is(element, 'bpmn:TextAnnotation')) {
return getTextAnnotationPosition(source, element);
}
if (isAny(element, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
return getDataElementPosition(source, element);
}
if (is(element, 'bpmn:FlowNode')) {
return getFlowNodePosition(source, element);
}
return getDefaultPosition(source, element);
}

View File

@ -1,4 +1,5 @@
import { is } from '../../util/ModelUtil';
import { isAny } from '../modeling/util/ModelingUtil';
import {
getMid,
@ -18,6 +19,31 @@ var MAX_HORIZONTAL_DISTANCE = 250;
// padding to detect element placement
var PLACEMENT_DETECTION_PAD = 10;
/**
* Find the new position for the target element to
* connect to source.
*
* @param {djs.model.Shape} source
* @param {djs.model.Shape} element
*
* @return {Point}
*/
export function getNewShapePosition(source, element) {
if (is(element, 'bpmn:TextAnnotation')) {
return getTextAnnotationPosition(source, element);
}
if (isAny(element, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
return getDataElementPosition(source, element);
}
if (is(element, 'bpmn:FlowNode')) {
return getFlowNodePosition(source, element);
}
return getDefaultPosition(source, element);
}
/**
* Always try to place element right of source;