Class ConstantSize

  • All Implemented Interfaces:
    Size, java.io.Serializable

    public final class ConstantSize
    extends java.lang.Object
    implements Size, java.io.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:

    Size units
    Unit   Abbreviation   Size
    Millimetermm0.1 cm
    Centimetercm10.0 mm
    Inchin25.4 mm
    DTP Pointpt1/72 in
    Pixelpx1/(resolution in dpi) in
    Dialog Unitdluhonors l&f, resolution, and dialog font size

    Examples:

     Sizes.ZERO;
     Sizes.DLUX9;
     Sizes.dluX(42);
     Sizes.pixel(99);
     
    Version:
    $Revision$
    Author:
    Karsten Lentzsch
    See Also:
    Size, Sizes, Serialized Form
    • Method Detail

      • getPixelSize

        public int getPixelSize​(java.awt.Component component)
        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​(java.awt.Container container,
                               java.util.List components,
                               com.jgoodies.forms.layout.FormLayout.Measure minMeasure,
                               com.jgoodies.forms.layout.FormLayout.Measure prefMeasure,
                               com.jgoodies.forms.layout.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 interface Size
        Parameters:
        container - the layout container
        components - the list of components used to compute the size
        minMeasure - the measure that determines the minimum sizes
        prefMeasure - the measure that determines the preferred sizes
        defaultMeasure - the measure that determines the default sizes
        Returns:
        the computed maximum size in pixel
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether some other ConstantSize is "equal to" this one.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the Object with which to compare
        Returns:
        true if this object is the same as the obj argument; false otherwise.
        See Also:
        Object.hashCode(), Hashtable
      • 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 by java.util.Hashtable.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value for this object.
        See Also:
        Object.equals(java.lang.Object), Hashtable
      • toString

        public java.lang.String toString()
        Returns a string representation of this size object. Note: The string representation may change at any time. It is strongly recommended to not use this string for parsing purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the constant size