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 WriteCloneable
public final int getX()
getX
in interface RectangleImmutable
public final int getY()
getY
in interface RectangleImmutable
public final int getWidth()
getWidth
in interface RectangleImmutable
public final int getHeight()
getHeight
in interface RectangleImmutable
public 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)
RectangleImmutable
union
in interface RectangleImmutable
public final RectangleImmutable union(int rx1, int ry1, int rx2, int ry2)
RectangleImmutable
union
in interface RectangleImmutable
public final Rectangle union(List<RectangleImmutable> rectangles)
rectangles
- given list of rectanglespublic final RectangleImmutable intersection(RectangleImmutable r)
RectangleImmutable
intersection
in interface RectangleImmutable
public final RectangleImmutable intersection(int rx1, int ry1, int rx2, int ry2)
RectangleImmutable
intersection
in interface RectangleImmutable
public final float coverage(RectangleImmutable r)
RectangleImmutable
0.0
and 1.0
.
Coverage is computed by:
isect = this.intersection(r); coverage = area( isect ) / area( this ) ;
coverage
in interface RectangleImmutable
public 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)
RectangleImmutable
Compares square of size 1st, if equal the square of position.
compareTo
in interface Comparable<RectangleImmutable>
compareTo
in interface RectangleImmutable
public boolean equals(Object obj)
RectangleImmutable
Rectangle
are equal if the four integer values
of the fields y
, x
,
height
, and width
are all equal.equals
in interface RectangleImmutable
equals
in class Object
true
if the two rectangles are equal;
otherwise false
.public int hashCode()
hashCode
in interface RectangleImmutable
hashCode
in class Object
Copyright 2010 JogAmp Community.