Class CmsPositionBean


  • public class CmsPositionBean
    extends java.lang.Object
    Bean holding the position data of a HTML DOM element.

    Since:
    8.0.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CmsPositionBean.Area
      Position area.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void avoidCollision​(CmsPositionBean posA, CmsPositionBean posB, int margin)
      Manipulates the position infos to ensure a minimum margin between the rectangles.
      static boolean checkCollision​(CmsPositionBean posA, CmsPositionBean posB, int margin)
      Checks whether the two position rectangles collide.
      boolean containsPoint​(int x, int y)
      Checks if the rectangle defined by this bean contains the given point.
      void ensureSurrounds​(CmsPositionBean child, int padding)
      Increases the dimensions to completely surround the child.
      static CmsPositionBean generatePositionInfo​(com.google.gwt.dom.client.Element element)
      Collects the position information of the given UI object and returns a position info bean.
      static CmsPositionBean generatePositionInfo​(com.google.gwt.user.client.ui.UIObject uiObject)
      Collects the position information of the given UI object and returns a position info bean.
      CmsPositionBean.Area getArea​(int absLeft, int absTop, int offset)
      Returns over which area of this the given position is.
      static CmsPositionBean getBoundingClientRect​(com.google.gwt.dom.client.Element panel)
      Returns the bounding rectangle dimensions of the element including all floated elements.
      static CmsPositionBean getBoundingClientRect​(com.google.gwt.dom.client.Element panel, boolean addScroll)
      Returns the bounding rectangle dimensions of the element including all floated elements.
      int getHeight()
      Returns the height.
      static CmsPositionBean getInnerDimensions​(com.google.gwt.dom.client.Element panel)
      Returns a position info representing the dimensions of all visible child elements of the given panel (excluding elements with position:absolute).
      int getLeft()
      Returns the left.
      int getTop()
      Returns the top.
      int getWidth()
      Returns the width.
      static boolean isInRangeInclusive​(int min, int max, int value)
      Checks whether a value is in a given interval (including the end points).
      boolean isInside​(CmsPositionBean child, int padding)
      Checks whether the given position is completely surrounded by this position.
      boolean isOverElement​(int absLeft, int absTop)
      Returns if given position is inside the position beans coordinates.
      boolean isOverTopHalf​(int absTop)
      Returns if given absolute top is above the vertical middle of the position beans coordinates.
      void setHeight​(int height)
      Sets the height.
      void setLeft​(int left)
      Sets the left.
      void setTop​(int top)
      Sets the top.
      void setWidth​(int width)
      Sets the width.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • avoidCollision

        public static void avoidCollision​(CmsPositionBean posA,
                                          CmsPositionBean posB,
                                          int margin)
        Manipulates the position infos to ensure a minimum margin between the rectangles.

        Parameters:
        posA - the first position to check
        posB - the second position to check
        margin - the required margin
      • checkCollision

        public static boolean checkCollision​(CmsPositionBean posA,
                                             CmsPositionBean posB,
                                             int margin)
        Checks whether the two position rectangles collide.

        Parameters:
        posA - the first position to check
        posB - the second position to check
        margin - the required margin
        Returns:
        true if the two position rectangles collide
      • generatePositionInfo

        public static CmsPositionBean generatePositionInfo​(com.google.gwt.dom.client.Element element)
        Collects the position information of the given UI object and returns a position info bean.

        Parameters:
        element - the object to read the position data from
        Returns:
        the position data
      • generatePositionInfo

        public static CmsPositionBean generatePositionInfo​(com.google.gwt.user.client.ui.UIObject uiObject)
        Collects the position information of the given UI object and returns a position info bean.

        Parameters:
        uiObject - the object to read the position data from
        Returns:
        the position data
      • getBoundingClientRect

        public static CmsPositionBean getBoundingClientRect​(com.google.gwt.dom.client.Element panel)
        Returns the bounding rectangle dimensions of the element including all floated elements.

        Parameters:
        panel - the panel
        Returns:
        the position info
      • getBoundingClientRect

        public static CmsPositionBean getBoundingClientRect​(com.google.gwt.dom.client.Element panel,
                                                            boolean addScroll)
        Returns the bounding rectangle dimensions of the element including all floated elements.

        Parameters:
        panel - the panel
        addScroll - if true, the result will contain the coordinates in the document's coordinate system, not the viewport coordinate system
        Returns:
        the position info
      • getInnerDimensions

        public static CmsPositionBean getInnerDimensions​(com.google.gwt.dom.client.Element panel)
        Returns a position info representing the dimensions of all visible child elements of the given panel (excluding elements with position:absolute). If the panel has no visible child elements, it's outer dimensions are returned.

        Parameters:
        panel - the panel
        Returns:
        the position info
      • isInRangeInclusive

        public static boolean isInRangeInclusive​(int min,
                                                 int max,
                                                 int value)
        Checks whether a value is in a given interval (including the end points).

        Parameters:
        min - the minimum of the interval
        max - the maximum of the interval
        value - the value to check
        Returns:
        true if the value is in the given interval
      • containsPoint

        public boolean containsPoint​(int x,
                                     int y)
        Checks if the rectangle defined by this bean contains the given point.

        Parameters:
        x - the horizontal coordinate
        y - the vertical coordinate
        Returns:
        true if this object contains the given point
      • ensureSurrounds

        public void ensureSurrounds​(CmsPositionBean child,
                                    int padding)
        Increases the dimensions to completely surround the child.

        Parameters:
        child - the child position info
        padding - the padding to apply
      • getArea

        public CmsPositionBean.Area getArea​(int absLeft,
                                            int absTop,
                                            int offset)
        Returns over which area of this the given position is. Will return null if the provided position is not within this position.

        Parameters:
        absLeft - the left position
        absTop - the right position
        offset - the border offset
        Returns:
        the area
      • getHeight

        public int getHeight()
        Returns the height.

        Returns:
        the height
      • getLeft

        public int getLeft()
        Returns the left.

        Returns:
        the left
      • getTop

        public int getTop()
        Returns the top.

        Returns:
        the top
      • getWidth

        public int getWidth()
        Returns the width.

        Returns:
        the width
      • isInside

        public boolean isInside​(CmsPositionBean child,
                                int padding)
        Checks whether the given position is completely surrounded by this position.

        Parameters:
        child - the child position
        padding - the padding to use
        Returns:
        true if the child position is completely surrounded
      • isOverElement

        public boolean isOverElement​(int absLeft,
                                     int absTop)
        Returns if given position is inside the position beans coordinates.

        Parameters:
        absLeft - the absolute left position
        absTop - the absolute top position
        Returns:
        true if the given position if within the beans coordinates
      • isOverTopHalf

        public boolean isOverTopHalf​(int absTop)
        Returns if given absolute top is above the vertical middle of the position beans coordinates.

        Parameters:
        absTop - the absolute top position
        Returns:
        true if given absolute top is above the vertical middle
      • setHeight

        public void setHeight​(int height)
        Sets the height.

        Parameters:
        height - the height to set
      • setLeft

        public void setLeft​(int left)
        Sets the left.

        Parameters:
        left - the left to set
      • setTop

        public void setTop​(int top)
        Sets the top.

        Parameters:
        top - the top to set
      • setWidth

        public void setWidth​(int width)
        Sets the width.

        Parameters:
        width - the width to set
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()