Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: better identify incoming and outgoing edges #128

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading