public abstract class AbstractUnitConverter extends java.lang.Object implements UnitConverter
UnitConverter
interface that
minimizes the effort required to convert font-dependent sizes to pixels.DefaultUnitConverter
,
Size
,
Sizes
Constructor and Description |
---|
AbstractUnitConverter() |
Modifier and Type | Method and Description |
---|---|
int |
centimeterAsPixel(double cm,
java.awt.Component component)
Converts Centimeters and returns pixels using the resolution of the
given component's graphics object.
|
protected int |
centimeterAsPixel(double cm,
int dpi)
Converts Centimeters and returns pixels using the specified resolution.
|
protected double |
computeAverageCharWidth(java.awt.FontMetrics metrics,
java.lang.String testString)
Computes and returns the average character width
of the specified test string using the given FontMetrics.
|
int |
dialogUnitXAsPixel(int dluX,
java.awt.Component c)
Converts horizontal dialog units and returns pixels.
|
protected int |
dialogUnitXAsPixel(int dluX,
double dialogBaseUnitsX)
Converts horizontal dialog units and returns pixels.
|
int |
dialogUnitYAsPixel(int dluY,
java.awt.Component c)
Converts vertical dialog units and returns pixels.
|
protected int |
dialogUnitYAsPixel(int dluY,
double dialogBaseUnitsY)
Converts vertical dialog units and returns pixels.
|
protected int |
getDefaultScreenResolution()
Computes and returns the default resolution.
|
protected abstract double |
getDialogBaseUnitsX(java.awt.Component component)
Gets and returns the horizontal dialog base units.
|
protected abstract double |
getDialogBaseUnitsY(java.awt.Component component)
Gets and returns the vertical dialog base units.
|
protected int |
getScreenResolution(java.awt.Component c)
Returns the components screen resolution or the default screen
resolution if the component is null or has no toolkit assigned yet.
|
int |
inchAsPixel(double in,
java.awt.Component component)
Converts Inches and returns pixels using the specified resolution.
|
protected int |
inchAsPixel(double in,
int dpi)
Converts Inches and returns pixels using the specified resolution.
|
int |
millimeterAsPixel(double mm,
java.awt.Component component)
Converts Millimeters and returns pixels using the resolution of the
given component's graphics object.
|
protected int |
millimeterAsPixel(double mm,
int dpi)
Converts Millimeters and returns pixels using the specified resolution.
|
int |
pointAsPixel(int pt,
java.awt.Component component)
Converts DTP Points and returns pixels using the resolution of the
given component's graphics object.
|
protected int |
pointAsPixel(int pt,
int dpi)
Converts DTP Points and returns pixels using the specified resolution.
|
public int inchAsPixel(double in, java.awt.Component component)
inchAsPixel
in interface UnitConverter
in
- the Inchescomponent
- the component that provides the graphics objectpublic int millimeterAsPixel(double mm, java.awt.Component component)
millimeterAsPixel
in interface UnitConverter
mm
- Millimeterscomponent
- the component that provides the graphics objectpublic int centimeterAsPixel(double cm, java.awt.Component component)
centimeterAsPixel
in interface UnitConverter
cm
- Centimeterscomponent
- the component that provides the graphics objectpublic int pointAsPixel(int pt, java.awt.Component component)
pointAsPixel
in interface UnitConverter
pt
- DTP Pointscomponent
- the component that provides the graphics objectpublic int dialogUnitXAsPixel(int dluX, java.awt.Component c)
dialogUnitXAsPixel
in interface UnitConverter
dluX
- the horizontal dialog unitsc
- a Component that provides the font and graphicspublic int dialogUnitYAsPixel(int dluY, java.awt.Component c)
dialogUnitYAsPixel
in interface UnitConverter
dluY
- the vertical dialog unitsc
- a Component that provides the font and graphicsprotected abstract double getDialogBaseUnitsX(java.awt.Component component)
component
- a Component that provides the font and graphicsprotected abstract double getDialogBaseUnitsY(java.awt.Component component)
component
- a Component that provides the font and graphicsprotected final int inchAsPixel(double in, int dpi)
in
- the Inchesdpi
- the resolutionprotected final int millimeterAsPixel(double mm, int dpi)
mm
- Millimetersdpi
- the resolutionprotected final int centimeterAsPixel(double cm, int dpi)
cm
- Centimetersdpi
- the resolutionprotected final int pointAsPixel(int pt, int dpi)
pt
- DTP Pointsdpi
- the resolution in dpiprotected int dialogUnitXAsPixel(int dluX, double dialogBaseUnitsX)
dluX
- the horizontal dialog unitsdialogBaseUnitsX
- the horizontal dialog base unitsprotected int dialogUnitYAsPixel(int dluY, double dialogBaseUnitsY)
dluY
- the vertical dialog unitsdialogBaseUnitsY
- the vertical dialog base unitsprotected double computeAverageCharWidth(java.awt.FontMetrics metrics, java.lang.String testString)
metrics
- used to compute the test string's widthtestString
- the string that shall represent an "average" textprotected int getScreenResolution(java.awt.Component c)
c
- the component to ask for a toolkitprotected int getDefaultScreenResolution()