Package com.jogamp.nativewindow.util
Class Rectangle
- java.lang.Object
-
- com.jogamp.nativewindow.util.Rectangle
-
- All Implemented Interfaces:
WriteCloneable,RectangleImmutable,Cloneable,Comparable<RectangleImmutable>
public class Rectangle extends Object implements Cloneable, RectangleImmutable
-
-
Constructor Summary
Constructors Constructor Description Rectangle()Rectangle(int x, int y, int width, int height)Rectangle(RectangleImmutable s)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcloneMutable()intcompareTo(RectangleImmutable d)Compares square of size 1st, if equal the square of position.floatcoverage(RectangleImmutable r)Returns the coverage of given rectangle w/ this this one, i.e.booleanequals(Object obj)Checks whether two rect objects are equal.intgetHeight()intgetWidth()intgetX()intgetY()inthashCode()RectangleImmutableintersection(int rx1, int ry1, int rx2, int ry2)Returns the intersection of this rectangleand the given coordinates.RectangleImmutableintersection(RectangleImmutable r)Returns the intersection of this rectangleand the given rectangle.Rectanglescale(int sx, int sy)Scale this instance's components, i.e.RectanglescaleInv(int sx, int sy)Inverse scale this instance's components, i.e.voidset(int x, int y, int width, int height)voidset(Rectangle s)voidset(RectangleImmutable s)voidsetHeight(int height)voidsetWidth(int width)voidsetX(int x)voidsetY(int y)StringtoString()RectangleImmutableunion(int rx1, int ry1, int rx2, int ry2)Returns the union of this rectangleand the given coordinates.RectangleImmutableunion(RectangleImmutable r)Returns the union of this rectangle and the given rectangle.Rectangleunion(List<RectangleImmutable> rectangles)Calculates the union of the given rectangles, stores it in this instance and returns this instance.
-
-
-
Constructor Detail
-
Rectangle
public Rectangle()
-
Rectangle
public Rectangle(int x, int y, int width, int height)
-
Rectangle
public Rectangle(RectangleImmutable s)
-
-
Method Detail
-
cloneMutable
public Object cloneMutable()
- Specified by:
cloneMutablein interfaceWriteCloneable
-
getX
public final int getX()
- Specified by:
getXin interfaceRectangleImmutable
-
getY
public final int getY()
- Specified by:
getYin interfaceRectangleImmutable
-
getWidth
public final int getWidth()
- Specified by:
getWidthin interfaceRectangleImmutable
-
getHeight
public final int getHeight()
- Specified by:
getHeightin interfaceRectangleImmutable
-
set
public final void set(int x, int y, int width, int height)
-
set
public final void set(Rectangle s)
-
set
public final void set(RectangleImmutable s)
-
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
public final RectangleImmutable union(RectangleImmutable r)
Description copied from interface:RectangleImmutableReturns the union of this rectangle and the given rectangle.- Specified by:
unionin interfaceRectangleImmutable
-
union
public final RectangleImmutable union(int rx1, int ry1, int rx2, int ry2)
Description copied from interface:RectangleImmutableReturns the union of this rectangleand the given coordinates.- Specified by:
unionin interfaceRectangleImmutable
-
union
public final Rectangle union(List<RectangleImmutable> rectangles)
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
public final RectangleImmutable intersection(RectangleImmutable r)
Description copied from interface:RectangleImmutableReturns the intersection of this rectangleand the given rectangle.- Specified by:
intersectionin interfaceRectangleImmutable
-
intersection
public final RectangleImmutable intersection(int rx1, int ry1, int rx2, int ry2)
Description copied from interface:RectangleImmutableReturns the intersection of this rectangleand the given coordinates.- Specified by:
intersectionin interfaceRectangleImmutable
-
coverage
public final float coverage(RectangleImmutable r)
Description copied from interface:RectangleImmutableReturns the coverage of given rectangle w/ this this one, i.e. between0.0and1.0.Coverage is computed by:
isect = this.intersection(r); coverage = area( isect ) / area( this ) ;- Specified by:
coveragein interfaceRectangleImmutable
-
scale
public final Rectangle scale(int sx, int sy)
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
public final Rectangle scaleInv(int sx, int sy)
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
public int compareTo(RectangleImmutable d)
Description copied from interface:RectangleImmutableCompares square of size 1st, if equal the square of position.
- Specified by:
compareToin interfaceComparable<RectangleImmutable>- Specified by:
compareToin interfaceRectangleImmutable
-
equals
public boolean equals(Object obj)
Description copied from interface:RectangleImmutableChecks whether two rect objects are equal. Two instances ofRectangleare equal if the four integer values of the fieldsy,x,height, andwidthare all equal.- Specified by:
equalsin interfaceRectangleImmutable- Overrides:
equalsin classObject- Returns:
trueif the two rectangles are equal; otherwisefalse.
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceRectangleImmutable- Overrides:
hashCodein classObject
-
-