UNPKG

@logicflow/core

Version:

LogicFlow, help you quickly create flowcharts

743 lines (742 loc) 33.3 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; import { get, assign, cloneDeep } from 'lodash-es'; import { observable, action } from 'mobx'; import { BaseEdgeModel } from '.'; import { ModelType, SegmentDirection } from '../../constant'; import { isInNode, distance, getClosestRadiusCenter, inStraightLineOfRect, getCrossPointWithCircle, getCrossPointWithEllipse, getCrossPointWithPolygon, getPolylinePoints, getLongestEdge, getCrossPointInRect, isSegmentsInNode, isSegmentsCrossNode, segmentDirection, points2PointsList, pointFilter, } from '../../util'; var isFinitePoint = function (point) { return !!point && Number.isFinite(point.x) && Number.isFinite(point.y); }; var PolylineEdgeModel = /** @class */ (function (_super) { __extends(PolylineEdgeModel, _super); function PolylineEdgeModel() { var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; _this.modelType = ModelType.POLYLINE_EDGE; _this.draggingPointList = []; return _this; } PolylineEdgeModel.prototype.initEdgeData = function (data) { var providedOffset = get(data, 'properties.offset'); // 当用户未传入 offset 时,按“箭头与折线重叠长度 + 5”作为默认值 // 其中“重叠长度”采用箭头样式中的 offset(沿边方向的长度) this.offset = typeof providedOffset === 'number' ? providedOffset : this.getDefaultOffset(); if (data.pointsList) { var corrected = this.orthogonalizePath(data.pointsList); data.pointsList = corrected; this.pointsList = corrected; } _super.prototype.initEdgeData.call(this, data); }; PolylineEdgeModel.prototype.setAttributes = function () { var newOffset = this.properties.offset; if (newOffset && newOffset !== this.offset) { this.offset = newOffset; this.updatePoints(); } }; PolylineEdgeModel.prototype.orthogonalizePath = function (points) { // 输入非法或不足两点时直接返回副本 if (!Array.isArray(points) || points.length < 2) { return points; } // pushUnique: 向数组中添加唯一点,避免重复 var pushUnique = function (arr, p) { var last = arr[arr.length - 1]; if (!last || last.x !== p.x || last.y !== p.y) { arr.push({ x: p.x, y: p.y }); } }; // isAxisAligned: 检查两点是否在同一条轴上 var isAxisAligned = function (a, b) { return a.x === b.x || a.y === b.y; }; // manhattanDistance: 计算两点在曼哈顿距离上的距离 var manhattanDistance = function (a, b) { return Math.abs(a.x - b.x) + Math.abs(a.y - b.y); }; // 1) 生成严格正交路径,尽量延续前一段方向以减少折点 var orthogonal = []; pushUnique(orthogonal, points[0]); // previousDirection: 记录前一段的方向,用于判断当前段的PreferredCorner var previousDirection; // 遍历所有点对,生成正交路径 for (var i = 0; i < points.length - 1; i++) { var current = orthogonal[orthogonal.length - 1]; var next = points[i + 1]; if (!current || !next) continue; if (isAxisAligned(current, next)) { pushUnique(orthogonal, next); previousDirection = current.x === next.x ? SegmentDirection.VERTICAL : SegmentDirection.HORIZONTAL; continue; } var cornerHV = { x: next.x, y: current.y }; var cornerVH = { x: current.x, y: next.y }; // 根据前一段的方向,优先选择能延续该方向的拐角点,以减少折点数量; // 若前一段为垂直方向,则优先选择垂直-水平拐角(cornerVH); // 若前一段为水平方向,则优先选择水平-垂直拐角(cornerHV); // 若前一段无方向(初始情况),则比较两个拐角的曼哈顿距离,选更近者。 var preferredCorner = previousDirection === SegmentDirection.VERTICAL ? cornerVH : previousDirection === SegmentDirection.HORIZONTAL ? cornerHV : manhattanDistance(current, cornerHV) <= manhattanDistance(current, cornerVH) ? cornerHV : cornerVH; if (preferredCorner.x !== current.x || preferredCorner.y !== current.y) { pushUnique(orthogonal, preferredCorner); } pushUnique(orthogonal, next); var a = orthogonal[orthogonal.length - 2]; var b = orthogonal[orthogonal.length - 1]; previousDirection = a && b ? a.x === b.x ? SegmentDirection.VERTICAL : SegmentDirection.HORIZONTAL : previousDirection; } // 2) 去除冗余共线中间点 var simplified = []; for (var i = 0; i < orthogonal.length; i++) { var prev = orthogonal[i - 1]; var curr = orthogonal[i]; var next = orthogonal[i + 1]; // 如果当前点与前一个点和后一个点在同一条水平线或垂直线上,则跳过该点,去除冗余的共线中间点 if (prev && curr && next && ((prev.x === curr.x && curr.x === next.x) || // 水平共线 (prev.y === curr.y && curr.y === next.y)) // 垂直共线 ) { continue; } pushUnique(simplified, curr); } // 3) 保留原始起点与终点位置 if (simplified.length >= 2) { simplified[0] = { x: points[0].x, y: points[0].y }; simplified[simplified.length - 1] = { x: points[points.length - 1].x, y: points[points.length - 1].y, }; } // 4) 结果校验:任意相邻段都必须为水平/垂直;失败则退化为起止两点 var isOrthogonal = simplified.length < 2 || simplified.every(function (_, idx, arr) { if (idx === 0) return true; return isAxisAligned(arr[idx - 1], arr[idx]); }); return isOrthogonal ? simplified : [ { x: points[0].x, y: points[0].y }, { x: points[points.length - 1].x, y: points[points.length - 1].y }, ]; }; /** * 计算默认 offset:箭头与折线重叠长度 + 5 * 重叠长度采用箭头样式中的 offset(沿边方向的长度) */ PolylineEdgeModel.prototype.getDefaultOffset = function () { var arrowStyle = this.getArrowStyle(); var arrowOverlap = typeof arrowStyle.offset === 'number' ? arrowStyle.offset : 0; return arrowOverlap + 5; }; PolylineEdgeModel.prototype.getEdgeStyle = function () { var polyline = this.graphModel.theme.polyline; var style = _super.prototype.getEdgeStyle.call(this); var _a = this.properties.style, customStyle = _a === void 0 ? {} : _a; return __assign(__assign(__assign({}, style), cloneDeep(polyline)), cloneDeep(customStyle)); }; PolylineEdgeModel.prototype.getTextPosition = function () { var _a; // 在文本为空的情况下,文本位置为双击位置 var textValue = (_a = this.text) === null || _a === void 0 ? void 0 : _a.value; if (this.dbClickPosition && !textValue) { var _b = this.dbClickPosition, x = _b.x, y = _b.y; return { x: x, y: y }; } // 文本不为空或者没有双击位置时,取最长边的中点作为文本位置 var currentPositionList = points2PointsList(this.points); var _c = __read(getLongestEdge(currentPositionList), 2), p1 = _c[0], p2 = _c[1]; return { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2, }; }; // 获取下一个锚点 PolylineEdgeModel.prototype.getAfterAnchor = function (direction, position, anchorList) { var anchor; var minDistance; anchorList.forEach(function (item) { var distanceX; if (direction === SegmentDirection.HORIZONTAL) { distanceX = Math.abs(position.y - item.y); } else if (direction === SegmentDirection.VERTICAL) { distanceX = Math.abs(position.x - item.x); } if (!minDistance || minDistance > distanceX) { minDistance = distanceX; anchor = item; } }); return anchor; }; /* 获取拖拽过程中产生的交点 */ PolylineEdgeModel.prototype.getCrossPoint = function (direction, start, end) { var position; if (direction === SegmentDirection.HORIZONTAL) { position = { x: end.x, y: start.y, }; } else if (direction === SegmentDirection.VERTICAL) { position = { x: start.x, y: end.y, }; } return position; }; // 删除在图形内的过个交点 PolylineEdgeModel.prototype.removeCrossPoints = function (startIndex, endIndex, pointList) { var list = pointList.map(function (i) { return i; }); if (startIndex === 1) { var start_1 = list[startIndex]; var end = list[endIndex]; var pre_1 = list[startIndex - 1]; var isInStartNode = isSegmentsInNode(pre_1, start_1, this.sourceNode); if (isInStartNode) { var isSegmentsCrossStartNode = isSegmentsCrossNode(start_1, end, this.sourceNode); if (isSegmentsCrossStartNode) { var point = getCrossPointInRect(start_1, end, this.sourceNode); if (point) { list[startIndex] = point; list.splice(startIndex - 1, 1); startIndex--; endIndex--; } } } else { var anchorList = this.sourceNode.anchors; anchorList.forEach(function (item) { if ((item.x === pre_1.x && item.x === start_1.x) || (item.y === pre_1.y && item.y === start_1.y)) { var distance1 = distance(item.x, item.y, start_1.x, start_1.y); var distance2 = distance(pre_1.x, pre_1.y, start_1.x, start_1.y); if (distance1 < distance2) { list[startIndex - 1] = item; } } }); } } if (endIndex === pointList.length - 2) { var start = list[startIndex]; var end_1 = list[endIndex]; var next_1 = list[endIndex + 1]; var isInEndNode = isSegmentsInNode(end_1, next_1, this.targetNode); if (isInEndNode) { var isSegmentsCrossStartNode = isSegmentsCrossNode(start, end_1, this.targetNode); if (isSegmentsCrossStartNode) { var point = getCrossPointInRect(start, end_1, this.targetNode); if (point) { list[endIndex] = point; list.splice(endIndex + 1, 1); } } } else { var anchorList = this.targetNode.anchors; anchorList.forEach(function (item) { if ((item.x === next_1.x && item.x === end_1.x) || (item.y === next_1.y && item.y === end_1.y)) { var distance1 = distance(item.x, item.y, end_1.x, end_1.y); var distance2 = distance(next_1.x, next_1.y, end_1.x, end_1.y); if (distance1 < distance2) { list[endIndex + 1] = item; } } }); } } return list; }; // 获取在拖拽过程中可能产生的点 PolylineEdgeModel.prototype.getDraggingPoints = function (direction, positionType, position, anchorList, draggingPointList) { var pointList = draggingPointList.map(function (i) { return i; }); var anchor = this.getAfterAnchor(direction, position, anchorList); var crossPoint = this.getCrossPoint(direction, position, anchor); if (positionType === 'start') { pointList.unshift(crossPoint); pointList.unshift(anchor); } else { pointList.push(crossPoint); pointList.push(anchor); } return pointList; }; // 更新相交点[起点,终点],更加贴近图形, 未修改observable不作为action PolylineEdgeModel.prototype.updateCrossPoints = function (pointList) { var list = pointList.map(function (i) { return i; }); var start = pointList[0]; var next = pointList[1]; var pre = pointList[list.length - 2]; var end = pointList[list.length - 1]; var _a = this, sourceNode = _a.sourceNode, targetNode = _a.targetNode; var sourceModelType = sourceNode.modelType; var targetModelType = targetNode.modelType; var startPointDirection = segmentDirection(start, next); var startCrossPoint = list[0]; switch (sourceModelType) { case ModelType.RECT_NODE: if (sourceNode.radius !== 0) { var inInnerNode = inStraightLineOfRect(start, sourceNode); if (!inInnerNode) { startCrossPoint = getClosestRadiusCenter(start, startPointDirection, sourceNode); } } break; case ModelType.CIRCLE_NODE: startCrossPoint = getCrossPointWithCircle(start, startPointDirection, sourceNode); break; case ModelType.ELLIPSE_NODE: startCrossPoint = getCrossPointWithEllipse(start, startPointDirection, sourceNode); break; case ModelType.DIAMOND_NODE: startCrossPoint = getCrossPointWithPolygon(start, startPointDirection, sourceNode); break; case ModelType.POLYGON_NODE: startCrossPoint = getCrossPointWithPolygon(start, startPointDirection, sourceNode); break; default: break; } // 如果线段和形状没有交点时startCrossPoint会为undefined导致后续计算报错 if (isFinitePoint(startCrossPoint)) { list[0] = startCrossPoint; } var endPointDirection = segmentDirection(pre, end); var endCrossPoint = list[list.length - 1]; switch (targetModelType) { case ModelType.RECT_NODE: if (targetNode.radius !== 0) { var inInnerNode = inStraightLineOfRect(end, targetNode); if (!inInnerNode) { endCrossPoint = getClosestRadiusCenter(end, endPointDirection, targetNode); } } break; case ModelType.CIRCLE_NODE: endCrossPoint = getCrossPointWithCircle(end, endPointDirection, targetNode); break; case ModelType.ELLIPSE_NODE: endCrossPoint = getCrossPointWithEllipse(end, endPointDirection, targetNode); break; case ModelType.DIAMOND_NODE: endCrossPoint = getCrossPointWithPolygon(end, endPointDirection, targetNode); break; case ModelType.POLYGON_NODE: endCrossPoint = getCrossPointWithPolygon(end, endPointDirection, targetNode); break; default: break; } // 如果线段和形状没有交点时startCrossPoint会为undefined导致后续计算报错 if (isFinitePoint(endCrossPoint)) { list[list.length - 1] = endCrossPoint; } return list; }; PolylineEdgeModel.prototype.updatePath = function (pointList) { this.pointsList = this.orthogonalizePath(pointList); this.points = this.getPath(this.pointsList); }; PolylineEdgeModel.prototype.getData = function () { var data = _super.prototype.getData.call(this); var pointsList = this.pointsList.map(function (_a) { var x = _a.x, y = _a.y; return ({ x: x, y: y, }); }); return Object.assign({}, data, { pointsList: pointsList, }); }; PolylineEdgeModel.prototype.getPath = function (points) { return points.map(function (point) { return "".concat(point.x, ",").concat(point.y); }).join(' '); }; PolylineEdgeModel.prototype.initPoints = function () { if (this.pointsList.length > 0) { this.points = this.getPath(this.pointsList); } else { this.updatePoints(); } }; PolylineEdgeModel.prototype.updatePoints = function () { var pointsList = getPolylinePoints({ x: this.startPoint.x, y: this.startPoint.y, }, { x: this.endPoint.x, y: this.endPoint.y, }, this.sourceNode, this.targetNode, this.offset || 0); this.pointsList = this.orthogonalizePath(pointsList); this.points = this.pointsList .map(function (point) { return "".concat(point.x, ",").concat(point.y); }) .join(' '); }; PolylineEdgeModel.prototype.updateStartPoint = function (anchor) { this.startPoint = Object.assign({}, anchor); this.updatePoints(); }; PolylineEdgeModel.prototype.moveStartPoint = function (deltaX, deltaY) { this.startPoint.x += deltaX; this.startPoint.y += deltaY; this.updatePoints(); // todo: 尽量保持边的整体轮廓, 通过deltaX和deltaY更新pointsList,而不是重新计算。 }; PolylineEdgeModel.prototype.updateEndPoint = function (anchor) { this.endPoint = Object.assign({}, anchor); this.updatePoints(); }; PolylineEdgeModel.prototype.moveEndPoint = function (deltaX, deltaY) { this.endPoint.x += deltaX; this.endPoint.y += deltaY; this.updatePoints(); }; PolylineEdgeModel.prototype.updatePointsList = function (deltaX, deltaY) { this.pointsList.forEach(function (item) { item.x += deltaX; item.y += deltaY; }); var startPoint = this.pointsList[0]; this.startPoint = Object.assign({}, startPoint); var endPoint = this.pointsList[this.pointsList.length - 1]; this.endPoint = Object.assign({}, endPoint); this.initPoints(); }; PolylineEdgeModel.prototype.dragAppendStart = function () { // mobx observer 对象被iterator处理会有问题 this.draggingPointList = this.pointsList.map(function (i) { return i; }); }; PolylineEdgeModel.prototype.dragAppendSimple = function (appendInfo, dragInfo) { var _a; // 因为drag事件是mouseDown事件触发的,因此当真实拖拽之后再设置isDragging // 避免因为点击事件造成,在dragStart触发之后,没有触发dragEnd错误设置了isDragging状态,对history计算造成错误 this.isDragging = true; var start = appendInfo.start, end = appendInfo.end, startIndex = appendInfo.startIndex, endIndex = appendInfo.endIndex, direction = appendInfo.direction; var pointsList = this.pointsList; var draggingPointList = pointsList; if (direction === SegmentDirection.HORIZONTAL) { // 水平,仅调整y坐标,拿到当前线段两个端点移动后的坐标 pointsList[startIndex] = { x: start.x, y: start.y + dragInfo.y, }; pointsList[endIndex] = { x: end.x, y: end.y + dragInfo.y, }; draggingPointList = this.pointsList.map(function (i) { return i; }); } else if (direction === SegmentDirection.VERTICAL) { // 垂直,仅调整x坐标, 与水平调整同理 pointsList[startIndex] = { x: start.x + dragInfo.x, y: start.y, }; pointsList[endIndex] = { x: end.x + dragInfo.x, y: end.y, }; draggingPointList = this.pointsList.map(function (i) { return i; }); } this.updatePointsAfterDrag(draggingPointList); this.draggingPointList = draggingPointList; // TODO: 判断该逻辑是否需要 if ((_a = this.text) === null || _a === void 0 ? void 0 : _a.value) { this.setText(assign({}, this.text, this.textPosition)); } return { start: assign({}, pointsList[startIndex]), end: assign({}, pointsList[endIndex]), startIndex: startIndex, endIndex: endIndex, direction: direction, }; }; PolylineEdgeModel.prototype.dragAppend = function (appendInfo, dragInfo) { var _a; this.isDragging = true; var start = appendInfo.start, end = appendInfo.end, startIndex = appendInfo.startIndex, endIndex = appendInfo.endIndex, direction = appendInfo.direction; var pointsList = this.pointsList; if (direction === SegmentDirection.HORIZONTAL) { // 水平,仅调整y坐标 // step1: 拿到当前线段两个端点移动后的坐标 pointsList[startIndex] = { x: start.x, y: start.y + dragInfo.y, }; pointsList[endIndex] = { x: end.x, y: end.y + dragInfo.y, }; // step2: 计算拖拽后,两个端点与节点外框的交点 // 定义一个拖住中节点list var draggingPointList = this.pointsList.map(function (i) { return i; }); if (startIndex !== 0 && endIndex !== this.pointsList.length - 1) { // 2.1)如果线段没有连接起终点,过滤会穿插在图形内部的线段,取整个图形离线段最近的点 draggingPointList = this.removeCrossPoints(startIndex, endIndex, draggingPointList); } if (startIndex === 0) { // 2.2)如果线段连接了起点, 判断起点是否在节点内部 var startPosition = { x: start.x, y: start.y + dragInfo.y, }; var inNode = isInNode(startPosition, this.sourceNode); if (!inNode) { // 如果不在节点内部,更换起点为线段与节点的交点 var anchorList = this.sourceNode.anchors; draggingPointList = this.getDraggingPoints(direction, 'start', startPosition, anchorList, draggingPointList); } } if (endIndex === this.pointsList.length - 1) { // 2.2)如果线段连接了终点, 判断起点是否在节点内部 var endPosition = { x: end.x, y: end.y + dragInfo.y, }; var inNode = isInNode(endPosition, this.targetNode); if (!inNode) { // 如果不在节点内部,更换终点为线段与节点的交点 var anchorList = this.targetNode.anchors; draggingPointList = this.getDraggingPoints(direction, 'end', endPosition, anchorList, draggingPointList); } } this.updatePointsAfterDrag(draggingPointList); // step3: 调整到对应外框的位置后,执行updatePointsAfterDrag,找到当前线段和图形的准确交点 this.draggingPointList = draggingPointList; } else if (direction === SegmentDirection.VERTICAL) { // 垂直,仅调整x坐标, 与水平调整同理 pointsList[startIndex] = { x: start.x + dragInfo.x, y: start.y, }; pointsList[endIndex] = { x: end.x + dragInfo.x, y: end.y, }; var draggingPointList = this.pointsList.map(function (i) { return i; }); if (startIndex !== 0 && endIndex !== this.pointsList.length - 1) { draggingPointList = this.removeCrossPoints(startIndex, endIndex, draggingPointList); } if (startIndex === 0) { var startPosition = { x: start.x + dragInfo.x, y: start.y, }; var inNode = isInNode(startPosition, this.sourceNode); if (!inNode) { var anchorList = this.sourceNode.anchors; draggingPointList = this.getDraggingPoints(direction, 'start', startPosition, anchorList, draggingPointList); } } if (endIndex === this.pointsList.length - 1) { var endPosition = { x: end.x + dragInfo.x, y: end.y, }; var inNode = isInNode(endPosition, this.targetNode); if (!inNode) { var anchorList = this.targetNode.anchors; draggingPointList = this.getDraggingPoints(direction, 'end', endPosition, anchorList, draggingPointList); } } this.updatePointsAfterDrag(draggingPointList); this.draggingPointList = draggingPointList; } // TODO: 确认该判断逻辑是否需要 if ((_a = this.text) === null || _a === void 0 ? void 0 : _a.value) { this.setText(assign({}, this.text, this.textPosition)); } return { start: assign({}, pointsList[startIndex]), end: assign({}, pointsList[endIndex]), startIndex: startIndex, endIndex: endIndex, direction: direction, }; }; PolylineEdgeModel.prototype.dragAppendEnd = function () { if (this.draggingPointList) { var pointsList = pointFilter(points2PointsList(this.points)); // 更新pointsList,重新渲染appendWidth this.pointsList = pointsList.map(function (i) { return i; }); // draggingPointList清空 this.draggingPointList = []; // 更新起终点 var startPoint = pointsList[0]; this.startPoint = assign({}, startPoint); var endPoint = pointsList[pointsList.length - 1]; this.endPoint = assign({}, endPoint); } this.isDragging = false; }; /* 拖拽之后个更新points,仅更新边,不更新pointsList, appendWidth会依赖pointsList,更新pointsList会重新渲染appendWidth,从而导致不能继续拖拽 在拖拽结束后再进行pointsList的更新 */ PolylineEdgeModel.prototype.updatePointsAfterDrag = function (pointsList) { // 找到准确的连接点后,更新points, 更新边,同时更新依赖points的箭头 var list = this.updateCrossPoints(pointsList); this.points = list.map(function (point) { return "".concat(point.x, ",").concat(point.y); }).join(' '); }; // 获取边调整的起点 PolylineEdgeModel.prototype.getAdjustStart = function () { return this.pointsList[0] || this.startPoint; }; // 获取边调整的终点 PolylineEdgeModel.prototype.getAdjustEnd = function () { var pointsList = this.pointsList; return pointsList[pointsList.length - 1] || this.endPoint; }; // 起终点拖拽调整过程中,进行折线路径更新 PolylineEdgeModel.prototype.updateAfterAdjustStartAndEnd = function (_a) { var startPoint = _a.startPoint, endPoint = _a.endPoint, sourceNode = _a.sourceNode, targetNode = _a.targetNode; this.pointsList = this.orthogonalizePath(getPolylinePoints({ x: startPoint.x, y: startPoint.y, }, { x: endPoint.x, y: endPoint.y, }, sourceNode, targetNode, this.offset || 0)); this.initPoints(); }; __decorate([ observable ], PolylineEdgeModel.prototype, "offset", void 0); __decorate([ observable ], PolylineEdgeModel.prototype, "dbClickPosition", void 0); __decorate([ action ], PolylineEdgeModel.prototype, "initPoints", null); __decorate([ action ], PolylineEdgeModel.prototype, "updatePoints", null); __decorate([ action ], PolylineEdgeModel.prototype, "updateStartPoint", null); __decorate([ action ], PolylineEdgeModel.prototype, "moveStartPoint", null); __decorate([ action ], PolylineEdgeModel.prototype, "updateEndPoint", null); __decorate([ action ], PolylineEdgeModel.prototype, "moveEndPoint", null); __decorate([ action ], PolylineEdgeModel.prototype, "updatePointsList", null); __decorate([ action ], PolylineEdgeModel.prototype, "dragAppendStart", null); __decorate([ action ], PolylineEdgeModel.prototype, "dragAppendSimple", null); __decorate([ action ], PolylineEdgeModel.prototype, "dragAppend", null); __decorate([ action ], PolylineEdgeModel.prototype, "dragAppendEnd", null); __decorate([ action ], PolylineEdgeModel.prototype, "updatePointsAfterDrag", null); __decorate([ action ], PolylineEdgeModel.prototype, "getAdjustStart", null); __decorate([ action ], PolylineEdgeModel.prototype, "getAdjustEnd", null); __decorate([ action ], PolylineEdgeModel.prototype, "updateAfterAdjustStartAndEnd", null); return PolylineEdgeModel; }(BaseEdgeModel)); export { PolylineEdgeModel }; export default PolylineEdgeModel;