import { Rect } from "../../Core/Rect"; import { RegionData } from "../../Core/RegionData"; import { EventListeners } from "../../Interface/IEventDescriptor"; import { IFreezable } from "../../Interface/IFreezable"; import { IHideable } from "../../Interface/IHideadble"; import { IMovable } from "../../Interface/IMovable"; import { IPoint2D } from "../../Interface/IPoint2D"; import { IRegionCallbacks } from "../../Interface/IRegionCallbacks"; import { IResizable } from "../../Interface/IResizable"; /** * An abstract visual component to define a component of region presentation UI. */ export declare abstract class RegionComponent implements IHideable, IResizable, IMovable, IFreezable { /** * The `Snap.Element` object of the component to be used in DOM tree composition. */ node: Snap.Element; /** * The `RegionData` object describing current region state. */ regionData: RegionData; /** * Defines if the component is visible. */ isVisible: boolean; /** * Defines if the component is in a frozen state. */ isFrozen: boolean; /** * Defines if the component is selected. */ isSelected: boolean; /** * Reference to the `Snap.Paper` object to draw on. */ protected paper: Snap.Paper; /** * Reference to the size of parent host. */ protected paperRect: Rect; /** * The `x`-coordinate of the component. Defined through the `regionsData`. */ get x(): number; /** * The `y`-coordinate of the component. Defined through the `regionsData`. */ get y(): number; /** * The `width` of the component. Defined through the `regionsData`. */ get width(): number; /** * The `height` of the component. Defined through the `regionsData`. */ get height(): number; /** * The `area` of the component. Defined through the `regionsData`. */ get area(): number; /** * The `boundRect` of the component. Defined through the `regionsData`. * @remarks Returns the `Rect` object of the same `width` and `height` as the component. */ get boundRect(): Rect; /** * Reference to external callbacks collection. */ protected callbacks: IRegionCallbacks; /** * Creates a new UI component (part of the region). * @param paper - The `Snap.Paper` object to draw on. * @param paperRect - The parent bounding box for created component. * @param regionData - The `RegionData` object shared across components. Used also for initial setup. * @param callbacks - The external callbacks collection. */ constructor(paper: Snap.Paper, paperRect: Rect, regionData: RegionData, callbacks?: IRegionCallbacks); /** * Switches the component presentation to the hidden state. */ hide(): void; /** * Switches the component presentation to the visible state. */ show(): void; /** * Selects the component. */ select(): void; /** * Unselects the component. */ unselect(): void; /** * Switches the component to the frozen state. */ freeze(): void; /** * Switches the component to the unfrozen state. */ unfreeze(): void; /** * Moves the component to specified location * @param point - The new component location. */ move(point: IPoint2D): void; /** * Moves the component to specified `x` and `y` coordinates. * @param x - The new `x`-coordinate. * @param y - The new `y`-coordinate. */ move(x: number, y: number): void; /** * Redraws the visual of the component. Should be redefined in child classes. */ abstract redraw(): void; /** * Resizes the component to specified `width` and `height`. * @param width - The new `width` for the component. * @param height - The new `height` for the component. */ resize(width: number, height: number): void; /** * Resizes the bounding box for the component. * @param width - The new `width` of the bounding box. * @param height - The new `height` of the bounding box. */ resizePaper(width: number, height: number): void; /** * Subscribes the component elements according to provided event descriptors. Binds to the `this` object. * @param listeners - The collection of event descriptors. */ protected subscribeToEvents(listeners: EventListeners): void; /** * A helper function to make event listeners frozen if the component state is frozen. * @param f - Function to wrap. * @param bypass - A flag whether event should bypass. */ protected makeFreezable(f: (args: PointerEvent | KeyboardEvent) => void, bypass?: boolean): (args: PointerEvent | KeyboardEvent) => void; }