com.jgoodies.forms.util
Class AbstractUnitConverter

java.lang.Object
  extended by com.jgoodies.forms.util.AbstractUnitConverter
All Implemented Interfaces:
UnitConverter
Direct Known Subclasses:
DefaultUnitConverter

public abstract class AbstractUnitConverter
extends java.lang.Object
implements UnitConverter

An abstract implementation of the UnitConverter that minimizes the effort required to convert font-dependent sizes to pixels.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
DefaultUnitConverter, Size, Sizes

Constructor Summary
AbstractUnitConverter()
           
 
Method Summary
 int centimeterAsPixel(double cm, java.awt.Component component)
          Converts Centimeters and answers pixels using the resolution of the given component's graphics object.
 int dialogUnitXAsPixel(int dluX, java.awt.Component c)
          Converts horizontal dialog units and answers pixels.
 int dialogUnitYAsPixel(int dluY, java.awt.Component c)
          Converts vertical dialog units and answers pixels.
 int inchAsPixel(double in, java.awt.Component component)
          Converts Inches and answers pixels using the specified resolution.
 int millimeterAsPixel(double mm, java.awt.Component component)
          Converts Millimeters and answers pixels using the resolution of the given component's graphics object.
 int pointAsPixel(int pt, java.awt.Component component)
          Converts DTP Points and answers pixels using the resolution of the given component's graphics object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractUnitConverter

public AbstractUnitConverter()
Method Detail

inchAsPixel

public int inchAsPixel(double in,
                       java.awt.Component component)
Converts Inches and answers pixels using the specified resolution.

Specified by:
inchAsPixel in interface UnitConverter
Parameters:
in - the Inches
component - the component that provides the graphics object
Returns:
the given Inches as pixels

millimeterAsPixel

public int millimeterAsPixel(double mm,
                             java.awt.Component component)
Converts Millimeters and answers pixels using the resolution of the given component's graphics object.

Specified by:
millimeterAsPixel in interface UnitConverter
Parameters:
mm - Millimeters
component - the component that provides the graphics object
Returns:
the given Millimeters as pixels

centimeterAsPixel

public int centimeterAsPixel(double cm,
                             java.awt.Component component)
Converts Centimeters and answers pixels using the resolution of the given component's graphics object.

Specified by:
centimeterAsPixel in interface UnitConverter
Parameters:
cm - Centimeters
component - the component that provides the graphics object
Returns:
the given Centimeters as pixels

pointAsPixel

public int pointAsPixel(int pt,
                        java.awt.Component component)
Converts DTP Points and answers pixels using the resolution of the given component's graphics object.

Specified by:
pointAsPixel in interface UnitConverter
Parameters:
pt - DTP Points
component - the component that provides the graphics object
Returns:
the given Points as pixels

dialogUnitXAsPixel

public int dialogUnitXAsPixel(int dluX,
                              java.awt.Component c)
Converts horizontal dialog units and answers pixels. Honors the resolution, dialog font size, platform, and l&f.

Specified by:
dialogUnitXAsPixel in interface UnitConverter
Parameters:
dluX - the horizontal dialog units
c - a Component that provides the font and graphics
Returns:
the given horizontal dialog units as pixels

dialogUnitYAsPixel

public int dialogUnitYAsPixel(int dluY,
                              java.awt.Component c)
Converts vertical dialog units and answers pixels. Honors the resolution, dialog font size, platform, and l&f.

Specified by:
dialogUnitYAsPixel in interface UnitConverter
Parameters:
dluY - the vertical dialog units
c - a Component that provides the font and graphics
Returns:
the given vertical dialog units as pixels