public Rectangle computeScaledBounds(final int zoom, final Dimension size) {
        final double sDPI = dpi;
        double width = sWidth * sDPI;
        double height = sHeight * sDPI;
        switch (zoom) {
            case FIT_WIDTH: // FIT_WIDTH
            {
                double sw = ((double) size.width) / width;
                if (favorFast && (sw < 1.0D)) {
                    sw = 1.0D / Math.ceil(1.0D / sw);
                    width *= sw;
                } else {
                    width = size.width;
                }
                height *= sw;
                break;
            }
            case FIT_PAGE: // FIT_PAGE
            {
                final double sw = (double) size.width / (double) width;
                final double sh = (double) size.height / (double) height;
                double s = (sw < sh) ? sw : sh;
                if (favorFast && (s < 1.0D)) {
                    s = 1.0D / Math.ceil(1.0D / s);
                }
                width *= s;
                height *= s;
                break;
            }
            case 0: {
                break;
            }
            default: // regular scaling
            {
                final double s = ((double) ((zoom < 1) ? 1 : zoom)) / sDPI;
                width *= s;
                height *= s;
                break;
            }
        }
        return new Rectangle(0, 0, (int) Math.ceil(width), (int) Math.ceil(height));
    }