import { SharedSettings } from "@hylimo/diagram-protocol"; import { type Matrix } from "transformation-matrix"; import { type HandleMoveResult } from "../../move/moveHandler.js"; import type { ResizeMoveCursor } from "../../cursor/cursor.js"; import { type SnapLines } from "../../snap/model.js"; import type { SCanvasElement } from "../../../model/canvas/sCanvasElement.js"; import { SnapHandler } from "../../snap/snapHandler.js"; import type { SModelElementImpl } from "sprotty"; import { SnapMoveHandler } from "../../snap/snapMoveHandler.js"; /** * Elements with an optional original width and height. * If originalWidth is given, all elements in the group have the same original width. * If originalHeight is given, all elements in the group have the same original height. * At least one of the two must be given. */ export interface ElementsGroupedBySize { /** * The ids of the elements in the group. */ elements: string[]; /** * The original width of the elements in the group, or undefined if the elements have different widths. */ originalWidth?: number; /** * The original height of the elements in the group, or undefined if the elements have different heights. */ originalHeight?: number; } /** * A move handler that resizes the elements. * Expects relative coordinates to its own coordinate system. */ export declare class ResizeMoveHandler extends SnapMoveHandler { private readonly scaleX; private readonly scaleY; private readonly groupedElements; /** * The original width of the primary resize element, used to calculate the resize factor. */ private readonly originalWidth; /** * The original height of the primary resize element, used to calculate the resize factor. */ private readonly originalHeight; /** * Creates a new ResizeHandler. * * @param element the canvas element to resize. * @param ignoredElements the set of element IDs to ignore during operations. * @param settings the shared settings used for operations. * @param scaleX the scale factor in x direction. The resize is scaled by this to account for resize in the opposite direction. * @param scaleY the scale factor in y direction. The resize is scaled by this to account for resize in the opposite direction. * @param groupedElements the elements grouped by size. * @param snappingEnabled whether snapping is enabled. * @param transformationMatrix the transformation matrix to apply to obtain the relative position. * @param moveCursor the cursor to use while resizing. */ constructor(element: SCanvasElement, ignoredElements: Set, settings: SharedSettings | undefined, scaleX: number | undefined, scaleY: number | undefined, groupedElements: ElementsGroupedBySize[], snappingEnabled: boolean, transformationMatrix: Matrix, moveCursor: ResizeMoveCursor | undefined); handleMove(x: number, y: number, event: MouseEvent, target: SModelElementImpl): HandleMoveResult; } /** * Snap handler for resizing canvas elements */ declare class ResizeSnapHandler extends SnapHandler { private readonly scaleX; private readonly scaleY; private readonly effectiveRotation; /** * The transformation matrix to convert between element and target coordinates. */ private readonly elementToTargetMatrix; /** * The transformation matrix to convert between target and element coordinates. */ private readonly targetToElementMatrix; /** * Properties of the CanvasElement before resizing. */ private readonly current; /** * The corners of the element in the target coordinate system. */ private readonly corners; /** * The snapping options for gaps. */ private readonly gapSnapOptions; /** * Indices of the corners that are used for (point) snapping. */ private readonly snapPointIndices; /** * The relative dx value of the element (between 0 and 1). */ private readonly dxRelative; /** * The relative dy value of the element (between 0 and 1). */ private readonly dyRelative; /** * The context ID of the element being resized. */ private readonly context; /** * Creates a new ResizeMoveSnapDataComputer. * * @param element The element being resized * @param scaleX The scale factor in x direction * @param scaleY The scale factor in y direction * @param ignoredElements The elements to be ignored during snapping * @param effectiveRotation The effective rotation of the element in quaters (1 = 90 degrees etc.) * @param settings the shared settings for snap data computation */ constructor(element: SCanvasElement, scaleX: number | undefined, scaleY: number | undefined, ignoredElements: Set, effectiveRotation: number, settings: SharedSettings | undefined); /** * Calculates gap snap options based on differences between original and resized element bounds * * @param bounds The original element bounds * @param resizedBounds The resized element bounds * @returns The gap snap options configuration */ private calculateGapSnapOptions; /** * Gets the snapped factors and snap lines based on the current resize operation. * * @param zoom The current zoom level * @param factorX The x resize factor * @param factorY The y resize factor * @param uniform Whether the resize should be uniform * @returns The adjusted factors and snap lines */ snap(zoom: number, factorX: number | undefined, factorY: number | undefined, uniform: boolean): { factorX: number | undefined; factorY: number | undefined; snapLines: SnapLines | undefined; }; /** * Creates a scale matrix for resizing the element. * * @param factorX the x resize factor * @param factorY the y resize factor * @param newFactors the new resize factors * @returns a translation matrix with the rounded coordinates */ private createRoundedScale; /** * Calculates the rounded resize factors based on the input factors. * * @param inputFactors The resize factors before rounding. * @returns The rounded resize factors. */ private calculateRoundedFactors; /** * Processes snap results and calculates adjusted factors. * * @param result The snap result * @param factorX The x resize factor * @param factorY The y resize factor * @param uniform Whether the resize should be uniform * @param resizedCorners The corners of the resized element * @returns The adjusted factors and their directions */ private processSnaps; /** * Adapts factors based on snap results. * * @param result The snap result * @param factorX The x resize factor * @param factorY The y resize factor * @param resizedCorners The corners of the resized element * @param context The snap factor context to update */ private adaptFactorsBasedOnSnaps; /** * Adapts factors based on the horizontal snap result. * * @param snapX The horizontal snap data * @param result The snap result * @param factorX The x resize factor * @param factorY The y resize factor * @param resizedCorners The corners of the resized element * @param context The snap factor context to update */ private adaptFactorsBasedOnXSnap; /** * Adapts factors based on the vertical snap result. * * @param snapY The vertical snap data * @param result The snap result * @param factorX The x resize factor * @param factorY The y resize factor * @param resizedCorners The corners of the resized element * @param context The snap factor context to update */ private adaptFactorsBasedOnYSnap; /** * Calculates final factors based on context and uniform resize settings. * * @param factorX The x resize factor * @param factorY The y resize factor * @param uniform Whether the resize should be uniform * @param context The snap factor context with overrides * @returns The adjusted factors */ private calculateFinalResizeFactors; /** * Adapts factors based on snap constraints. * * @param value The original position value * @param target The target position value to snap to * @param x2 the neighboring position value in the x direction * @param cx the relative attachement point in x direction * @param y2 the neighboring position value in the y direction * @param cy the relative attachement point in y direction * @param snapDirection The snap direction (horizontal or vertical) * @param factorX The current x resize factor * @param factorY The current y resize factor * @param context The snap factor context to update * @returns true if adaptation was successful, false otherwise */ private adaptFactor; /** * Gets the target position for horizontal snapping. * * @param snapX The horizontal snap data * @returns The target x position */ private getHorizontalSnapTarget; /** * Gets the target position for vertical snapping. * * @param snapY The vertical snap data * @returns The target y position */ private getVerticalSnapTarget; } export {}; //# sourceMappingURL=resizeMoveHandler.d.ts.map