public Screen flip(int dir) {
        BufferedImage flippedImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
        Graphics2D ig = (Graphics2D) flippedImage.getGraphics();
        AffineTransform tx = null, sx = null;
        switch (dir) {
            case FLIP_HORIZONTAL:
                tx = AffineTransform.getTranslateInstance(image.getWidth(), 0);
                sx = AffineTransform.getScaleInstance(-1D, 1D);
                tx.concatenate(sx);

                ig.setTransform(tx);
                ig.drawImage(image, 0, 0, null);
                ig.dispose();

                image = flippedImage;
                break;
            case FLIP_VERTICAL:
                tx = AffineTransform.getTranslateInstance(0, image.getHeight());
                sx = AffineTransform.getScaleInstance(1D, -1D);
                tx.concatenate(sx);

                ig.setTransform(tx);
                ig.drawImage(image, 0, 0, null);
                ig.dispose();

                image = flippedImage;
                break;
            case FLIP_BOTH:
                tx = AffineTransform.getTranslateInstance(image.getWidth(), image.getHeight());
                sx = AffineTransform.getScaleInstance(-1D, -1D);
                tx.concatenate(sx);

                ig.setTransform(tx);
                ig.drawImage(image, 0, 0, null);
                ig.dispose();

                image = flippedImage;
                break;
        }
        return this;
    }