package gr.softaware.lib_1_3.io;

import org.imgscalr.Scalr;

/**
 *
 * @author siggouroglou@gmail.com
 */
public enum PhotoSizeAction {

    /**
     * Used to indicate that the scaling implementation should calculate
     * dimensions for the resultant image by looking at the image's orientation
     * and generating proportional dimensions that best fit into the target
     * width and height given
     *
     * See "Image Proportions" in the {@link Scalr} class description for more
     * detail.
     */
    AUTOMATIC(1),
    /**
     * Used to fit the image to the exact dimensions given regardless of the
     * image's proportions. If the dimensions are not proportionally correct,
     * this will introduce vertical or horizontal stretching to the image.
     * <p/>
     * It is recommended that you use one of the other <code>FIT_TO</code> modes
     * or {@link Mode#AUTOMATIC} if you want the image to look correct, but if
     * dimension-fitting is the #1 priority regardless of how it makes the image
     * look, that is what this mode is for.
     */
    FIT_EXACT(2),
    /**
     * Used to indicate that the scaling implementation should calculate
     * dimensions for the resultant image that best-fit within the given width,
     * regardless of the orientation of the image.
     */
    FIT_TO_WIDTH(3),
    /**
     * Used to indicate that the scaling implementation should calculate
     * dimensions for the resultant image that best-fit within the given height,
     * regardless of the orientation of the image.
     */
    FIT_TO_HEIGHT(4),
    /**
     * No action will be used. File will be saved as it is.
     */
    NONE(5);
    private final int value;

    private PhotoSizeAction(int value) {
        this.value = value;
    }

    public Scalr.Mode getScalrMode() {
        switch (value) {
            case 1:
                return Scalr.Mode.AUTOMATIC;
            case 2:
                return Scalr.Mode.FIT_EXACT;
            case 3:
                return Scalr.Mode.FIT_TO_WIDTH;
            case 4:
                return Scalr.Mode.FIT_TO_HEIGHT;
            case 5:
                return null;
        }
        throw new NullPointerException("Object's value was not valid:" + value);
    }

}
