public class Rectangle extends Object implements Cloneable, RectangleImmutable
| Constructor and Description |
|---|
Rectangle() |
Rectangle(int x,
int y,
int width,
int height) |
| Modifier and Type | Method and Description |
|---|---|
Object |
cloneMutable() |
int |
compareTo(RectangleImmutable d)
Compares square of size 1st, if equal the square of position.
|
float |
coverage(RectangleImmutable r)
Returns the coverage of given rectangle w/ this this one, i.e.
|
boolean |
equals(Object obj)
Checks whether two rect objects are equal.
|
int |
getHeight() |
int |
getWidth() |
int |
getX() |
int |
getY() |
int |
hashCode() |
RectangleImmutable |
intersection(int rx1,
int ry1,
int rx2,
int ry2)
Returns the intersection of this rectangleand the given coordinates.
|
RectangleImmutable |
intersection(RectangleImmutable r)
Returns the intersection of this rectangleand the given rectangle.
|
Rectangle |
scale(int sx,
int sy)
Scale this instance's components,
i.e.
|
Rectangle |
scaleInv(int sx,
int sy)
Inverse scale this instance's components,
i.e.
|
void |
set(int x,
int y,
int width,
int height) |
void |
setHeight(int height) |
void |
setWidth(int width) |
void |
setX(int x) |
void |
setY(int y) |
String |
toString() |
RectangleImmutable |
union(int rx1,
int ry1,
int rx2,
int ry2)
Returns the union of this rectangleand the given coordinates.
|
Rectangle |
union(List<RectangleImmutable> rectangles)
Calculates the union of the given rectangles, stores it in this instance and returns this instance.
|
RectangleImmutable |
union(RectangleImmutable r)
Returns the union of this rectangle and the given rectangle.
|
public Rectangle()
public Rectangle(int x,
int y,
int width,
int height)
public Object cloneMutable()
cloneMutable in interface WriteCloneablepublic final int getX()
getX in interface RectangleImmutablepublic final int getY()
getY in interface RectangleImmutablepublic final int getWidth()
getWidth in interface RectangleImmutablepublic final int getHeight()
getHeight in interface RectangleImmutablepublic final void set(int x,
int y,
int width,
int height)
public final void setX(int x)
public final void setY(int y)
public final void setWidth(int width)
public final void setHeight(int height)
public final RectangleImmutable union(RectangleImmutable r)
RectangleImmutableunion in interface RectangleImmutablepublic final RectangleImmutable union(int rx1, int ry1, int rx2, int ry2)
RectangleImmutableunion in interface RectangleImmutablepublic final Rectangle union(List<RectangleImmutable> rectangles)
rectangles - given list of rectanglespublic final RectangleImmutable intersection(RectangleImmutable r)
RectangleImmutableintersection in interface RectangleImmutablepublic final RectangleImmutable intersection(int rx1, int ry1, int rx2, int ry2)
RectangleImmutableintersection in interface RectangleImmutablepublic final float coverage(RectangleImmutable r)
RectangleImmutable0.0 and 1.0.
Coverage is computed by:
isect = this.intersection(r);
coverage = area( isect ) / area( this ) ;
coverage in interface RectangleImmutablepublic final Rectangle scale(int sx, int sy)
sx - scale factor for xsy - scale factor for ypublic final Rectangle scaleInv(int sx, int sy)
sx - inverse scale factor for xsy - inverse scale factor for ypublic int compareTo(RectangleImmutable d)
RectangleImmutableCompares square of size 1st, if equal the square of position.
compareTo in interface Comparable<RectangleImmutable>compareTo in interface RectangleImmutablepublic boolean equals(Object obj)
RectangleImmutableRectangle are equal if the four integer values
of the fields y, x,
height, and width are all equal.equals in interface RectangleImmutableequals in class Objecttrue if the two rectangles are equal;
otherwise false.public int hashCode()
hashCode in interface RectangleImmutablehashCode in class ObjectCopyright 2010 JogAmp Community.