private Figure findConnectableFigure(Point2D.Double p, Drawing drawing) {
   for (Figure f : drawing.getFiguresFrontToBack()) {
     if (!f.includes(getOwner()) && f.canConnect() && f.contains(p)) {
       return f;
     }
   }
   return null;
 }
  private Connector findConnectionTarget(Point2D.Double p, Drawing drawing) {
    Figure targetFigure = findConnectableFigure(p, drawing);

    if (getSource() == null && targetFigure != null) {
      return findConnector(p, targetFigure, getOwner());
    } else if (targetFigure != null) {
      Connector target = findConnector(p, targetFigure, getOwner());
      if ((targetFigure != null)
          && targetFigure.canConnect()
          && targetFigure != savedTarget
          && !targetFigure.includes(getOwner())
          && (canConnect(getSource(), target)
              || getTarget() != null && getTarget().getOwner() == targetFigure)) {
        return target;
      }
    }
    return null;
  }