Last updated

API / geotoolkit / controls / shapes / BubbleChart / BubbleRect

Class: BubbleRect

shapes.BubbleChart.BubbleRect

Represents a rectangle with sides parallel to the axes. This rectangle has methods that allow the geometry to be queried and modified. 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.

Example

const r1 = new Rect({'x': 4,
'y': 3,
'width': 2,
'height': 1
});

const r2 = new Rect(r1);
const r3 = new Rect(4, 3, 6, 4);  // x1, y1, x2, y2
// r1, r2, and r3 are now equal

Hierarchy

Table of contents

Constructors
Accessors
Methods
Css Properties
Name Type Description
heightnumberHeight
readonlybooleanReadonly
widthnumberWidth
xnumberLeft
ynumberTop

Contents

Constructors

new BubbleRect(x1, y1, x2, y2)

new BubbleRect(x1, y1, x2, y2)

Parameters

Name Type
x1number
y1number
x2number
y2number

Overrides

Rect.constructor

Accessors

datax

get datax(): number

Returns

number

set datax(value): void

Parameters

Name Type
valuenumber

Returns

void


datay

get datay(): number

Returns

number

set datay(value): void

Parameters

Name Type
valuenumber

Returns

void


index

get index(): number

Returns

number

set index(value): void

Parameters

Name Type
valuenumber

Returns

void

Methods

clipLine

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.

Parameters

Name Type Description
a1Pointthe first input point
a2Pointthe second input point
result1Pointthe first output point
result2Pointthe second output point

Returns

number

how many times line intersects rectangle

Inherited from

Rect.clipLine


clone

clone(): Rect

Return clone object.

Returns

Rect

clone a copy of this object

Inherited from

Rect.clone


contains

contains(x, y?): boolean

Check if the area contains point

Throws

if illegal argument count

Parameters

Name Type Description
xnumber | Pointx position of the point
Optional ynumbery position of the point

Returns

boolean

Inherited from

Rect.contains


containsPolygon

containsPolygon(polygon): boolean

Check if rectangle contains polygon

Parameters

Name Type Description
polygonPolygonpolygon

Returns

boolean

true if contains, else false

Inherited from

Rect.containsPolygon


containsRect

containsRect(x, y, w, h): boolean

Check if rectangle contains rectangle

Throws

if illegal argument count

Parameters

Name Type Description
xnumberx position
ynumbery position
wnumberwidth
hnumberheight

Returns

boolean

Inherited from

Rect.containsRect

containsRect(rect): boolean

Check if rectangle contains rectangle

Throws

if illegal argument count

Parameters

Name Type Description
rectRectrect

Returns

boolean

Inherited from

Rect.containsRect


equalsRect

equalsRect(rect, epsilon?): boolean

Returns true if rectangles are identical

Parameters

Name Type Description
rectRect | Optionsrect to compare to
Optional epsilonnumberacceptance criteria

Returns

boolean

equals this and rect have same x, y, width, height

Inherited from

Rect.equalsRect


getBottom

getBottom(): number

Return bottom coordinate (always top < bottom)

Returns

number

y

Inherited from

Rect.getBottom


getBottomCenter

getBottomCenter(): Point

Return Bottom center position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getBottomCenter


getBounds

getBounds(): Rect

Return bounds

Returns

Rect

bounds

Inherited from

Rect.getBounds


getCenter

getCenter(): Point

Gets coordinates of the rectangle's center

Returns

Point

coordinates of the center

Inherited from

Rect.getCenter


getCenterX

getCenterX(): number

Gets X coordinate of the rectangle's center

Returns

number

X coordinate of the center

Inherited from

Rect.getCenterX


getCenterY

getCenterY(): number

Gets Y coordinate of the rectangle's center

Returns

number

Y coordinate of the center

Inherited from

Rect.getCenterY


getClassName

getClassName(): string

Returns

string

Inherited from

Rect.getClassName


getDiagonalLength

getDiagonalLength(): number

Get diagonal length of rectangle

Returns

number

diagonal length

Inherited from

Rect.getDiagonalLength


getHeight

getHeight(): number

Return height

Returns

number

Inherited from

Rect.getHeight


getLeft

getLeft(): number

Return coordinate of left corner

Returns

number

x

Inherited from

Rect.getLeft


getLeftBottom

getLeftBottom(): Point

Return left bottom position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getLeftBottom


getLeftCenter

getLeftCenter(): Point

Return Left center position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getLeftCenter


getLeftTop

getLeftTop(): Point

Return left top position

Returns

Point

a new point to specify left top position

Inherited from

Rect.getLeftTop


getProperties

getProperties(): Options

Gets all the properties pertaining to this object

Returns

Options

Inherited from

Rect.getProperties


getRight

getRight(): number

Return coordinate of right corner

Returns

number

x

Inherited from

Rect.getRight


getRightBottom

getRightBottom(): Point

Return right bottom position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getRightBottom


getRightCenter

getRightCenter(): Point

Return Right center position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getRightCenter


getRightTop

getRightTop(): Point

Return left top position

Returns

Point

a new point to specify left top position

Inherited from

Rect.getRightTop


getTop

getTop(): number

Return top coordinate

Returns

number

y

Inherited from

Rect.getTop


getTopCenter

getTopCenter(): Point

Return Top center position

Returns

Point

a new point to specify right bottom position

Inherited from

Rect.getTopCenter


getWidth

getWidth(): number

Return width

Returns

number

Inherited from

Rect.getWidth


getX

getX(): number

Return left position

Returns

number

Inherited from

Rect.getX


getY

getY(): number

Return top position

Returns

number

y

Inherited from

Rect.getY


inflate

inflate(width, height?): BubbleRect

Inflate rectangle from each side by width and height

Parameters

Name Type Description
widthnumberextend in horizontal direction
Optional heightnumberextend in vertical direction

Returns

BubbleRect

Inherited from

Rect.inflate


intersect

intersect(x, y, width, height): BubbleRect

Intersects this rectangle with the specified one

Throws

if the rect is null or if illegal arguments

Parameters

Name Type Description
xnumberThe x coordinate
ynumberThe y coordinate
widthnumberThe width
heightnumberThe height

Returns

BubbleRect

this

Inherited from

Rect.intersect

intersect(rect): BubbleRect

Intersects this rectangle with the specified one

Throws

if the rect is null or if illegal arguments

Parameters

Name Type Description
rectRectrectangle to intersect with

Returns

BubbleRect

this

Inherited from

Rect.intersect


intersects

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.

Parameters

Name Type Description
rectRectThe x coordinate or another rectangle

Returns

boolean

Inherited from

Rect.intersects

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.

Parameters

Name Type Description
xnumberThe x coordinate
ynumberThe y coordinate
wnumberThe width
hnumberThe height

Returns

boolean

Inherited from

Rect.intersects


isEmpty

isEmpty(): boolean

returns Rect state

Returns

boolean

true if width or height == 0

Inherited from

Rect.isEmpty


isReadOnly

isReadOnly(): boolean

return Rect state. If true, rect cannot be modified.

Returns

boolean

readOnly

Inherited from

Rect.isReadOnly


lock

lock(): BubbleRect

protect Rect instance from modification.

Returns

BubbleRect

this

Inherited from

Rect.lock


merge

merge(newRect, operation?): BubbleRect

Merges with provided rectangular area according to the operation applied.

Throws

if the rects provided is null

Parameters

Name Type Description
newRectRectrect to be merged with the current
Optional operationGeometryOperationoperation to apply

Returns

BubbleRect

this

Inherited from

Rect.merge


round

round(): BubbleRect

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.

Returns

BubbleRect

this

Inherited from

Rect.round


setCenter

setCenter(x, y): BubbleRect

Sets rectangle center

Parameters

Name Type Description
xnumberX coordinate of the rectangle's center
ynumberY coordinate of the rectangle's center

Returns

BubbleRect

the actual instance

Inherited from

Rect.setCenter


setHeight

setHeight(h): BubbleRect

Sets height

Parameters

Name Type Description
hnumberheight

Returns

BubbleRect

Inherited from

Rect.setHeight


setProperties

setProperties(properties?): BubbleRect

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsobject containing the properties to set

Returns

BubbleRect

this

Inherited from

Rect.setProperties


setRect

setRect(rect): BubbleRect

Sets rectangle

Throws

if illegal argument count

Parameters

Name Type Description
rectRect | Optionsrect or params

Returns

BubbleRect

this

Inherited from

Rect.setRect

setRect(x1, y1, x2, y2): BubbleRect

Sets rectangle

Throws

if illegal argument count

Parameters

Name Type Description
x1numberthe x-coordinate of one corner
y1numberthe y-coordinate of one corner
x2numberthe x-coordinate of the opposite corner
y2numberthe y coordinate of the opposite corner

Returns

BubbleRect

this

Inherited from

Rect.setRect


setWidth

setWidth(w): BubbleRect

Sets width

Parameters

Name Type Description
wnumberwidth

Returns

BubbleRect

Inherited from

Rect.setWidth


setX

setX(x): BubbleRect

Set left position

Parameters

Name Type Description
xnumberleft position

Returns

BubbleRect

this

Inherited from

Rect.setX


setY

setY(y): BubbleRect

Set top position

Parameters

Name Type Description
ynumbertop position

Returns

BubbleRect

this

Inherited from

Rect.setY


toString

toString(): string

Returns string like: "Rect: x1,y1:x2,y2" With x1 left With y1 top With x2 right With y2 bottom

Returns

string

string value

Inherited from

Rect.toString


translate

translate(tx, ty): BubbleRect

Translates rectangle a specified distance

Parameters

Name Type Description
txnumberx translation
tynumbery translation

Returns

BubbleRect

this

Inherited from

Rect.translate


union

union(rect): BubbleRect

Union this Rect with the specified

Parameters

Name Type Description
rectRectThe rect to union with current one

Returns

BubbleRect

this

Inherited from

Rect.union


unionPoint

unionPoint(x, y): BubbleRect

Unions this Rect with the specified x,y-point

Parameters

Name Type Description
xnumberThe x coordinate
ynumberThe y coordinate

Returns

BubbleRect

this

Inherited from

Rect.unionPoint


containsRect

Static containsRect(rect1, rect2): boolean

Check if rectangle1 contains rectangle2

Parameters

Name Type Description
rect1Rectrectangle 1
rect2Rectrectangle 2

Returns

boolean

true if contains, else false

Inherited from

Rect.containsRect


fromObject

Static fromObject(object?): Rect

Create or get rect from object

Parameters

Name Type Description
Optional objectTypeobject can be in format of constructor of Rect

Returns

Rect

rect

Inherited from

Rect.fromObject


getClassName

Static getClassName(): string

Returns

string

Inherited from

Rect.getClassName


inflateRect

Static inflateRect(source, w, h): Rect

Inflate rectangle

Parameters

Name Type Description
sourceRectrect to be inflated
wnumberThe width to inflate
hnumberThe height to inflate

Returns

Rect

a new inflated rectangle

Inherited from

Rect.inflateRect


intersectsRect

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.

Parameters

Name Type Description
rect1Rectrectangle 1
rect2Rectrectangle 2

Returns

boolean

true if intersects, else false

Inherited from

Rect.intersectsRect


merge

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

Parameters

Name Type Description
oldRectRect1st rect to merge
newRectRect2nd rect to merge
Optional operationGeometryOperationoperation to be performed on the new rect
Optional dstRectRectdestination rectangular geometry

Returns

Rect

merged rectangular geometry

Inherited from

Rect.merge