Class CmsRectangle
- java.lang.Object
-
- org.opencms.ade.galleries.client.preview.util.CmsRectangle
-
public class CmsRectangle extends java.lang.Object
Axis-aligned rectangle in 2D space.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CmsRectangle()
Hidden default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.opencms.ade.galleries.shared.CmsPoint
constrain(org.opencms.ade.galleries.shared.CmsPoint point)
Constrains a point to this rectangle.boolean
contains(org.opencms.ade.galleries.shared.CmsPoint point)
Checks if this rectangle contains a given point.static CmsRectangle
fromLeftTopWidthHeight(double left, double top, double width, double height)
Creates a new rectangle given its left, top coordinates and its width and height.static CmsRectangle
fromPoints(org.opencms.ade.galleries.shared.CmsPoint topLeft, org.opencms.ade.galleries.shared.CmsPoint bottomRight)
Creates a new rectangle from its top left and bottom right corner points.org.opencms.ade.galleries.shared.CmsPoint
getBottomRight()
Gets the bottom right corner.org.opencms.ade.galleries.shared.CmsPoint
getTopLeft()
Gets the top left corner.
-
-
-
Constructor Detail
-
CmsRectangle
protected CmsRectangle()
Hidden default constructor.
-
-
Method Detail
-
fromLeftTopWidthHeight
public static CmsRectangle fromLeftTopWidthHeight(double left, double top, double width, double height)
Creates a new rectangle given its left, top coordinates and its width and height.- Parameters:
left
- the left sidetop
- the top sidewidth
- the widthheight
- the height- Returns:
- the new rectangel
-
fromPoints
public static CmsRectangle fromPoints(org.opencms.ade.galleries.shared.CmsPoint topLeft, org.opencms.ade.galleries.shared.CmsPoint bottomRight)
Creates a new rectangle from its top left and bottom right corner points.- Parameters:
topLeft
- the top left cornerbottomRight
- the bottom right corner- Returns:
- the new rectangle
-
constrain
public org.opencms.ade.galleries.shared.CmsPoint constrain(org.opencms.ade.galleries.shared.CmsPoint point)
Constrains a point to this rectangle.If any of the coordinates of the point lie in the projection of this rectangle on the corresponding axis, that coordinate in the result will be unchanged, otherwise it will be either the maximum or the minimum depending on on which side the original coordinate is located.
- Parameters:
point
- the point to constrain- Returns:
- the constrained point
-
contains
public boolean contains(org.opencms.ade.galleries.shared.CmsPoint point)
Checks if this rectangle contains a given point.- Parameters:
point
- the point to check- Returns:
- true if the point is contained in the rectangle
-
getBottomRight
public org.opencms.ade.galleries.shared.CmsPoint getBottomRight()
Gets the bottom right corner.- Returns:
- the bottom right corner
-
getTopLeft
public org.opencms.ade.galleries.shared.CmsPoint getTopLeft()
Gets the top left corner.- Returns:
- the top left corner
-
-