private static @NotNull BufferedImage doClipImage(@NotNull BufferedImage image, @NotNull Shape clip) {
    @SuppressWarnings("UndesirableClassUsage")
    BufferedImage newImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = newImage.createGraphics();
    try {
      applyQualityRenderingHints(g);
      g.setPaint(new TexturePaint(image, new Rectangle(0, 0, image.getWidth(), image.getHeight())));
      g.fill(clip);
      return newImage;
    }
    finally {
      g.dispose();
    }
  }
private static @NotNull BufferedImage doClipImage(@NotNull BufferedImage image, @NotNull Shape clip)