@eclipse-glsp/client
Version:
A sprotty-based client for GLSP
108 lines • 6.33 kB
JavaScript
;
/********************************************************************************
* Copyright (c) 2024 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
********************************************************************************/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GLSPBezierEdgeRouter = exports.GLSPManhattanEdgeRouter = exports.GLSPPolylineEdgeRouter = exports.GLSPAbstractEdgeRouter = void 0;
const sprotty_1 = require("@eclipse-glsp/sprotty");
const inversify_1 = require("inversify");
let GLSPAbstractEdgeRouter = class GLSPAbstractEdgeRouter extends sprotty_1.AbstractEdgeRouter {
getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection) {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return sprotty_1.Point.isValid(anchor) ? anchor : refPoint;
}
cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints) {
// sometimes it might happen that the source or target has the bounds not properly set when using the feedback edge
if (ensureBounds(edge.source) && ensureBounds(edge.target)) {
super.cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints);
}
}
};
exports.GLSPAbstractEdgeRouter = GLSPAbstractEdgeRouter;
exports.GLSPAbstractEdgeRouter = GLSPAbstractEdgeRouter = __decorate([
(0, inversify_1.injectable)()
], GLSPAbstractEdgeRouter);
let GLSPPolylineEdgeRouter = class GLSPPolylineEdgeRouter extends sprotty_1.PolylineEdgeRouter {
getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection) {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return sprotty_1.Point.isValid(anchor) ? anchor : refPoint;
}
cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints) {
// sometimes it might happen that the source or target has the bounds not properly set when using the feedback edge
if (ensureBounds(edge.source) && ensureBounds(edge.target)) {
super.cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints);
}
}
};
exports.GLSPPolylineEdgeRouter = GLSPPolylineEdgeRouter;
exports.GLSPPolylineEdgeRouter = GLSPPolylineEdgeRouter = __decorate([
(0, inversify_1.injectable)()
], GLSPPolylineEdgeRouter);
let GLSPManhattanEdgeRouter = class GLSPManhattanEdgeRouter extends sprotty_1.ManhattanEdgeRouter {
getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection) {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return sprotty_1.Point.isValid(anchor) ? anchor : refPoint;
}
cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints) {
// sometimes it might happen that the source or target has the bounds not properly set when using the feedback edge
if (ensureBounds(edge.source) && ensureBounds(edge.target)) {
super.cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints);
}
}
};
exports.GLSPManhattanEdgeRouter = GLSPManhattanEdgeRouter;
exports.GLSPManhattanEdgeRouter = GLSPManhattanEdgeRouter = __decorate([
(0, inversify_1.injectable)()
], GLSPManhattanEdgeRouter);
let GLSPBezierEdgeRouter = class GLSPBezierEdgeRouter extends sprotty_1.BezierEdgeRouter {
getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection) {
// users may define all kinds of anchors and anchor computers, we want to make sure we return a valid one in any case
const anchor = super.getTranslatedAnchor(connectable, refPoint, refContainer, edge, anchorCorrection);
return sprotty_1.Point.isValid(anchor) ? anchor : refPoint;
}
cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints) {
// sometimes it might happen that the source or target has the bounds not properly set when using the feedback edge
if (ensureBounds(edge.source) && ensureBounds(edge.target)) {
super.cleanupRoutingPoints(edge, routingPoints, updateHandles, addRoutingPoints);
}
}
};
exports.GLSPBezierEdgeRouter = GLSPBezierEdgeRouter;
exports.GLSPBezierEdgeRouter = GLSPBezierEdgeRouter = __decorate([
(0, inversify_1.injectable)()
], GLSPBezierEdgeRouter);
function ensureBounds(element) {
if (!element) {
return false;
}
if (element.bounds) {
return true;
}
if (element.position && element.size) {
element.bounds = { ...element.position, ...element.size };
return true;
}
return false;
}
//# sourceMappingURL=edge-router.js.map