Package swingtree.layout
Class ResponsiveGridFlowLayout
java.lang.Object
swingtree.layout.ResponsiveGridFlowLayout
- All Implemented Interfaces:
LayoutManager
,LayoutManager2
A flow layout arranges components in a directional flow, much
like lines of text in a paragraph.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newFlowLayout
with a centered alignment and a default 5-unit horizontal and vertical gap.Constructs a newFlowLayout
with 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 TypeMethodDescriptionvoid
addLayoutComponent
(Component comp, Object constraints) void
addLayoutComponent
(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.boolean
Returns true if components are to be vertically aligned along their baseline.float
getLayoutAlignmentX
(Container target) float
getLayoutAlignmentY
(Container target) int
Gets the horizontal gap between components and between the components and the borders of theContainer
void
invalidateLayout
(Container target) void
layoutContainer
(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.void
Removes the specified component from the layout.void
Sets the alignment for this layout.void
setAlignOnBaseline
(boolean alignOnBaseline) Sets whether or not components should be vertically aligned along their baseline.void
setHorizontalGapSize
(int size) Sets the horizontal gap between components and between the components and the borders of theContainer
.void
setVerticalGapSize
(int size) Sets the vertical gap between components and between the components and the borders of theContainer
.toString()
Returns a string representation of thisFlowLayout
object and its values.int
Gets the vertical gap between components and between the components and the borders of theContainer
.
-
Constructor Details
-
ResponsiveGridFlowLayout
public ResponsiveGridFlowLayout()Constructs a newFlowLayout
with a centered alignment and a default 5-unit horizontal and vertical gap. -
ResponsiveGridFlowLayout
Constructs a newFlowLayout
with 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
FlowLayout.LEFT
,FlowLayout.RIGHT
,FlowLayout.CENTER
,FlowLayout.LEADING
, orFlowLayout.TRAILING
.- Parameters:
align
- the alignment valuehorizontalGapSize
- the horizontal gap between components and between the components and the borders of theContainer
verticalGapSize
- 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 areUI.HorizontalAlignment.LEFT
UI.HorizontalAlignment.RIGHT
UI.HorizontalAlignment.CENTER
UI.HorizontalAlignment.LEADING
UI.HorizontalAlignment.TRAILING
- 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:
addLayoutComponent
in 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:
removeLayoutComponent
in 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:
preferredLayoutSize
in 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:
-
minimumLayoutSize
Returns the minimum dimensions needed to layout the visible components contained in the specified target container.- Specified by:
minimumLayoutSize
in 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:
layoutContainer
in interfaceLayoutManager
- Parameters:
target
- the specified component being laid out- See Also:
-
toString
Returns a string representation of thisFlowLayout
object and its values. -
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager2
-
maximumLayoutSize
- Specified by:
maximumLayoutSize
in interfaceLayoutManager2
-
getLayoutAlignmentX
- Specified by:
getLayoutAlignmentX
in interfaceLayoutManager2
-
getLayoutAlignmentY
- Specified by:
getLayoutAlignmentY
in interfaceLayoutManager2
-
invalidateLayout
- Specified by:
invalidateLayout
in interfaceLayoutManager2
-
cellFromCellConf
public Optional<swingtree.layout.ResponsiveGridFlowLayout.Cell> cellFromCellConf(Component parent, FlowCell flowCell, Component child, AtomicInteger componentCounter, int maxWidth, int generalMaxWidth)
-