code: public static double getDistance(double x1, double y1, double x2, double y2, int w2, int h2)
      {
          final double maxX = x2 + w2;
          final double maxY = y2 + h2;
  
          double min = getDistance(x1, y1, x2, y2);
          for (double x = x2; Double.compare(x, maxX) <= 0; x++)
          {
              for (double y = y2; Double.compare(y, maxY) <= 0; y++)
              {
                  final double dist = getDistance(x1, y1, x, y);
                  if (dist < min)
                  {
                      min = dist;
                  }
              }
          }
          return min;
      }
docs: Get distance from point to area.
  
  @param x1 The first area x.
  @param y1 The first area y.
  @param x2 The second area x.
  @param y2 The second area y.
  @param w2 The second area width.
  @param h2 The second area height.
  @return The distance between them.