Package org.docx4j

Class UnitsOfMeasurement

java.lang.Object
org.docx4j.UnitsOfMeasurement

public class UnitsOfMeasurement
extends java.lang.Object
Author:
jharrop, azerolo
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int DPI  
    static java.text.DecimalFormat format2DP  
  • Constructor Summary

    Constructors 
    Constructor Description
    UnitsOfMeasurement()  
  • Method Summary

    Modifier and Type Method Description
    static int combineColors​(int fgColor, int bgColor, int pctFg)  
    static int inchToTwip​(float inch)  
    static double inchToTwipDouble​(double inch)
    Convert an inches value to twips and return as a double.
    static int mmToTwip​(float mm)  
    static int pointToTwip​(float point)  
    static int pxToTwip​(float px)  
    static double pxToTwipDouble​(double px)
    Convert a pixel value to twips and return as a double.
    static java.lang.String rgbTripleToHex​(float red, float green, float blue)  
    static java.lang.String toHexColor​(int color)  
    static java.lang.String twipToBest​(int leftL)
    1440 twip = 1 inch;Try to guess whether inches or mm looks nicer
    static long twipToEMU​(double twips)  
    static float twipToInch​(int twip)  
    static float twipToMm​(int twip)  
    static float twipToPoint​(int twip)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • format2DP

      public static final java.text.DecimalFormat format2DP
    • DPI

      public static final int DPI
  • Constructor Details

  • Method Details

    • twipToEMU

      public static long twipToEMU​(double twips)
    • inchToTwip

      public static int inchToTwip​(float inch)
    • twipToInch

      public static float twipToInch​(int twip)
    • twipToMm

      public static float twipToMm​(int twip)
      Since:
      3.0.0
    • mmToTwip

      public static int mmToTwip​(float mm)
    • twipToPoint

      public static float twipToPoint​(int twip)
      Since:
      3.0.0
    • pointToTwip

      public static int pointToTwip​(float point)
      Since:
      3.0.0
    • pxToTwip

      public static int pxToTwip​(float px)
      Since:
      3.0.0
    • inchToTwipDouble

      public static double inchToTwipDouble​(double inch)
      Convert an inches value to twips and return as a double.
    • pxToTwipDouble

      public static double pxToTwipDouble​(double px)
      Convert a pixel value to twips and return as a double. This may be useful where the returned value will then be converted to another unit, and we don't want to lose precision due to rounding.
    • twipToBest

      public static java.lang.String twipToBest​(int leftL)
      1440 twip = 1 inch;Try to guess whether inches or mm looks nicer
      Parameters:
      left -
      Returns:
    • rgbTripleToHex

      public static java.lang.String rgbTripleToHex​(float red, float green, float blue)
    • toHexColor

      public static java.lang.String toHexColor​(int color)
      Since:
      3.0.0
    • combineColors

      public static int combineColors​(int fgColor, int bgColor, int pctFg)
      Since:
      3.0.0