Package com.ardor3d.math
Class Rectangle2
java.lang.Object
com.ardor3d.math.Rectangle2
- All Implemented Interfaces:
Poolable
,ReadOnlyRectangle2
,Savable
,Externalizable
,Serializable
,Cloneable
public class Rectangle2
extends Object
implements Cloneable, Savable, Externalizable, ReadOnlyRectangle2, Poolable
Defines a finite plane within two dimensional space that is specified via an origin (x,y - considered bottom left usually) and a width and height.
This class is at least partially patterned after awt's Rectangle class.- See Also:
-
Constructor Summary
ConstructorDescriptionConstructor creates a newRectangle2
with its origin at 0,0 and width/height of 0.Rectangle2
(int x, int y, int width, int height) Constructor creates a newRectangle2
with using the given x,y,width and height values.Rectangle2
(ReadOnlyRectangle2 source) Constructor creates a newRectangle2
using the values of the provided source rectangle. -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
static final Rectangle2
Class
<? extends Rectangle2> int
int
getWidth()
int
getX()
int
getY()
int
hashCode()
intersect
(ReadOnlyRectangle2 other, Rectangle2 store) static Rectangle2
intersect
(ReadOnlyRectangle2 src1, ReadOnlyRectangle2 src2, Rectangle2 store) void
read
(InputCapsule capsule) void
Used with serialization.static final void
releaseTempInstance
(Rectangle2 rectangle) Releases a Rectangle2 back to be used by a future call to fetchTempInstance.set
(int x, int y, int width, int height) set
(ReadOnlyRectangle2 rect) void
setHeight
(int height) void
setWidth
(int width) void
setX
(int x) void
setY
(int y) toString()
void
write
(OutputCapsule capsule) void
Used with serialization.
-
Constructor Details
-
Rectangle2
public Rectangle2()Constructor creates a newRectangle2
with its origin at 0,0 and width/height of 0. -
Rectangle2
public Rectangle2(int x, int y, int width, int height) Constructor creates a newRectangle2
with using the given x,y,width and height values.- Parameters:
x
- the x valuey
- the y valuewidth
- the widthheight
- the height
-
Rectangle2
Constructor creates a newRectangle2
using the values of the provided source rectangle.- Parameters:
source
- the rectangle to copy from
-
-
Method Details
-
getX
public int getX()- Specified by:
getX
in interfaceReadOnlyRectangle2
- Returns:
- the x coordinate of the origin of this rectangle.
-
setX
public void setX(int x) - Parameters:
x
- the new x coordinate of the origin of this rectangle
-
getY
public int getY()- Specified by:
getY
in interfaceReadOnlyRectangle2
- Returns:
- the y coordinate of the origin of this rectangle.
-
setY
public void setY(int y) - Parameters:
y
- the new y coordinate of the origin of this rectangle
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceReadOnlyRectangle2
- Returns:
- the width of this rectangle.
-
setWidth
public void setWidth(int width) - Parameters:
width
- the new width of this rectangle
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceReadOnlyRectangle2
- Returns:
- the height of this rectangle.
-
setHeight
public void setHeight(int height) - Parameters:
height
- the new height of this rectangle
-
set
-
set
-
intersect
-
intersect
public static Rectangle2 intersect(ReadOnlyRectangle2 src1, ReadOnlyRectangle2 src2, Rectangle2 store) -
toString
-
hashCode
public int hashCode() -
equals
-
clone
- Specified by:
clone
in interfaceReadOnlyRectangle2
- Overrides:
clone
in classObject
- Returns:
- a new instance of Rectangle2 with the same value as this object.
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-
readExternal
Used with serialization. Not to be called manually.- Specified by:
readExternal
in interfaceExternalizable
- Parameters:
in
- ObjectInput- Throws:
IOException
- if something wrong occurs while readingClassNotFoundException
- if a class is not found
-
writeExternal
Used with serialization. Not to be called manually.- Specified by:
writeExternal
in interfaceExternalizable
- Parameters:
out
- ObjectOutput- Throws:
IOException
- if something wrong occurs while writing
-
fetchTempInstance
- Returns:
- An instance of Rectangle2 that is intended for temporary use in calculations and so forth. Multiple calls to the method should return instances of this class that are not currently in use.
-
releaseTempInstance
Releases a Rectangle2 back to be used by a future call to fetchTempInstance. TAKE CARE: this object should no longer have other classes referencing it or "Bad Things" will happen.- Parameters:
rectangle
- the Rectangle2 to release.
-