com.jgoodies.forms.layout
Class Sizes

java.lang.Object
  extended by com.jgoodies.forms.layout.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 UnitConverter. The conversion methods require the layout container as parameter to read its current font and resolution.

Version:
$Revision: 1.10 $
Author:
Karsten Lentzsch
See Also:
Size, UnitConverter, DefaultUnitConverter

Field Summary
static 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.
static ConstantSize DLUX1
          one dialog unit for x direction
static ConstantSize DLUX11
          11 dialog units for x direction
static ConstantSize DLUX14
          14 dialog units for x direction
static ConstantSize DLUX2
          two dialog units for x direction
static ConstantSize DLUX3
          three dialog units for x direction
static ConstantSize DLUX4
          four dialog units for x direction
static ConstantSize DLUX5
          five dialog units for x direction
static ConstantSize DLUX6
          six dialog units for x direction
static ConstantSize DLUX7
          seven dialog units for x direction
static ConstantSize DLUX8
          eight dialog units for x direction
static ConstantSize DLUX9
          nine dialog units for x direction
static ConstantSize DLUY1
          one dialog unit for y direction
static ConstantSize DLUY11
          11 dialog units for x direction
static ConstantSize DLUY14
          14 dialog units for x direction
static ConstantSize DLUY2
          two dialog units for x direction
static ConstantSize DLUY3
          three dialog units for x direction
static ConstantSize DLUY4
          four dialog units for x direction
static ConstantSize DLUY5
          five dialog units for x direction
static ConstantSize DLUY6
          six dialog units for x direction
static ConstantSize DLUY7
          seven dialog units for x direction
static ConstantSize DLUY8
          eight dialog units for x direction
static ConstantSize DLUY9
          nine dialog units for x direction
static com.jgoodies.forms.layout.Sizes.ComponentSize MINIMUM
          Use the maximum of all component minimum sizes as column or row size.
static com.jgoodies.forms.layout.Sizes.ComponentSize PREFERRED
          Use the maximum of all component preferred sizes as column or row size.
static ConstantSize ZERO
          zero pixel unit for x direction
 
Method Summary
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.
static int centimeterAsPixel(double cm, Component component)
          Converts Centimeters and returns pixels using the resolution of the given component's graphics object.
static ConstantSize constant(String encodedValueAndUnit, boolean horizontal)
          Creates and returns an instance of ConstantSize from the given encoded size and unit description.
static int dialogUnitXAsPixel(int dluX, Component component)
          Converts horizontal dialog units and returns pixels.
static int dialogUnitYAsPixel(int dluY, Component component)
          Converts vertical dialog units and returns pixels.
static ConstantSize dluX(int value)
          Returns an instance of Size for the specified value in horizontal dialog units.
static ConstantSize dluY(int value)
          Returns an instance of Size for the specified value in vertical dialog units.
static UnitConverter getUnitConverter()
          Returns the current UnitConverter.
static int inchAsPixel(double in, Component component)
          Converts Inches and returns pixels using the specified resolution.
static int millimeterAsPixel(double mm, Component component)
          Converts Millimeters and returns pixels using the resolution of the given component's graphics object.
static ConstantSize pixel(int value)
          Creates and returns an instance of Size for the specified pixel value.
static int pointAsPixel(int pt, Component component)
          Converts DTP Points and returns pixels using the resolution of the given component's graphics object.
static void setUnitConverter(UnitConverter newUnitConverter)
          Sets a new UnitConverter that will be used to convert font-dependent sizes to pixel sizes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final ConstantSize ZERO
zero pixel unit for x direction


DLUX1

public static final ConstantSize DLUX1
one dialog unit for x direction


DLUX2

public static final ConstantSize DLUX2
two dialog units for x direction


DLUX3

public static final ConstantSize DLUX3
three dialog units for x direction


DLUX4

public static final ConstantSize DLUX4
four dialog units for x direction


DLUX5

public static final ConstantSize DLUX5
five dialog units for x direction


DLUX6

public static final ConstantSize DLUX6
six dialog units for x direction


DLUX7

public static final ConstantSize DLUX7
seven dialog units for x direction


DLUX8

public static final ConstantSize DLUX8
eight dialog units for x direction


DLUX9

public static final ConstantSize DLUX9
nine dialog units for x direction


DLUX11

public static final ConstantSize DLUX11
11 dialog units for x direction


DLUX14

public static final ConstantSize DLUX14
14 dialog units for x direction


DLUY1

public static final ConstantSize DLUY1
one dialog unit for y direction


DLUY2

public static final ConstantSize DLUY2
two dialog units for x direction


DLUY3

public static final ConstantSize DLUY3
three dialog units for x direction


DLUY4

public static final ConstantSize DLUY4
four dialog units for x direction


DLUY5

public static final ConstantSize DLUY5
five dialog units for x direction


DLUY6

public static final ConstantSize DLUY6
six dialog units for x direction


DLUY7

public static final ConstantSize DLUY7
seven dialog units for x direction


DLUY8

public static final ConstantSize DLUY8
eight dialog units for x direction


DLUY9

public static final ConstantSize DLUY9
nine dialog units for x direction


DLUY11

public static final ConstantSize DLUY11
11 dialog units for x direction


DLUY14

public static final ConstantSize DLUY14
14 dialog units for x direction


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.


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.

Method Detail

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

dluX

public static ConstantSize dluX(int value)
Returns an instance of Size 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)
Returns an instance of Size for the specified value in vertical dialog units.

Parameters:
value - size value in vertical dialog units
Returns:
the associated ConstantSize

pixel

public static ConstantSize pixel(int value)
Creates and returns an instance of Size for the specified pixel value.

Parameters:
value - value in pixel
Returns:
the associated ConstantSize

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

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

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

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

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

getUnitConverter

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

Returns:
the current UnitConverter

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-2004 JGoodies Karsten Lentzsch. All Rights Reserved.