com.jgoodies.forms.util
public final class DefaultUnitConverter extends AbstractUnitConverter
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.
Since the Forms 1.1 this converter logs font information at
the CONFIG
level.
Version: $Revision: 1.5 $
See Also: UnitConverter Size Sizes
Method Summary | |
---|---|
void | addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void | addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific
property. |
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.
|
protected double | getDialogBaseUnitsX(Component component)
Returns the cached or computed horizontal dialog base units.
|
protected double | getDialogBaseUnitsY(Component 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 | removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void | removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific
property. |
void | setAverageCharacterWidthTestString(String newTestString)
Sets a string that will be used to compute the average character width.
|
void | setDefaultDialogFont(Font newFont)
Sets a dialog font that will be used to compute the dialog base units.
|
If listener is null, no exception is thrown and no action is performed.
Parameters: listener the PropertyChangeListener to be added
See Also: removePropertyChangeListener DefaultUnitConverter DefaultUnitConverter
Note that if this Model is inheriting a bound property, then no event will be fired in response to a change in the inherited property.
If listener is null, no exception is thrown and no action is performed.
Parameters: propertyName one of the property names listed above listener the PropertyChangeListener to be added
See Also: DefaultUnitConverter DefaultUnitConverter
Returns: the test string used to compute the average character width
Returns: the font used to compute the dialog base units
Parameters: component a Component that provides the font and graphics
Returns: the horizontal dialog base units
Parameters: component a Component that provides the font and graphics
Returns: the vertical dialog base units
Returns: the lazily instantiated sole instance
If listener is null, no exception is thrown and no action is performed.
Parameters: listener the PropertyChangeListener to be removed
See Also: addPropertyChangeListener DefaultUnitConverter DefaultUnitConverter
If listener is null, no exception is thrown and no action is performed.
Parameters: propertyName a valid property name listener the PropertyChangeListener to be removed
Parameters: newTestString the test string to be used
Throws: IllegalArgumentException if the test string is empty NullPointerException if the test string is null
Parameters: newFont the default dialog font to be set