|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.util.AbstractUnitConverter
public abstract class AbstractUnitConverter
An abstract implementation of the UnitConverter
interface that
minimizes the effort required to convert font-dependent sizes to pixels.
DefaultUnitConverter
,
Size
,
Sizes
Field Summary | |
---|---|
private static int |
defaultScreenResolution
|
private static int |
DTP_RESOLUTION
|
Constructor Summary | |
---|---|
AbstractUnitConverter()
|
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int DTP_RESOLUTION
private static int defaultScreenResolution
Constructor Detail |
---|
public AbstractUnitConverter()
Method Detail |
---|
public int inchAsPixel(double in, java.awt.Component component)
inchAsPixel
in interface UnitConverter
in
- the Inchescomponent
- the component that provides the graphics object
public int millimeterAsPixel(double mm, java.awt.Component component)
millimeterAsPixel
in interface UnitConverter
mm
- Millimeterscomponent
- the component that provides the graphics object
public int centimeterAsPixel(double cm, java.awt.Component component)
centimeterAsPixel
in interface UnitConverter
cm
- Centimeterscomponent
- the component that provides the graphics object
public int pointAsPixel(int pt, java.awt.Component component)
pointAsPixel
in interface UnitConverter
pt
- DTP Pointscomponent
- the component that provides the graphics object
public int dialogUnitXAsPixel(int dluX, java.awt.Component c)
dialogUnitXAsPixel
in interface UnitConverter
dluX
- the horizontal dialog unitsc
- a Component that provides the font and graphics
public int dialogUnitYAsPixel(int dluY, java.awt.Component c)
dialogUnitYAsPixel
in interface UnitConverter
dluY
- the vertical dialog unitsc
- a Component that provides the font and graphics
protected abstract double getDialogBaseUnitsX(java.awt.Component component)
component
- a Component that provides the font and graphics
protected abstract double getDialogBaseUnitsY(java.awt.Component component)
component
- a Component that provides the font and graphics
protected final int inchAsPixel(double in, int dpi)
in
- the Inchesdpi
- the resolution
protected final int millimeterAsPixel(double mm, int dpi)
mm
- Millimetersdpi
- the resolution
protected final int centimeterAsPixel(double cm, int dpi)
cm
- Centimetersdpi
- the resolution
protected final int pointAsPixel(int pt, int dpi)
pt
- DTP Pointsdpi
- the resolution in dpi
protected int dialogUnitXAsPixel(int dluX, double dialogBaseUnitsX)
dluX
- the horizontal dialog unitsdialogBaseUnitsX
- the horizontal dialog base units
protected int dialogUnitYAsPixel(int dluY, double dialogBaseUnitsY)
dluY
- the vertical dialog unitsdialogBaseUnitsY
- the vertical dialog base units
protected 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" text
protected int getScreenResolution(java.awt.Component c)
c
- the component to ask for a toolkit
protected int getDefaultScreenResolution()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |