Class DefaultUnitConverter
- All Implemented Interfaces:
ObservableBean,ObservableBean2,UnitConverter,Serializable
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 custom computation. More information how to use dialog units in screen design can be found in Microsoft's Design Specifications and Guidelines.
Since the Forms 1.1 this converter logs font information at the CONFIG level.
- Version:
- $Revision: 1.23 $
- Author:
- Karsten Lentzsch
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.privatejgoodies.common.bean.Bean
changeSupport -
Method Summary
Modifier and TypeMethodDescriptionReturns the string used to compute the average character width.Returns the dialog font that is used to compute the dialog base units.protected doublegetDialogBaseUnitsX(Component component) Returns the cached or computed horizontal dialog base units.protected doublegetDialogBaseUnitsY(Component component) Returns the cached or computed vertical dialog base units for the given component.static DefaultUnitConverterLazily instantiates and returns the sole instance.voidsetAverageCharacterWidthTestString(String newTestString) Sets a string that will be used to compute the average character width.voidsetDefaultDialogFont(Font newFont) Sets a dialog font that will be used to compute the dialog base units.Methods inherited from class com.privatejgoodies.forms.util.AbstractUnitConverter
centimeterAsPixel, centimeterAsPixel, computeAverageCharWidth, dialogUnitXAsPixel, dialogUnitXAsPixel, dialogUnitYAsPixel, dialogUnitYAsPixel, getDefaultScreenResolution, getScreenResolution, inchAsPixel, inchAsPixel, millimeterAsPixel, millimeterAsPixel, pointAsPixel, pointAsPixelMethods inherited from class com.privatejgoodies.common.bean.Bean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPropertyChangeSupport, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Field Details
-
PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING
- See Also:
-
PROPERTY_DEFAULT_DIALOG_FONT
- See Also:
-
OLD_AVERAGE_CHARACTER_TEST_STRING
- Since:
- 1.6
- See Also:
-
MODERN_AVERAGE_CHARACTER_TEST_STRING
- Since:
- 1.4
- See Also:
-
BALANCED_AVERAGE_CHARACTER_TEST_STRING
- Since:
- 1.4
- See Also:
-
-
Method Details
-
getInstance
Lazily instantiates and returns the sole instance.- Returns:
- the lazily instantiated sole instance
-
getAverageCharacterWidthTestString
Returns the string used to compute the average character width. By default it is initialized toBALANCED_AVERAGE_CHARACTER_TEST_STRING.- Returns:
- the test string used to compute the average character width
-
setAverageCharacterWidthTestString
Sets a string that will be used to compute the average character width. By default it is initialized toBALANCED_AVERAGE_CHARACTER_TEST_STRING. You can provide other test strings, for example:- "Xximeee"
- "ABCEDEFHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- Parameters:
newTestString- the test string to be used- Throws:
NullPointerException- ifnewTestStringisnullIllegalArgumentException- ifnewTestStringis empty or whitespace
-
getDefaultDialogFont
Returns the dialog font that is used to compute the dialog base units. If a default dialog font has been set usingsetDefaultDialogFont(Font), this font will be returned. Otherwise a cached fallback will be lazily created.- Returns:
- the font used to compute the dialog base units
-
setDefaultDialogFont
Sets a dialog font that will be used to compute the dialog base units.- Parameters:
newFont- the default dialog font to be set
-
getDialogBaseUnitsX
Returns the cached or computed horizontal dialog base units.- Specified by:
getDialogBaseUnitsXin classAbstractUnitConverter- Parameters:
component- a Component that provides the font and graphics- Returns:
- the horizontal dialog base units
-
getDialogBaseUnitsY
Returns the cached or computed vertical dialog base units for the given component.- Specified by:
getDialogBaseUnitsYin classAbstractUnitConverter- Parameters:
component- a Component that provides the font and graphics- Returns:
- the vertical dialog base units
-