if (context.draggable instanceof EndPoint) {
// Glue end point to the nearest connection point
if (getDropTarget() instanceof Shape) {
Shape dropTarget = (Shape) getDropTarget();
EndPoint endPoint = (EndPoint) context.draggable;
endPoint
.glueToConnectionPoint(dropTarget.findNearestFreeConnectionPoint(endPoint.getLeft(), endPoint.getTop()));
// Unglue if EndPoints are glued to the same element
Connector conn = endPoint.connector;
if (conn.startEndPoint.isGluedToConnectionPoint() && conn.endEndPoint.isGluedToConnectionPoint()) {