Skip to content

Commit

Permalink
refactor(svg waypoints): use polyline instead of multi lines (#77)
Browse files Browse the repository at this point in the history
We now support any number of waypoints instead of only 3 as before.
  • Loading branch information
tbouffard authored Jun 3, 2021
1 parent 4a4d130 commit 623a688
Showing 1 changed file with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import io.process.analytics.tools.bpmn.generator.model.ShapeType;
import lombok.extern.log4j.Log4j2;

import java.util.stream.Collectors;

@Log4j2
public class SVGExporter {

Expand Down Expand Up @@ -142,33 +144,18 @@ else if (flowNode.type == ShapeType.GATEWAY) {
}

for (DisplayEdge edge : model.edges) {
// TODO manage couples in a generic way or build svg path instead of line (remove duplication)
if (edge.wayPoints.size() >= 2) {
DisplayPoint start = edge.wayPoints.get(0);
DisplayPoint end = edge.wayPoints.get(1);
content.append("<line")
.append(" x1=\"").append(start.x).append("\"")
.append(" y1=\"").append(start.y).append("\"")
.append(" x2=\"").append(end.x).append("\"")
.append(" y2=\"").append(end.y).append("\"")
String points = edge.wayPoints.stream()
.map(point -> point.x + "," + point.y)
.collect(Collectors.joining(" "));

content.append("<polyline")
.append(" points=\"").append(points).append("\"")
.append(" stroke=\"").append(colorEgeStroke).append("\"")
.append(" stroke-width=\"").append(edgeStrokeWidth).append("\"")
.append(" stroke-opacity=\"").append(edgeStrokeOpacity).append("\"")
.append(" fill=\"none\"")
.append(" />\n");

if (edge.wayPoints.size() >= 3) {
start = end;
end = edge.wayPoints.get(2);
content.append("<line")
.append(" x1=\"").append(start.x).append("\"")
.append(" y1=\"").append(start.y).append("\"")
.append(" x2=\"").append(end.x).append("\"")
.append(" y2=\"").append(end.y).append("\"")
.append(" stroke=\"").append(colorEgeStroke).append("\"")
.append(" stroke-width=\"").append(edgeStrokeWidth).append("\"")
.append(" stroke-opacity=\"").append(edgeStrokeOpacity).append("\"")
.append(" />\n");
}
}
}

Expand Down

0 comments on commit 623a688

Please sign in to comment.