com.jgoodies.forms.util
Class DefaultUnitConverter

java.lang.Object
  extended by com.jgoodies.common.bean.Bean
      extended by com.jgoodies.forms.util.AbstractUnitConverter
          extended by com.jgoodies.forms.util.DefaultUnitConverter
All Implemented Interfaces:
com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, UnitConverter, Serializable

public final class DefaultUnitConverter
extends AbstractUnitConverter

This is the default implementation of the UnitConverter interface It converts horizontal and vertical dialog base units to pixels.

defaultDialogFont and averageCharacterWidthTestString See also Microsoft's suggestion for a custom computatio custom computation More information how to use dialog units in screen design can be foun in Microsoft' Desig Specifications and Guidelines.

CONFIG level.

Version:
$Revision: 1.23 $
Author:
Karsten Lentzsch
See Also:
UnitConverter, Size, Sizes, Serialized Form

Field Summary
static String BALANCED_AVERAGE_CHARACTER_TEST_STRING
           
static String MODERN_AVERAGE_CHARACTER_TEST_STRING
           
static String OLD_AVERAGE_CHARACTER_TEST_STRING
           
static String PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING
           
static String PROPERTY_DEFAULT_DIALOG_FONT
           
 
Fields inherited from class com.jgoodies.common.bean.Bean
changeSupport
 
Method Summary
 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 unit for the given component.
static DefaultUnitConverter getInstance()
          Lazily instantiates and returns the sole instance.
 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.
 
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 com.jgoodies.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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING

public static final String PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING
See Also:
Constant Field Values

PROPERTY_DEFAULT_DIALOG_FONT

public static final String PROPERTY_DEFAULT_DIALOG_FONT
See Also:
Constant Field Values

OLD_AVERAGE_CHARACTER_TEST_STRING

public static final String OLD_AVERAGE_CHARACTER_TEST_STRING
Since:
1.6
See Also:
Constant Field Values

MODERN_AVERAGE_CHARACTER_TEST_STRING

public static final String MODERN_AVERAGE_CHARACTER_TEST_STRING
Since:
1.4
See Also:
Constant Field Values

BALANCED_AVERAGE_CHARACTER_TEST_STRING

public static final String BALANCED_AVERAGE_CHARACTER_TEST_STRING
Since:
1.4
See Also:
Constant Field Values
Method Detail

getInstance

public static DefaultUnitConverter getInstance()
Lazily instantiates and returns the sole instance.

Returns:
the lazily instantiated sole instance

getAverageCharacterWidthTestString

public String getAverageCharacterWidthTestString()
Returns the string used to compute the average character width By default it is initialized t BALANCED_AVERAGE_CHARACTER_TEST_STRING.

Returns:
the test string used to compute the average character width

setAverageCharacterWidthTestString

public void setAverageCharacterWidthTestString(String newTestString)
Sets a string that will be used to compute the average character width By default it is initialized t BALANCED_AVERAGE_CHARACTER_TEST_STRING. You can provid other test strings, for example

getDefaultDialogFont

public Font getDefaultDialogFont()
Returns the dialog font that is used to compute the dialog base units If a default dialog font has been set usin setDefaultDialogFont(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

public void setDefaultDialogFont(Font newFont)
Sets a dialog font that will be used to compute the dialog base units.

Parameters:
newFont - the default dialog font to be set

getDialogBaseUnitsX

protected double getDialogBaseUnitsX(Component component)
Returns the cached or computed horizontal dialog base units.

Specified by:
getDialogBaseUnitsX in class AbstractUnitConverter
Parameters:
component - a Component that provides the font and graphics
Returns:
the horizontal dialog base units

getDialogBaseUnitsY

protected double getDialogBaseUnitsY(Component component)
Returns the cached or computed vertical dialog base unit for the given component.

Specified by:
getDialogBaseUnitsY in class AbstractUnitConverter
Parameters:
component - a Component that provides the font and graphics
Returns:
the vertical dialog base units


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.