Class Dock


  • public class Dock
    extends ej.mwt.Container
    Lays out any number of children by docking each child one by one on a side.

    Each child is laid out individually on one of the sides of the remaining space, following the order in which they have been added to the dock. If a widget is set at the center of the dock, it will take the final remaining space.

    In a dock, all widgets docked on the left side and on the right side will have the height of the remaining space and will have their optimal width. All widgets docked on the top side and on the bottom side will have the width of the remaining space and will have their optimal height. The center widget will have the size of the remaining space.

    Example of dock that contains (added in this order):

    1. widget on the left,
    2. widget on the top,
    3. widget on the right,
    4. widget on the bottom,
    5. widget on the left,
    6. widget on the bottom,
    7. widget on the center.
    Dock.
    • Field Summary

      • Fields inherited from class ej.mwt.Widget

        NO_CONSTRAINT
    • Constructor Summary

      Constructors 
      Constructor Description
      Dock()
      Creates a dock.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChildOnBottom​(ej.mwt.Widget child)
      Adds a child which will be docked on the bottom side.
      void addChildOnLeft​(ej.mwt.Widget child)
      Adds a child which will be docked on the left side.
      void addChildOnRight​(ej.mwt.Widget child)
      Adds a child which will be docked on the right side.
      void addChildOnTop​(ej.mwt.Widget child)
      Adds a child which will be docked on the top side.
      protected void computeContentOptimalSize​(ej.mwt.util.Size size)  
      ej.mwt.Widget getCenterChild()
      Gets the child at the center of this dock.
      protected void layOutChildren​(int contentWidth, int contentHeight)  
      void removeAllChildren()  
      void removeChild​(ej.mwt.Widget child)  
      void setCenterChild​(ej.mwt.Widget child)
      Sets the child which will be at the center.
      • Methods inherited from class ej.mwt.Container

        addChild, changeChildIndex, computeChildOptimalSize, getChild, getChildIndex, getChildren, getChildrenCount, getContentBounds, getContentHeight, getContentWidth, getContentX, getContentY, getWidgetAt, insertChild, layOutAlignedChild, layOutChild, renderChild, renderContent, replaceChild, setHiddenChild, setHiddenChildren, setShownChild, setShownChildren, updateStyle
      • Methods inherited from class ej.mwt.Widget

        addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getDesktop, getHeight, getParent, getStyle, getWidth, getX, getY, handleEvent, hasClassSelector, isAttached, isEnabled, isInState, isShown, isTransparent, onAttached, onDetached, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Dock

        public Dock()
        Creates a dock.
    • Method Detail

      • addChildOnLeft

        public void addChildOnLeft​(ej.mwt.Widget child)
        Adds a child which will be docked on the left side.
        Parameters:
        child - the widget to add.
        Throws:
        java.lang.NullPointerException - if the given widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • addChildOnRight

        public void addChildOnRight​(ej.mwt.Widget child)
        Adds a child which will be docked on the right side.
        Parameters:
        child - the widget to add.
        Throws:
        java.lang.NullPointerException - if the given widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • addChildOnTop

        public void addChildOnTop​(ej.mwt.Widget child)
        Adds a child which will be docked on the top side.
        Parameters:
        child - the widget to add.
        Throws:
        java.lang.NullPointerException - if the given widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • addChildOnBottom

        public void addChildOnBottom​(ej.mwt.Widget child)
        Adds a child which will be docked on the bottom side.
        Parameters:
        child - the widget to add.
        Throws:
        java.lang.NullPointerException - if the given widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • setCenterChild

        public void setCenterChild​(ej.mwt.Widget child)
        Sets the child which will be at the center.
        Parameters:
        child - the widget to add.
        Throws:
        java.lang.NullPointerException - if the given widget is null.
        java.lang.IllegalArgumentException - if the specified widget is already in a hierarchy (already contained in a container or desktop).
        See Also:
        Container.addChild(Widget)
      • getCenterChild

        @Nullable
        public ej.mwt.Widget getCenterChild()
        Gets the child at the center of this dock.
        Returns:
        the center child, or null is it has not been set.
      • removeChild

        public void removeChild​(ej.mwt.Widget child)
        Overrides:
        removeChild in class ej.mwt.Container
      • removeAllChildren

        public void removeAllChildren()
        Overrides:
        removeAllChildren in class ej.mwt.Container
      • computeContentOptimalSize

        protected void computeContentOptimalSize​(ej.mwt.util.Size size)
        Specified by:
        computeContentOptimalSize in class ej.mwt.Widget
      • layOutChildren

        protected void layOutChildren​(int contentWidth,
                                      int contentHeight)
        Specified by:
        layOutChildren in class ej.mwt.Container