From f908283a8c66efcf71980fecdda77ded742295b8 Mon Sep 17 00:00:00 2001 From: Dennis Huebner Date: Wed, 8 Feb 2023 10:52:23 +0100 Subject: [PATCH] Move single routing point with Manhattan #310 --- .../src/features/routing/manhattan-edge-router.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/sprotty/src/features/routing/manhattan-edge-router.ts b/packages/sprotty/src/features/routing/manhattan-edge-router.ts index 0d8da9d5..80f0099a 100644 --- a/packages/sprotty/src/features/routing/manhattan-edge-router.ts +++ b/packages/sprotty/src/features/routing/manhattan-edge-router.ts @@ -118,10 +118,14 @@ export class ManhattanEdgeRouter extends AbstractEdgeRouter { switch (handle.kind) { case 'manhattan-50%': if (index < 0) { - if (almostEquals(route[0].x, route[1].x)) + if (routingPoints.length === 0) { + routingPoints.push({ x: correctedX, y: correctedY }); + handle.pointIndex = 0; + } else if (almostEquals(route[0].x, route[1].x)) { this.alignX(routingPoints, 0, correctedX); - else + } else { this.alignY(routingPoints, 0, correctedY); + } } else if (index < routingPoints.length - 1) { if (almostEquals(routingPoints[index].x, routingPoints[index + 1].x)) { this.alignX(routingPoints, index, correctedX); @@ -131,10 +135,11 @@ export class ManhattanEdgeRouter extends AbstractEdgeRouter { this.alignY(routingPoints, index + 1, correctedY); } } else { - if (almostEquals(route[route.length - 2].x, route[route.length - 1].x)) + if (almostEquals(route[route.length - 2].x, route[route.length - 1].x)) { this.alignX(routingPoints, routingPoints.length - 1, correctedX); - else + } else { this.alignY(routingPoints, routingPoints.length - 1, correctedY); + } } break; }