if (DI_CIRCLES.contains(sourceRefStencilId)) {
Circle2D eventCircle = new Circle2D(sourceInfo.getX() + sourceDockersX,
sourceInfo.getY() + sourceDockersY, sourceDockersX);
Collection<Point2D> intersections = eventCircle.intersections(firstLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
} else if (DI_RECTANGLES.contains(sourceRefStencilId)) {
Polyline2D rectangle = createRectangle(sourceInfo);
Collection<Point2D> intersections = rectangle.intersections(firstLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
} else if (DI_GATEWAY.contains(sourceRefStencilId)) {
Polyline2D gatewayRectangle = createGateway(sourceInfo);
Collection<Point2D> intersections = gatewayRectangle.intersections(firstLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
}
Line2D lastLine = null;
if (dockersNode.size() > 2) {
for(int i = 1; i < dockersNode.size() - 1; i++) {
double x = dockersNode.get(i).get(EDITOR_BOUNDS_X).getDoubleValue();
double y = dockersNode.get(i).get(EDITOR_BOUNDS_Y).getDoubleValue();
graphicInfoList.add(createGraphicInfo(x, y));
}
double startLastLineX = dockersNode.get(dockersNode.size() - 2).get(EDITOR_BOUNDS_X).getDoubleValue();
double startLastLineY = dockersNode.get(dockersNode.size() - 2).get(EDITOR_BOUNDS_Y).getDoubleValue();
double endLastLineX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).getDoubleValue();
double endLastLineY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).getDoubleValue();
endLastLineX += targetInfo.getX();
endLastLineY += targetInfo.getY();
lastLine = new Line2D(startLastLineX, startLastLineY, endLastLineX, endLastLineY);
} else {
lastLine = firstLine;
}
if (DI_RECTANGLES.contains(targetRefStencilId)) {
Polyline2D rectangle = createRectangle(targetInfo);
Collection<Point2D> intersections = rectangle.intersections(lastLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
} else if (DI_CIRCLES.contains(targetRefStencilId)) {
double targetDockersX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).getDoubleValue();
double targetDockersY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).getDoubleValue();
Circle2D eventCircle = new Circle2D(targetInfo.getX() + targetDockersX,
targetInfo.getY() + targetDockersY, targetDockersX);
Collection<Point2D> intersections = eventCircle.intersections(lastLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
} else if (DI_GATEWAY.contains(targetRefStencilId)) {
Polyline2D gatewayRectangle = createGateway(targetInfo);
Collection<Point2D> intersections = gatewayRectangle.intersections(lastLine);
Point2D intersection = intersections.iterator().next();
graphicInfoList.add(createGraphicInfo(intersection.getX(), intersection.getY()));
}
BPMNEdge eggeTemp=BpmnDiFactory.eINSTANCE.createBPMNEdge();
eggeTemp.getWaypoint().addAll(graphicInfoList);
eggeTemp.setId(edgeId);