Class ResponsiveGridFlowLayout
- All Implemented Interfaces:
LayoutManager,LayoutManager2
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newFlowLayoutwith a centered alignment and a default 5-unit horizontal and vertical gap.Constructs a newFlowLayoutwith the specified alignment and a default 5-unit horizontal and vertical gap.ResponsiveGridFlowLayout(UI.HorizontalAlignment align, int horizontalGapSize, int verticalGapSize) Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(Component comp, Object constraints) voidaddLayoutComponent(String name, Component comp) Adds the specified component to the layout.Optional<swingtree.layout.ResponsiveGridFlowLayout.Cell> cellFromCellConf(Component parent, FlowCell flowCell, Component child, AtomicInteger componentCounter, int maxWidth, int generalMaxWidth) Gets the alignment for this layout.booleanReturns true if components are to be vertically aligned along their baseline.floatgetLayoutAlignmentX(Container target) floatgetLayoutAlignmentY(Container target) intGets the horizontal gap between components and between the components and the borders of theContainervoidinvalidateLayout(Container target) voidlayoutContainer(Container target) Lays out the container.maximumLayoutSize(Container target) minimumLayoutSize(Container target) Returns the minimum dimensions needed to layout the visible components contained in the specified target container.preferredLayoutSize(Container target) Returns the preferred dimensions for this layout given the visible components in the specified target container.preferredLayoutSizeAtWidth(Container target, int width) Returns the size this layout would like to have if its target container werewidthpixels wide.voidRemoves the specified component from the layout.voidSets the alignment for this layout.voidsetAlignOnBaseline(boolean alignOnBaseline) Sets whether or not components should be vertically aligned along their baseline.voidsetHorizontalGapSize(int size) Sets the horizontal gap between components and between the components and the borders of theContainer.voidsetVerticalGapSize(int size) Sets the vertical gap between components and between the components and the borders of theContainer.toString()Returns a string representation of thisFlowLayoutobject and its values.intGets the vertical gap between components and between the components and the borders of theContainer.
-
Constructor Details
-
ResponsiveGridFlowLayout
public ResponsiveGridFlowLayout()Constructs a newFlowLayoutwith a centered alignment and a default 5-unit horizontal and vertical gap. -
ResponsiveGridFlowLayout
Constructs a newFlowLayoutwith the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one ofFlowLayout.LEFT,FlowLayout.RIGHT,FlowLayout.CENTER,FlowLayout.LEADING, orFlowLayout.TRAILING.- Parameters:
align- the alignment value
-
ResponsiveGridFlowLayout
public ResponsiveGridFlowLayout(UI.HorizontalAlignment align, int horizontalGapSize, int verticalGapSize) Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps.The value of the alignment argument must be one of
UI.HorizontalAlignment.LEFT,UI.HorizontalAlignment.RIGHT,UI.HorizontalAlignment.CENTER,UI.HorizontalAlignment.LEADING, orUI.HorizontalAlignment.TRAILING.- Parameters:
align- the alignment valuehorizontalGapSize- the horizontal gap between components and between the components and the borders of theContainerverticalGapSize- the vertical gap between components and between the components and the borders of theContainer
-
-
Method Details
-
getAlignment
Gets the alignment for this layout. Possible values areUI.HorizontalAlignment.LEFT,UI.HorizontalAlignment.RIGHT,UI.HorizontalAlignment.CENTER,UI.HorizontalAlignment.LEADING, orUI.HorizontalAlignment.TRAILING.- Returns:
- the alignment value for this layout
- See Also:
-
setAlignment
Sets the alignment for this layout. Possible values are- Parameters:
align- one of the alignment values shown above- See Also:
-
horizontalGapSize
public int horizontalGapSize()Gets the horizontal gap between components and between the components and the borders of theContainer- Returns:
- the horizontal gap between components
and between the components and the borders
of the
Container - See Also:
-
setHorizontalGapSize
public void setHorizontalGapSize(int size) Sets the horizontal gap between components and between the components and the borders of theContainer.- Parameters:
size- the horizontal gap between components and between the components and the borders of theContainer- See Also:
-
verticalGapSize
public int verticalGapSize()Gets the vertical gap between components and between the components and the borders of theContainer.- Returns:
- the vertical gap between components
and between the components and the borders
of the
Container - See Also:
-
setVerticalGapSize
public void setVerticalGapSize(int size) Sets the vertical gap between components and between the components and the borders of theContainer.- Parameters:
size- the vertical gap between components and between the components and the borders of theContainer- See Also:
-
setAlignOnBaseline
public void setAlignOnBaseline(boolean alignOnBaseline) Sets whether or not components should be vertically aligned along their baseline. Components that do not have a baseline will be centered. The default is false.- Parameters:
alignOnBaseline- whether or not components should be vertically aligned on their baseline
-
getAlignOnBaseline
public boolean getAlignOnBaseline()Returns true if components are to be vertically aligned along their baseline. The default is false.- Returns:
- true if components are to be vertically aligned along their baseline
-
addLayoutComponent
Adds the specified component to the layout. Not used by this class.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- the name of the componentcomp- the component to be added
-
removeLayoutComponent
Removes the specified component from the layout. Not used by this class.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component to remove- See Also:
-
preferredLayoutSize
Returns the preferred dimensions for this layout given the visible components in the specified target container.- Specified by:
preferredLayoutSizein interfaceLayoutManager- Parameters:
target- the container that needs to be laid out- Returns:
- the preferred dimensions to lay out the subcomponents of the specified container
- See Also:
-
preferredLayoutSizeAtWidth
Returns the size this layout would like to have if its target container werewidthpixels wide.This layout wraps its children into rows, which makes it a width-for-height layout: the height it needs is a function of the width it is given, and it cannot be expressed as a single fixed number. A parent container which itself decides the width of this layout's target must therefore ask this method rather than
preferredLayoutSize(Container), because at the time it asks, the target still has the width of the previous layout pass.The returned width does not depend on
width: it is the "ideal" width of a single row holding all children, raised to the explicitly set preferred width of the target if there is one and it is larger. Only the height varies withwidth.Mind that the returned width is not necessarily the reference width against which the
ParentSizeClassof the children is measured. That reference is the explicitly set preferred width whenever there is one, even when it is smaller than the ideal single row width — which is exactly how a nested grid keeps its own size categories usable without imposing its single row width on the grid it sits in. An explicitly set preferred size therefore acts as a lower bound on the returned size and, independently of that, as the reference width.- Parameters:
target- The container whose layout size should be computed.width- The width the container is assumed to have, where a value of0or less means that no width is known yet, in which case the children are assumed to fit into a single row.- Returns:
- The preferred size of the given container at the given width.
-
minimumLayoutSize
Returns the minimum dimensions needed to layout the visible components contained in the specified target container.- Specified by:
minimumLayoutSizein interfaceLayoutManager- Parameters:
target- the container that needs to be laid out- Returns:
- the minimum dimensions to lay out the subcomponents of the specified container
- See Also:
-
layoutContainer
Lays out the container. This method lets each visible component take its preferred size by reshaping the components in the target container in order to satisfy the alignment of this layout manager.- Specified by:
layoutContainerin interfaceLayoutManager- Parameters:
target- the specified component being laid out- See Also:
-
toString
Returns a string representation of thisFlowLayoutobject and its values. -
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager2
-
maximumLayoutSize
- Specified by:
maximumLayoutSizein interfaceLayoutManager2
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentXin interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentYin interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
cellFromCellConf
public Optional<swingtree.layout.ResponsiveGridFlowLayout.Cell> cellFromCellConf(Component parent, FlowCell flowCell, Component child, AtomicInteger componentCounter, int maxWidth, int generalMaxWidth)
-