com.jgoodies.forms.layout

## Class FormSpec

- java.lang.Object
- - com.jgoodies.forms.layout.FormSpec

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    ColumnSpec, RowSpec

      public abstract class FormSpec
      extends Object
      implements Serializable

  An abstract class that specifies columns and rows in FormLayout by their default alignment, start size and resizing behavior. API users will use the subclasses `ColumnSpec` and `RowSpec`.

  Also implements the parser for encoded column and row specifications and provides parser convenience behavior for its subclasses ColumnSpec and RowSpec.

  TODO: Consider extracting the parser role to a separate class.

  Version:
    $Revision: 1.25 $
  Author:
    Karsten Lentzsch
  See Also:
    `ColumnSpec`, `RowSpec`, `FormLayout`, `CellConstraints`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FormSpec.DefaultAlignment` An ordinal-based serializable typesafe enumeration for the column and row default alignment types.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static double` | `DEFAULT_GROW` The default resize weight.
    `static double` | `NO_GROW` Gives a column or row a fixed size.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FormSpec(FormSpec.DefaultAlignment defaultAlignment, Size size, double resizeWeight)` Constructs a `FormSpec` for the given default alignment, size, and resize weight.
    `protected` | `FormSpec(FormSpec.DefaultAlignment defaultAlignment, String encodedDescription)` Constructs a FormSpec from the specified encoded description.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `encode()` Returns a short and parseable string representation of this form specification.
    `FormSpec.DefaultAlignment` | `getDefaultAlignment()` Returns the default alignment.
    `boolean` | `getDefaultAlignmentExplictlySet()` Returns whether the default alignment has been explicitly set or not.
    `double` | `getResizeWeight()` Returns the current resize weight.
    `Size` | `getSize()` Returns the size.
    `String` | `toShortString()` Returns a string representation of this form specification.
    `String` | `toString()` Returns a string representation of this form specification.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### NO_GROW

          public static final double NO_GROW

      Gives a column or row a fixed size.
      See Also:
        Constant Field Values

    - #### DEFAULT_GROW

          public static final double DEFAULT_GROW

      The default resize weight.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FormSpec

          protected FormSpec(FormSpec.DefaultAlignment defaultAlignment,
                  Size size,
                  double resizeWeight)

      Constructs a `FormSpec` for the given default alignment, size, and resize weight. The resize weight must be a non-negative double; you can use `NONE` as a convenience value for no resize.
      Parameters:
        `defaultAlignment` - the spec's default alignment
        `size` - a constant, component or bounded size
        `resizeWeight` - the spec resize weight
      Throws:
        `NullPointerException` - if the `size` is `null`
        `IllegalArgumentException` - if the `resizeWeight` is negative

    - #### FormSpec

          protected FormSpec(FormSpec.DefaultAlignment defaultAlignment,
                  String encodedDescription)

      Constructs a FormSpec from the specified encoded description. The description will be parsed to set initial values.
      Parameters:
        `defaultAlignment` - the default alignment
        `encodedDescription` - the encoded description

  - ### Method Detail

    - #### getDefaultAlignment

          public final FormSpec.DefaultAlignment getDefaultAlignment()

      Returns the default alignment.
      Returns:
        the default alignment

    - #### getDefaultAlignmentExplictlySet

          public final boolean getDefaultAlignmentExplictlySet()

      Returns whether the default alignment has been explicitly set or not.
      Returns:
        `true` if the default alignment has been provided during the parse process, `false` if the default alignment has been set by the constructor at the instance creation time

    - #### getSize

          public final Size getSize()

      Returns the size.
      Returns:
        the size

    - #### getResizeWeight

          public final double getResizeWeight()

      Returns the current resize weight.
      Returns:
        the resize weight.

    - #### toString

          public final String toString()

      Returns a string representation of this form specification. The string representation consists of three elements separated by a colon (`":"`), first the alignment, second the size, and third the resize spec.

      This method does not return an encoded version of this object; the contrary is the case. Many instances will return a string that cannot be parsed.

      Note: The string representation may change at any time. For parsing use `encode()` instead.

      Overrides:
        `toString` in class `Object`
      Returns:
        a string representation of the form specification.

    - #### toShortString

          public final String toShortString()

      Returns a string representation of this form specification. The string representation consists of three elements separated by a colon (`":"`), first the alignment, second the size, and third the resize spec.

      This method does not return an encoded version of this object; the contrary is the case. Many instances will return a string that cannot be parsed.

      Note: The string representation may change at any time. For parsing use `encode()` instead.

      Returns:
        a string representation of the form specification.

    - #### encode

          public final String encode()

      Returns a short and parseable string representation of this form specification. The string will omit the alignment and resize specifications if these are the default values.

      Returns:
        a string representation of the form specification.
      Since:
        1.2
      See Also:
        `for a more verbose string representation`

Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.