Skip to content

Commit

Permalink
feat: better identify incoming and outgoing edges (#128)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tbouffard authored Aug 23, 2024
1 parent 4fb732e commit be34c5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -139,13 +142,15 @@ private List<DisplayPoint> 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<DisplayPoint> 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;
Expand Down

0 comments on commit be34c5a

Please sign in to comment.