Represents a two-dimensional rectangle of size (width x height)
, located at the point (x, y)
.
Type Details
- yfiles module
- algorithms
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.algorithms.Rectangle2D
Constructors
Creates a new rectangle of the specified size at the specified location.
Parameters
A map of options to pass to the method.
- x - number
- the x-coordinate of the upper left corner of the created rectangle.
- y - number
- the y-coordinate of the upper left corner of the created rectangle.
- width - number
- the width of the created rectangle.
- height - number
- the height of the created rectangle.
Properties
Gets the bounds of this instance in double precision.
Gets or sets the outer bounds of this rectangle in double coordinates.
Sets the location and size of this rectangle to be similar to the specified rectangle.
Methods
Adds a point, specified by its coordinates, to this rectangle.
Remarks
false
for the added point.Parameters
A map of options to pass to the method.
- px - number
- the x coordinate of the point to add
- py - number
- the y coordinate of the point to add
Adds a rectangle to this rectangle.
Remarks
Parameters
A map of options to pass to the method.
- r - Rectangle2D
- the rectangle to add
Creates a new instance of this class that has the same values as this objects.
Checks if the point specified by the given coordinates is contained in this rectangle.
Parameters
A map of options to pass to the method.
- x - number
- the x-coordinate of the point.
- y - number
- the y-coordinate of the point.
Returns
- ↪boolean
true
if the specified point is contained in this rectangle;false
otherwise.
Checks whether this rectangle completely contains the second specified rectangle.
Parameters
A map of options to pass to the method.
- x - number
- the x coordinate of the second rectangle.
- y - number
- the y coordinate of the second rectangle.
- width - number
- the width coordinate of the second rectangle.
- height - number
- the height coordinate of the second rectangle.
Returns
- ↪boolean
true
if this rectangle contains the second one
Checks whether this rectangle completely contains the second specified rectangle.
Parameters
A map of options to pass to the method.
- rect - Rectangle2D
- the rectangle to check for containment
Returns
- ↪boolean
true
if this rectangle contains the second one
Calculates the intersection of this rectangle with the given rectangle and returns the result as new rectangle.
Parameters
A map of options to pass to the method.
- r - Rectangle2D
- a rectangle to intersect with this rectangle.
Returns
- ↪Rectangle2D
- a new rectangle that represents the calculated intersection.
Calculates the union of this rectangle with the given rectangle and returns the result as new rectangle.
Parameters
A map of options to pass to the method.
- r - Rectangle2D
- a rectangle to union with this rectangle.
Returns
- ↪Rectangle2D
- a new rectangle that represents the calculated union.
Returns whether this rectangle and obj
are equal.
Remarks
Parameters
A map of options to pass to the method.
- obj - Object
- The object to test for equality.
Returns
- ↪boolean
true
if both objects are equal.
Returns a hash code for this object.
Remarks
The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.
Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.
Returns
- ↪number
- the hash code for this object
Checks whether this rectangle and the second specified rectangle intersect.
Parameters
A map of options to pass to the method.
- x - number
- the x coordinate of the second rectangle.
- y - number
- the y coordinate of the second rectangle.
- width - number
- the width coordinate of the second rectangle.
- height - number
- the height coordinate of the second rectangle.
Returns
- ↪boolean
true
if both rectangles intersect
Checks whether this rectangle and the second specified rectangle intersect.
Parameters
A map of options to pass to the method.
- rect - Rectangle2D
- the rectangle to check for intersection
Returns
- ↪boolean
true
if both rectangles intersect
Checks if the line segment specified by the given coordinates intersects this rectangle.
Parameters
A map of options to pass to the method.
- x1 - number
- the x-coordinate of the first end point of the line.
- y1 - number
- the y-coordinate of the first end point of the line.
- x2 - number
- the x-coordinate of the other end point of the line.
- y2 - number
- the y-coordinate of the other end point of the line.
Returns
- ↪boolean
true
if the specified line intersects this rectangle;false
otherwise.
Sets the outer bounds of this rectangle based on the specified location and size.
Parameters
A map of options to pass to the method.
- x - number
- the new x-coordinate of the upper left corner.
- y - number
- the new y-coordinate of the upper left corner.
- width - number
- the new width.
- height - number
- the new height.
Sets the outer bounds of this rectangle based on the specified new center and corner.
Parameters
A map of options to pass to the method.
- centerX - number
- the x-coordinate of the new center of this rectangle.
- centerY - number
- the y-coordinate of the new center of this rectangle.
- cornerX - number
- the x-coordinate of any new corner of this rectangle.
- cornerY - number
- the y-coordinate of any new corner of this rectangle.
Sets the outer bounds of this rectangle based on the end points of one of its diagonals.
Parameters
A map of options to pass to the method.
- x1 - number
- the x-coordinate of the first end point of a diagonal.
- y1 - number
- the y-coordinate of the first end point of a diagonal.
- x2 - number
- the x-coordinate of the other end point of a diagonal.
- y2 - number
- the y-coordinate of the other end point of a diagonal.
Sets the location and size of this rectangle to the specified values.
Parameters
A map of options to pass to the method.
- x - number
- the new x-coordinate of the upper left corner.
- y - number
- the new y-coordinate of the upper left corner.
- width - number
- the new width.
- height - number
- the new height.
Creates a Rect from a given Rectangle2D.
Returns
Class.ensure(LayoutExecutor)
More information.Static Methods
Calculates the intersection of the first and second specified rectangle and sets the resulting location and size to the third rectangle.
Parameters
A map of options to pass to the method.
- src1 - Rectangle2D
- the first rectangle to intersect.
- src2 - Rectangle2D
- the second rectangle to intersect.
- dst - Rectangle2D
- the rectangle to which the result is set.
Calculates the union of the first and second specified rectangle and sets the resulting location and size to the third rectangle.
Parameters
A map of options to pass to the method.
- src1 - Rectangle2D
- the first rectangle to union.
- src2 - Rectangle2D
- the second rectangle to union.
- dst - Rectangle2D
- the rectangle to which the result is set.