Package com.jgoodies.forms.layout
Class ConstantSize
java.lang.Object
com.jgoodies.forms.layout.ConstantSize
- All Implemented Interfaces:
Size
,Serializable
An implementation of the
Size
interface that represents constant
sizes described by a value and unit, for example:
10 pixel, 15 point or 4 dialog units.
You can get instances of ConstantSize
using
the factory methods and constants in the Sizes
class.
Logical constant sizes that vary with the current layout style
are delivered by the LayoutStyle
class.This class supports different size units:
Unit | Abbreviation | Size |
Millimeter | mm | 0.1 cm |
Centimeter | cm | 10.0 mm |
Inch | in | 25.4 mm |
DTP Point | pt | 1/72 in |
Pixel | px | 1/(resolution in dpi) in |
Dialog Unit | dlu | honors l&f, resolution, and dialog font size |
Examples:
Sizes.ZERO; Sizes.DLUX9; Sizes.dluX(42); Sizes.pixel(99);
- Version:
- $Revision: 1.18 $
- Author:
- Karsten Lentzsch
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
An ordinal-based serializable typesafe enumeration for units as used in instances ofConstantSize
. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
static final ConstantSize.Unit
-
Constructor Summary
ConstructorsConstructorDescriptionConstantSize
(double value, ConstantSize.Unit unit) Constructs a ConstantSize for the given size and unit.ConstantSize
(int value, ConstantSize.Unit unit) Constructs a ConstantSize for the given size and unit. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Describes if this Size can be compressed, if container space gets scarce.encode()
Returns a parseable string representation of this constant size.boolean
Indicates whether some other ConstantSize is "equal to" this one.int
getPixelSize
(Component component) Converts the size if necessary and returns the value in pixels.getUnit()
Returns this size's unit.double
getValue()
Returns this size's value.int
hashCode()
Returns a hash code value for the object.int
maximumSize
(Container container, List components, FormLayout.Measure minMeasure, FormLayout.Measure prefMeasure, FormLayout.Measure defaultMeasure) Returns this size as pixel size.toString()
Returns a string representation of this size object.
-
Field Details
-
PIXEL
-
POINT
-
DIALOG_UNITS_X
-
DIALOG_UNITS_Y
-
MILLIMETER
-
CENTIMETER
-
INCH
-
PX
-
PT
-
DLUX
-
DLUY
-
MM
-
CM
-
IN
-
-
Constructor Details
-
ConstantSize
Constructs a ConstantSize for the given size and unit.- Parameters:
value
- the size value interpreted in the given unitsunit
- the size's unit- Since:
- 1.1
-
ConstantSize
Constructs a ConstantSize for the given size and unit.- Parameters:
value
- the size value interpreted in the given unitsunit
- the size's unit- Since:
- 1.1
-
-
Method Details
-
getValue
public double getValue()Returns this size's value.- Returns:
- the size value
- Since:
- 1.1
-
getUnit
Returns this size's unit.- Returns:
- the size unit
- Since:
- 1.1
-
getPixelSize
Converts the size if necessary and returns the value in pixels.- Parameters:
component
- the associated component- Returns:
- the size in pixels
-
maximumSize
public int maximumSize(Container container, List components, FormLayout.Measure minMeasure, FormLayout.Measure prefMeasure, FormLayout.Measure defaultMeasure) Returns this size as pixel size. Neither requires the component list nor the specified measures.Invoked by
FormSpec
to determine the size of a column or row.- Specified by:
maximumSize
in interfaceSize
- Parameters:
container
- the layout containercomponents
- the list of components used to compute the sizeminMeasure
- the measure that determines the minimum sizesprefMeasure
- the measure that determines the preferred sizesdefaultMeasure
- the measure that determines the default sizes- Returns:
- the computed maximum size in pixel
-
compressible
public boolean compressible()Describes if this Size can be compressed, if container space gets scarce. Used by the FormLayout size computations in#compressedSizes
to check whether a column or row can be compressed or not.ConstantSizes are incompressible.
- Specified by:
compressible
in interfaceSize
- Returns:
false
- Since:
- 1.1
-
equals
Indicates whether some other ConstantSize is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided byjava.util.Hashtable
. -
toString
Returns a string representation of this size object. Note: This string representation may change at any time. It is intended for debugging purposes. For parsing, useencode()
instead. -
encode
Returns a parseable string representation of this constant size.
-