Class GroupLayout

java.lang.Object
com.vaadin.featurepack.desktop.layouts.GroupLayout
All Implemented Interfaces:
LayoutManager, Serializable

public class GroupLayout extends Object implements LayoutManager, Serializable
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration of the possible ways ParallelGroup can align its children.
    class 
    Group provides the basis for the two types of operations supported by GroupLayout: laying out components one after another (SequentialGroup) or aligned (ParallelGroup).
    class 
    A Group that aligns and sizes its children.
    class 
    A Group that positions and sizes its elements sequentially, one after another.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Indicates the size from the component or gap should be used for a particular range value.
    static final int
    Indicates the preferred size from the component or gap should be used for a particular range value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GroupLayout(com.vaadin.flow.component.Component host)
    Creates a GroupLayout for the specified Container.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addLayoutComponent(com.vaadin.flow.component.Component comp, Object constraints)
    Adds the specified component to the layout, using the specified constraint object.
    void
    addLayoutComponent(String name, com.vaadin.flow.component.Component comp)
    If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
    createBaselineGroup(boolean resizable, boolean anchorBaselineToTop)
    Creates and returns a ParallelGroup that aligns its elements along the baseline.
    Creates and returns a ParallelGroup with an alignment of Alignment.LEADING.
    Creates and returns a ParallelGroup with the specified alignment.
    createParallelGroup(GroupLayout.Alignment alignment, boolean resizable)
    Creates and returns a ParallelGroup with the specified alignment and resize behavior.
    Creates and returns a SequentialGroup.
    boolean
    Returns true if gaps between the container and components that border the container are automatically created.
    boolean
    Returns true if gaps between components are automatically created.
    boolean
    Returns whether component visibility is considered when sizing and positioning components.
    float
    getLayoutAlignmentX(com.vaadin.flow.component.Component parentContainer)
    Returns the alignment along the x axis.
    float
    getLayoutAlignmentY(com.vaadin.flow.component.Component parentContainer)
    Returns the alignment along the y axis.
    Returns the LayoutStyle used for calculating the preferred gap between components.
    void
    invalidateLayout(com.vaadin.flow.component.Component parentContainer)
    Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
    void
    layoutContainer(com.vaadin.flow.component.Component parentContainer)
    Lays out the specified container.
    void
    linkSize(int axis, com.vaadin.flow.component.Component... components)
    Forces the specified components to have the same size along the specified axis regardless of their preferred, minimum or maximum sizes.
    void
    linkSize(com.vaadin.flow.component.Component... components)
    Forces the specified components to have the same size regardless of their preferred, minimum or maximum sizes.
    maximumLayoutSize(com.vaadin.flow.component.Component parentContainer)
    Calculates the maximum size dimensions for the specified container, given the components it contains.
    minimumLayoutSize(com.vaadin.flow.component.Component parentContainer)
    Calculates the minimum size dimensions for the specified container, given the components it contains.
    preferredLayoutSize(com.vaadin.flow.component.Component parentContainer)
    Calculates the preferred size dimensions for the specified container, given the components it contains.
    void
    removeLayoutComponent(com.vaadin.flow.component.Component component)
    Removes the specified component from the layout.
    void
    replace(com.vaadin.flow.component.Component existingComponent, com.vaadin.flow.component.Component newComponent)
    Replaces an existing component with a new one.
    void
    setAutoCreateContainerGaps(boolean autoCreateContainerPadding)
    Sets whether a gap between the container and components that touch the border of the container should automatically be created.
    void
    setAutoCreateGaps(boolean autoCreatePadding)
    Sets whether a gap between components should automatically be created.
    void
    setComponentGeometryLambdas(Function<com.vaadin.flow.component.Component,Dimension> getSize, Function<com.vaadin.flow.component.Component,Dimension> getMaximumSize, Function<com.vaadin.flow.component.Component,Dimension> getMinimumSize, Function<com.vaadin.flow.component.Component,Dimension> getPreferredSize, Function<com.vaadin.flow.component.Component,Insets> getInsets, BiConsumer<com.vaadin.flow.component.Component,Rectangle> setBounds, BiFunction<com.vaadin.flow.component.Component,Dimension,Integer> getBaseline, Function<com.vaadin.flow.component.Component,Component.BaselineResizeBehavior> getBaselineResizeBehavior)
     
    void
    setHonorsVisibility(boolean honorsVisibility)
    Sets whether component visibility is considered when sizing and positioning components.
    void
    setHonorsVisibility(com.vaadin.flow.component.Component component, Boolean honorsVisibility)
    Sets whether the component's visibility is considered for sizing and positioning.
    void
    Sets the Group that positions and sizes components along the horizontal axis.
    void
    Sets the LayoutStyle used to calculate the preferred gaps between components.
    void
    Sets the Group that positions and sizes components along the vertical axis.
    Returns a string representation of this GroupLayout.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_SIZE

      public static final int DEFAULT_SIZE
      Indicates the size from the component or gap should be used for a particular range value.
      See Also:
    • PREFERRED_SIZE

      public static final int PREFERRED_SIZE
      Indicates the preferred size from the component or gap should be used for a particular range value.
      See Also:
  • Constructor Details

    • GroupLayout

      public GroupLayout(com.vaadin.flow.component.Component host)
      Creates a GroupLayout for the specified Container.
      Parameters:
      host - the Container the GroupLayout is the LayoutManager for
      Throws:
      IllegalArgumentException - if host is null
  • Method Details

    • setHonorsVisibility

      public void setHonorsVisibility(boolean honorsVisibility)
      Sets whether component visibility is considered when sizing and positioning components. A value of true indicates that non-visible components should not be treated as part of the layout. A value of false indicates that components should be positioned and sized regardless of visibility.

      A value of false is useful when the visibility of components is dynamically adjusted and you don't want surrounding components and the sizing to change.

      The specified value is used for components that do not have an explicit visibility specified.

      The default is true.

      Parameters:
      honorsVisibility - whether component visibility is considered when sizing and positioning components
      See Also:
    • getHonorsVisibility

      public boolean getHonorsVisibility()
      Returns whether component visibility is considered when sizing and positioning components.
      Returns:
      whether component visibility is considered when sizing and positioning components
    • setHonorsVisibility

      public void setHonorsVisibility(com.vaadin.flow.component.Component component, Boolean honorsVisibility)
      Sets whether the component's visibility is considered for sizing and positioning. A value of Boolean.TRUE indicates that if component is not visible it should not be treated as part of the layout. A value of false indicates that component is positioned and sized regardless of its visibility. A value of null indicates the value specified by the single argument method setHonorsVisibility should be used.

      If component is not a child of the Container this GroupLayout is managing, it will be added to the Container.

      Parameters:
      component - the component
      honorsVisibility - whether visibility of this component should be considered for sizing and positioning
      Throws:
      IllegalArgumentException - if component is null
      See Also:
    • setAutoCreateGaps

      public void setAutoCreateGaps(boolean autoCreatePadding)
      Sets whether a gap between components should automatically be created. For example, if this is true and you add two components to a SequentialGroup a gap between the two components is automatically be created. The default is false.
      Parameters:
      autoCreatePadding - whether a gap between components is automatically created
    • getAutoCreateGaps

      public boolean getAutoCreateGaps()
      Returns true if gaps between components are automatically created.
      Returns:
      true if gaps between components are automatically created
    • setAutoCreateContainerGaps

      public void setAutoCreateContainerGaps(boolean autoCreateContainerPadding)
      Sets whether a gap between the container and components that touch the border of the container should automatically be created. The default is false.
      Parameters:
      autoCreateContainerPadding - whether a gap between the container and components that touch the border of the container should automatically be created
    • getAutoCreateContainerGaps

      public boolean getAutoCreateContainerGaps()
      Returns true if gaps between the container and components that border the container are automatically created.
      Returns:
      true if gaps between the container and components that border the container are automatically created
    • setHorizontalGroup

      public void setHorizontalGroup(GroupLayout.Group group)
      Sets the Group that positions and sizes components along the horizontal axis.
      Parameters:
      group - the Group that positions and sizes components along the horizontal axis
      Throws:
      IllegalArgumentException - if group is null
    • setVerticalGroup

      public void setVerticalGroup(GroupLayout.Group group)
      Sets the Group that positions and sizes components along the vertical axis.
      Parameters:
      group - the Group that positions and sizes components along the vertical axis
      Throws:
      IllegalArgumentException - if group is null
    • createSequentialGroup

      public GroupLayout.SequentialGroup createSequentialGroup()
      Creates and returns a SequentialGroup.
      Returns:
      a new SequentialGroup
    • createParallelGroup

      public GroupLayout.ParallelGroup createParallelGroup()
      Creates and returns a ParallelGroup with an alignment of Alignment.LEADING. This is a cover method for the more general createParallelGroup(Alignment) method.
      Returns:
      a new ParallelGroup
      See Also:
    • createParallelGroup

      public GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment)
      Creates and returns a ParallelGroup with the specified alignment. This is a cover method for the more general createParallelGroup(Alignment,boolean) method with true supplied for the second argument.
      Parameters:
      alignment - the alignment for the elements of the group
      Returns:
      a new ParallelGroup
      Throws:
      IllegalArgumentException - if alignment is null
      See Also:
    • createParallelGroup

      public GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment, boolean resizable)
      Creates and returns a ParallelGroup with the specified alignment and resize behavior. The alignment argument specifies how children elements are positioned that do not fill the group. For example, if a ParallelGroup with an alignment of TRAILING is given 100 and a child only needs 50, the child is positioned at the position 50 (with a component orientation of left-to-right).

      Baseline alignment is only useful when used along the vertical axis. A ParallelGroup created with a baseline alignment along the horizontal axis is treated as LEADING.

      Refer to ParallelGroup for details on the behavior of baseline groups.

      Parameters:
      alignment - the alignment for the elements of the group
      resizable - true if the group is resizable; if the group is not resizable the preferred size is used for the minimum and maximum size of the group
      Returns:
      a new ParallelGroup
      Throws:
      IllegalArgumentException - if alignment is null
      See Also:
    • createBaselineGroup

      public GroupLayout.ParallelGroup createBaselineGroup(boolean resizable, boolean anchorBaselineToTop)
      Creates and returns a ParallelGroup that aligns its elements along the baseline.
      Parameters:
      resizable - whether the group is resizable
      anchorBaselineToTop - whether the baseline is anchored to the top or bottom of the group
      Returns:
      the ParallelGroup
      See Also:
    • linkSize

      public void linkSize(com.vaadin.flow.component.Component... components)
      Forces the specified components to have the same size regardless of their preferred, minimum or maximum sizes. Components that are linked are given the maximum of the preferred size of each of the linked components. For example, if you link two components with a preferred width of 10 and 20, both components are given a width of 20.

      This can be used multiple times to force any number of components to share the same size.

      Linked Components are not be resizable.

      Parameters:
      components - the Components that are to have the same size
      Throws:
      IllegalArgumentException - if components is null, or contains null
      See Also:
    • linkSize

      public void linkSize(int axis, com.vaadin.flow.component.Component... components)
      Forces the specified components to have the same size along the specified axis regardless of their preferred, minimum or maximum sizes. Components that are linked are given the maximum of the preferred size of each of the linked components. For example, if you link two components along the horizontal axis and the preferred width is 10 and 20, both components are given a width of 20.

      This can be used multiple times to force any number of components to share the same size.

      Linked Components are not be resizable.

      Parameters:
      axis - the axis to link the size along; one of SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
      components - the Components that are to have the same size
      Throws:
      IllegalArgumentException - if components is null, or contains null; or axis is not SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
    • replace

      public void replace(com.vaadin.flow.component.Component existingComponent, com.vaadin.flow.component.Component newComponent)
      Replaces an existing component with a new one.
      Parameters:
      existingComponent - the component that should be removed and replaced with newComponent
      newComponent - the component to put in existingComponent's place
      Throws:
      IllegalArgumentException - if either of the components are null or existingComponent is not being managed by this layout manager
    • setLayoutStyle

      public void setLayoutStyle(LayoutStyle layoutStyle)
      Sets the LayoutStyle used to calculate the preferred gaps between components. A value of null indicates the shared instance of LayoutStyle should be used.
      Parameters:
      layoutStyle - the LayoutStyle to use
      See Also:
    • getLayoutStyle

      public LayoutStyle getLayoutStyle()
      Returns the LayoutStyle used for calculating the preferred gap between components. This returns the value specified to setLayoutStyle, which may be null.
      Returns:
      the LayoutStyle used for calculating the preferred gap between components
    • toString

      public String toString()
      Returns a string representation of this GroupLayout. This method is intended to be used for debugging purposes, and the content and format of the returned string may vary between implementations.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this GroupLayout
    • addLayoutComponent

      public void addLayoutComponent(com.vaadin.flow.component.Component comp, Object constraints)
      Description copied from interface: LayoutManager
      Adds the specified component to the layout, using the specified constraint object.
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      comp - the component to be added
      constraints - where/how the component is added to the layout.
    • maximumLayoutSize

      public Dimension maximumLayoutSize(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Calculates the maximum size dimensions for the specified container, given the components it contains.
      Specified by:
      maximumLayoutSize in interface LayoutManager
      Returns:
      the maximum size of the container
      See Also:
    • getLayoutAlignmentX

      public float getLayoutAlignmentX(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentX in interface LayoutManager
      Returns:
      the x-axis alignment preference
    • getLayoutAlignmentY

      public float getLayoutAlignmentY(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentY in interface LayoutManager
      Returns:
      the y-axis alignment preference
    • invalidateLayout

      public void invalidateLayout(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
      Specified by:
      invalidateLayout in interface LayoutManager
    • addLayoutComponent

      public void addLayoutComponent(String name, com.vaadin.flow.component.Component comp)
      Description copied from interface: LayoutManager
      If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      name - the string to be associated with the component
      comp - the component to be added
    • removeLayoutComponent

      public void removeLayoutComponent(com.vaadin.flow.component.Component component)
      Description copied from interface: LayoutManager
      Removes the specified component from the layout.
      Specified by:
      removeLayoutComponent in interface LayoutManager
    • preferredLayoutSize

      public Dimension preferredLayoutSize(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Calculates the preferred size dimensions for the specified container, given the components it contains.
      Specified by:
      preferredLayoutSize in interface LayoutManager
      Returns:
      the preferred dimension for the container
      See Also:
    • minimumLayoutSize

      public Dimension minimumLayoutSize(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Calculates the minimum size dimensions for the specified container, given the components it contains.
      Specified by:
      minimumLayoutSize in interface LayoutManager
      Returns:
      the minimum dimension for the container
      See Also:
    • layoutContainer

      public void layoutContainer(com.vaadin.flow.component.Component parentContainer)
      Description copied from interface: LayoutManager
      Lays out the specified container.
      Specified by:
      layoutContainer in interface LayoutManager
    • setComponentGeometryLambdas

      public void setComponentGeometryLambdas(Function<com.vaadin.flow.component.Component,Dimension> getSize, Function<com.vaadin.flow.component.Component,Dimension> getMaximumSize, Function<com.vaadin.flow.component.Component,Dimension> getMinimumSize, Function<com.vaadin.flow.component.Component,Dimension> getPreferredSize, Function<com.vaadin.flow.component.Component,Insets> getInsets, BiConsumer<com.vaadin.flow.component.Component,Rectangle> setBounds, BiFunction<com.vaadin.flow.component.Component,Dimension,Integer> getBaseline, Function<com.vaadin.flow.component.Component,Component.BaselineResizeBehavior> getBaselineResizeBehavior)