Class ResponsiveGridFlowLayout

java.lang.Object
swingtree.layout.ResponsiveGridFlowLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public final class ResponsiveGridFlowLayout extends Object implements LayoutManager2
A flow layout arranges components in a directional flow, much like lines of text in a paragraph.
  • Constructor Details

    • ResponsiveGridFlowLayout

      public ResponsiveGridFlowLayout()
      Constructs a new FlowLayout with a centered alignment and a default 5-unit horizontal and vertical gap.
    • ResponsiveGridFlowLayout

      public ResponsiveGridFlowLayout(UI.HorizontalAlignment align)
      Constructs a new FlowLayout with the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayout.CENTER, FlowLayout.LEADING, or FlowLayout.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, or FlowLayout.TRAILING.

      Parameters:
      align - the alignment value
      horizontalGapSize - the horizontal gap between components and between the components and the borders of the Container
      verticalGapSize - the vertical gap between components and between the components and the borders of the Container
  • Method Details

    • getAlignment

      public UI.HorizontalAlignment getAlignment()
      Gets the alignment for this layout. Possible values are UI.HorizontalAlignment.LEFT, UI.HorizontalAlignment.RIGHT, UI.HorizontalAlignment.CENTER, UI.HorizontalAlignment.LEADING, or UI.HorizontalAlignment.TRAILING.
      Returns:
      the alignment value for this layout
      See Also:
    • setAlignment

      public void setAlignment(UI.HorizontalAlignment align)
      Sets the alignment for this layout. Possible values are
      • UI.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 the Container
      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 the Container.
      Parameters:
      size - the horizontal gap between components and between the components and the borders of the Container
      See Also:
    • verticalGapSize

      public int verticalGapSize()
      Gets the vertical gap between components and between the components and the borders of the Container.
      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 the Container.
      Parameters:
      size - the vertical gap between components and between the components and the borders of the Container
      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

      public void addLayoutComponent(String name, Component comp)
      Adds the specified component to the layout. Not used by this class.
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      name - the name of the component
      comp - the component to be added
    • removeLayoutComponent

      public void removeLayoutComponent(Component comp)
      Removes the specified component from the layout. Not used by this class.
      Specified by:
      removeLayoutComponent in interface LayoutManager
      Parameters:
      comp - the component to remove
      See Also:
    • preferredLayoutSize

      public Dimension preferredLayoutSize(Container target)
      Returns the preferred dimensions for this layout given the visible components in the specified target container.
      Specified by:
      preferredLayoutSize in interface LayoutManager
      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

      public Dimension minimumLayoutSize(Container target)
      Returns the minimum dimensions needed to layout the visible components contained in the specified target container.
      Specified by:
      minimumLayoutSize in interface LayoutManager
      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

      public void layoutContainer(Container target)
      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 interface LayoutManager
      Parameters:
      target - the specified component being laid out
      See Also:
    • toString

      public String toString()
      Returns a string representation of this FlowLayout object and its values.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this layout
    • addLayoutComponent

      public void addLayoutComponent(Component comp, Object constraints)
      Specified by:
      addLayoutComponent in interface LayoutManager2
    • maximumLayoutSize

      public Dimension maximumLayoutSize(Container target)
      Specified by:
      maximumLayoutSize in interface LayoutManager2
    • getLayoutAlignmentX

      public float getLayoutAlignmentX(Container target)
      Specified by:
      getLayoutAlignmentX in interface LayoutManager2
    • getLayoutAlignmentY

      public float getLayoutAlignmentY(Container target)
      Specified by:
      getLayoutAlignmentY in interface LayoutManager2
    • invalidateLayout

      public void invalidateLayout(Container target)
      Specified by:
      invalidateLayout in interface LayoutManager2
    • cellFromCellConf

      public Optional<swingtree.layout.ResponsiveGridFlowLayout.Cell> cellFromCellConf(Component parent, FlowCell flowCell, Component child, AtomicInteger componentCounter, int maxWidth, int generalMaxWidth)