Package org.opencms.gwt.client.util
Class CmsPositionBean
java.lang.Object
org.opencms.gwt.client.util.CmsPositionBean
Bean holding the position data of a HTML DOM element.
- Since:
- 8.0.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidavoidCollision(CmsPositionBean posA, CmsPositionBean posB, int margin) Manipulates the position infos to ensure a minimum margin between the rectangles.static booleancheckCollision(CmsPositionBean posA, CmsPositionBean posB, int margin) Checks whether the two position rectangles collide.booleancontainsPoint(int x, int y) Checks if the rectangle defined by this bean contains the given point.voidensureSurrounds(CmsPositionBean child, int padding) Increases the dimensions to completely surround the child.static CmsPositionBeangeneratePositionInfo(com.google.gwt.dom.client.Element element) Collects the position information of the given UI object and returns a position info bean.static CmsPositionBeangeneratePositionInfo(com.google.gwt.user.client.ui.UIObject uiObject) Collects the position information of the given UI object and returns a position info bean.getArea(int absLeft, int absTop, int offset) Returns over which area of this the given position is.static CmsPositionBeangetBoundingClientRect(com.google.gwt.dom.client.Element panel) Returns the bounding rectangle dimensions of the element including all floated elements.static CmsPositionBeangetBoundingClientRect(com.google.gwt.dom.client.Element panel, boolean addScroll) Returns the bounding rectangle dimensions of the element including all floated elements.intReturns the height.static CmsPositionBeangetInnerDimensions(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).intgetLeft()Returns the left.intgetTop()Returns the top.intgetWidth()Returns the width.static booleanisInRangeInclusive(int min, int max, int value) Checks whether a value is in a given interval (including the end points).booleanisInside(CmsPositionBean child, int padding) Checks whether the given position is completely surrounded by this position.booleanisOverElement(int absLeft, int absTop) Returns if given position is inside the position beans coordinates.booleanisOverTopHalf(int absTop) Returns if given absolute top is above the vertical middle of the position beans coordinates.voidsetHeight(int height) Sets the height.voidsetLeft(int left) Sets the left.voidsetTop(int top) Sets the top.voidsetWidth(int width) Sets the width.toString()
-
Constructor Details
-
CmsPositionBean
public CmsPositionBean()Constructor. -
CmsPositionBean
Copy constructor. Generating a copy of the given model.- Parameters:
model- the model to copy
-
-
Method Details
-
avoidCollision
Manipulates the position infos to ensure a minimum margin between the rectangles.- Parameters:
posA- the first position to checkposB- the second position to checkmargin- the required margin
-
checkCollision
Checks whether the two position rectangles collide.- Parameters:
posA- the first position to checkposB- the second position to checkmargin- the required margin- Returns:
trueif the two position rectangles collide
-
generatePositionInfo
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
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
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 paneladdScroll- if true, the result will contain the coordinates in the document's coordinate system, not the viewport coordinate system- Returns:
- the position info
-
getInnerDimensions
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
Checks whether a value is in a given interval (including the end points).- Parameters:
min- the minimum of the intervalmax- the maximum of the intervalvalue- the value to check- Returns:
- true if the value is in the given interval
-
containsPoint
Checks if the rectangle defined by this bean contains the given point.- Parameters:
x- the horizontal coordinatey- the vertical coordinate- Returns:
- true if this object contains the given point
-
ensureSurrounds
Increases the dimensions to completely surround the child.- Parameters:
child- the child position infopadding- the padding to apply
-
getArea
Returns over which area of this the given position is. Will returnnullif the provided position is not within this position.- Parameters:
absLeft- the left positionabsTop- the right positionoffset- the border offset- Returns:
- the area
-
getHeight
Returns the height.- Returns:
- the height
-
getLeft
Returns the left.- Returns:
- the left
-
getTop
Returns the top.- Returns:
- the top
-
getWidth
Returns the width.- Returns:
- the width
-
isInside
Checks whether the given position is completely surrounded by this position.- Parameters:
child- the child positionpadding- the padding to use- Returns:
trueif the child position is completely surrounded
-
isOverElement
Returns if given position is inside the position beans coordinates.- Parameters:
absLeft- the absolute left positionabsTop- the absolute top position- Returns:
- true if the given position if within the beans coordinates
-
isOverTopHalf
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
Sets the height.- Parameters:
height- the height to set
-
setLeft
Sets the left.- Parameters:
left- the left to set
-
setTop
Sets the top.- Parameters:
top- the top to set
-
setWidth
Sets the width.- Parameters:
width- the width to set
-
toString
-