Class Sizes

java.lang.Object
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.19 $
See Also:
  • Field Details

  • Constructor Details

    • Sizes

      private Sizes()
  • Method Details

    • 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)
      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

      public static ConstantSize dluY(int value)
      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

      public static ConstantSize pixel(int value)
      Creates and returns a ConstantSize 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, or if both lowerBound and upperBound are 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
    • getDefaultUnit

      public static ConstantSize.Unit 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

      public static void setDefaultUnit(ConstantSize.Unit unit)
      Sets the Unit that shall be used if an encoded ConstantSize provides no unit string.
      Parameters:
      unit - the new default Unit, null for dialog units
      Throws:
      IllegalArgumentException - if unit is ConstantSize.DLUX or ConstantSize.DLUY.
      Since:
      1.2