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.

241 lines
9.9 KiB

4 months ago
import type { AABB, DisplayObject, TextStyleProps } from '@antv/g';
import type { BaseShape, BaseShapeStyleProps } from '../elements/shapes';
import type { Combo, Edge, Element, Node, NodePortStyleProps, Placement, Point, TriangleDirection } from '../types';
import type { NodeLabelStyleProps, Port } from '../types/node';
/**
* <zh/> Node
*
* <en/> Judge whether the instance is Node
* @param shape - <zh/> | <en/> instance
* @returns <zh/> Node | <en/> whether the instance is Node
*/
export declare function isNode(shape: DisplayObject | Port): shape is Node;
/**
* <zh/> Edge
*
* <en/> Judge whether the instance is Edge
* @param shape - <zh/> | <en/> instance
* @returns <zh/> Edge | <en/> whether the instance is Edge
*/
export declare function isEdge(shape: DisplayObject): shape is Edge;
/**
* <zh/> Combo
*
* <en/> Judge whether the instance is Combo
* @param shape - <zh/> | <en/> instance
* @returns <zh/> Combo | <en/> whether the instance is Combo
*/
export declare function isCombo(shape: any): shape is Combo;
/**
* <zh/> Element
*
* <en/> Judge whether the instance is Element
* @param shape - <zh/> | <en/> instance
* @returns <zh/> Element | <en/> whether the instance is Element
*/
export declare function isElement(shape: any): shape is Element;
/**
* <zh/>
*
* <en/> Whether the two nodes are the same
* @param node1 - <zh/> 1 | <en/> Node1
* @param node2 - <zh/> 2 | <en/> Node2
* @returns <zh/> | <en/> Whether the same
*/
export declare function isSameNode(node1: Node, node2: Node): boolean;
/**
* Get the Port x, y by `position`.
* @param bbox - BBox of element.
* @param placement - The position relative with element.
* @param portMap - The map of position.
* @param isRelative - Whether the position in MAP is relative.
* @returns [x, y]
*/
export declare function getPortXYByPlacement(bbox: AABB, placement?: Placement, portMap?: Record<string, Point>, isRelative?: boolean): Point;
/**
* <zh/>
*
* <en/> Get all ports
* @param node - <zh/> | <en/> Node
* @returns <zh/> | <en/> All Ports
*/
export declare function getAllPorts(node: Node): Record<string, Port>;
/**
* <zh/>
*
* <en/> Whether it is a simple port, which will not draw additional graphics
* @param portStyle - <zh/> | <en/> Port Style
* @returns <zh/> | <en/> Whether it is a simple port
*/
export declare function isSimplePort(portStyle: NodePortStyleProps): boolean;
/**
* <zh/>
*
* <en/> Get the position of the port
* @param port - <zh/> | <en/> Port
* @returns <zh/> | <en/> Port Position
*/
export declare function getPortPosition(port: Port): Point;
/**
* <zh/>
*
* <en/> Find the source port and target port
* @param sourceNode - <zh/> | <en/> Source Node
* @param targetNode - <zh/> | <en/> Target Node
* @param sourcePortKey - <zh/> key | <en/> Source Port Key
* @param targetPortKey - <zh/> key | <en/> Target Port Key
* @returns <zh/> | <en/> Source Port and Target Port
*/
export declare function findPorts(sourceNode: Node, targetNode: Node, sourcePortKey?: string, targetPortKey?: string): [Port | undefined, Port | undefined];
/**
* <zh/>
*
* <en/> Find the most likely connected port on the node
* @remarks
* 1. If `portKey` is specified, return the port.
* 2. If `portKey` is not specified, return the port closest to the opposite connection points.
* 3. If the node has no ports, return undefined.
* @param node - <zh/> | <en/> Node
* @param oppositeNode - <zh/> | <en/> Opposite Node
* @param portKey - <zh/> key | <en/> Port Key
* @param oppositePortKey - <zh/> key | <en/> Opposite Port Key
* @returns <zh/> | <en/> Port
*/
export declare function findPort(node: Node, oppositeNode: Node, portKey?: string, oppositePortKey?: string): Port | undefined;
/**
* <zh/> , 线
*
* <en/> Get the connection point
* @param node - <zh/> | <en/> Node or Port
* @param opposite - <zh/> | <en/> Opposite Point or Node
* @returns <zh/> | <en/> Connection Point
*/
export declare function getConnectionPoint(node: Port | Node | Combo, opposite: Node | Port): Point;
/**
* <zh/> 线
*
* <en/> Get the connection point of the port
* @param port - <zh/> | <en/> Port
* @param opposite - <zh/> | <en/> Opposite Point or Node
* // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
* @returns <zh/> | <en/> Port Point
*/
export declare function getPortConnectionPoint(port: Port, opposite: Node | Port): Point;
/**
* <zh/>
*
* <en/> Get the Node Connection Point
* @param nodeLike - <zh/> | <en/> Node or Combo
* @param opposite - <zh/> | <en/> Opposite Point or Node
* // @param oppositePort - <zh/> 对端连接桩 | <en/> Opposite Port
* @returns <zh/> | <en/> Node Point
*/
export declare function getNodeConnectionPoint(nodeLike: Node | Combo, opposite: Node | Port): Point;
/**
* Get the Text style by `position`.
* @param bbox - BBox of element.
* @param placement - The position relative with element.
* @param offsetX - The offset x.
* @param offsetY - The offset y.
* @param isReverseBaseline - Whether reverse the baseline.
* @returns Partial<TextStyleProps>
*/
export declare function getTextStyleByPlacement(bbox: AABB, placement?: NodeLabelStyleProps['placement'], offsetX?: number, offsetY?: number, isReverseBaseline?: boolean): Partial<TextStyleProps>;
/**
* <zh/>
*
* <en/> Get Star Points
* @param outerR - <zh/> | <en/> outer radius
* @param innerR - <zh/> | <en/> inner radius
* @returns <zh/> | <en/> Star Points
*/
export declare function getStarPoints(outerR: number, innerR: number): Point[];
/**
* Get Star Port Point.
* @param outerR - outer radius
* @param innerR - inner radius
* @returns Port points for Star.
*/
export declare function getStarPorts(outerR: number, innerR: number): Record<string, Point>;
/**
* <zh/>
*
* <en/> Get the points of a triangle
* @param width - <zh/> | <en/> width
* @param height - <zh/> | <en/> height
* @param direction - <zh/> | <en/> The direction of the triangle
* @returns <zh/> | <en/> The points of a rectangle
*/
export declare function getTrianglePoints(width: number, height: number, direction: TriangleDirection): Point[];
/**
* <zh/>
*
* <en/> Get the Ports of Triangle.
* @param width - <zh/> | <en/> width
* @param height - <zh/> | <en/> height
* @param direction - <zh/> | <en/> The direction of the triangle
* @returns <zh/> | <en/> The Ports of Triangle
*/
export declare function getTrianglePorts(width: number, height: number, direction: TriangleDirection): Record<string, Point>;
/**
* <zh/>
*
* <en/> Get the points of a rectangle
* @param width - <zh/> | <en/> width
* @param height - <zh/> | <en/> height
* @returns <zh/> | <en/> The points of a rectangle
*/
export declare function getBoundingPoints(width: number, height: number): Point[];
/**
* Get Diamond PathArray.
* @param width - diamond width
* @param height - diamond height
* @returns The PathArray for G
*/
export declare function getDiamondPoints(width: number, height: number): Point[];
/**
* <zh/>
*
* <en/> Whether the element is visible
* @param element - <zh/> | <en/> element
* @returns <zh/> | <en/> whether the element is visible
*/
export declare function isVisible(element: DisplayObject): boolean;
/**
* <zh/>
*
* <en/> Set element attributes (optimize performance)
* @param element - <zh/> | <en/> element
* @param style - <zh/> | <en/> style
*/
export declare function setAttributes(element: BaseShape<any>, style: Partial<BaseShapeStyleProps> & Record<string, any>): void;
/**
* <zh/>
*
* <en/> Update shape style
* @param shape - <zh/> | <en/> shape
* @param style - <zh/> | <en/> style
*/
export declare function updateStyle<T extends DisplayObject>(shape: T, style: Record<string, unknown>): void;
/**
* Get Hexagon PathArray
* @param outerR - <zh/> | <en/> the radius of circumscribed circle
* @returns The PathArray for G
*/
export declare function getHexagonPoints(outerR: number): Point[];
/**
* <zh/> element controller
*
* <en/> Mark the element as to be destroyed, used to identify the element to be destroyed in the element controller
* @param element - <zh/> | <en/> element
*/
export declare function markToBeDestroyed(element: DisplayObject): void;
/**
* <zh/>
*
* <en/> Determine whether the element is to be destroyed
* @param element - <zh/> | <en/> element
* @returns <zh/> | <en/> whether the element is to be destroyed
*/
export declare function isToBeDestroyed(element: DisplayObject | unknown): any;