|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.util.AbstractUnitConverter
com.jgoodies.forms.util.DefaultUnitConverter
public final class 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 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.
UnitConverter
,
Size
,
Sizes
Field Summary | |
---|---|
static java.lang.String |
PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING
|
static java.lang.String |
PROPERTY_DEFAULT_DIALOG_FONT
|
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. |
java.lang.String |
getAverageCharacterWidthTestString()
Returns the string used to compute the average character width. |
java.awt.Font |
getDefaultDialogFont()
Returns the dialog font that is used to compute the dialog base units. |
protected double |
getDialogBaseUnitsX(java.awt.Component component)
Returns the cached or computed horizontal dialog base units. |
protected double |
getDialogBaseUnitsY(java.awt.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(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. |
void |
setAverageCharacterWidthTestString(java.lang.String newTestString)
Sets a string that will be used to compute the average character width. |
void |
setDefaultDialogFont(java.awt.Font newFont)
Sets a dialog font that will be used to compute the dialog base units. |
Methods inherited from class com.jgoodies.forms.util.AbstractUnitConverter |
---|
centimeterAsPixel, centimeterAsPixel, computeAverageCharWidth, dialogUnitXAsPixel, dialogUnitXAsPixel, dialogUnitYAsPixel, dialogUnitYAsPixel, getDefaultScreenResolution, 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 |
Field Detail |
---|
public static final java.lang.String PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING
public static final java.lang.String PROPERTY_DEFAULT_DIALOG_FONT
Method Detail |
---|
public static DefaultUnitConverter getInstance()
public java.lang.String getAverageCharacterWidthTestString()
public void setAverageCharacterWidthTestString(java.lang.String newTestString)
newTestString
- 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 java.awt.Font getDefaultDialogFont()
setDefaultDialogFont(Font)
, this font will be returned.
Otherwise a cached fallback will be lazily created.
public void setDefaultDialogFont(java.awt.Font newFont)
newFont
- the default dialog font to be setprotected double getDialogBaseUnitsX(java.awt.Component component)
getDialogBaseUnitsX
in class AbstractUnitConverter
component
- a Component that provides the font and graphics
protected double getDialogBaseUnitsY(java.awt.Component component)
getDialogBaseUnitsY
in class AbstractUnitConverter
component
- a Component that provides the font and graphics
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
listener
- the PropertyChangeListener to be addedremovePropertyChangeListener(PropertyChangeListener)
,
removePropertyChangeListener(String, PropertyChangeListener)
,
addPropertyChangeListener(String, PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
listener
- the PropertyChangeListener to be removedaddPropertyChangeListener(PropertyChangeListener)
,
addPropertyChangeListener(String, PropertyChangeListener)
,
removePropertyChangeListener(String, PropertyChangeListener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
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.
propertyName
- one of the property names listed abovelistener
- the PropertyChangeListener to be addedremovePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,
addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
If listener is null, no exception is thrown and no action is performed.
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removedaddPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
,
removePropertyChangeListener(java.beans.PropertyChangeListener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |