Class Sizes
java.lang.Object
com.jgoodies.forms.layout.Sizes
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.19 $
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classAn ordinal-based serializable typesafe enumeration that implements theSizeinterface for the component sizes: min, pref, default. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Sizes.ComponentSizeUse 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.private static ConstantSize.UnitHolds the Unit that is used if no Unit is provided in encoded ConstantSizes.static final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSize21 horizontal dialog units.static final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSize21 vertical dialog units.static final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final ConstantSizestatic final Sizes.ComponentSizeUse the maximum of all component minimum sizes as column or row size.static final Sizes.ComponentSizeUse the maximum of all component preferred sizes as column or row size.private static UnitConverterHolds the current converter that maps non-pixel sizes to pixels.private static final Sizes.ComponentSize[]An array of all enumeration values used to canonicalize deserialized component sizes.static final ConstantSize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SizeCreates 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 ConstantSizeCreates and returns an instance ofConstantSizefrom 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 ConstantSize.UnitReturns the Unit that is used if an encoded ConstantSize contains no unit string.static UnitConverterReturns the currentUnitConverter.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 voidSets the Unit that shall be used if an encoded ConstantSize provides no unit string.static voidsetUnitConverter(UnitConverter newUnitConverter) Sets a new UnitConverter that will be used to convert font-dependent sizes to pixel sizes.
-
Field Details
-
ZERO
-
DLUX1
-
DLUX2
-
DLUX3
-
DLUX4
-
DLUX5
-
DLUX6
-
DLUX7
-
DLUX8
-
DLUX9
-
DLUX11
-
DLUX14
-
DLUX21
-
DLUY1
-
DLUY2
-
DLUY3
-
DLUY4
-
DLUY5
-
DLUY6
-
DLUY7
-
DLUY8
-
DLUY9
-
DLUY11
-
DLUY14
-
DLUY21
-
MINIMUM
Use the maximum of all component minimum sizes as column or row size. -
PREFERRED
Use the maximum of all component preferred sizes as column or row size. -
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. -
VALUES
An array of all enumeration values used to canonicalize deserialized component sizes. -
unitConverter
Holds the current converter that maps non-pixel sizes to pixels.- See Also:
-
defaultUnit
Holds the Unit that is used if no Unit is provided in encoded ConstantSizes.- See Also:
-
-
Constructor Details
-
Sizes
private Sizes()
-
-
Method Details
-
constant
Creates and returns an instance ofConstantSizefrom the given encoded size and unit description.- Parameters:
encodedValueAndUnit- value and unit in string representationhorizontal- true for horizontal, false for vertical- Returns:
- a
ConstantSizefor the given value and unit
-
dluX
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
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
-
pixel
Creates and returns a ConstantSize for the specified pixel value.- Parameters:
value- value in pixel- Returns:
- the associated
ConstantSize
-
bounded
Creates and returns a BoundedSize for the given basis using the specified lower and upper bounds.- Parameters:
basis- the base sizelowerBound- the lower bound sizeupperBound- the upper bound size- Returns:
- a
BoundedSizefor the given basis and bounds - Throws:
NullPointerException- ifbasisisnull, or if bothlowerBoundandupperBoundarenull.
-
inchAsPixel
Converts Inches and returns pixels using the specified resolution.- Parameters:
in- the Inchescomponent- the component that provides the graphics object- Returns:
- the given Inches as pixels
-
millimeterAsPixel
Converts Millimeters and returns pixels using the resolution of the given component's graphics object.- Parameters:
mm- Millimeterscomponent- the component that provides the graphics object- Returns:
- the given Millimeters as pixels
-
centimeterAsPixel
Converts Centimeters and returns pixels using the resolution of the given component's graphics object.- Parameters:
cm- Centimeterscomponent- the component that provides the graphics object- Returns:
- the given Centimeters as pixels
-
pointAsPixel
Converts DTP Points and returns pixels using the resolution of the given component's graphics object.- Parameters:
pt- DTP Pointscomponent- the component that provides the graphics object- Returns:
- the given Points as pixels
-
dialogUnitXAsPixel
Converts horizontal dialog units and returns pixels. Honors the resolution, dialog font size, platform, and l&f.- Parameters:
dluX- the horizontal dialog unitscomponent- the component that provides the graphics object- Returns:
- the given horizontal dialog units as pixels
-
dialogUnitYAsPixel
Converts vertical dialog units and returns pixels. Honors the resolution, dialog font size, platform, and l&f.- Parameters:
dluY- the vertical dialog unitscomponent- the component that provides the graphics object- Returns:
- the given vertical dialog units as pixels
-
getUnitConverter
Returns the currentUnitConverter. If it has not been initialized before it will get an instance ofDefaultUnitConverter.- Returns:
- the current
UnitConverter
-
setUnitConverter
Sets a new UnitConverter that will be used to convert font-dependent sizes to pixel sizes.- Parameters:
newUnitConverter- the unit converter to be set
-
getDefaultUnit
Returns the Unit that is used if an encoded ConstantSize contains no unit string.- Returns:
- the Unit if no unit string is provided
- Since:
- 1.2
-
setDefaultUnit
Sets the Unit that shall be used if an encoded ConstantSize provides no unit string.- Parameters:
unit- the new default Unit,nullfor dialog units- Throws:
IllegalArgumentException- ifunitisConstantSize.DLUXorConstantSize.DLUY.- Since:
- 1.2
-