import type { Bounds2D } from '@math.gl/types'; import type { Graph, NodeInterface, EdgeInterface } from "../graph/graph.js"; export type GraphLayoutState = 'init' | 'start' | 'calculating' | 'done' | 'error'; export type GraphLayoutEventDetail = { bounds: Bounds2D | null; }; export type GraphLayoutProps = { onLayoutStart?: (detail?: GraphLayoutEventDetail) => void; onLayoutChange?: (detail?: GraphLayoutEventDetail) => void; onLayoutDone?: (detail?: GraphLayoutEventDetail) => void; onLayoutError?: (error?: unknown) => void; }; export declare abstract class GraphLayout { static defaultProps: Readonly>; get [Symbol.toStringTag](): string; /** Extra configuration props of the layout. */ protected props: Required; /** * Last computed layout bounds in local layout coordinates. * * Subclasses should update this value by overriding {@link _updateBounds} * so it reflects the latest geometry before layout lifecycle events fire. */ protected _bounds: Bounds2D | null; version: number; state: GraphLayoutState; /** * Constructor of GraphLayout * @param props extra configuration props of the layout */ constructor(props: PropsT, defaultProps?: Required); getProps(): PropsT; setProps(props: Partial): void; /** * Check the equality of two layouts * @param layout - The layout to be compared. * @return - True if the layout is the same as itself. */ equals(layout: GraphLayout): boolean; /** access the position of the node in the layout */ getNodePosition(node: NodeInterface): [number, number]; /** access the layout information of the edge */ getEdgePosition(edge: EdgeInterface): { type: string; sourcePosition: number[]; targetPosition: number[]; controlPoints: any[]; }; /** * Pin the node to a designated position, and the node won't move anymore * @param node Node to be locked * @param x x coordinate * @param y y coordinate */ lockNodePosition(node: NodeInterface, x: number, y: number): void; /** * Unlock the node, the node will be able to move freely. * @param {Object} node Node to be unlocked */ unlockNodePosition(node: NodeInterface): void; /** Returns the last computed layout bounds, if available. */ getBounds(): Bounds2D | null; /** virtual functions: will be implemented in the child class */ /** first time to pass the graph data into this layout */ abstract initializeGraph(graph: Graph): void; /** update the existing graph */ abstract updateGraph(graph: Graph): void; /** start the layout calculation */ abstract start(): any; /** update the layout calculation */ abstract update(): any; /** resume the layout calculation */ abstract resume(): any; /** stop the layout calculation */ abstract stop(): any; /** Hook for subclasses to update bounds prior to emitting events. */ protected _updateBounds(): void; /** * Utility for subclasses to derive layout bounds from an iterable of [x, y] positions. * @param positions Iterable of node positions. * @returns Layout bounds for the supplied positions or `null` if none are finite. */ protected _calculateBounds(positions: Iterable | null | undefined>): Bounds2D | null; /** * Attempt to coerce an arbitrary value into a finite 2D point. * @param value Candidate value that may represent a position. * @returns Finite [x, y] tuple or null if the value cannot be interpreted. */ protected _normalizePosition(value: unknown): [number, number] | null; private _isFiniteNumber; protected _updateState(state: GraphLayoutState): void; /** @fires GraphLayout#onLayoutStart */ protected _onLayoutStart: () => void; /** @fires GraphLayout#onLayoutChange */ protected _onLayoutChange: () => void; /** @fires GraphLayout#onLayoutDone */ protected _onLayoutDone: () => void; /** @fires GraphLayout#onLayoutError */ protected _onLayoutError: () => void; } //# sourceMappingURL=graph-layout.d.ts.map