Class PrototypeSize

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

    public final class PrototypeSize
    extends java.lang.Object
    implements Size, java.io.Serializable
    A Size implementation that computes its width and height by a prototype String.

    Examples:

     new PrototypeSize("123-456-789");
     new FormLayout("p, 2dlu, 'MMMM'");
     
    Since:
    1.2
    Version:
    $Revision: 1.7 $
    See Also:
    Size, Sizes, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String prototype  
    • Constructor Summary

      Constructors 
      Constructor Description
      PrototypeSize​(java.lang.String prototype)
      Constructs a PrototypeSize for the given String.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean compressible()
      Describes if this Size can be compressed, if container space gets scarce.
      java.lang.String encode()
      Returns a parseable string representation of this prototype size.
      boolean equals​(java.lang.Object o)
      Indicates whether some other ConstantSize is "equal to" this one.
      java.lang.String getPrototype()
      Returns this size's prototype string.
      int hashCode()
      Returns a hash code value for the object.
      int maximumSize​(java.awt.Container container, java.util.List components, FormLayout.Measure minMeasure, FormLayout.Measure prefMeasure, FormLayout.Measure defaultMeasure)
      Computes and returns the width of this Size's prototype in pixel.
      java.lang.String toString()
      Returns a string representation of this size object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • prototype

        private final java.lang.String prototype
    • Constructor Detail

      • PrototypeSize

        public PrototypeSize​(java.lang.String prototype)
        Constructs a PrototypeSize for the given String.
        Parameters:
        prototype - the String used to compute the width and height.
        Throws:
        java.lang.NullPointerException - if prototype is null.
        Since:
        1.2
    • Method Detail

      • getPrototype

        public java.lang.String getPrototype()
        Returns this size's prototype string.
        Returns:
        the prototype string
      • maximumSize

        public int maximumSize​(java.awt.Container container,
                               java.util.List components,
                               FormLayout.Measure minMeasure,
                               FormLayout.Measure prefMeasure,
                               FormLayout.Measure defaultMeasure)
        Computes and returns the width of this Size's prototype in pixel. Ignores the component list and measures. Obtains the FontMetrics from the given layout container for the default dialog font provided by DefaultUnitConverter.getDefaultDialogFont().

        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 stringWidth for this size's prototype string computed by the container's FontMetrics for the DefaultUnitConverter's default dialog font
      • 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.

        PrototypeSizes are incompressible.

        Specified by:
        compressible in interface Size
        Returns:
        false
      • encode

        public java.lang.String encode()
        Returns a parseable string representation of this prototype size.
        Specified by:
        encode in interface Size
        Returns:
        a String that can be parsed by the Forms parser
      • 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: This string representation may change at any time. It is intended for debugging purposes. For parsing, use encode() instead.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the constant size