Top Fields Constructors Methods
org.apache.poi.util

public Class Units

extends Object
Class Inheritance
Imports
java.awt.geom.Dimension2D, .Rectangle2D

Field Summary

Modifier and TypeField and Description
public static final float
DEFAULT_CHARACTER_WIDTH

Width of one "standard character" of the default font in pixels.

public static final int
public static final int
EMU_PER_CHARACTER

Column widths are in fractional characters, this is the EMU equivalent.

public static final int
EMU_PER_DXA

EMU_PER_POINT/20

public static final int
EMU_PER_INCH

72 points per inch (dpi)

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.

public static final int
public static final int
MASTER_DPI

Master DPI (576 pixels per inch).

public static final int
PIXEL_DPI

Pixels DPI (96 pixels per inch)

public static final int
POINT_DPI

Points DPI (72 pixels per inch)

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static int
charactersToEMU(double characters)

public static int

Returns:

equivalent EMUs
columnWidthToEMU
(int
specified in 256ths of a standard character
columnWidth
)

public static int

Returns:

fixedPoint value in fixed points notation
doubleToFixedPoint
(double
value in floating point notation
floatPoint
)

Converts a value of type floating point to a FixedPoint

public static double

Returns:

floating point (double)
fixedPointToDouble
(int
value in fixed point notation
fixedPoint
)

Converts a value of type FixedPoint to a floating point

public static double
masterToPoints(int masterDPI)

public static int

Returns:

EMUs
pixelToEMU
(int
pixels
pixels
)

Converts pixels to EMUs

public static double
pixelToPoints(double pixel)

public static Dimension2D
public static Rectangle2D
public static int
pointsToMaster(double points)

public static int
pointsToPixel(double points)

public static Dimension2D
public static Rectangle2D
public static double
toDXA(long emu)

public static int

Returns:

EMUs
toEMU
(double
points
points
)

Converts points to EMUs

public static double

Returns:

points
toPoints
(long
emu
emu
)

Converts EMUs to points

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CHARACTER_WIDTHback to summary
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.

EMU_PER_CENTIMETERback to summary
public static final int EMU_PER_CENTIMETER
EMU_PER_CHARACTERback to summary
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.

EMU_PER_DXAback to summary
public static final int EMU_PER_DXA

EMU_PER_POINT/20

EMU_PER_INCHback to summary
public static final int EMU_PER_INCH

72 points per inch (dpi)

EMU_PER_PIXELback to summary
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.

EMU_PER_POINTback to summary
public static final int EMU_PER_POINT
MASTER_DPIback to summary
public static final int MASTER_DPI

Master DPI (576 pixels per inch). Used by the reference coordinate system in PowerPoint (HSLF)

PIXEL_DPIback to summary
public static final int PIXEL_DPI

Pixels DPI (96 pixels per inch)

POINT_DPIback to summary
public static final int POINT_DPI

Points DPI (72 pixels per inch)

Constructor Detail

Unitsback to summary
public Units()

Method Detail

charactersToEMUback to summary
public static int charactersToEMU(double characters)
columnWidthToEMUback to summary
public static int columnWidthToEMU(int columnWidth)
Parameters
columnWidth:int

specified in 256ths of a standard character

Returns:int

equivalent EMUs

doubleToFixedPointback to summary
public static int doubleToFixedPoint(double floatPoint)

Converts a value of type floating point to a FixedPoint

Parameters
floatPoint:double

value in floating point notation

Returns:int

fixedPoint value in fixed points notation

See Also
[MS-OSHARED] - 2.2.1.6 FixedPoint
fixedPointToDoubleback to summary
public static double fixedPointToDouble(int fixedPoint)

Converts a value of type FixedPoint to a floating point

Parameters
fixedPoint:int

value in fixed point notation

Returns:double

floating point (double)

See Also
[MS-OSHARED] - 2.2.1.6 FixedPoint
masterToPointsback to summary
public static double masterToPoints(int masterDPI)
pixelToEMUback to summary
public static int pixelToEMU(int pixels)

Converts pixels to EMUs

Parameters
pixels:int

pixels

Returns:int

EMUs

pixelToPointsback to summary
public static double pixelToPoints(double pixel)
pixelToPointsback to summary
public static Dimension2D pixelToPoints(Dimension2D pointsDim)
pixelToPointsback to summary
public static Rectangle2D pixelToPoints(Rectangle2D pointsDim)
pointsToMasterback to summary
public static int pointsToMaster(double points)
pointsToPixelback to summary
public static int pointsToPixel(double points)
pointsToPixelback to summary
public static Dimension2D pointsToPixel(Dimension2D pointsDim)
pointsToPixelback to summary
public static Rectangle2D pointsToPixel(Rectangle2D pointsDim)
toDXAback to summary
public static double toDXA(long emu)
toEMUback to summary
public static int toEMU(double points)

Converts points to EMUs

Parameters
points:double

points

Returns:int

EMUs

toPointsback to summary
public static double toPoints(long emu)

Converts EMUs to points

Parameters
emu:long

emu

Returns:double

points