All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.utils.MeasurementUtils Maven / Gradle / Ivy

package com.adobe.aemds.guide.utils;

public class MeasurementUtils {

    private MeasurementUtils() {
        throw new UnsupportedOperationException();
    }


    /**
     * @param size
     * @pad.exclude Exclude from Published API.
     */
    public static double convertToPx(String size) {
        Double pxSize = Double.parseDouble(size.substring(0, size.length() - 2));
        if (size.indexOf("in") >= 0) {
            pxSize = mm2px(pxSize * GuideConstants.INCH_TO_MM_FACTOR);
        } else if (size.indexOf("mm") >= 0) {
            pxSize = mm2px(pxSize);
        } else if (size.indexOf("cm") >= 0) {
            pxSize = mm2px(pxSize * 10);
        } else if (size.indexOf("pt") >= 0) {
            pxSize = pxSize * (GuideConstants.DEVICE_RESOLUTION / GuideConstants.PDF_RESOLUTION);
        }
        return pxSize;
    }

    /**
     * @param mmSize
     * @pad.exclude Exclude from Published API.
     */
    public static double mm2px(double mmSize) {
        double mm2in = 1 / GuideConstants.INCH_TO_MM_FACTOR;
        return mmSize * mm2in * GuideConstants.DEVICE_RESOLUTION;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy