Example usage for com.itextpdf.text Utilities inchesToPoints

List of usage examples for com.itextpdf.text Utilities inchesToPoints

Introduction

In this page you can find the example usage for com.itextpdf.text Utilities inchesToPoints.

Prototype

public static final float inchesToPoints(final float value) 

Source Link

Document

Measurement conversion from inches to points.

Usage

From source file:net.sf.mzmine.util.DimensionUnitUtil.java

License:Open Source License

/**
 * Converts any value+unit to pixel//  w ww.  ja  v  a 2 s . com
 * 
 * @param value
 * @param unit
 * @return Float.NaN if the no conversion was defined for this unit
 */
public static float toPixel(float value, DimUnit unit) {
    // convert to pt
    switch (unit) {
    case CM:
        return Utilities.millimetersToPoints(value * 10.f);
    case MM:
        return Utilities.millimetersToPoints(value);
    case INCH:
        return Utilities.inchesToPoints(value);
    case PX:
    case PT:
        return value;
    }
    return Float.NaN;
}

From source file:nz.ac.waikato.cms.doc.SimplePDFOverlay.java

License:Open Source License

/**
 * Parses the location string.//from   ww  w . java  2s  .c o m
 *
 * @param str      the string to parse
 * @param max      the maximum to use if position string is -1
 * @param units   the units the location is in (in|mm|pt)
 * @return      the position in points
 */
protected float parseLocation(String str, float max, String units) {
    float result;

    result = Float.parseFloat(str);

    if (result >= 0) {
        switch (units) {
        case "mm":
            result = Utilities.millimetersToPoints(result);
            break;
        case "in":
            result = Utilities.inchesToPoints(result);
            break;
        case "pt":
            // nothing to do
            break;
        default:
            m_Logger.warning("Unknown units: " + units);
        }
    } else {
        result = max;
    }

    return result;
}