From 7663e544f6d5217d70edca9c3080ef320e564b42 Mon Sep 17 00:00:00 2001 From: Thomas Bouffard <27200110+tbouffard@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:15:38 +0200 Subject: [PATCH] feat: better identify incoming and outgoing edges Previously, it was possible to have vertically incoming and vertically outgoing edges on the same shape. This made it difficult to distinguish one from the other. This usually happened on gateways. To easily identify the two edge types, only incoming edges can now be connected vertically. Outgoing edges always start with a small horizontal segment. --- .../generator/converter/Configuration.java | 2 ++ .../waypoint/WayPointsConverter.java | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/Configuration.java b/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/Configuration.java index e5268bb3..3e913ca4 100644 --- a/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/Configuration.java +++ b/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/Configuration.java @@ -16,4 +16,6 @@ public class Configuration { // TODO this should be configurable for by the client code public static final int CELL_WIDTH = 200; public static final int CELL_HEIGHT = 100; + + public static final int EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH = 20; } diff --git a/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/waypoint/WayPointsConverter.java b/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/waypoint/WayPointsConverter.java index 1005f2f1..2c4ff965 100644 --- a/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/waypoint/WayPointsConverter.java +++ b/java/src/main/java/io/process/analytics/tools/bpmn/generator/converter/waypoint/WayPointsConverter.java @@ -16,6 +16,7 @@ package io.process.analytics.tools.bpmn.generator.converter.waypoint; import static io.process.analytics.tools.bpmn.generator.converter.Configuration.CELL_HEIGHT; +import static io.process.analytics.tools.bpmn.generator.converter.Configuration.EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH; import static io.process.analytics.tools.bpmn.generator.converter.waypoint.Orientation.*; import java.util.ArrayList; @@ -64,10 +65,11 @@ else if (orientation == VerticalHorizontalVertical) { wayPoints.add(new DisplayPoint(to.x, from.y)); wayPoints.add(to); } else if (orientation == VerticalHorizontal) { - DisplayPoint from = edgeTerminalPoints.centerTop(dimensionFrom); + DisplayPoint from = edgeTerminalPoints.rightMiddle(dimensionFrom); DisplayPoint to = edgeTerminalPoints.leftMiddle(dimensionTo); wayPoints.add(from); - wayPoints.add(new DisplayPoint(from.x, to.y)); + wayPoints.add(new DisplayPoint(from.x + EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH, from.y)); + wayPoints.add(new DisplayPoint(from.x + EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH, to.y)); wayPoints.add(to); } break; @@ -94,10 +96,11 @@ else if (orientation == VerticalHorizontalVertical) { wayPoints.add(new DisplayPoint(to.x, from.y)); wayPoints.add(to); } else if (orientation == VerticalHorizontal) { - DisplayPoint from = edgeTerminalPoints.centerBottom(dimensionFrom); + DisplayPoint from = edgeTerminalPoints.rightMiddle(dimensionFrom); DisplayPoint to = edgeTerminalPoints.leftMiddle(dimensionTo); wayPoints.add(from); - wayPoints.add(new DisplayPoint(from.x, to.y)); + wayPoints.add(new DisplayPoint(from.x + EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH, from.y)); + wayPoints.add(new DisplayPoint(from.x + EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH, to.y)); wayPoints.add(to); } break; @@ -139,13 +142,15 @@ private List computeWaypointsWithBendPoint(BendConfiguration bendC DisplayDimension dimensionFrom, DisplayDimension dimensionTo) { log.debug("Bend configuration: {}", bendConfiguration); - DisplayPoint from = bendConfiguration.direction == BendDirection.BOTTOM ? edgeTerminalPoints.centerBottom(dimensionFrom): edgeTerminalPoints.centerTop(dimensionFrom); + DisplayPoint from = edgeTerminalPoints.rightMiddle(dimensionFrom); DisplayPoint to = bendConfiguration.direction == BendDirection.BOTTOM ? edgeTerminalPoints.centerBottom(dimensionTo): edgeTerminalPoints.centerTop(dimensionTo); - int bendPointY = from.y + bendConfiguration.direction.numericFactor() * bendConfiguration.offset * CELL_HEIGHT; + int bendPointY = from.y + bendConfiguration.direction.numericFactor() * ( dimensionFrom.height / 2 + bendConfiguration.offset * CELL_HEIGHT); List wayPoints = new ArrayList<>(); wayPoints.add(from); - wayPoints.add(new DisplayPoint(from.x, bendPointY)); + DisplayPoint intermediate = new DisplayPoint(from.x + EDGE_OUTGOING_FIRST_HORIZONTAL_SEGMENT_LENGTH, from.y); + wayPoints.add(intermediate); + wayPoints.add(new DisplayPoint(intermediate.x, bendPointY)); wayPoints.add(new DisplayPoint(to.x, bendPointY)); wayPoints.add(to); return wayPoints;