import type { AABB, DisplayObject } from '@antv/g'; import type { PathArray } from '@antv/util'; import type { EdgeData } from '../spec'; import type { EdgeBadgeStyleProps, EdgeKey, EdgeLabelStyleProps, ID, LoopPlacement, Node, NodeLikeData, Point, Port, Size } from '../types'; /** * 获取标签的位置样式 * * Get the style of the label's position * @param key - 边对象 | The edge object * @param placement - 标签位置 | Position of the label * @param autoRotate - 是否自动旋转 | Whether to auto-rotate * @param offsetX - 标签相对于边的水平偏移量 | Horizontal offset of the label relative to the edge * @param offsetY - 标签相对于边的垂直偏移量 | Vertical offset of the label relative to the edge * @returns 标签的位置样式 | Returns the style of the label's position */ export declare function getLabelPositionStyle(key: EdgeKey, placement: EdgeLabelStyleProps['placement'], autoRotate: boolean, offsetX: number, offsetY: number): Partial; /** * 获取边上徽标的位置样式 * * Get the position style of the badge on the edge * @param shapeMap - 边上的图形映射 | Shape map on the edge * @param placement - 徽标位置 | Badge position * @param labelPlacement - 标签位置 | Label position * @param offsetX - 水平偏移量 | Horizontal offset * @param offsetY - 垂直偏移量 | Vertical offset * @returns 徽标的位置样式 | Position style of the badge */ export declare function getBadgePositionStyle(shapeMap: Record>, placement: EdgeBadgeStyleProps['placement'], labelPlacement: EdgeLabelStyleProps['placement'], offsetX: number, offsetY: number): Partial; /** ==================== Curve Edge =========================== */ /** * 计算曲线的控制点 * * Calculate the control point of the curve * @param sourcePoint - 起点 | Source point * @param targetPoint - 终点 | Target point * @param curvePosition - 控制点在连线上的相对位置(取值范围为 0-1) | The relative position of the control point on the line (value range from 0 to 1) * @param curveOffset - 控制点距离两端点连线的距离 | The distance between the control point and the line * @returns 控制点 | Control points */ export declare function getCurveControlPoint(sourcePoint: Point, targetPoint: Point, curvePosition: number, curveOffset: number): Point; /** * 解析控制点距离两端点连线的距离 `curveOffset` * * parse the distance of the control point from the line `curveOffset` * @param curveOffset - curveOffset | curveOffset * @returns 标准 curveOffset | standard curveOffset */ export declare function parseCurveOffset(curveOffset: number | [number, number]): [number, number]; /** * 解析控制点在两端点连线上的相对位置 `curvePosition`,范围为`0-1` * * parse the relative position of the control point on the line `curvePosition` * @param curvePosition - curvePosition | curvePosition * @returns 标准 curvePosition | standard curvePosition */ export declare function parseCurvePosition(curvePosition: number | [number, number]): [number, number]; /** * 获取二次贝塞尔曲线绘制路径 * * Calculate the path for drawing a quadratic Bessel curve * @param sourcePoint - 边的起点 | Source point * @param targetPoint - 边的终点 | Target point * @param controlPoint - 控制点 | Control point * @returns 返回绘制曲线的路径 | Returns curve path */ export declare function getQuadraticPath(sourcePoint: Point, targetPoint: Point, controlPoint: Point): PathArray; /** * 获取三次贝塞尔曲线绘制路径 * * Calculate the path for drawing a cubic Bessel curve * @param sourcePoint - 边的起点 | Source point * @param targetPoint - 边的终点 | Target point * @param controlPoints - 控制点 | Control point * @returns 返回绘制曲线的路径 | Returns curve path */ export declare function getCubicPath(sourcePoint: Point, targetPoint: Point, controlPoints: [Point, Point]): PathArray; /** ==================== Polyline Edge =========================== */ /** * 获取折线的绘制路径 * * Calculates the path for drawing a polyline * @param points - 折线的顶点 | The vertices of the polyline * @param radius - 圆角半径 | Radius of the rounded corner * @param z - 路径是否闭合 | Whether the path is closed * @returns 返回绘制折线的路径 | Returns the path for drawing a polyline */ export declare function getPolylinePath(points: Point[], radius?: number, z?: boolean): PathArray; /** * 根据给定的半径计算出不共线的三点生成贝塞尔曲线的控制点,以模拟接近圆弧 * * Calculates the control points of the Bezier curve generated by three non-collinear points according to the given radius to simulate an arc * @param prevPoint - 前一个点 | Previous point * @param midPoint - 中间点 | Middle point * @param nextPoint - 后一个点 | Next point * @param radius - 圆角半径 | Radius of the rounded corner * @returns 返回控制点 | Returns control points */ export declare function getBorderRadiusPoints(prevPoint: Point, midPoint: Point, nextPoint: Point, radius: number): [Point, Point]; /** ==================== Loop Edge =========================== */ export declare const getRadians: (bbox: AABB) => Record; /** * 获取环形边的起点和终点 * * Get the start and end points of the loop edge * @param node - 节点实例 | Node instance * @param placement - 环形边相对于节点位置 | Loop position relative to the node * @param clockwise - 是否顺时针 | Whether to draw the loop clockwise * @param sourcePort - 起点连接桩 | Source port * @param targetPort - 终点连接桩 | Target port * @returns 起点和终点 | Start and end points */ export declare function getLoopEndpoints(node: Node, placement: LoopPlacement, clockwise: boolean, sourcePort?: Port, targetPort?: Port): [Point, Point]; /** * 获取环形边的绘制路径 * * Get the path of the loop edge * @param node - 节点实例 | Node instance * @param placement - 环形边相对于节点位置 | Loop position relative to the node * @param clockwise - 是否顺时针 | Whether to draw the loop clockwise * @param dist - 从节点 keyShape 边缘到自环顶部的距离 | The distance from the edge of the node keyShape to the top of the self-loop * @param sourcePortKey - 起点连接桩 key | Source port key * @param targetPortKey - 终点连接桩 key | Target port key * @returns 返回绘制环形边的路径 | Returns the path of the loop edge */ export declare function getCubicLoopPath(node: Node, placement: LoopPlacement, clockwise: boolean, dist: number, sourcePortKey?: string, targetPortKey?: string): PathArray; /** * 获取环形边的控制点 * * Get the control points of the loop edge * @param node - 节点实例 | Node instance * @param sourcePoint - 起点 | Source point * @param targetPoint - 终点 | Target point * @param dist - 从节点 keyShape 边缘到自环顶部的距离 | The distance from the edge of the node keyShape to the top of the self-loop * @returns 控制点 | Control points */ export declare function getCubicLoopControlPoints(node: Node, sourcePoint: Point, targetPoint: Point, dist: number): [Point, Point]; /** * 获取环形折线边的绘制路径 * * Get the path of the loop polyline edge * @param node - 节点实例 | Node instance * @param radius - 圆角半径 | Radius of the rounded corner * @param placement - 环形边相对于节点位置 | Loop position relative to the node * @param clockwise - 是否顺时针 | Whether to draw the loop clockwise * @param dist - 从节点 keyShape 边缘到自环顶部的距离 | The distance from the edge of the node keyShape to the top of the self-loop * @param sourcePortKey - 起点连接桩 key | Source port key * @param targetPortKey - 终点连接桩 key | Target port key * @returns 返回绘制环形折线边的路径 | Returns the path of the loop polyline edge */ export declare function getPolylineLoopPath(node: Node, radius: number, placement: LoopPlacement, clockwise: boolean, dist: number, sourcePortKey?: string, targetPortKey?: string): PathArray; /** * 获取环形折线边的控制点 * * Get the control points of the loop polyline edge * @param node - 节点实例 | Node instance * @param sourcePoint - 起点 | Source point * @param targetPoint - 终点 | Target point * @param dist - 从节点 keyShape 边缘到自环顶部的距离 | The distance from the edge of the node keyShape to the top of the self-loop * @returns 控制点 | Control points */ export declare function getPolylineLoopControlPoints(node: Node, sourcePoint: Point, targetPoint: Point, dist: number): Point[]; /** * 获取子图内的所有边,并按照内部边和外部边分组 * * Get all the edges in the subgraph and group them into internal and external edges * @param ids - 节点 ID 数组 | Node ID array * @param getRelatedEdges - 获取节点邻边 | Get node edges * @returns 子图边 | Subgraph edges */ export declare function getSubgraphRelatedEdges(ids: ID[], getRelatedEdges: (id: ID) => EdgeData[]): { edges: EdgeData[]; internal: EdgeData[]; external: EdgeData[]; }; /** * 获取边的实际连接节点 * * Get the actual connected object of the edge * @param node - 逻辑连接节点数据 | Logical connection node data * @param getParentData - 获取父节点数据 | Get parent node data * @returns 实际连接节点数据 | Actual connected node data */ export declare function findActualConnectNodeData(node: NodeLikeData, getParentData: (id: ID) => NodeLikeData | undefined): NodeLikeData; /** * 获取箭头大小,若用户未指定,则根据线宽自动计算 * * Get the size of the arrow * @param lineWidth - 箭头所在边的线宽 | The line width of the edge where the arrow is located * @param size - 自定义箭头大小 | Custom arrow size * @returns 箭头大小 | Arrow size */ export declare function getArrowSize(lineWidth: number, size?: Size): Size;