Class Flow


  • public class Flow
    extends Container
    Lays out any number of children horizontally or vertically, using multiple rows if necessary.

    As many children as possible will be laid out on the first row. If the next remaining child does not fit on the row, a new row is created in order to lay out the remaining children. This process is repeated until all children are laid out. To know how many children can be laid out in a single row, the optimal size of the children is used.

    In a horizontal flow, all the widgets of the same row will have the same height. In a vertical flow, all the widgets of the same row will have the same width.

    Horizontal:

    Horizontal flow.

    Vertical:

    Vertical flow.

    • Constructor Detail

      • Flow

        public Flow​(boolean orientation)
        Creates a flow specifying its orientation.
        Parameters:
        orientation - the orientation of the flow (see LayoutOrientation).
    • Method Detail

      • setOrientation

        public void setOrientation​(boolean orientation)
        Sets the orientation of this flow.
        Parameters:
        orientation - the orientation to set (see LayoutOrientation).
      • getOrientation

        public boolean getOrientation()
        Gets the orientation of this flow.
        Returns:
        the orientation of this flow (see LayoutOrientation).
      • addChild

        public void addChild​(Widget child)
        Description copied from class: Container
        Adds the specified widget to the end of the list of children of this container.

        The container needs to be laid out again.

        Should be called in the display thread to avoid concurrency issues.

        Overrides:
        addChild in class Container
        Parameters:
        child - the widget to add.
        See Also:
        Widget.requestLayOut(), Widget.isAttached()
      • removeChild

        public void removeChild​(Widget child)
        Description copied from class: Container
        Removes the specified widget from the list of children of this container.

        The container needs to be laid out again.

        If the widget is not in the list of children of the container, nothing is done.

        Should be called in the display thread to avoid concurrency issues.

        Overrides:
        removeChild in class Container
        Parameters:
        child - the widget to remove.
        See Also:
        Widget.requestLayOut()
      • insertChild

        public void insertChild​(Widget child,
                                int index)
        Description copied from class: Container
        Inserts the specified widget at the specified index in the list of children of this container.

        The container needs to be laid out again.

        Should be called in the display thread to avoid concurrency issues.

        Overrides:
        insertChild in class Container
        Parameters:
        child - the widget to add.
        index - the index at which the widget should be inserted.
        See Also:
        Widget.requestLayOut(), Widget.isAttached()
      • replaceChild

        public void replaceChild​(int index,
                                 Widget child)
        Description copied from class: Container
        Replaces the child at the specified index in the list of children of this container by the specified widget.

        If the specified widget is already the child at the specified index of the list of children, nothing is done.

        The container needs to be laid out again.

        Should be called in the display thread to avoid concurrency issues.

        Overrides:
        replaceChild in class Container
        Parameters:
        index - the index of the child to replace.
        child - the widget to add.
        See Also:
        Widget.requestLayOut(), Widget.isAttached()
      • removeAllChildren

        public void removeAllChildren()
        Description copied from class: Container
        Removes all the children of this container.

        The container needs to be laid out again.

        Should be called in the display thread to avoid concurrency issues.

        Overrides:
        removeAllChildren in class Container
        See Also:
        Widget.requestLayOut()
      • computeContentOptimalSize

        protected void computeContentOptimalSize​(Size size)
        Description copied from class: Widget
        Computes the optimal size of the widget.

        This method does not consider the border, margin, padding and dimension specified in the style.

        The given size is the available size for this widget in its parent. A width or a height equal to Widget#NO_CONSTRAINT means that there is no constraint on this dimension.

        The given size is modified to set the optimal size.

        Specified by:
        computeContentOptimalSize in class Widget
        Parameters:
        size - the size available for the content.
      • layOutChildren

        protected void layOutChildren​(int contentWidth,
                                      int contentHeight)
        Description copied from class: Container
        Lays out the children of this container.

        The given size is the size of this container minus the border, margin and padding specified in the style.

        When this method returns the children of this container have been lay out using Container.layOutChild(Widget, int, int, int, int).

        Specified by:
        layOutChildren in class Container
        Parameters:
        contentWidth - the width available for the content.
        contentHeight - the height available for the content.