You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
11 KiB

4 months ago
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';
/**
* <zh/>
*
* <en/> Get the style of the label's position
* @param key - <zh/> | <en/> The edge object
* @param placement - <zh/> | <en/> Position of the label
* @param autoRotate - <zh/> | <en/> Whether to auto-rotate
* @param offsetX - <zh/> | <en/> Horizontal offset of the label relative to the edge
* @param offsetY - <zh/> | <en/> Vertical offset of the label relative to the edge
* @returns <zh/> | <en/> Returns the style of the label's position
*/
export declare function getLabelPositionStyle(key: EdgeKey, placement: EdgeLabelStyleProps['placement'], autoRotate: boolean, offsetX: number, offsetY: number): Partial<EdgeLabelStyleProps>;
/**
* <zh/>
*
* <en/> Get the position style of the badge on the edge
* @param shapeMap - <zh/> | <en/> Shape map on the edge
* @param placement - <zh/> | <en/> Badge position
* @param labelPlacement - <zh/> | <en/> Label position
* @param offsetX - <zh/> | <en/> Horizontal offset
* @param offsetY - <zh/> | <en/> Vertical offset
* @returns <zh/> | <en/> Position style of the badge
*/
export declare function getBadgePositionStyle(shapeMap: Record<string, DisplayObject<any, any>>, placement: EdgeBadgeStyleProps['placement'], labelPlacement: EdgeLabelStyleProps['placement'], offsetX: number, offsetY: number): Partial<EdgeLabelStyleProps>;
/** ==================== Curve Edge =========================== */
/**
* <zh/> 线
*
* <en/> Calculate the control point of the curve
* @param sourcePoint - <zh/> | <en/> Source point
* @param targetPoint - <zh/> | <en/> Target point
* @param curvePosition - <zh/> 线 0-1 | <en/> The relative position of the control point on the line (value range from 0 to 1)
* @param curveOffset - <zh/> 线 | <en/> The distance between the control point and the line
* @returns <zh/> | <en/> Control points
*/
export declare function getCurveControlPoint(sourcePoint: Point, targetPoint: Point, curvePosition: number, curveOffset: number): Point;
/**
* <zh/> 线 `curveOffset`
*
* <en/> parse the distance of the control point from the line `curveOffset`
* @param curveOffset - <zh/> curveOffset | <en/> curveOffset
* @returns <zh/> curveOffset | <en/> standard curveOffset
*/
export declare function parseCurveOffset(curveOffset: number | [number, number]): [number, number];
/**
* <zh/> 线 `curvePosition``0-1`
*
* <en/> parse the relative position of the control point on the line `curvePosition`
* @param curvePosition - <zh/> curvePosition | <en/> curvePosition
* @returns <zh/> curvePosition | <en/> standard curvePosition
*/
export declare function parseCurvePosition(curvePosition: number | [number, number]): [number, number];
/**
* <zh/> 线
*
* <en/> Calculate the path for drawing a quadratic Bessel curve
* @param sourcePoint - <zh/> | <en/> Source point
* @param targetPoint - <zh/> | <en/> Target point
* @param controlPoint - <zh/> | <en/> Control point
* @returns <zh/> 线 | <en/> Returns curve path
*/
export declare function getQuadraticPath(sourcePoint: Point, targetPoint: Point, controlPoint: Point): PathArray;
/**
* <zh/> 线
*
* <en/> Calculate the path for drawing a cubic Bessel curve
* @param sourcePoint - <zh/> | <en/> Source point
* @param targetPoint - <zh/> | <en/> Target point
* @param controlPoints - <zh/> | <en/> Control point
* @returns <zh/> 线 | <en/> Returns curve path
*/
export declare function getCubicPath(sourcePoint: Point, targetPoint: Point, controlPoints: [Point, Point]): PathArray;
/** ==================== Polyline Edge =========================== */
/**
* <zh/> 线
*
* <en/> Calculates the path for drawing a polyline
* @param points - <zh/> 线 | <en/> The vertices of the polyline
* @param radius - <zh/> | <en/> Radius of the rounded corner
* @param z - <zh/> | <en/> Whether the path is closed
* @returns <zh/> 线 | <en/> Returns the path for drawing a polyline
*/
export declare function getPolylinePath(points: Point[], radius?: number, z?: boolean): PathArray;
/**
* <zh/> 线线
*
* <en/> 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 - <zh/> | <en/> Previous point
* @param midPoint - <zh/> | <en/> Middle point
* @param nextPoint - <zh/> | <en/> Next point
* @param radius - <zh/> | <en/> Radius of the rounded corner
* @returns <zh/> | <en/> 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<LoopPlacement, [number, number]>;
/**
* <zh/>
*
* <en/> Get the start and end points of the loop edge
* @param node - <zh/> | <en/> Node instance
* @param placement - <zh/> | <en/> Loop position relative to the node
* @param clockwise - <zh/> | <en/> Whether to draw the loop clockwise
* @param sourcePort - <zh/> | <en/> Source port
* @param targetPort - <zh/> | <en/> Target port
* @returns <zh/> | <en/> Start and end points
*/
export declare function getLoopEndpoints(node: Node, placement: LoopPlacement, clockwise: boolean, sourcePort?: Port, targetPort?: Port): [Point, Point];
/**
* <zh/>
*
* <en/> Get the path of the loop edge
* @param node - <zh/> | <en/> Node instance
* @param placement - <zh/> | <en/> Loop position relative to the node
* @param clockwise - <zh/> | <en/> Whether to draw the loop clockwise
* @param dist - <zh/> keyShape | <en/> The distance from the edge of the node keyShape to the top of the self-loop
* @param sourcePortKey - <zh/> key | <en/> Source port key
* @param targetPortKey - <zh/> key | <en/> Target port key
* @returns <zh/> | <en/> Returns the path of the loop edge
*/
export declare function getCubicLoopPath(node: Node, placement: LoopPlacement, clockwise: boolean, dist: number, sourcePortKey?: string, targetPortKey?: string): PathArray;
/**
* <zh/>
*
* <en/> Get the control points of the loop edge
* @param node - <zh/> | <en/> Node instance
* @param sourcePoint - <zh/> | <en/> Source point
* @param targetPoint - <zh/> | <en/> Target point
* @param dist - <zh/> keyShape | <en/> The distance from the edge of the node keyShape to the top of the self-loop
* @returns <zh/> | <en/> Control points
*/
export declare function getCubicLoopControlPoints(node: Node, sourcePoint: Point, targetPoint: Point, dist: number): [Point, Point];
/**
* <zh/> 线
*
* <en/> Get the path of the loop polyline edge
* @param node - <zh/> | <en/> Node instance
* @param radius - <zh/> | <en/> Radius of the rounded corner
* @param placement - <zh/> | <en/> Loop position relative to the node
* @param clockwise - <zh/> | <en/> Whether to draw the loop clockwise
* @param dist - <zh/> keyShape | <en/> The distance from the edge of the node keyShape to the top of the self-loop
* @param sourcePortKey - <zh/> key | <en/> Source port key
* @param targetPortKey - <zh/> key | <en/> Target port key
* @returns <zh/> 线 | <en/> 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;
/**
* <zh/> 线
*
* <en/> Get the control points of the loop polyline edge
* @param node - <zh/> | <en/> Node instance
* @param sourcePoint - <zh/> | <en/> Source point
* @param targetPoint - <zh/> | <en/> Target point
* @param dist - <zh/> keyShape | <en/> The distance from the edge of the node keyShape to the top of the self-loop
* @returns <zh/> | <en/> Control points
*/
export declare function getPolylineLoopControlPoints(node: Node, sourcePoint: Point, targetPoint: Point, dist: number): Point[];
/**
* <zh/>
*
* <en/> Get all the edges in the subgraph and group them into internal and external edges
* @param ids - <zh/> ID | <en/> Node ID array
* @param getRelatedEdges - <zh/> | <en/> Get node edges
* @returns <zh/> | <en/> Subgraph edges
*/
export declare function getSubgraphRelatedEdges(ids: ID[], getRelatedEdges: (id: ID) => EdgeData[]): {
edges: EdgeData[];
internal: EdgeData[];
external: EdgeData[];
};
/**
* <zh/>
*
* <en/> Get the actual connected object of the edge
* @param node - <zh/> | <en/> Logical connection node data
* @param getParentData - <zh/> | <en/> Get parent node data
* @returns <zh/> | <en/> Actual connected node data
*/
export declare function findActualConnectNodeData(node: NodeLikeData, getParentData: (id: ID) => NodeLikeData | undefined): NodeLikeData;
/**
* <zh/> 线
*
* <en/> Get the size of the arrow
* @param lineWidth - <zh/> 线 | <en/> The line width of the edge where the arrow is located
* @param size - <zh/> | <en/> Custom arrow size
* @returns <zh/> | <en/> Arrow size
*/
export declare function getArrowSize(lineWidth: number, size?: Size): Size;