import { DisplayObject, IRenderer } from '@antv/g'; import type { RuntimeContext } from '../../runtime/types'; import type { ElementType, Padding, Placement } from '../../types'; import type { BasePluginOptions } from '../base-plugin'; import { BasePlugin } from '../base-plugin'; /** * 缩略图插件配置项 * * Minimap plugin options */ export interface MinimapOptions extends BasePluginOptions { /** * 宽度和高度 * * Width and height * @defaultValue [240, 160] */ size?: [number, number]; /** * 内边距 * * Padding * @defaultValue 10 */ padding?: Padding; /** * 缩略图相对于画布的位置 * * The position of the minimap relative to the canvas * @defaultValue 'right-bottom' */ position?: Placement; /** * 过滤器,用于过滤不必显示的元素 * * Filter, used to filter elements that do not need to be displayed * @param id - 元素的 id | The id of the element * @param elementType - 元素的类型 | The type of the element * @returns 是否显示 | Whether to display */ filter?: (id: string, elementType: ElementType) => boolean; /** * 元素缩略图形的生成方法 * * The method of generating the thumbnail of the element * @defaultValue 'key' * @remarks * * - 'key' 使用元素的主图形作为缩略图形 * - 'icon' 使用元素中心的 icon 作为缩略图形 * - 更多图形名称可查阅 https://g6.antv.antgroup.com/manual/element/node/base-node#style * - 也可以传入一个函数,接收元素的 [id, 类型, 元素节点],返回一个自定义样式的图形 * * * - 'key' uses the key shape of the element as the thumbnail shape * - 'icon' uses the icon shape of the element as the thumbnail shape * - more shape name see https://g6.antv.antgroup.com/manual/element/node/base-node#style * - You can also pass in a function that receives the [id, type of the element, element] and returns a custom shape */ shape?: string | 'key' | 'icon' | ((id: string, elementType: ElementType, element: DisplayObject) => DisplayObject); /** * 缩略图画布类名,传入外置容器时不生效 * * The class name of the minimap canvas, which does not take effect when an external container is passed in */ className?: string; /** * 缩略图挂载的容器,无则挂载到 Graph 所在容器 * * The container where the minimap is mounted, if not, it will be mounted to the container where the Graph is located */ container?: HTMLElement | string; /** * 缩略图的容器样式,传入外置容器时不生效 * * The style of the minimap container, which does not take effect when an external container is passed in */ containerStyle?: Partial; /** * 遮罩的样式 * * The style of the mask */ maskStyle?: Partial; /** * 渲染器,默认使用 Canvas 渲染器 * * Renderer, default to use Canvas renderer */ renderer?: IRenderer; /** * 延迟更新时间(毫秒),用于性能优化 * * Delay update time(ms), used for performance optimization * @defaultValue 128 */ delay?: number; } /** * 缩略图插件 * * Minimap plugin */ export declare class Minimap extends BasePlugin { static defaultOptions: Partial; private canvas; constructor(context: RuntimeContext, options: MinimapOptions); update(options: Partial): void; private setOnRender; private bindEvents; private unbindEvents; private onDraw; private onRender; /** * 创建或更新缩略图 * * Create or update the minimap */ private renderMinimap; private getElements; private setShapes; private container; private initCanvas; private landmarkMap; private createLandmark; private setCamera; private mask; private get maskBBox(); /** * 计算遮罩包围盒 * * Calculate the bounding box of the mask * @returns 遮罩包围盒 | Mask bounding box */ private calculateMaskBBox; /** * 创建或更新遮罩 * * Create or update the mask */ private renderMask; private isMaskDragging; private onMaskDragStart; private onMaskDrag; private onMaskDragEnd; private onTransform; private updateMask; destroy(): void; }