API / geotoolkit / util / ReadOnlyRect / ReadOnlyRect
util.ReadOnlyRect.ReadOnlyRect
Represents a readonly rectangle with sides parallel to the axes. This rectangle has methods that allow the geometry to be queried. The geometry that makes up a rectangle consists of two coordinate points that define the diagonal between the left bottom corner and the right top corner. Note that the bottom vertical coordinate is guaranteed to be less than the top vertical coordinate, and that the left horizontal coordinate is less than the right horizontal coordinate.
↳
ReadOnlyRect
Constructors
| [new ReadOnlyRect()](/solutions/geotoolkit/apis/classes/geotoolkit.util.readonlyrect.readonlyrect.md#new readonlyrect()) | [new ReadOnlyRect(properties)](/solutions/geotoolkit/apis/classes/geotoolkit.util.readonlyrect.readonlyrect.md#new readonlyrect(properties)) | [new ReadOnlyRect(rect)](/solutions/geotoolkit/apis/classes/geotoolkit.util.readonlyrect.readonlyrect.md#new readonlyrect(rect)) |
|---|---|---|
| [new ReadOnlyRect(x1, y1, x2, y2)](/solutions/geotoolkit/apis/classes/geotoolkit.util.readonlyrect.readonlyrect.md#new readonlyrect(x1, y1, x2, y2)) |
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
height | number | Height |
readonly | boolean | Readonly |
width | number | Width |
x | number | Left |
y | number | Top |
Constructors
• new ReadOnlyRect()
Rect.constructor
• new ReadOnlyRect(properties)
| Name | Type | Description |
|---|---|---|
properties | Options | object to copy |
Rect.constructor
• new ReadOnlyRect(rect)
| Name | Type | Description |
|---|---|---|
rect | Rect | Rect instance to copy |
Rect.constructor
• new ReadOnlyRect(x1, y1, x2, y2)
| Name | Type | Description |
|---|---|---|
x1 | number | left |
y1 | number | top |
x2 | number | right |
y2 | number | bottom |
Rect.constructor
Methods
▸ clipLine(a1, a2, result1, result2): number
Clips a line by rectangle.
a1 [IN] the start position of the line. a2 [IN] the end position of the line. result1 [OUT] the first point of the clipped line. result2 [OUT] the end point of the clipped line. return true if clipped rectangle intersects line or line is inside of the rectangle.
| Name | Type | Description |
|---|---|---|
a1 | Point | the first input point |
a2 | Point | the second input point |
result1 | Point | the first output point |
result2 | Point | the second output point |
number
how many times line intersects rectangle
▸ clone(): Rect
Return clone object.
clone a copy of this object
▸ contains(x, y?): boolean
Check if the area contains point
Throws
if illegal argument count
| Name | Type | Description |
|---|---|---|
x | number | Point | x position of the point |
Optional y | number | y position of the point |
boolean
▸ containsPolygon(polygon): boolean
Check if rectangle contains polygon
| Name | Type | Description |
|---|---|---|
polygon | Polygon | polygon |
boolean
true if contains, else false
▸ containsRect(x, y, w, h): boolean
Check if rectangle contains rectangle
Throws
if illegal argument count
| Name | Type | Description |
|---|---|---|
x | number | x position |
y | number | y position |
w | number | width |
h | number | height |
boolean
▸ containsRect(rect): boolean
Check if rectangle contains rectangle
Throws
if illegal argument count
| Name | Type | Description |
|---|---|---|
rect | Rect | rect |
boolean
▸ equalsRect(rect, epsilon?): boolean
Returns true if rectangles are identical
boolean
equals this and rect have same x, y, width, height
▸ getBottom(): number
Return bottom coordinate (always top < bottom)
number
y
▸ getBottomCenter(): Point
Return Bottom center position
a new point to specify right bottom position
▸ getBounds(): Rect
Return bounds
bounds
▸ getCenter(): Point
Gets coordinates of the rectangle's center
coordinates of the center
▸ getCenterX(): number
Gets X coordinate of the rectangle's center
number
X coordinate of the center
▸ getCenterY(): number
Gets Y coordinate of the rectangle's center
number
Y coordinate of the center
▸ getClassName(): string
string
▸ getDiagonalLength(): number
Get diagonal length of rectangle
number
diagonal length
▸ getHeight(): number
Return height
number
▸ getLeft(): number
Return coordinate of left corner
number
x
▸ getLeftBottom(): Point
Return left bottom position
a new point to specify right bottom position
▸ getLeftCenter(): Point
Return Left center position
a new point to specify right bottom position
▸ getLeftTop(): Point
Return left top position
a new point to specify left top position
▸ getProperties(): Options
Gets all the properties pertaining to this object
▸ getRight(): number
Return coordinate of right corner
number
x
▸ getRightBottom(): Point
Return right bottom position
a new point to specify right bottom position
▸ getRightCenter(): Point
Return Right center position
a new point to specify right bottom position
▸ getRightTop(): Point
Return left top position
a new point to specify left top position
▸ getTop(): number
Return top coordinate
number
y
▸ getTopCenter(): Point
Return Top center position
a new point to specify right bottom position
▸ getWidth(): number
Return width
number
▸ getX(): number
Return left position
number
▸ getY(): number
Return top position
number
y
▸ inflate(width, height?): ReadOnlyRect
Inflate rectangle from each side by width and height
| Name | Type | Description |
|---|---|---|
width | number | extend in horizontal direction |
Optional height | number | extend in vertical direction |
▸ intersect(x, y?, width?, height?): ReadOnlyRect
Intersects this rectangle with the specified one
Throws
if the rect is null or if illegal arguments
| Name | Type | Description |
|---|---|---|
x | number | Rect | The x coordinate |
Optional y | number | The y coordinate |
Optional width | number | The width |
Optional height | number | The height |
this
▸ intersects(rect): boolean
Determines whether or not this Rectangle and the specified Rectangle intersection. Two rectangles intersect if their intersection is non-empty or if they touch on either side.
| Name | Type | Description |
|---|---|---|
rect | Rect | The x coordinate or another rectangle |
boolean
▸ intersects(x, y, w, h): boolean
Determines whether or not this Rectangle and the specified Rectangle intersection. Two rectangles intersect if their intersection is non-empty or if they touch on either side.
| Name | Type | Description |
|---|---|---|
x | number | The x coordinate |
y | number | The y coordinate |
w | number | The width |
h | number | The height |
boolean
▸ isEmpty(): boolean
returns Rect state
boolean
true if width or height == 0
▸ isReadOnly(): boolean
return Rect state. If true, rect cannot be modified.
boolean
readOnly
▸ lock(): ReadOnlyRect
protect Rect instance from modification.
this
▸ merge(newRect, operation?): ReadOnlyRect
Merges with provided rectangular area according to the operation applied.
Throws
if the rects provided is null
| Name | Type | Description |
|---|---|---|
newRect | Rect | rect to be merged with the current |
Optional operation | GeometryOperation | operation to apply |
this
▸ round(): ReadOnlyRect
Round this rectangle to integer values for coordinates. This method sets the largest whole numbers less than or equal to the current values of left-top corner and sets the smallest whole numbers greater than or equal to the current values of right-bottom corner of the rectangle.
this
▸ setCenter(x, y): ReadOnlyRect
Sets rectangle center
| Name | Type | Description |
|---|---|---|
x | number | X coordinate of the rectangle's center |
y | number | Y coordinate of the rectangle's center |
the actual instance
▸ setHeight(h): ReadOnlyRect
Sets height
| Name | Type | Description |
|---|---|---|
h | number | height |
▸ setProperties(properties?): ReadOnlyRect
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | object containing the properties to set |
this
▸ setRect(x1, y1?, x2?, y2?): ReadOnlyRect
Sets rectangle
Throws
if illegal argument count
| Name | Type | Description |
|---|---|---|
x1 | number | Rect | Options | rect or params |
Optional y1 | number | |
Optional x2 | number | |
Optional y2 | number |
this
▸ setWidth(w): ReadOnlyRect
Sets width
| Name | Type | Description |
|---|---|---|
w | number | width |
▸ setX(x): ReadOnlyRect
Set left position
| Name | Type | Description |
|---|---|---|
x | number | left position |
this
▸ setY(y): ReadOnlyRect
Set top position
| Name | Type | Description |
|---|---|---|
y | number | top position |
this
▸ toString(): string
Returns string like: "Rect: x1,y1:x2,y2" With x1 left With y1 top With x2 right With y2 bottom
string
string value
▸ translate(tx, ty): ReadOnlyRect
Translates rectangle a specified distance
| Name | Type | Description |
|---|---|---|
tx | number | x translation |
ty | number | y translation |
this
▸ union(rect): ReadOnlyRect
Union this Rect with the specified
| Name | Type | Description |
|---|---|---|
rect | Rect | The rect to union with current one |
this
▸ unionPoint(x, y): ReadOnlyRect
Unions this Rect with the specified x,y-point
| Name | Type | Description |
|---|---|---|
x | number | The x coordinate |
y | number | The y coordinate |
this
▸ Static containsRect(rect1, rect2): boolean
Check if rectangle1 contains rectangle2
boolean
true if contains, else false
▸ Static fromObject(object?): Rect
Create or get rect from object
rect
▸ Static getClassName(): string
string
▸ Static getEmpty(): ReadOnlyRect
Gets empty rectangle
▸ Static getUnitSquare(): ReadOnlyRect
Gets unit square (0, 0, 1, 1)
▸ Static inflateRect(source, w, h): Rect
Inflate rectangle
| Name | Type | Description |
|---|---|---|
source | Rect | rect to be inflated |
w | number | The width to inflate |
h | number | The height to inflate |
a new inflated rectangle
▸ Static intersectsRect(rect1, rect2): boolean
Check if rectangle1 intersects rectangle2. Two rectangles intersect if their intersection is non-empty or if they touch on either side.
boolean
true if intersects, else false
▸ Static merge(oldRect, newRect, operation?, dstRect?): Rect
Merges provided rectangular areas according to the operation applied.
Throws
if either of the rects provided is null
| Name | Type | Description |
|---|---|---|
oldRect | Rect | 1st rect to merge |
newRect | Rect | 2nd rect to merge |
Optional operation | GeometryOperation | operation to be performed on the new rect |
Optional dstRect | Rect | destination rectangular geometry |
merged rectangular geometry