|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.geom2d.polygon.Rectangle2D
public class Rectangle2D
Rectangle2D defines a rectangle rotated around its first corner.
Field Summary |
---|
Fields inherited from interface math.geom2d.Shape2D |
---|
ACCURACY |
Constructor Summary | |
---|---|
Rectangle2D()
Empty constructor (size and position zero) |
|
Rectangle2D(double x0,
double y0,
double w,
double h)
Main constructor, specifying position of reference corner and rectangle dimensions. |
|
Rectangle2D(Point2D p1,
Point2D p2)
Creates a rectangle from two corner points. |
|
Rectangle2D(java.awt.geom.Rectangle2D rect)
Constructor from awt, to allow easy construction from existing apps. |
Method Summary | |
---|---|
void |
addVertex(Point2D point)
Adds a vertex as last vertex of this polygon. |
boolean |
almostEquals(GeometricObject2D obj,
double eps)
Checks if the two objects are similar up to a given threshold value. |
double |
area()
Computes the area of this rectangle, given by the product of width by height. |
Polygon2D |
asPolygon(int n)
Returns an approximation of the domain as a polygon, or a MultiPolygon. |
CirculinearContourArray2D<LinearRing2D> |
boundary()
Overrides the definition of boundary() such that the boundary of a polygon is defined as a set of LinearRing2D. |
Box2D |
boundingBox()
Returns the bounding box of the rectangle. |
CirculinearDomain2D |
buffer(double dist)
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d. |
Point2D |
centroid()
Computes the centroid (center of mass) of this rectangle. |
Polygon2D |
clip(Box2D box)
Returns the clipped polygon. |
int |
closestVertexIndex(Point2D point)
Computes the index of the closest vertex to the input point. |
Polygon2D |
complement()
Returns a new simple Polygon whose vertices are in reverse order of this rectangle. |
boolean |
contains(double x,
double y)
Checks if this rectangle contains the point given by (x,y) |
boolean |
contains(Point2D point)
Checks if this rectangle contains the given point. |
java.util.Collection<LinearRing2D> |
contours()
Returns the set of contours that enclose this domain. |
double |
distance(double x,
double y)
Returns the distance of the point to the polygon. |
double |
distance(Point2D p)
Returns the distance of the point to the polygon. |
void |
draw(java.awt.Graphics2D g2)
Draws the shape on the given graphics. |
int |
edgeNumber()
Returns 4, as a rectangle has four edges. |
java.util.Collection<LineSegment2D> |
edges()
Returns the four edges that constitute the boundary of this rectangle. |
boolean |
equals(java.lang.Object obj)
Tests if rectangles are the same. |
void |
fill(java.awt.Graphics2D g2)
Fills the interior of the domain, using the Graphics current Paint. |
double |
getHeight()
|
double |
getWidth()
|
double |
getX()
|
double |
getY()
|
void |
insertVertex(int i,
Point2D point)
Inserts a vertex at the specified position. |
boolean |
isBounded()
Always returns true, because a rectangle is always bounded. |
boolean |
isEmpty()
Returns true if the shape does not contain any point. |
void |
removeVertex(int i)
Removes the vertex at the given index. |
void |
setVertex(int i,
Point2D point)
Sets the position of the i-th vertex |
SimplePolygon2D |
transform(AffineTransform2D trans)
Returns the new Polygon created by an affine transform of this polygon. |
CirculinearDomain2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion. |
Point2D |
vertex(int i)
Returns the i-th vertex of the polygon. |
int |
vertexNumber()
Returns the number of vertices of the rectangle, which is 4. |
java.util.Collection<Point2D> |
vertices()
Returns the vertices of the rectangle as a collection of points. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Rectangle2D(double x0, double y0, double w, double h)
public Rectangle2D()
public Rectangle2D(java.awt.geom.Rectangle2D rect)
public Rectangle2D(Point2D p1, Point2D p2)
Method Detail |
---|
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public java.util.Collection<Point2D> vertices()
vertices
in interface Polygon2D
public int vertexNumber()
vertexNumber
in interface Polygon2D
public Point2D vertex(int i)
vertex
in interface Polygon2D
i
- index of the vertex, between 0 and 3public void setVertex(int i, Point2D point)
Polygon2D
setVertex
in interface Polygon2D
i
- the vertex indexpoint
- the new position of the vertexpublic void addVertex(Point2D point)
Polygon2D
addVertex
in interface Polygon2D
point
- the position of the new vertexpublic void insertVertex(int i, Point2D point)
Polygon2D
insertVertex
in interface Polygon2D
i
- index at which the specified vertex is to be insertedpoint
- the position of the new vertexpublic void removeVertex(int i)
Polygon2D
removeVertex
in interface Polygon2D
i
- index of the vertex to removepublic int closestVertexIndex(Point2D point)
closestVertexIndex
in interface Polygon2D
public java.util.Collection<LineSegment2D> edges()
edges
in interface Polygon2D
public int edgeNumber()
edgeNumber
in interface Polygon2D
public double area()
area
in interface Polygon2D
public Point2D centroid()
centroid
in interface Polygon2D
public Polygon2D asPolygon(int n)
Domain2D
asPolygon
in interface Domain2D
public CirculinearDomain2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearDomain2D
transform
in interface CirculinearShape2D
inv
- the circle inversion
public CirculinearDomain2D buffer(double dist)
CirculinearShape2D
buffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shape
public CirculinearContourArray2D<LinearRing2D> boundary()
Polygon2D
boundary
in interface CirculinearDomain2D
boundary
in interface Domain2D
boundary
in interface Polygon2D
public java.util.Collection<LinearRing2D> contours()
Domain2D
contours
in interface CirculinearDomain2D
contours
in interface Domain2D
contours
in interface Polygon2D
Contour2D
public Polygon2D complement()
complement
in interface CirculinearDomain2D
complement
in interface Domain2D
complement
in interface Polygon2D
public boolean isBounded()
isBounded
in interface Shape2D
public boolean isEmpty()
Shape2D
isEmpty
in interface Shape2D
public double distance(Point2D p)
distance
in interface Shape2D
public double distance(double x, double y)
distance
in interface Shape2D
public Polygon2D clip(Box2D box)
clip
in interface Domain2D
clip
in interface Polygon2D
clip
in interface Shape2D
box
- the clipping box
public Box2D boundingBox()
boundingBox
in interface Shape2D
public SimplePolygon2D transform(AffineTransform2D trans)
transform
in interface Domain2D
transform
in interface Polygon2D
transform
in interface Shape2D
trans
- an affine transform
public boolean contains(Point2D point)
contains
in interface Shape2D
public boolean contains(double x, double y)
contains
in interface Shape2D
public void draw(java.awt.Graphics2D g2)
Shape2D
draw
in interface Domain2D
draw
in interface Shape2D
g2
- the Graphics to draw onpublic void fill(java.awt.Graphics2D g2)
Domain2D
fill
in interface Domain2D
g2
- the Graphics to fill onpublic boolean almostEquals(GeometricObject2D obj, double eps)
GeometricObject2D
almostEquals
in interface GeometricObject2D
obj
- the object to compareeps
- a threshold value, for example the minimal coordinate difference
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |