Package com.jogamp.nativewindow.util
Class Rectangle
java.lang.Object
com.jogamp.nativewindow.util.Rectangle
- All Implemented Interfaces:
com.jogamp.common.type.WriteCloneable
,RectangleImmutable
,Cloneable
,Comparable<RectangleImmutable>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compares square of size 1st, if equal the square of position.final float
Returns the coverage of given rectangle w/ this this one, i.e.boolean
Checks whether two rect objects are equal.final int
final int
getWidth()
final int
getX()
final int
getY()
int
hashCode()
final RectangleImmutable
intersection
(int rx1, int ry1, int rx2, int ry2) Returns the intersection of this rectangleand the given coordinates.final RectangleImmutable
Returns the intersection of this rectangleand the given rectangle.final Rectangle
scale
(int sx, int sy) Scale this instance's components, i.e.final Rectangle
scaleInv
(int sx, int sy) Inverse scale this instance's components, i.e.final void
set
(int x, int y, int width, int height) final void
final void
final void
setHeight
(int height) final void
setWidth
(int width) final void
setX
(int x) final void
setY
(int y) toString()
final RectangleImmutable
union
(int rx1, int ry1, int rx2, int ry2) Returns the union of this rectangleand the given coordinates.final RectangleImmutable
Returns the union of this rectangle and the given rectangle.final Rectangle
union
(List<RectangleImmutable> rectangles) Calculates the union of the given rectangles, stores it in this instance and returns this instance.
-
Constructor Details
-
Rectangle
public Rectangle() -
Rectangle
public Rectangle(int x, int y, int width, int height) -
Rectangle
-
-
Method Details
-
cloneMutable
- Specified by:
cloneMutable
in interfacecom.jogamp.common.type.WriteCloneable
-
getX
public final int getX()- Specified by:
getX
in interfaceRectangleImmutable
-
getY
public final int getY()- Specified by:
getY
in interfaceRectangleImmutable
-
getWidth
public final int getWidth()- Specified by:
getWidth
in interfaceRectangleImmutable
-
getHeight
public final int getHeight()- Specified by:
getHeight
in interfaceRectangleImmutable
-
set
public final void set(int x, int y, int width, int height) -
set
-
set
-
setX
public final void setX(int x) -
setY
public final void setY(int y) -
setWidth
public final void setWidth(int width) -
setHeight
public final void setHeight(int height) -
union
Description copied from interface:RectangleImmutable
Returns the union of this rectangle and the given rectangle.- Specified by:
union
in interfaceRectangleImmutable
-
union
Description copied from interface:RectangleImmutable
Returns the union of this rectangleand the given coordinates.- Specified by:
union
in interfaceRectangleImmutable
-
union
Calculates the union of the given rectangles, stores it in this instance and returns this instance.- Parameters:
rectangles
- given list of rectangles- Returns:
- this instance holding the union of given rectangles.
-
intersection
Description copied from interface:RectangleImmutable
Returns the intersection of this rectangleand the given rectangle.- Specified by:
intersection
in interfaceRectangleImmutable
-
intersection
Description copied from interface:RectangleImmutable
Returns the intersection of this rectangleand the given coordinates.- Specified by:
intersection
in interfaceRectangleImmutable
-
coverage
Description copied from interface:RectangleImmutable
Returns the coverage of given rectangle w/ this this one, i.e. between0.0
and1.0
.Coverage is computed by:
isect = this.intersection(r); coverage = area( isect ) / area( this ) ;
- Specified by:
coverage
in interfaceRectangleImmutable
-
scale
Scale this instance's components, i.e. multiply them by the given scale factors.- Parameters:
sx
- scale factor for xsy
- scale factor for y- Returns:
- this instance for scaling
-
scaleInv
Inverse scale this instance's components, i.e. divide them by the given scale factors.- Parameters:
sx
- inverse scale factor for xsy
- inverse scale factor for y- Returns:
- this instance for scaling
-
compareTo
Description copied from interface:RectangleImmutable
Compares square of size 1st, if equal the square of position.
- Specified by:
compareTo
in interfaceComparable<RectangleImmutable>
- Specified by:
compareTo
in interfaceRectangleImmutable
-
equals
Description copied from interface:RectangleImmutable
Checks whether two rect objects are equal. Two instances ofRectangle
are equal if the four integer values of the fieldsy
,x
,height
, andwidth
are all equal.- Specified by:
equals
in interfaceRectangleImmutable
- Overrides:
equals
in classObject
- Returns:
true
if the two rectangles are equal; otherwisefalse
.
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceRectangleImmutable
- Overrides:
hashCode
in classObject
-
toString
-