public static BufferedImage rotate(BufferedImage var0, double var1, int var3, int var4) {
        int var5 = var0.getWidth(null);
        int var6 = var0.getHeight(null);
        int var10 = 0;
        int var9 = 0;
        int var8 = 0;
        int var7 = 0;
        int[] var11 = new int[]{0, 0, var5, 0, var5, var6, 0, var6};
        double var12 = Math.toRadians(var1);

        for (int var14 = 0; var14 < var11.length; var14 += 2) {
            int var15 = (int) (Math.cos(var12) * (double) (var11[var14] - var3) -
                    Math.sin(var12) * (double) (var11[var14 + 1] - var4) + (double) var3);
            int var16 = (int) (Math.sin(var12) * (double) (var11[var14] - var3) +
                    Math.cos(var12) * (double) (var11[var14 + 1] - var4) + (double) var4);
            if (var15 > var9) {
                var9 = var15;
            }

            if (var15 < var7) {
                var7 = var15;
            }

            if (var16 > var10) {
                var10 = var16;
            }

            if (var16 < var8) {
                var8 = var16;
            }
        }

        var3 -= var7;
        var4 -= var8;
        BufferedImage var17 = new BufferedImage(var9 - var7, var10 - var8, var0.getType());
        Graphics2D var18 = var17.createGraphics();
        var18.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        var18.setBackground(Color.white);
        var18.fillRect(0, 0, var17.getWidth(), var17.getHeight());
        AffineTransform var19 = new AffineTransform();
        var19.rotate(var12, var3, var4);
        var18.setTransform(var19);
        var18.drawImage(var0, -var7, -var8, null);
        var18.dispose();
        return var17;
    }
Copied and pasted from Tess4j (https://sourceforge.net/projects/tess4j/)
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-ocr-module/src/main/java/org/apache/tika/parser/ocr/tess4j/ImageUtil.java