Consists only of static methods that create and convert sizes
as required by the FormLayout. The conversion of sizes
that are not based on pixel is delegated to an implementation
of
UnitConverter
. The conversion methods require the
layout container as parameter to read its current font and resolution.
DEFAULT
public static final com.jgoodies.forms.layout.Sizes.ComponentSize DEFAULT
Use the maximum of all component sizes as column or row size;
measures preferred sizes when asked for the preferred size
and minimum sizes when asked for the minimum size.
DLUX21
public static final ConstantSize DLUX21
21 horizontal dialog units.
DLUY21
public static final ConstantSize DLUY21
21 vertical dialog units.
MINIMUM
public static final com.jgoodies.forms.layout.Sizes.ComponentSize MINIMUM
Use the maximum of all component minimum sizes as column or row size.
PREFERRED
public static final com.jgoodies.forms.layout.Sizes.ComponentSize PREFERRED
Use the maximum of all component preferred sizes as column or row size.
bounded
public static Size bounded(Size basis,
Size lowerBound,
Size upperBound)
Creates and returns a BoundedSize for the given basis
using the specified lower and upper bounds.
basis
- the base sizelowerBound
- the lower bound sizeupperBound
- the upper bound size
- a
BoundedSize
for the given basis and bounds
centimeterAsPixel
public static int centimeterAsPixel(double cm,
Component component)
Converts Centimeters and returns pixels using the resolution of the
given component's graphics object.
cm
- Centimeterscomponent
- the component that provides the graphics object
- the given Centimeters as pixels
constant
public static ConstantSize constant(String encodedValueAndUnit,
boolean horizontal)
Creates and returns an instance of ConstantSize
from the
given encoded size and unit description.
encodedValueAndUnit
- value and unit in string representationhorizontal
- true for horizontal, false for vertical
- a
ConstantSize
for the given value and unit
dialogUnitXAsPixel
public static int dialogUnitXAsPixel(int dluX,
Component component)
Converts horizontal dialog units and returns pixels.
Honors the resolution, dialog font size, platform, and l&f.
dluX
- the horizontal dialog unitscomponent
- the component that provides the graphics object
- the given horizontal dialog units as pixels
dialogUnitYAsPixel
public static int dialogUnitYAsPixel(int dluY,
Component component)
Converts vertical dialog units and returns pixels.
Honors the resolution, dialog font size, platform, and l&f.
dluY
- the vertical dialog unitscomponent
- the component that provides the graphics object
- the given vertical dialog units as pixels
dluX
public static ConstantSize dluX(int value)
Creates and returns a ConstantSize for the specified value
in horizontal dialog units.
value
- size value in horizontal dialog units
- the associated
ConstantSize
dluY
public static ConstantSize dluY(int value)
Creates and returns a ConstantSize for the specified value
in vertical dialog units.
value
- size value in vertical dialog units
- the associated
ConstantSize
getDefaultUnit
public static ConstantSize.Unit getDefaultUnit()
Returns the Unit that is used if an encoded ConstantSize contains
no unit string.
- the Unit if no unit string is provided
getUnitConverter
public static UnitConverter getUnitConverter()
- the current
UnitConverter
inchAsPixel
public static int inchAsPixel(double in,
Component component)
Converts Inches and returns pixels using the specified resolution.
in
- the Inchescomponent
- the component that provides the graphics object
- the given Inches as pixels
millimeterAsPixel
public static int millimeterAsPixel(double mm,
Component component)
Converts Millimeters and returns pixels using the resolution of the
given component's graphics object.
mm
- Millimeterscomponent
- the component that provides the graphics object
- the given Millimeters as pixels
pixel
public static ConstantSize pixel(int value)
Creates and returns a ConstantSize
for the specified pixel value.
- the associated
ConstantSize
pointAsPixel
public static int pointAsPixel(int pt,
Component component)
Converts DTP Points and returns pixels using the resolution of the
given component's graphics object.
pt
- DTP Pointscomponent
- the component that provides the graphics object
- the given Points as pixels
setDefaultUnit
public static void setDefaultUnit(ConstantSize.Unit unit)
Sets the Unit that shall be used if an encoded ConstantSize
provides no unit string.
unit
- the new default Unit, null
for dialog units
setUnitConverter
public static void setUnitConverter(UnitConverter newUnitConverter)
Sets a new UnitConverter that will be used to convert
font-dependent sizes to pixel sizes.
newUnitConverter
- the unit converter to be set