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 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.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
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.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:
true
if 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 returnnull
if 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:
true
if 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
-