MeltingLayout
Date: 2014-08-08

meltinggui

## Class MeltingLayout

- java.lang.Object
- - meltinggui.MeltingLayout

- All Implemented Interfaces:
    java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

      public class MeltingLayout
      extends java.lang.Object
      implements java.awt.LayoutManager2, java.io.Serializable

  A layout manager designed for use with label/text pairs. Components added to a container with this layout are constrained to belong either to a label group or to an input group; the groups are made up of consecutive components that have been constrained to belong to the same group. Each new label group starts at the left hand edge of a new line; the input group following a label group is placed directly to the right of it ('appended') if there is space, or on a new line ('wrapped') if there isn't. In either case, the first component in the group is resized to take up all available space. The left-hand edges of the appended input groups are aligned. No attempt is made to further wrap input groups that have already been wrapped and are too long for the line they have been put on.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MeltingLayout.ComponentGroupType` The two possible component groups: Label group and Input group.
    `static class` | `MeltingLayout.Size` Different types of sizes that we might want to find: maximum size, preferred size and minimum size.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static MeltingLayout.ComponentGroupType` | `INPUT_GROUP` Component group type: input group.
    `static MeltingLayout.ComponentGroupType` | `LABEL_GROUP` Component group type: label group.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MeltingLayout(java.awt.Container parent)` Constructs a new MELTING layout with no gaps between components.
    `MeltingLayout(java.awt.Container parent, int hgap, int vgap)` Constructs a MELTING layout with the specified gaps between components.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLayoutComponent(java.awt.Component component, java.lang.Object constraints)` Adds a component to the layout, specifying that it belongs either to the label group or to the input group, according to the constraint given.
    `void` | `addLayoutComponent(java.lang.String name, java.awt.Component component)` Deprecated. Only here because the interface demands it. Replaced by `addLayoutComponent(Component, Object)`.
    `void` | `checkContainer(java.awt.Container target)` Checks that a supplied container is the parent container for this layout.
    `float` | `getLayoutAlignmentX(java.awt.Container parent)` Returns the alignment along the x axis.
    `float` | `getLayoutAlignmentY(java.awt.Container parent)` Returns the alignment along the y axis.
    `void` | `invalidateLayout(java.awt.Container parent)` Invalidates the layout, indicating that any cached information should be discarded.
    `void` | `layoutContainer(java.awt.Container target)` Lays out the container argument using this MELTING layout.
    `java.awt.Dimension` | `maximumLayoutSize(java.awt.Container parent)` Returns the maximum size for the specified container.
    `java.awt.Dimension` | `minimumLayoutSize(java.awt.Container parent)` Returns the minimum size for the specified container.
    `java.awt.Dimension` | `preferredLayoutSize(java.awt.Container parent)` Returns the preferred size for the specified container.
    `void` | `removeLayoutComponent(java.awt.Component component)` Removes the specified component from this MELTING layout.

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

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

- - ### Field Detail

    - #### LABEL_GROUP

          public static final MeltingLayout.ComponentGroupType LABEL_GROUP

      Component group type: label group.

    - #### INPUT_GROUP

          public static final MeltingLayout.ComponentGroupType INPUT_GROUP

      Component group type: input group.

  - ### Constructor Detail

    - #### MeltingLayout

          public MeltingLayout(java.awt.Container parent)

      Constructs a new MELTING layout with no gaps between components.
      Parameters:
        `parent` - the parent `Container`.

    - #### MeltingLayout

          public MeltingLayout(java.awt.Container parent,
                       int hgap,
                       int vgap)

      Constructs a MELTING layout with the specified gaps between components. The horizontal gap is specified by `hgap` and the vertical gap is specified by `vgap`.
      Parameters:
        `parent` - the parent `Container`.
        `hgap` - the horizontal gap.
        `vgap` - the vertical gap.

  - ### Method Detail

    - #### addLayoutComponent

          public void addLayoutComponent(java.awt.Component component,
                                java.lang.Object constraints)

      Adds a component to the layout, specifying that it belongs either to the label group or to the input group, according to the constraint given. Most applications do not call this method directly; instead, it is called whenever a new component is added to a container using the `Container.add` method with the same argument types.
      Specified by:
        `addLayoutComponent` in interface `java.awt.LayoutManager2`
      Parameters:
        `component` - the component to be added.
        `constraints` - an object that specifies whether the new component should be added to the label group, or whether it should be added to the input group.
      Throws:
        `java.lang.IllegalArgumentException` - if the constraint object is not an integer, or if it does not refer to one of the two groups.

    - #### addLayoutComponent

          @Deprecated
          public void addLayoutComponent(java.lang.String name,
                                           java.awt.Component component)

      Deprecated. Only here because the interface demands it. Replaced by `addLayoutComponent(Component, Object)`.
      Specified by:
        `addLayoutComponent` in interface `java.awt.LayoutManager`

    - #### removeLayoutComponent

          public void removeLayoutComponent(java.awt.Component component)

      Removes the specified component from this MELTING layout. This method is called when a container calls its `remove` or `removeAll` methods. Most applications do not call this method directly.
      Specified by:
        `removeLayoutComponent` in interface `java.awt.LayoutManager`
      Parameters:
        `component` - the component to be removed.

    - #### preferredLayoutSize

          public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)

      Returns the preferred size for the specified container.
      Specified by:
        `preferredLayoutSize` in interface `java.awt.LayoutManager`
      Parameters:
        `parent` - The container to return the preferred size for.
      Returns:
        The preferred size for the parent container.

    - #### minimumLayoutSize

          public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)

      Returns the minimum size for the specified container.
      Specified by:
        `minimumLayoutSize` in interface `java.awt.LayoutManager`
      Parameters:
        `parent` - The container to return the minimum size for.
      Returns:
        The minimum size for the parent container.

    - #### maximumLayoutSize

          public java.awt.Dimension maximumLayoutSize(java.awt.Container parent)

      Returns the maximum size for the specified container.
      Specified by:
        `maximumLayoutSize` in interface `java.awt.LayoutManager2`
      Parameters:
        `parent` - The container to return the maximum size for.
      Returns:
        The maximum size for the parent container.

    - #### layoutContainer

          public void layoutContainer(java.awt.Container target)

      Lays out the container argument using this MELTING layout.

      The method moves through each label group-input group pair (a 'component line') and decides whether it has space to put the label group and the input group on the same line. If it does, then the left hand edge of the input group is aligned with the left hand edges of all other appended input groups. Otherwise, the input group is placed on a new line. In both cases, the input group is resized in order to take up all available space, or left alone if there is not enough space.

      Specified by:
        `layoutContainer` in interface `java.awt.LayoutManager`
      Parameters:
        `target` - The container in which to do the layout.

    - #### getLayoutAlignmentX

          public float getLayoutAlignmentX(java.awt.Container parent)

      Returns the alignment along the x axis.
      Specified by:
        `getLayoutAlignmentX` in interface `java.awt.LayoutManager2`
      Parameters:
        `parent` - The parent container.

    - #### getLayoutAlignmentY

          public float getLayoutAlignmentY(java.awt.Container parent)

      Returns the alignment along the y axis.
      Specified by:
        `getLayoutAlignmentY` in interface `java.awt.LayoutManager2`
      Parameters:
        `parent` - The parent container.

    - #### invalidateLayout

          public void invalidateLayout(java.awt.Container parent)

      Invalidates the layout, indicating that any cached information should be discarded.
      Specified by:
        `invalidateLayout` in interface `java.awt.LayoutManager2`
      Parameters:
        `parent` - The parent container.

    - #### checkContainer

          public void checkContainer(java.awt.Container target)

      Checks that a supplied container is the parent container for this layout.