org.apache.xmlgraphics.util

## Class UnitConv

- java.lang.Object
- - org.apache.xmlgraphics.util.UnitConv

-     public final class UnitConv
      extends java.lang.Object

  Utility class for unit conversions.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `CM` Describes the unit centimeter.
    `static float` | `IN2CM` conversion factory from centimeters to inches.
    `static float` | `IN2MM` conversion factory from millimeters to inches.
    `static int` | `IN2PT` conversion factory from inches to points.
    `static java.lang.String` | `INCH` Describes the unit inch.
    `static java.lang.String` | `MM` Describes the unit millimeter.
    `static java.lang.String` | `MPT` Describes the unit millipoint.
    `static java.lang.String` | `PICA` Describes the unit pica.
    `static java.lang.String` | `POINT` Describes the unit point.
    `static java.lang.String` | `PX` Describes the unit pixel.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `convert(java.lang.String value)` Convert the given unit length to a dimensionless integer representing a whole number of base units (milli-points).
    `static double` | `in2mm(double in)` Converts inches (in) to millimeters (mm)
    `static double` | `in2mpt(double in)` Converts inches (in) to millipoints (mpt)
    `static double` | `in2pt(double in)` Converts inches (in) to points (pt)
    `static double` | `mm2in(double mm)` Converts millimeters (mm) to inches (in)
    `static double` | `mm2mpt(double mm)` Converts millimeters (mm) to millipoints (mpt)
    `static double` | `mm2pt(double mm)` Converts millimeters (mm) to points (pt)
    `static double` | `mm2px(double mm, int resolution)` Converts millimeters (mm) to pixels (px)
    `static double` | `mpt2in(double mpt)` Converts millipoints (mpt) to inches (in)
    `static double` | `mpt2px(double mpt, int resolution)` Converts millipoints (mpt) to pixels (px)
    `static java.awt.geom.AffineTransform` | `mptToPt(java.awt.geom.AffineTransform at)` Converts a millipoint-based transformation matrix to points.
    `static double` | `pt2mm(double pt)` Converts points (pt) to millimeters (mm)
    `static java.awt.geom.AffineTransform` | `ptToMpt(java.awt.geom.AffineTransform at)` Converts a point-based transformation matrix to millipoints.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### IN2MM

          public static final float IN2MM

      conversion factory from millimeters to inches.
      See Also:
        Constant Field Values

    - #### IN2CM

          public static final float IN2CM

      conversion factory from centimeters to inches.
      See Also:
        Constant Field Values

    - #### IN2PT

          public static final int IN2PT

      conversion factory from inches to points.
      See Also:
        Constant Field Values

    - #### PICA

          public static final java.lang.String PICA

      Describes the unit pica.
      See Also:
        Constant Field Values

    - #### POINT

          public static final java.lang.String POINT

      Describes the unit point.
      See Also:
        Constant Field Values

    - #### MM

          public static final java.lang.String MM

      Describes the unit millimeter.
      See Also:
        Constant Field Values

    - #### CM

          public static final java.lang.String CM

      Describes the unit centimeter.
      See Also:
        Constant Field Values

    - #### INCH

          public static final java.lang.String INCH

      Describes the unit inch.
      See Also:
        Constant Field Values

    - #### MPT

          public static final java.lang.String MPT

      Describes the unit millipoint.
      See Also:
        Constant Field Values

    - #### PX

          public static final java.lang.String PX

      Describes the unit pixel.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### mm2pt

          public static double mm2pt(double mm)

      Converts millimeters (mm) to points (pt)
      Parameters:
        `mm` - the value in mm
      Returns:
        the value in pt

    - #### mm2mpt

          public static double mm2mpt(double mm)

      Converts millimeters (mm) to millipoints (mpt)
      Parameters:
        `mm` - the value in mm
      Returns:
        the value in mpt

    - #### pt2mm

          public static double pt2mm(double pt)

      Converts points (pt) to millimeters (mm)
      Parameters:
        `pt` - the value in pt
      Returns:
        the value in mm

    - #### mm2in

          public static double mm2in(double mm)

      Converts millimeters (mm) to inches (in)
      Parameters:
        `mm` - the value in mm
      Returns:
        the value in inches

    - #### in2mm

          public static double in2mm(double in)

      Converts inches (in) to millimeters (mm)
      Parameters:
        `in` - the value in inches
      Returns:
        the value in mm

    - #### in2mpt

          public static double in2mpt(double in)

      Converts inches (in) to millipoints (mpt)
      Parameters:
        `in` - the value in inches
      Returns:
        the value in mpt

    - #### in2pt

          public static double in2pt(double in)

      Converts inches (in) to points (pt)
      Parameters:
        `in` - the value in inches
      Returns:
        the value in pt

    - #### mpt2in

          public static double mpt2in(double mpt)

      Converts millipoints (mpt) to inches (in)
      Parameters:
        `mpt` - the value in mpt
      Returns:
        the value in inches

    - #### mm2px

          public static double mm2px(double mm,
                                     int resolution)

      Converts millimeters (mm) to pixels (px)
      Parameters:
        `mm` - the value in mm
        `resolution` - the resolution in dpi (dots per inch)
      Returns:
        the value in pixels

    - #### mpt2px

          public static double mpt2px(double mpt,
                                      int resolution)

      Converts millipoints (mpt) to pixels (px)
      Parameters:
        `mpt` - the value in mpt
        `resolution` - the resolution in dpi (dots per inch)
      Returns:
        the value in pixels

    - #### mptToPt

          public static java.awt.geom.AffineTransform mptToPt(java.awt.geom.AffineTransform at)

      Converts a millipoint-based transformation matrix to points.
      Parameters:
        `at` - a millipoint-based transformation matrix
      Returns:
        a point-based transformation matrix

    - #### ptToMpt

          public static java.awt.geom.AffineTransform ptToMpt(java.awt.geom.AffineTransform at)

      Converts a point-based transformation matrix to millipoints.
      Parameters:
        `at` - a point-based transformation matrix
      Returns:
        a millipoint-based transformation matrix

    - #### convert

          public static int convert(java.lang.String value)

      Convert the given unit length to a dimensionless integer representing a whole number of base units (milli-points).
      Parameters:
        `value` - input unit value
      Returns:
        int millipoints

Copyright 1999-2025 The Apache Software Foundation. All Rights Reserved.