Package org.apache.poi.util
Class Units
- java.lang.Object
-
- org.apache.poi.util.Units
-
public class Units extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_CHARACTER_WIDTHWidth of one "standard character" of the default font in pixels.static intEMU_PER_CENTIMETERstatic intEMU_PER_CHARACTERColumn widths are in fractional characters, this is the EMU equivalent.static intEMU_PER_DXAEMU_PER_POINT/20static intEMU_PER_INCH72 points per inch (dpi)static intEMU_PER_PIXELIn Escher absolute distances are specified in English Metric Units (EMUs), occasionally referred to as A units; there are 360000 EMUs per centimeter, 914400 EMUs per inch, 12700 EMUs per point.static intEMU_PER_POINTstatic intMASTER_DPIMaster DPI (576 pixels per inch).static intPIXEL_DPIPixels DPI (96 pixels per inch)static intPOINT_DPIPoints DPI (72 pixels per inch)
-
Constructor Summary
Constructors Constructor Description Units()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcharactersToEMU(double characters)static intcolumnWidthToEMU(int columnWidth)static intdoubleToFixedPoint(double floatPoint)Converts a value of type floating point to a FixedPointstatic doublefixedPointToDouble(int fixedPoint)Converts a value of type FixedPoint to a floating pointstatic doublemasterToPoints(int masterDPI)static intpixelToEMU(int pixels)Converts pixels to EMUsstatic doublepixelToPoints(double pixel)static Dimension2DpixelToPoints(Dimension2D pointsDim)static Rectangle2DpixelToPoints(Rectangle2D pointsDim)static intpointsToMaster(double points)static intpointsToPixel(double points)static Dimension2DpointsToPixel(Dimension2D pointsDim)static Rectangle2DpointsToPixel(Rectangle2D pointsDim)static doubletoDXA(long emu)static inttoEMU(double points)Converts points to EMUsstatic doubletoPoints(long emu)Converts EMUs to points
-
-
-
Field Detail
-
EMU_PER_PIXEL
public static final int EMU_PER_PIXEL
In Escher absolute distances are specified in English Metric Units (EMUs), occasionally referred to as A units; there are 360000 EMUs per centimeter, 914400 EMUs per inch, 12700 EMUs per point.- See Also:
- Constant Field Values
-
EMU_PER_POINT
public static final int EMU_PER_POINT
- See Also:
- Constant Field Values
-
EMU_PER_CENTIMETER
public static final int EMU_PER_CENTIMETER
- See Also:
- Constant Field Values
-
EMU_PER_INCH
public static final int EMU_PER_INCH
72 points per inch (dpi)- See Also:
- Constant Field Values
-
EMU_PER_DXA
public static final int EMU_PER_DXA
EMU_PER_POINT/20- See Also:
- Constant Field Values
-
MASTER_DPI
public static final int MASTER_DPI
Master DPI (576 pixels per inch). Used by the reference coordinate system in PowerPoint (HSLF)- See Also:
- Constant Field Values
-
PIXEL_DPI
public static final int PIXEL_DPI
Pixels DPI (96 pixels per inch)- See Also:
- Constant Field Values
-
POINT_DPI
public static final int POINT_DPI
Points DPI (72 pixels per inch)- See Also:
- Constant Field Values
-
DEFAULT_CHARACTER_WIDTH
public static final float DEFAULT_CHARACTER_WIDTH
Width of one "standard character" of the default font in pixels. Same for Calibri and Arial. "Standard character" defined as the widest digit character in the given font. Copied from XSSFWorkbook, since that isn't available here.Note this is only valid for workbooks using the default Excel font.
Would be nice to eventually support arbitrary document default fonts.
- See Also:
- Constant Field Values
-
EMU_PER_CHARACTER
public static final int EMU_PER_CHARACTER
Column widths are in fractional characters, this is the EMU equivalent. One character is defined as the widest value for the integers 0-9 in the default font.- See Also:
- Constant Field Values
-
-
Method Detail
-
toEMU
public static int toEMU(double points)
Converts points to EMUs- Parameters:
points- points- Returns:
- EMUs
-
pixelToEMU
public static int pixelToEMU(int pixels)
Converts pixels to EMUs- Parameters:
pixels- pixels- Returns:
- EMUs
-
toPoints
public static double toPoints(long emu)
Converts EMUs to points- Parameters:
emu- emu- Returns:
- points
-
fixedPointToDouble
public static double fixedPointToDouble(int fixedPoint)
Converts a value of type FixedPoint to a floating point- Parameters:
fixedPoint- value in fixed point notation- Returns:
- floating point (double)
- See Also:
- [MS-OSHARED] - 2.2.1.6 FixedPoint
-
doubleToFixedPoint
public static int doubleToFixedPoint(double floatPoint)
Converts a value of type floating point to a FixedPoint- Parameters:
floatPoint- value in floating point notation- Returns:
- fixedPoint value in fixed points notation
- See Also:
- [MS-OSHARED] - 2.2.1.6 FixedPoint
-
masterToPoints
public static double masterToPoints(int masterDPI)
-
pointsToMaster
public static int pointsToMaster(double points)
-
pointsToPixel
public static int pointsToPixel(double points)
-
pixelToPoints
public static double pixelToPoints(double pixel)
-
pointsToPixel
public static Dimension2D pointsToPixel(Dimension2D pointsDim)
-
pixelToPoints
public static Dimension2D pixelToPoints(Dimension2D pointsDim)
-
pointsToPixel
public static Rectangle2D pointsToPixel(Rectangle2D pointsDim)
-
pixelToPoints
public static Rectangle2D pixelToPoints(Rectangle2D pointsDim)
-
charactersToEMU
public static int charactersToEMU(double characters)
-
columnWidthToEMU
public static int columnWidthToEMU(int columnWidth)
- Parameters:
columnWidth- specified in 256ths of a standard character- Returns:
- equivalent EMUs
-
toDXA
public static double toDXA(long emu)
-
-