Class SimpleDock
- java.lang.Object
-
- ej.mwt.Widget
-
- ej.mwt.Container
-
- ej.widget.container.SimpleDock
-
public class SimpleDock extends Container
Lays out three children vertically or horizontally.The three children are laid out on the same horizontal or vertical line, one at the center and the two others on each side.
In a horizontal simple dock, the first and last widgets will have the height of the available space and will have their optimal width. In a vertical simple dock, the first and last widgets will have the width of the available space and will have their optimal height. Regardless of the orientation of the simple dock, the center widget will have the size of the remaining space.
Horizontal:
Vertical:

-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ej.mwt.Widget
Widget.WidgetListener
-
-
Field Summary
-
Fields inherited from class ej.mwt.Widget
DEBUG_WIDGET_ENABLED_CONSTANT, DEBUG_WIDGET_MONITOR_CONSTANT, NO_CONSTRAINT
-
-
Constructor Summary
Constructors Constructor Description SimpleDock(boolean orientation)Creates a simple dock specifying its orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcomputeContentOptimalSize(Size size)Computes the optimal size of the widget.WidgetgetCenterChild()Gets the center widget of this simple dock.WidgetgetFirstChild()Gets the first widget of this simple dock.WidgetgetLastChild()Gets the last widget of this simple dock.booleangetOrientation()Gets the orientation of this simple dock.protected voidlayOutChildren(int contentWidth, int contentHeight)Lays out the children of this container.voidremoveAllChildren()Removes all the children of this container.voidremoveChild(Widget widget)Removes the specified widget from the list of children of this container.voidsetCenterChild(Widget child)Sets the center widget of this simple dock.voidsetFirstChild(Widget child)Sets the first widget of this simple dock.voidsetLastChild(Widget child)Sets the last widget of this simple dock.voidsetOrientation(boolean orientation)Sets the orientation of this simple dock.-
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, setX, setY
-
-
-
-
Constructor Detail
-
SimpleDock
public SimpleDock(boolean orientation)
Creates a simple dock specifying its orientation.- Parameters:
orientation- the orientation of the simple dock (seeLayoutOrientation).
-
-
Method Detail
-
setOrientation
public void setOrientation(boolean orientation)
Sets the orientation of this simple dock.- Parameters:
orientation- the orientation to set (seeLayoutOrientation).
-
getOrientation
public boolean getOrientation()
Gets the orientation of this simple dock.- Returns:
- the orientation of this simple dock (see
LayoutOrientation).
-
setFirstChild
public void setFirstChild(Widget child)
Sets the first widget of this simple dock. If this simple dock is horizontal, the first widget is on the left side, otherwise it is on the top side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
getFirstChild
@Nullable public Widget getFirstChild()
Gets the first widget of this simple dock.- Returns:
- the first widget of this simple dock, or
nullis it has not been set.
-
setLastChild
public void setLastChild(Widget child)
Sets the last widget of this simple dock. If this simple dock is horizontal, the last widget is on the right side, otherwise it is on the bottom side.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.IllegalArgumentException- if the specified widget is already in a hierarchy (already contained in a container or desktop).- See Also:
Container.addChild(Widget)
-
getLastChild
@Nullable public Widget getLastChild()
Gets the last widget of this simple dock.- Returns:
- the last widget of this simple dock, or
nullis it has not been set.
-
setCenterChild
public void setCenterChild(Widget child)
Sets the center widget of this simple dock.- Parameters:
child- the widget to add.- Throws:
NullPointerException- if the given widget isnull.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 Widget getCenterChild()
Gets the center widget of this simple dock.- Returns:
- the center widget of this simple dock, or
nullis it has not been set.
-
removeChild
public void removeChild(Widget widget)
Description copied from class:ContainerRemoves 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:
removeChildin classContainer- Parameters:
widget- the widget to remove.- See Also:
Widget.requestLayOut()
-
removeAllChildren
public void removeAllChildren()
Description copied from class:ContainerRemoves 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:
removeAllChildrenin classContainer- See Also:
Widget.requestLayOut()
-
computeContentOptimalSize
protected void computeContentOptimalSize(Size size)
Description copied from class:WidgetComputes 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_CONSTRAINTmeans that there is no constraint on this dimension.The given size is modified to set the optimal size.
- Specified by:
computeContentOptimalSizein classWidget- Parameters:
size- the size available for the content.
-
layOutChildren
protected void layOutChildren(int contentWidth, int contentHeight)Description copied from class:ContainerLays 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:
layOutChildrenin classContainer- Parameters:
contentWidth- the width available for the content.contentHeight- the height available for the content.
-
-