public void onDragEnd(DragEndEvent event) {
Widget widget = event.getContext().draggable;
if (event.getContext().vetoException != null) {
if (event.getContext().draggable instanceof Shape) {
Shape draggable = (Shape) event.getContext().draggable;
draggable.updateConnectors();
}
}
if (widget instanceof Shape) {
Shape shape = (Shape) event.getContext().draggable;
if (!ctrlPressed) {
fixShapePosition(shape);
for (ConnectionPoint cp : shape.connectionPoints) {
for (EndPoint ep : cp.gluedEndPoints) {
// connector between two dragged shapes
if (ep.connector.startEndPoint.gluedConnectionPoint != null
&& ep.connector.endEndPoint.gluedConnectionPoint != null
&& ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget() != null
&& ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget() != null
&& selectedWidgets.contains(ep.connector.startEndPoint.gluedConnectionPoint.getParentWidget())
&& selectedWidgets.contains(ep.connector.endEndPoint.gluedConnectionPoint.getParentWidget())) {
ep.connector.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
} else {
ep.connector.updateCornerPoints();
}
}
}
fixLineSections(shape);
} else {
fixShapePosition(shape);
for (Connector c : shape.getConnectedConnectors()) {
if (c.startEndPoint.gluedConnectionPoint != null && c.endEndPoint.gluedConnectionPoint != null
&& c.startEndPoint.gluedConnectionPoint.getParentWidget() != null
&& c.endEndPoint.gluedConnectionPoint.getParentWidget() != null
&& selectedWidgets.contains(c.startEndPoint.gluedConnectionPoint.getParentWidget())
&& selectedWidgets.contains(c.endEndPoint.gluedConnectionPoint.getParentWidget())) {
c.moveOffsetFromStartPos(shape.getTranslationX(), shape.getTranslationY());
} else {
c.fixEndSectionDirection(c.endEndPoint);
c.fixEndSectionDirection(c.startEndPoint);
c.fixLineSections(c.getCorners());
c.drawSections();