@eclipse-glsp/client
Version:
A sprotty-based client for GLSP
80 lines • 3.78 kB
TypeScript
/********************************************************************************
* Copyright (c) 2019-2025 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { Bounds, Dimension, GChildElement, GModelElement, GModelRoot, Point, Viewport } from '@eclipse-glsp/sprotty';
import { BoundsAwareModelElement } from './gmodel-util';
/**
* Return the position corresponding to this mouse event (Browser coordinates)
* in the diagram coordinates system (i.e. relative to the Diagram's 0;0 point)
*
* This functions takes into account the following transformations:
* - Location of the Diagram Canvas inside of the browser's page
* - Current viewport Scroll and Zoom
*
* @param target
* An element from the diagram
* @param mouseEvent
* A mouseEvent
*/
export declare function getAbsolutePosition(target: GModelElement, mouseEvent: MouseEvent): Point;
export declare function getAbsolutePositionByPoint(target: GModelElement, point: Point): Point;
export declare function getViewportBounds(target: GModelElement, bounds: Bounds): Bounds;
/**
* Translates the bounds of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsoluteBounds(element: BoundsAwareModelElement): Bounds;
/**
* Translates the position of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsolutePosition(target: BoundsAwareModelElement): Point;
/**
* Translates the size of the diagram element (local coordinates) into the diagram coordinates system
* (i.e. relative to the Diagram's 0;0 point)
*
* @param target A bounds-aware element from the diagram
*/
export declare function toAbsoluteSize(target: BoundsAwareModelElement): Dimension;
/**
* Convert a point, specified in absolute coordinates, to a point relative
* to the parent of the specified child element.
*
* @param element the child element
* @param absolutePoint a point in absolute coordinates
* @returns the equivalent point, relative to the element's parent coordinates
*/
export declare function absoluteToParent(element: BoundsAwareModelElement & GChildElement, absolutePoint: Point): Point;
/**
* Convert a point, specified in absolute coordinates, to a point relative
* to the specified element.
*
* @param element the element
* @param absolutePoint a point in absolute coordinates
* @returns the equivalent point, relative to the element's coordinates
*/
export declare function absoluteToLocal(element: BoundsAwareModelElement, absolutePoint: Point): Point;
/**
* Returns `true` if `point` is outside of the `viewport`.
* @param point The point to check.
* @param viewport The viewport.
* @returns `true` if `point` is outside, `false` otherwise.
*/
export declare function outsideOfViewport(point: Point, viewport: GModelRoot & Viewport): boolean;
//# sourceMappingURL=viewpoint-util.d.ts.map