code: public static final Rectangle toRect(Shape a)
      {
          return a instanceof Rectangle ? (Rectangle) a : a.getBounds();
      }
docs: Converts an Shape to instance of rectangle
  
  @param a
  the shape
  @return the rectangle