private BufferedImage createPopupContent(Rectangle bounds, Consumer<Graphics2D> painter, Shape clip) {
    // We paint to an 'opaque' image type (RGB, not ARGB) initially to support subpixel-antialiased text
    BufferedImage img = UIUtil.createImage(myComponent, bounds.width, bounds.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    painter.accept(g);
    g.dispose();
    if (clip == null) {
      return img;
    }
    else {
      BufferedImage clippedImg = UIUtil.createImage(myComponent, bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
      Graphics2D g2 = clippedImg.createGraphics();
      g2.clip(clip);
      UIUtil.drawImage(g2, img, 0, 0, null);
      g2.dispose();
      return clippedImg;
    }
  }
private BufferedImage createPopupContent(Rectangle bounds, Consumer<Graphics2D> painter, Shape clip)