com.jgoodies.forms.layout

Class Sizes

public final class Sizes extends Object

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 {@link UnitConverter}. The conversion methods require the layout container as parameter to read its current font and resolution.

Version: $Revision: 1.5 $

Author: Karsten Lentzsch

See Also: Size UnitConverter DefaultUnitConverter

Field Summary
static Sizes.ComponentSizeDEFAULT
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.
static ConstantSizeDLUX1
static ConstantSizeDLUX11
static ConstantSizeDLUX14
static ConstantSizeDLUX2
static ConstantSizeDLUX3
static ConstantSizeDLUX4
static ConstantSizeDLUX5
static ConstantSizeDLUX6
static ConstantSizeDLUX7
static ConstantSizeDLUX8
static ConstantSizeDLUX9
static ConstantSizeDLUY1
static ConstantSizeDLUY11
static ConstantSizeDLUY14
static ConstantSizeDLUY2
static ConstantSizeDLUY3
static ConstantSizeDLUY4
static ConstantSizeDLUY5
static ConstantSizeDLUY6
static ConstantSizeDLUY7
static ConstantSizeDLUY8
static ConstantSizeDLUY9
static Sizes.ComponentSizeMINIMUM
Use the maximum of all component minimum sizes as column or row size.
static Sizes.ComponentSizePREFERRED
Use the maximum of all component preferred sizes as column or row size.
static ConstantSizeZERO
Method Summary
static Sizebounded(Size basis, Size lowerBound, Size upperBound)
Creates and returns a BoundedSize for the given basis using the specified lower and upper bounds.
static intcentimeterAsPixel(double cm, Component component)
Converts Centimeters and returns pixels using the resolution of the given component's graphics object.
static ConstantSizeconstant(String encodedValueAndUnit, boolean horizontal)
Creates and returns an instance of ConstantSize from the given encoded size and unit description.
static intdialogUnitXAsPixel(int dluX, Component component)
Converts horizontal dialog units and returns pixels.
static intdialogUnitYAsPixel(int dluY, Component component)
Converts vertical dialog units and returns pixels.
static ConstantSizedluX(int value)
Creates and returns a ConstantSize for the specified value in horizontal dialog units.
static ConstantSizedluY(int value)
Creates and returns a ConstantSize for the specified value in vertical dialog units.
static UnitConvertergetUnitConverter()
Returns the current {@link UnitConverter}.
static intinchAsPixel(double in, Component component)
Converts Inches and returns pixels using the specified resolution.
static intmillimeterAsPixel(double mm, Component component)
Converts Millimeters and returns pixels using the resolution of the given component's graphics object.
static ConstantSizepixel(int value)
Creates and returns a ConstantSize for the specified pixel value.
static intpointAsPixel(int pt, Component component)
Converts DTP Points and returns pixels using the resolution of the given component's graphics object.
static voidsetUnitConverter(UnitConverter newUnitConverter)
Sets a new UnitConverter that will be used to convert font-dependent sizes to pixel sizes.

Field Detail

DEFAULT

public static final 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.

DLUX1

public static final ConstantSize DLUX1

DLUX11

public static final ConstantSize DLUX11

DLUX14

public static final ConstantSize DLUX14

DLUX2

public static final ConstantSize DLUX2

DLUX3

public static final ConstantSize DLUX3

DLUX4

public static final ConstantSize DLUX4

DLUX5

public static final ConstantSize DLUX5

DLUX6

public static final ConstantSize DLUX6

DLUX7

public static final ConstantSize DLUX7

DLUX8

public static final ConstantSize DLUX8

DLUX9

public static final ConstantSize DLUX9

DLUY1

public static final ConstantSize DLUY1

DLUY11

public static final ConstantSize DLUY11

DLUY14

public static final ConstantSize DLUY14

DLUY2

public static final ConstantSize DLUY2

DLUY3

public static final ConstantSize DLUY3

DLUY4

public static final ConstantSize DLUY4

DLUY5

public static final ConstantSize DLUY5

DLUY6

public static final ConstantSize DLUY6

DLUY7

public static final ConstantSize DLUY7

DLUY8

public static final ConstantSize DLUY8

DLUY9

public static final ConstantSize DLUY9

MINIMUM

public static final Sizes.ComponentSize MINIMUM
Use the maximum of all component minimum sizes as column or row size.

PREFERRED

public static final Sizes.ComponentSize PREFERRED
Use the maximum of all component preferred sizes as column or row size.

ZERO

public static final ConstantSize ZERO

Method Detail

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.

Parameters: basis the base size lowerBound the lower bound size upperBound the upper bound size

Returns: a BoundedSize for the given basis and bounds

Throws: NullPointerException if basis is null

centimeterAsPixel

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

Parameters: cm Centimeters component the component that provides the graphics object

Returns: 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.

Parameters: encodedValueAndUnit value and unit in string representation horizontal true for horizontal, false for vertical

Returns: 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.

Parameters: dluX the horizontal dialog units component the component that provides the graphics object

Returns: 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.

Parameters: dluY the vertical dialog units component the component that provides the graphics object

Returns: 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.

Parameters: value size value in horizontal dialog units

Returns: the associated ConstantSize

dluY

public static ConstantSize dluY(int value)
Creates and returns a ConstantSize for the specified value in vertical dialog units.

Parameters: value size value in vertical dialog units

Returns: the associated ConstantSize

getUnitConverter

public static UnitConverter getUnitConverter()
Returns the current {@link UnitConverter}. If it has not been initialized before it will get an instance of {@link DefaultUnitConverter}.

Returns: the current UnitConverter

inchAsPixel

public static int inchAsPixel(double in, Component component)
Converts Inches and returns pixels using the specified resolution.

Parameters: in the Inches component the component that provides the graphics object

Returns: 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.

Parameters: mm Millimeters component the component that provides the graphics object

Returns: the given Millimeters as pixels

pixel

public static ConstantSize pixel(int value)
Creates and returns a ConstantSize for the specified pixel value.

Parameters: value value in pixel

Returns: 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.

Parameters: pt DTP Points component the component that provides the graphics object

Returns: the given Points as pixels

setUnitConverter

public static void setUnitConverter(UnitConverter newUnitConverter)
Sets a new UnitConverter that will be used to convert font-dependent sizes to pixel sizes.

Parameters: newUnitConverter the unit converter to be set

Copyright © 2002-2007 JGoodies Karsten Lentzsch. All Rights Reserved.