mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-18 06:31:33 +08:00
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { findNewLineStartIndex, getAnchorPointAdjustment } from './LayoutUtil';
|
|
|
|
import { getMid } from 'diagram-js/lib/layout/LayoutUtil';
|
|
|
|
/**
|
|
* @typedef {import('./LineAttachmentUtil').Attachment} Attachment
|
|
*
|
|
* @typedef {import('./LayoutUtil').FindNewLineStartIndexHints} FindNewLineStartIndexHints
|
|
*
|
|
* @typedef {import('../../../../model/Types').BpmnLabel} BpmnLabel
|
|
*
|
|
* @typedef {import('diagram-js/lib/util/Types').Point} Point
|
|
*/
|
|
|
|
/**
|
|
* @param {Point[]} oldWaypoints
|
|
* @param {Point[]} newWaypoints
|
|
* @param {Attachment} attachment
|
|
* @param {FindNewLineStartIndexHints} hints
|
|
*
|
|
* @return {number}
|
|
*/
|
|
export function findNewLabelLineStartIndex(oldWaypoints, newWaypoints, attachment, hints) {
|
|
return findNewLineStartIndex(oldWaypoints, newWaypoints, attachment, hints);
|
|
}
|
|
|
|
/**
|
|
* Calculate the required adjustment (move delta) for the given label
|
|
* after the connection waypoints got updated.
|
|
*
|
|
* @param {BpmnLabel} label
|
|
* @param {Point[]} newWaypoints
|
|
* @param {Point[]} oldWaypoints
|
|
* @param {FindNewLineStartIndexHints} hints
|
|
*
|
|
* @return {Point}
|
|
*/
|
|
export function getLabelAdjustment(label, newWaypoints, oldWaypoints, hints) {
|
|
var labelPosition = getMid(label);
|
|
|
|
return getAnchorPointAdjustment(labelPosition, newWaypoints, oldWaypoints, hints).delta;
|
|
} |