use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class ProcessPostConverter method adjustEdgeConnection.
private static void adjustEdgeConnection(BpmnEdge.Simple edge, boolean targetConnection) {
Point2D siblingPoint = null;
Connection magnetConnection;
Point2D magnetPoint;
BpmnNode connectionPointNode;
List<Point2D> controlPoints = edge.getControlPoints();
if (targetConnection) {
magnetConnection = edge.getTargetConnection();
magnetPoint = magnetConnection.getLocation();
connectionPointNode = edge.getTarget();
if (controlPoints.size() >= 1) {
siblingPoint = controlPoints.get(controlPoints.size() - 1);
}
} else {
magnetConnection = edge.getSourceConnection();
magnetPoint = magnetConnection.getLocation();
connectionPointNode = edge.getSource();
if (controlPoints.size() >= 1) {
siblingPoint = controlPoints.get(0);
}
}
if (siblingPoint != null) {
Bounds bounds = connectionPointNode.value().getContent().getBounds();
Bound nodeUl = bounds.getUpperLeft();
if (connectionPointNode.isDocked()) {
// boundary nodes coordinates are relative to the target node, so we need to de-relativize the coordinates.
BpmnNode dockedNodeTarget = findDockedNodeTarget(connectionPointNode);
if (dockedNodeTarget != null) {
double width = bounds.getWidth();
double height = bounds.getHeight();
Bounds dockedNodeTargetBounds = dockedNodeTarget.value().getContent().getBounds();
Bound dockingNodeUL = dockedNodeTargetBounds.getUpperLeft();
// translate to absolute coordinates
nodeUl = new Bound(nodeUl.getX() + dockingNodeUL.getX(), nodeUl.getY() + dockingNodeUL.getY());
Bound nodeLr = new Bound(nodeUl.getX() + width, nodeUl.getY() + height);
bounds = Bounds.create(nodeUl, nodeLr);
}
}
if (!(magnetConnection instanceof MagnetConnection && ((MagnetConnection) magnetConnection).isAuto())) {
if (equals(magnetPoint.getY(), 0, PRECISION) || equals(magnetPoint.getY(), bounds.getHeight(), PRECISION)) {
// magnet point is on top or bottom
if (siblingPoint.getY() != (magnetPoint.getY() + nodeUl.getY())) {
siblingPoint.setX(nodeUl.getX() + (bounds.getWidth() / 2));
}
} else {
// magnet point is on left or right
if (siblingPoint.getX() != (magnetPoint.getX() + nodeUl.getX())) {
siblingPoint.setY(nodeUl.getY() + (bounds.getHeight() / 2));
}
}
}
}
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class GraphBoundsIndexerImpl method getNodeAbsoluteCoordinates.
private double[] getNodeAbsoluteCoordinates(final Node node, final double parentX, final double parentY) {
final View content = (View) node.getContent();
final Bounds bounds = content.getBounds();
final Bound ulBound = bounds.getUpperLeft();
final Bound lrBound = bounds.getLowerRight();
final double ulX = ulBound.getX() + parentX;
final double ulY = ulBound.getY() + parentY;
final double lrX = lrBound.getX() + parentX;
final double lrY = lrBound.getY() + parentY;
return new double[] { ulX, ulY, lrX, lrY };
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class GraphUtils method getSize.
private static double[] getSize(Bounds bounds) {
final Bound ul = bounds.getUpperLeft();
final Bound lr = bounds.getLowerRight();
final double w = lr.getX() - ul.getX();
final double h = lr.getY() - ul.getY();
return new double[] { Math.abs(w), Math.abs(h) };
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class GraphUtils method getPosition.
public static Point2D getPosition(final View element) {
final Bound ul = element.getBounds().getUpperLeft();
final double x = ul.getX();
final double y = ul.getY();
return new Point2D(x, y);
}
use of org.kie.workbench.common.stunner.core.graph.content.Bound in project kie-wb-common by kiegroup.
the class ClientBPMNDocumentationServiceTest method createNode.
private Node createNode(Object content) {
NodeImpl node = new NodeImpl(UUID.uuid());
node.setContent(new ViewImpl<>(content, new Bounds(new Bound(0d, 0d), new Bound(1d, 1d))));
return node;
}
Aggregations