import { Basecoat, Model, Collection, Cell, Node, Edge, Registry as CoreRegistry, Renderer as ViewRenderer } from '@antv/x6-core'; import { NumberExt, Dom, KeyValue } from '@antv/x6-common'; import { Point, Rectangle } from '@antv/x6-geometry'; import * as Registry from '../registry'; import { Base } from './base'; import { GraphView } from './view'; import { EventArgs } from './events'; import { CSSManager as Css } from './css'; import { Options as GraphOptions } from './options'; import { DefsManager as Defs } from './defs'; import { GridManager as Grid } from './grid'; import { CoordManager as Coord } from './coord'; import { TransformManager as Transform } from './transform'; import { BackgroundManager as Background } from './background'; import { PanningManager as Panning } from './panning'; import { MouseWheel as Wheel } from './mousewheel'; import { VirtualRenderManager as VirtualRender } from './virtual-render'; export declare class Graph extends Basecoat { readonly options: GraphOptions.Definition; readonly css: Css; readonly view: GraphView; readonly defs: Defs; readonly coord: Coord; readonly transform: Transform; readonly grid: Grid; readonly background: Background; readonly panning: Panning; readonly mousewheel: Wheel; readonly renderer: ViewRenderer; readonly virtualRender: VirtualRender; get container(): HTMLElement; protected get [Symbol.toStringTag](): string; constructor(options: Partial); get model(): Model; isNode(cell: Cell): cell is Node; isEdge(cell: Cell): cell is Edge; resetCells(cells: Cell[], options?: Collection.SetOptions): this; clearCells(options?: Cell.SetOptions): this; toJSON(options?: Model.ToJSONOptions): { cells: Cell.Properties[]; }; parseJSON(data: Model.FromJSONData): (Node | Edge)[]; fromJSON(data: Model.FromJSONData, options?: Model.FromJSONOptions): this; getCellById(id: string): Cell; addNode(metadata: Node.Metadata, options?: Model.AddOptions): Node; addNode(node: Node, options?: Model.AddOptions): Node; addNodes(nodes: (Node | Node.Metadata)[], options?: Model.AddOptions): this; createNode(metadata: Node.Metadata): Node; removeNode(nodeId: string, options?: Collection.RemoveOptions): Node | null; removeNode(node: Node, options?: Collection.RemoveOptions): Node | null; addEdge(metadata: Edge.Metadata, options?: Model.AddOptions): Edge; addEdge(edge: Edge, options?: Model.AddOptions): Edge; addEdges(edges: (Edge | Edge.Metadata)[], options?: Model.AddOptions): this; removeEdge(edgeId: string, options?: Collection.RemoveOptions): Edge | null; removeEdge(edge: Edge, options?: Collection.RemoveOptions): Edge | null; createEdge(metadata: Edge.Metadata): Edge; addCell(cell: Cell | Cell[], options?: Model.AddOptions): this; removeCell(cellId: string, options?: Collection.RemoveOptions): Cell | null; removeCell(cell: Cell, options?: Collection.RemoveOptions): Cell | null; removeCells(cells: (Cell | string)[], options?: Cell.RemoveOptions): (Cell | null)[]; removeConnectedEdges(cell: Cell | string, options?: Cell.RemoveOptions): Edge[]; disconnectConnectedEdges(cell: Cell | string, options?: Edge.SetOptions): this; hasCell(cellId: string): boolean; hasCell(cell: Cell): boolean; getCells(): Cell[]; getCellCount(): number; /** * Returns all the nodes in the graph. */ getNodes(): Node[]; /** * Returns all the edges in the graph. */ getEdges(): Edge[]; /** * Returns all outgoing edges for the node. */ getOutgoingEdges(cell: Cell | string): Edge[] | null; /** * Returns all incoming edges for the node. */ getIncomingEdges(cell: Cell | string): Edge[] | null; /** * Returns edges connected with cell. */ getConnectedEdges(cell: Cell | string, options?: Model.GetConnectedEdgesOptions): Edge[]; /** * Returns an array of all the roots of the graph. */ getRootNodes(): Node[]; /** * Returns an array of all the leafs of the graph. */ getLeafNodes(): Node[]; /** * Returns `true` if the node is a root node, i.e. * there is no edges coming to the node. */ isRootNode(cell: Cell | string): boolean; /** * Returns `true` if the node is a leaf node, i.e. * there is no edges going out from the node. */ isLeafNode(cell: Cell | string): boolean; /** * Returns all the neighbors of node in the graph. Neighbors are all * the nodes connected to node via either incoming or outgoing edge. */ getNeighbors(cell: Cell, options?: Model.GetNeighborsOptions): Cell[]; /** * Returns `true` if `cell2` is a neighbor of `cell1`. */ isNeighbor(cell1: Cell, cell2: Cell, options?: Model.GetNeighborsOptions): boolean; getSuccessors(cell: Cell, options?: Model.GetPredecessorsOptions): Cell[]; /** * Returns `true` if `cell2` is a successor of `cell1`. */ isSuccessor(cell1: Cell, cell2: Cell, options?: Model.GetPredecessorsOptions): boolean; getPredecessors(cell: Cell, options?: Model.GetPredecessorsOptions): Cell[]; /** * Returns `true` if `cell2` is a predecessor of `cell1`. */ isPredecessor(cell1: Cell, cell2: Cell, options?: Model.GetPredecessorsOptions): boolean; getCommonAncestor(...cells: (Cell | null | undefined)[]): Cell | null; /** * Returns an array of cells that result from finding nodes/edges that * are connected to any of the cells in the cells array. This function * loops over cells and if the current cell is a edge, it collects its * source/target nodes; if it is an node, it collects its incoming and * outgoing edges if both the edge terminal (source/target) are in the * cells array. */ getSubGraph(cells: Cell[], options?: Model.GetSubgraphOptions): Cell[]; /** * Clones the whole subgraph (including all the connected links whose * source/target is in the subgraph). If `options.deep` is `true`, also * take into account all the embedded cells of all the subgraph cells. * * Returns a map of the form: { [original cell ID]: [clone] }. */ cloneSubGraph(cells: Cell[], options?: Model.GetSubgraphOptions): KeyValue>; cloneCells(cells: Cell[]): KeyValue>; /** * Returns an array of nodes whose bounding box contains point. * Note that there can be more then one node as nodes might overlap. */ getNodesFromPoint(x: number, y: number): Node[]; getNodesFromPoint(p: Point.PointLike): Node[]; /** * Returns an array of nodes whose bounding box top/left coordinate * falls into the rectangle. */ getNodesInArea(x: number, y: number, w: number, h: number, options?: Model.GetCellsInAreaOptions): Node[]; getNodesInArea(rect: Rectangle.RectangleLike, options?: Model.GetCellsInAreaOptions): Node[]; getNodesUnderNode(node: Node, options?: { by?: 'bbox' | Rectangle.KeyPoint; }): Node[]; searchCell(cell: Cell, iterator: Model.SearchIterator, options?: Model.SearchOptions): this; /** * * Returns an array of IDs of nodes on the shortest * path between source and target. */ getShortestPath(source: Cell | string, target: Cell | string, options?: Model.GetShortestPathOptions): string[]; /** * Returns the bounding box that surrounds all cells in the graph. */ getAllCellsBBox(): Rectangle | null; /** * Returns the bounding box that surrounds all the given cells. */ getCellsBBox(cells: Cell[], options?: Cell.GetCellsBBoxOptions): Rectangle | null; startBatch(name: string | Model.BatchName, data?: KeyValue): void; stopBatch(name: string | Model.BatchName, data?: KeyValue): void; batchUpdate(execute: () => T, data?: KeyValue): T; batchUpdate(name: string | Model.BatchName, execute: () => T, data?: KeyValue): T; updateCellId(cell: Cell, newId: string): Cell; /** * Returns the current transformation matrix of the graph. */ matrix(): DOMMatrix; /** * Sets new transformation with the given `matrix` */ matrix(mat: DOMMatrix | Dom.MatrixLike | null): this; resize(width?: number, height?: number): this; scale(): Dom.Scale; scale(sx: number, sy?: number, cx?: number, cy?: number): this; zoom(): number; zoom(factor: number, options?: Transform.ZoomOptions): this; zoomTo(factor: number, options?: Omit): this; zoomToRect(rect: Rectangle.RectangleLike, options?: Transform.ScaleContentToFitOptions & Transform.ScaleContentToFitOptions): this; zoomToFit(options?: Transform.GetContentAreaOptions & Transform.ScaleContentToFitOptions): this; rotate(): Dom.Rotation; rotate(angle: number, cx?: number, cy?: number): this; translate(): Dom.Translation; translate(tx: number, ty: number): this; translateBy(dx: number, dy: number): this; getGraphArea(): Rectangle; getContentArea(options?: Transform.GetContentAreaOptions): Rectangle; getContentBBox(options?: Transform.GetContentAreaOptions): Rectangle; fitToContent(gridWidth?: number, gridHeight?: number, padding?: NumberExt.SideOptions, options?: Transform.FitToContentOptions): Rectangle; fitToContent(options?: Transform.FitToContentFullOptions): Rectangle; scaleContentToFit(options?: Transform.ScaleContentToFitOptions): this; centerCell(cell: Cell): this; positionPoint(point: Point.PointLike, x: number | string, y: number | string): this; snapToGrid(p: Point.PointLike): Point; snapToGrid(x: number, y: number): Point; pageToLocal(rect: Rectangle.RectangleLike): Rectangle; pageToLocal(x: number, y: number, width: number, height: number): Rectangle; pageToLocal(p: Point.PointLike): Point; pageToLocal(x: number, y: number): Point; localToPage(rect: Rectangle.RectangleLike): Rectangle; localToPage(x: number, y: number, width: number, height: number): Rectangle; localToPage(p: Point.PointLike): Point; localToPage(x: number, y: number): Point; clientToLocal(rect: Rectangle.RectangleLike): Rectangle; clientToLocal(x: number, y: number, width: number, height: number): Rectangle; clientToLocal(p: Point.PointLike): Point; clientToLocal(x: number, y: number): Point; localToClient(rect: Rectangle.RectangleLike): Rectangle; localToClient(x: number, y: number, width: number, height: number): Rectangle; localToClient(p: Point.PointLike): Point; localToClient(x: number, y: number): Point; /** * Transform the rectangle `rect` defined in the local coordinate system to * the graph coordinate system. */ localToGraph(rect: Rectangle.RectangleLike): Rectangle; /** * Transform the rectangle `x`, `y`, `width`, `height` defined in the local * coordinate system to the graph coordinate system. */ localToGraph(x: number, y: number, width: number, height: number): Rectangle; /** * Transform the point `p` defined in the local coordinate system to * the graph coordinate system. */ localToGraph(p: Point.PointLike): Point; /** * Transform the point `x`, `y` defined in the local coordinate system to * the graph coordinate system. */ localToGraph(x: number, y: number): Point; graphToLocal(rect: Rectangle.RectangleLike): Rectangle; graphToLocal(x: number, y: number, width: number, height: number): Rectangle; graphToLocal(p: Point.PointLike): Point; graphToLocal(x: number, y: number): Point; clientToGraph(rect: Rectangle.RectangleLike): Rectangle; clientToGraph(x: number, y: number, width: number, height: number): Rectangle; clientToGraph(p: Point.PointLike): Point; clientToGraph(x: number, y: number): Point; defineFilter(options: Defs.FilterOptions): string; defineGradient(options: Defs.GradientOptions): string; defineMarker(options: Defs.MarkerOptions): string; getGridSize(): number; setGridSize(gridSize: number): this; showGrid(): this; hideGrid(): this; clearGrid(): this; drawGrid(options?: Grid.DrawGridOptions): this; updateBackground(): this; drawBackground(options?: Background.Options): this; clearBackground(): this; dispose(): void; } export declare namespace Graph { export import View = GraphView; export import Renderer = ViewRenderer; export import CssManager = Css; export import BaseManager = Base; export import DefsManager = Defs; export import GridManager = Grid; export import CoordManager = Coord; export import TransformManager = Transform; export import BackgroundManager = Background; export import PanningManager = Panning; export import MouseWheel = Wheel; } export declare namespace Graph { interface Options extends GraphOptions.Manual { } } export declare namespace Graph { const toStringTag: string; function isGraph(instance: any): instance is Graph; } export declare namespace Graph { function render(options: Partial, data?: Model.FromJSONData): Graph; function render(container: HTMLElement, data?: Model.FromJSONData): Graph; } export declare namespace Graph { const registerNode: { (entities: { [name: string]: Node.Definition | (Node.Config & { inherit?: string | Node.Definition | undefined; }); }, force?: boolean | undefined): void; (name: K, entity: never[K], force?: boolean | undefined): Node.Definition; (name: string, entity: Node.Definition | (Node.Config & { inherit?: string | Node.Definition | undefined; }), force?: boolean | undefined): Node.Definition; }; const registerEdge: { (entities: { [name: string]: Edge.Definition | (Edge.Config & { inherit?: string | Edge.Definition | undefined; }); }, force?: boolean | undefined): void; (name: K, entity: never[K], force?: boolean | undefined): Edge.Definition; (name: string, entity: Edge.Definition | (Edge.Config & { inherit?: string | Edge.Definition | undefined; }), force?: boolean | undefined): Edge.Definition; }; const registerGrid: { (entities: { [name: string]: Registry.Grid.CommonDefinition; }, force?: boolean | undefined): void; (name: K, entity: typeof import("../registry/grid/main")[K], force?: boolean | undefined): Registry.Grid.CommonDefinition; (name: string, entity: Registry.Grid.CommonDefinition, force?: boolean | undefined): Registry.Grid.CommonDefinition; }; const registerFilter: { (entities: { [name: string]: Registry.Filter.CommonDefinition; }, force?: boolean | undefined): void; (name: K, entity: typeof import("../registry/filter/main")[K], force?: boolean | undefined): Registry.Filter.CommonDefinition; (name: string, entity: Registry.Filter.CommonDefinition, force?: boolean | undefined): Registry.Filter.CommonDefinition; }; const registerBackground: { (entities: { [name: string]: Registry.Background.Definition; }, force?: boolean | undefined): void; (name: K, entity: { [name: string]: Registry.Background.Definition; }[K], force?: boolean | undefined): Registry.Background.Definition; (name: string, entity: Registry.Background.Definition, force?: boolean | undefined): Registry.Background.Definition; }; const registerConnector: { (entities: { [name: string]: CoreRegistry.Connector.Definition; }, force?: boolean | undefined): void; (name: K, entity: typeof import("@antv/x6-core/lib/src/registry/connector/main")[K], force?: boolean | undefined): CoreRegistry.Connector.Definition; (name: string, entity: CoreRegistry.Connector.Definition, force?: boolean | undefined): CoreRegistry.Connector.Definition; }; } export declare namespace Graph { const unregisterNode: { (name: K): Node.Definition | null; (name: string): Node.Definition | null; }; const unregisterEdge: { (name: K): Edge.Definition | null; (name: string): Edge.Definition | null; }; const unregisterGrid: { (name: K): Registry.Grid.CommonDefinition | null; (name: string): Registry.Grid.CommonDefinition | null; }; const unregisterFilter: { (name: K): Registry.Filter.CommonDefinition | null; (name: string): Registry.Filter.CommonDefinition | null; }; const unregisterBackground: { (name: K): Registry.Background.Definition | null; (name: string): Registry.Background.Definition | null; }; const unregisterConnector: { (name: K): CoreRegistry.Connector.Definition | null; (name: string): CoreRegistry.Connector.Definition | null; }; }