|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectyu.ac.bg.etf.javaqx.qswing.layouts.formlayout.util.AbstractUnitConverter
yu.ac.bg.etf.javaqx.qswing.layouts.formlayout.util.DefaultUnitConverter
This is the default implementation of the UnitConverter
interface.
It converts horizontal and vertical dialog base units to pixels.
The horizontal base unit is equal to the average width, in pixels, of the characters in the system font; the vertical base unit is equal to the height, in pixels, of the font. Each horizontal base unit is equal to 4 horizontal dialog units; each vertical base unit is equal to 8 vertical dialog units.
The DefaultUnitConverter computes dialog base units using a default font and a test string for the average character width. You can configure the font and the test string via the bound Bean properties defaultDialogFont and averageCharacterWidthTestString. See also Microsoft's suggestion for a custom computation here.
NOTE: This code is part of the JGoodies Forms port.
Method Summary | |
java.lang.String |
getAverageCharacterWidthTestString()
Returns the string used to compute the average character width. |
Font |
getDefaultDialogFont()
Returns the dialog font that is used to compute the dialog base units. |
FontMetrics |
getDefaultDialogFontMetrics()
Returns default dialog font metrics. |
protected double |
getDialogBaseUnitsX(JQComponent component)
Returns the cached or computed horizontal dialog base units. |
protected double |
getDialogBaseUnitsY(JQComponent component)
Returns the cached or computed vertical dialog base units for the given component. |
static DefaultUnitConverter |
getInstance()
Lazily instantiates and returns the sole instance. |
void |
setAverageCharacterWidthTestString(java.lang.String testString)
Sets a string that will be used to compute the average character width. |
void |
setDefaultDialogFont(Font defaultDialogFont)
Sets a dialog font that will be used to compute the dialog base units. |
Methods inherited from class yu.ac.bg.etf.javaqx.qswing.layouts.formlayout.util.AbstractUnitConverter |
centimeterAsPixel, centimeterAsPixel, computeAverageCharWidth, dialogUnitXAsPixel, dialogUnitXAsPixel, dialogUnitYAsPixel, dialogUnitYAsPixel, getScreenResolution, inchAsPixel, inchAsPixel, millimeterAsPixel, millimeterAsPixel, pointAsPixel, pointAsPixel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static DefaultUnitConverter getInstance()
public java.lang.String getAverageCharacterWidthTestString()
public void setAverageCharacterWidthTestString(java.lang.String testString)
testString
- the test string to be used
java.lang.IllegalArgumentException
- if the test string is empty
java.lang.NullPointerException
- if the test string is null
public Font getDefaultDialogFont()
setDefaultDialogFont(Font)
, this font will be returned.
Otherwise a cached fallback will be lazily created.
public void setDefaultDialogFont(Font defaultDialogFont)
defaultDialogFont
- the default dialog font to be setpublic FontMetrics getDefaultDialogFontMetrics()
protected double getDialogBaseUnitsX(JQComponent component)
getDialogBaseUnitsX
in class AbstractUnitConverter
component
- a Component that provides the font and graphics
protected double getDialogBaseUnitsY(JQComponent component)
getDialogBaseUnitsY
in class AbstractUnitConverter
component
- a Component that provides the font and graphics
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |