Class SimpleContainer

  • All Implemented Interfaces:
    be.yildizgames.common.util.Registerable, Container, Element, Widget

    public abstract class SimpleContainer
    extends BaseWidget
    implements Container
    A container holding Widget.
    Author:
    Grégory Van Den Borre
    • Constructor Detail

      • SimpleContainer

        protected SimpleContainer​(String name,
                                  be.yildizgames.module.coordinate.BaseCoordinate coordinates,
                                  Material backgroundMaterial,
                                  SimpleContainer parent,
                                  boolean widget)
        Full container.
        Parameters:
        name - Container name, must be unique.
        coordinates - Container size and position.
        backgroundMaterial - The Material to use for background.
        parent - Parent container.
        widget - Flag to set this container being considered as container or widget.
      • SimpleContainer

        protected SimpleContainer​(String name,
                                  be.yildizgames.module.coordinate.BaseCoordinate coordinates,
                                  Material backgroundMaterial,
                                  boolean widget)
        Full container.
        Parameters:
        name - Container name, must be unique.
        coordinates - Container size and position.
        backgroundMaterial - The Material to use for background.
        widget - Flag to set this container being considered as container or widget.
    • Method Detail

      • zoom

        public final void zoom​(float zoomFactor)
        Make a zoom on the container.
        Parameters:
        zoomFactor - Zoom value.
      • showContent

        public final void showContent()
        Show all the container sub elements.
        Specified by:
        showContent in interface Container
      • hideContent

        public final void hideContent()
        Hide all the container sub elements.
        Specified by:
        hideContent in interface Container
      • getElementName

        public final String getElementName​(be.yildizgames.module.window.input.MousePosition position)
        Retrieve a child element from its position.
        Parameters:
        position - Element position.
        Returns:
        The element at the given position.
      • getElementName

        public abstract String getElementName​(int x,
                                              int y)
      • getElements

        public final List<Widget> getElements​(be.yildizgames.common.geometry.Rectangle rectangle)
        Retrieve all child elements contained in a rectangle.
        Parameters:
        rectangle - Rectangle containing the elements.
        Returns:
        All Widget in the rectangle.
      • addChildrenLeft

        public final void addChildrenLeft​(int left)
        Move all children left or right by adding a value to its current x value.
        Parameters:
        left - Value to add to the children current x position.
      • addChildrenTop

        public final void addChildrenTop​(int top)
        Move all children up or down by adding a value to its current y value.
        Parameters:
        top - Value to add to the children current y position.
      • addChildrenPosition

        public final void addChildrenPosition​(int left,
                                              int top)
        Move all children by adding a value to its current position.
        Parameters:
        left - Value to add to the children current x position.
        top - Value to add to the children current y position.
      • addEmptyZoneImpl

        protected final void addEmptyZoneImpl​(be.yildizgames.common.geometry.Rectangle zone)
        Specified by:
        addEmptyZoneImpl in class BaseWidget
      • addChildrenPositionImpl

        protected abstract void addChildrenPositionImpl​(int left,
                                                        int top)
        Implementation specific add children position.
        Parameters:
        left - Value to add to the children current x position.
        top - Value to add to the children current y position.
      • remove

        public final void remove​(BaseContainerChild element)
        Remove and delete a Widget from the GuiContainer.
        Parameters:
        element - Element to remove.
      • highlightImpl

        protected final void highlightImpl​(boolean over)
        Does nothing.
        Specified by:
        highlightImpl in class BaseWidget
        Parameters:
        over - Unused.
      • zoomImpl

        protected abstract void zoomImpl​(float factor)
        Zoom the GuiContainer in implementation.
        Parameters:
        factor - Factor of zoom.
      • setCurrentFocus

        public final void setCurrentFocus​(ContainerChild widget)
        Set a child widget as focused.
        Parameters:
        widget - Child to focus.
      • getNextFocusableElement

        public final Widget getNextFocusableElement()
        Get the next child with focusable status.
        Specified by:
        getNextFocusableElement in interface Container
        Returns:
        The focusable child following the current focused child, null if none found.
      • setMaterial

        public final void setMaterial​(Material newMaterial)
        Set the GuiContainer material.
        Specified by:
        setMaterial in interface Container
        Parameters:
        newMaterial - Material to use for background..
      • setMaterialImpl

        protected abstract void setMaterialImpl​(Material newMaterial)
        Set the Material in implementation.
        Parameters:
        newMaterial - New Material to use.
      • setContentVisible

        public final void setContentVisible​(boolean visible)
        Show or hide the content of this container.
        Parameters:
        visible - true will display the content, false will hide it.
      • setZ

        public final void setZ​(Zorder z)
        Set the container Z order.
        Specified by:
        setZ in interface Container
        Parameters:
        z - Z order.
      • setZImpl

        protected abstract void setZImpl​(Zorder z)
        Implementation specific to set the Z order.
        Parameters:
        z - Z order.
      • getWidgetAt

        public final Optional<Widget> getWidgetAt​(be.yildizgames.module.window.input.MousePosition position)
        Specified by:
        getWidgetAt in interface Container
      • getMaterial

        public final Material getMaterial()