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.

167 lines
7.3 KiB

4 months ago
import type { DisplayObject, DisplayObjectConfig, Group, PathStyleProps } from '@antv/g';
import { Path } from '@antv/g';
import type { PathArray } from '@antv/util';
import type { Edge, EdgeArrowStyleProps, EdgeBadgeStyleProps, EdgeLabelStyleProps, ID, Keyframe, LoopStyleProps, Node, Point, Prefix } from '../../types';
import { BaseElement } from '../base-element';
import type { BadgeStyleProps, BaseShapeStyleProps, LabelStyleProps } from '../shapes';
/**
* <zh/>
*
* <en/> Base style properties of the edge
*/
export interface BaseEdgeStyleProps extends BaseShapeStyleProps, Prefix<'label', EdgeLabelStyleProps>, Prefix<'halo', PathStyleProps>, Prefix<'badge', EdgeBadgeStyleProps>, Prefix<'startArrow', EdgeArrowStyleProps>, Prefix<'endArrow', EdgeArrowStyleProps>, Prefix<'loop', LoopStyleProps> {
/**
* <zh/>
*
* <en/> Whether to display the label of the edge
* @defaultValue true
*/
label?: boolean;
/**
* <zh/>
*
* <en/> Whether to enable self-loop edge
* @defaultValue true
*/
loop?: boolean;
/**
* <zh/>
*
* <en/> Whether to display the halo of the edge
* @defaultValue false
*/
halo?: boolean;
/**
* <zh/>
*
* <en/> Whether to display the badge of the edge
* @defaultValue true
*/
badge?: boolean;
/**
* <zh/>
*
* <en/> Whether to display the start arrow of the edge
* @defaultValue false
*/
startArrow?: boolean;
/**
* <zh/>
*
* <en/> Whether to display the end arrow of the edge
* @defaultValue false
*/
endArrow?: boolean;
/**
* <zh/>
*
* <en/> Offset of the start arrow
*/
startArrowOffset?: number;
/**
* <zh/>
*
* <en/> Offset of the end arrow
*/
endArrowOffset?: number;
/**
* <zh/> ID
*
* <en/> The ID of the source node
* @remarks
* <zh/> G6 `sourceNode` `source` `sourceNode` G6 Combo Combo `sourceNode` Combo ID
*
* <en/> This property concerning the physical origin, maintained internally by G6. In general, `sourceNode` corresponds to the `source` attribute of the parent level. However, in certain cases, such as when a Combo is collapsed and internal nodes are destroyed, corresponding edges will automatically connect to the parent Combo. At this point, `sourceNode` will be changed to the ID of the parent Combo
*/
sourceNode: ID;
/**
* <zh/> shape
*
* <en/> The source shape. Represents the start of the edge
*/
targetNode: ID;
/**
* <zh/> port
*
* <en/> The Port of the source node
*/
sourcePort?: string;
/**
* <zh/> port
*
* <en/> The Port of the target node
*/
targetPort?: string;
/**
* <zh/>
*
* <en/> Add a marker at the "start point", where the "start point" is the intersection of the edge and the source node
*/
markerStart?: DisplayObject | null;
/**
* <zh/>
*
* <en/> Adjust the position of the marker at the "start point", positive offset inward, negative offset outward
* @defaultValue 0
*/
markerStartOffset?: number;
/**
* <zh/>
*
* <en/> Add a marker at the "end point", where the "end point" is the intersection of the edge and the target node
*/
markerEnd?: DisplayObject | null;
/**
* <zh/>
*
* <en/> Adjust the position of the marker at the "end point", positive offset inward, negative offset outward
* @defaultValue 0
*/
markerEndOffset?: number;
/**
* <zh/> C 线
*
* <en/> Place a marker on each vertex of the path except for the "start point" and "end point". In the internal implementation, because we will convert some commands in the path to C commands, these controlPoints are actually the control points of the cubic Bezier curve
*/
markerMid?: DisplayObject | null;
/**
* <zh/> 3D 线
*
* <en/> Effective in 3D scenes, always facing the screen, so the line width is not affected by the perspective projection image
* @defaultValue true
*/
isBillboard?: boolean;
}
type ParsedBaseEdgeStyleProps = Required<BaseEdgeStyleProps>;
/**
* <zh/>
*
* <en/> Base class of the edge
*/
export declare abstract class BaseEdge extends BaseElement<BaseEdgeStyleProps> implements Edge {
type: string;
static defaultStyleProps: Partial<BaseEdgeStyleProps>;
constructor(options: DisplayObjectConfig<BaseEdgeStyleProps>);
protected get sourceNode(): Node;
protected get targetNode(): Node;
protected getKeyStyle(attributes: ParsedBaseEdgeStyleProps): PathStyleProps;
protected abstract getKeyPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
protected getLoopPath(attributes: ParsedBaseEdgeStyleProps): PathArray;
protected getEndpoints(attributes: ParsedBaseEdgeStyleProps, optimize?: boolean, controlPoints?: Point[] | (() => Point[])): [Point, Point];
protected getHaloStyle(attributes: ParsedBaseEdgeStyleProps): false | PathStyleProps;
protected getLabelStyle(attributes: ParsedBaseEdgeStyleProps): false | LabelStyleProps;
protected getBadgeStyle(attributes: ParsedBaseEdgeStyleProps): false | BadgeStyleProps;
protected drawArrow(attributes: ParsedBaseEdgeStyleProps, type: 'start' | 'end'): void;
private getArrowStyle;
protected drawLabelShape(attributes: ParsedBaseEdgeStyleProps, container: Group): void;
protected drawHaloShape(attributes: ParsedBaseEdgeStyleProps, container: Group): void;
protected drawBadgeShape(attributes: ParsedBaseEdgeStyleProps, container: Group): void;
protected drawSourceArrow(attributes: ParsedBaseEdgeStyleProps): void;
protected drawTargetArrow(attributes: ParsedBaseEdgeStyleProps): void;
protected drawKeyShape(attributes: ParsedBaseEdgeStyleProps, container: Group): Path | undefined;
render(attributes?: Required<BaseEdgeStyleProps>, container?: Group): void;
protected onframe(): void;
animate(keyframes: Keyframe[], options?: number | KeyframeAnimationOptions): import("@antv/g").IAnimation | null;
}
export {};