Class GroupLayout
- All Implemented Interfaces:
LayoutManager,Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of the possible waysParallelGroupcan align its children.classGroupprovides the basis for the two types of operations supported byGroupLayout: laying out components one after another (SequentialGroup) or aligned (ParallelGroup).classAGroupthat aligns and sizes its children.classAGroupthat positions and sizes its elements sequentially, one after another. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates the size from the component or gap should be used for a particular range value.static final intIndicates the preferred size from the component or gap should be used for a particular range value. -
Constructor Summary
ConstructorsConstructorDescriptionGroupLayout(com.vaadin.flow.component.Component host) Creates aGroupLayoutfor the specifiedContainer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(com.vaadin.flow.component.Component comp, Object constraints) Adds the specified component to the layout, using the specified constraint object.voidaddLayoutComponent(String name, com.vaadin.flow.component.Component comp) If the layout manager uses a per-component string, adds the componentcompto the layout, associating it with the string specified byname.createBaselineGroup(boolean resizable, boolean anchorBaselineToTop) Creates and returns aParallelGroupthat aligns its elements along the baseline.Creates and returns aParallelGroupwith an alignment ofAlignment.LEADING.createParallelGroup(GroupLayout.Alignment alignment) Creates and returns aParallelGroupwith the specified alignment.createParallelGroup(GroupLayout.Alignment alignment, boolean resizable) Creates and returns aParallelGroupwith the specified alignment and resize behavior.Creates and returns aSequentialGroup.booleanReturnstrueif gaps between the container and components that border the container are automatically created.booleanReturnstrueif gaps between components are automatically created.booleanReturns whether component visibility is considered when sizing and positioning components.floatgetLayoutAlignmentX(com.vaadin.flow.component.Component parentContainer) Returns the alignment along the x axis.floatgetLayoutAlignmentY(com.vaadin.flow.component.Component parentContainer) Returns the alignment along the y axis.Returns theLayoutStyleused for calculating the preferred gap between components.voidinvalidateLayout(com.vaadin.flow.component.Component parentContainer) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.voidlayoutContainer(com.vaadin.flow.component.Component parentContainer) Lays out the specified container.voidlinkSize(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.voidlinkSize(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.voidremoveLayoutComponent(com.vaadin.flow.component.Component component) Removes the specified component from the layout.voidreplace(com.vaadin.flow.component.Component existingComponent, com.vaadin.flow.component.Component newComponent) Replaces an existing component with a new one.voidsetAutoCreateContainerGaps(boolean autoCreateContainerPadding) Sets whether a gap between the container and components that touch the border of the container should automatically be created.voidsetAutoCreateGaps(boolean autoCreatePadding) Sets whether a gap between components should automatically be created.voidsetComponentGeometryLambdas(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) voidsetHonorsVisibility(boolean honorsVisibility) Sets whether component visibility is considered when sizing and positioning components.voidsetHonorsVisibility(com.vaadin.flow.component.Component component, Boolean honorsVisibility) Sets whether the component's visibility is considered for sizing and positioning.voidSets theGroupthat positions and sizes components along the horizontal axis.voidsetLayoutStyle(LayoutStyle layoutStyle) Sets theLayoutStyleused to calculate the preferred gaps between components.voidSets theGroupthat positions and sizes components along the vertical axis.toString()Returns a string representation of thisGroupLayout.
-
Field Details
-
DEFAULT_SIZE
public static final int DEFAULT_SIZEIndicates the size from the component or gap should be used for a particular range value.- See Also:
-
PREFERRED_SIZE
public static final int PREFERRED_SIZEIndicates 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 aGroupLayoutfor the specifiedContainer.- Parameters:
host- theContainertheGroupLayoutis theLayoutManagerfor- Throws:
IllegalArgumentException- if host isnull
-
-
Method Details
-
setHonorsVisibility
public void setHonorsVisibility(boolean honorsVisibility) Sets whether component visibility is considered when sizing and positioning components. A value oftrueindicates that non-visible components should not be treated as part of the layout. A value offalseindicates that components should be positioned and sized regardless of visibility.A value of
falseis 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 ofBoolean.TRUEindicates that ifcomponentis not visible it should not be treated as part of the layout. A value offalseindicates thatcomponentis positioned and sized regardless of its visibility. A value ofnullindicates the value specified by the single argument methodsetHonorsVisibilityshould be used.If
componentis not a child of theContainerthisGroupLayoutis managing, it will be added to theContainer.- Parameters:
component- the componenthonorsVisibility- whether visibility of thiscomponentshould be considered for sizing and positioning- Throws:
IllegalArgumentException- ifcomponentisnull- See Also:
-
setAutoCreateGaps
public void setAutoCreateGaps(boolean autoCreatePadding) Sets whether a gap between components should automatically be created. For example, if this istrueand you add two components to aSequentialGroupa gap between the two components is automatically be created. The default isfalse.- Parameters:
autoCreatePadding- whether a gap between components is automatically created
-
getAutoCreateGaps
public boolean getAutoCreateGaps()Returnstrueif gaps between components are automatically created.- Returns:
trueif 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 isfalse.- 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()Returnstrueif gaps between the container and components that border the container are automatically created.- Returns:
trueif gaps between the container and components that border the container are automatically created
-
setHorizontalGroup
Sets theGroupthat positions and sizes components along the horizontal axis.- Parameters:
group- theGroupthat positions and sizes components along the horizontal axis- Throws:
IllegalArgumentException- if group isnull
-
setVerticalGroup
Sets theGroupthat positions and sizes components along the vertical axis.- Parameters:
group- theGroupthat positions and sizes components along the vertical axis- Throws:
IllegalArgumentException- if group isnull
-
createSequentialGroup
Creates and returns aSequentialGroup.- Returns:
- a new
SequentialGroup
-
createParallelGroup
Creates and returns aParallelGroupwith an alignment ofAlignment.LEADING. This is a cover method for the more generalcreateParallelGroup(Alignment)method.- Returns:
- a new
ParallelGroup - See Also:
-
createParallelGroup
Creates and returns aParallelGroupwith the specified alignment. This is a cover method for the more generalcreateParallelGroup(Alignment,boolean)method withtruesupplied for the second argument.- Parameters:
alignment- the alignment for the elements of the group- Returns:
- a new
ParallelGroup - Throws:
IllegalArgumentException- ifalignmentisnull- See Also:
-
createParallelGroup
public GroupLayout.ParallelGroup createParallelGroup(GroupLayout.Alignment alignment, boolean resizable) Creates and returns aParallelGroupwith the specified alignment and resize behavior. Thealignmentargument specifies how children elements are positioned that do not fill the group. For example, if aParallelGroupwith an alignment ofTRAILINGis 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
ParallelGroupcreated with a baseline alignment along the horizontal axis is treated asLEADING.Refer to
ParallelGroupfor details on the behavior of baseline groups.- Parameters:
alignment- the alignment for the elements of the groupresizable-trueif 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- ifalignmentisnull- See Also:
-
createBaselineGroup
public GroupLayout.ParallelGroup createBaselineGroup(boolean resizable, boolean anchorBaselineToTop) Creates and returns aParallelGroupthat aligns its elements along the baseline.- Parameters:
resizable- whether the group is resizableanchorBaselineToTop- 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- theComponents that are to have the same size- Throws:
IllegalArgumentException- ifcomponentsisnull, or containsnull- 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 ofSwingConstants.HORIZONTALorSwingConstants.VERTICALcomponents- theComponents that are to have the same size- Throws:
IllegalArgumentException- ifcomponentsisnull, or containsnull; oraxisis notSwingConstants.HORIZONTALorSwingConstants.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 withnewComponentnewComponent- the component to put inexistingComponent's place- Throws:
IllegalArgumentException- if either of the components arenullorexistingComponentis not being managed by this layout manager
-
setLayoutStyle
Sets theLayoutStyleused to calculate the preferred gaps between components. A value ofnullindicates the shared instance ofLayoutStyleshould be used.- Parameters:
layoutStyle- theLayoutStyleto use- See Also:
-
getLayoutStyle
Returns theLayoutStyleused for calculating the preferred gap between components. This returns the value specified tosetLayoutStyle, which may benull.- Returns:
- the
LayoutStyleused for calculating the preferred gap between components
-
toString
Returns a string representation of thisGroupLayout. This method is intended to be used for debugging purposes, and the content and format of the returned string may vary between implementations. -
addLayoutComponent
Description copied from interface:LayoutManagerAdds the specified component to the layout, using the specified constraint object.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component to be addedconstraints- where/how the component is added to the layout.
-
maximumLayoutSize
Description copied from interface:LayoutManagerCalculates the maximum size dimensions for the specified container, given the components it contains.- Specified by:
maximumLayoutSizein interfaceLayoutManager- Returns:
- the maximum size of the container
- See Also:
-
getLayoutAlignmentX
public float getLayoutAlignmentX(com.vaadin.flow.component.Component parentContainer) Description copied from interface:LayoutManagerReturns 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:
getLayoutAlignmentXin interfaceLayoutManager- Returns:
- the x-axis alignment preference
-
getLayoutAlignmentY
public float getLayoutAlignmentY(com.vaadin.flow.component.Component parentContainer) Description copied from interface:LayoutManagerReturns 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:
getLayoutAlignmentYin interfaceLayoutManager- Returns:
- the y-axis alignment preference
-
invalidateLayout
public void invalidateLayout(com.vaadin.flow.component.Component parentContainer) Description copied from interface:LayoutManagerInvalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfaceLayoutManager
-
addLayoutComponent
Description copied from interface:LayoutManagerIf the layout manager uses a per-component string, adds the componentcompto the layout, associating it with the string specified byname.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- the string to be associated with the componentcomp- the component to be added
-
removeLayoutComponent
public void removeLayoutComponent(com.vaadin.flow.component.Component component) Description copied from interface:LayoutManagerRemoves the specified component from the layout.- Specified by:
removeLayoutComponentin interfaceLayoutManager
-
preferredLayoutSize
Description copied from interface:LayoutManagerCalculates the preferred size dimensions for the specified container, given the components it contains.- Specified by:
preferredLayoutSizein interfaceLayoutManager- Returns:
- the preferred dimension for the container
- See Also:
-
minimumLayoutSize
Description copied from interface:LayoutManagerCalculates the minimum size dimensions for the specified container, given the components it contains.- Specified by:
minimumLayoutSizein interfaceLayoutManager- Returns:
- the minimum dimension for the container
- See Also:
-
layoutContainer
public void layoutContainer(com.vaadin.flow.component.Component parentContainer) Description copied from interface:LayoutManagerLays out the specified container.- Specified by:
layoutContainerin interfaceLayoutManager
-
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)
-