public class Rectangle2D extends Object implements Polygon2D
| Modifier and Type | Field and Description |
|---|---|
protected double |
h |
protected double |
theta |
protected double |
w |
protected double |
x0 |
protected double |
y0 |
| Constructor and Description |
|---|
Rectangle2D()
Empty contructor (size and position zero)
|
Rectangle2D(double x0,
double y0,
double w,
double h)
Main constructor
|
Rectangle2D(double x0,
double y0,
double w,
double h,
double theta)
Main constructor
|
Rectangle2D(Point2D point,
double w,
double h)
Main constructor
|
Rectangle2D(Point2D point,
double w,
double h,
double theta)
Main constructor
|
Rectangle2D(Rectangle2D rect)
Constructor from awt, to allow easy construction from existing apps.
|
| Modifier and Type | Method and Description |
|---|---|
Domain2D |
clip(Box2D box)
Return the clipped polygon.
|
Polygon2D |
complement()
Returns the complementary polygon.
|
boolean |
contains(double x,
double y)
Checks if the shape contains the planar point defined by (x,y).
|
boolean |
contains(Point2D point)
This method simply invoke ancestor method.
|
void |
draw(Graphics2D g2)
Draw the shape on the given graphics.
|
boolean |
equals(Object obj)
Test if retangles are the same.
|
void |
fill(Graphics2D g)
Fills the interior of the domain, using the Graphics current Paint.
|
CirculinearBoundarySet2D<LinearRing2D> |
getBoundary()
Returns the boundary of the set.
|
Box2D |
getBoundingBox()
Return bounding box of the rectangle.
|
CirculinearDomain2D |
getBuffer(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.
|
double |
getDistance(double x,
double y)
get the distance of the shape to the given point, specified by x and y,
or the distance of point to the frontier of the shape in the case of a
plain (i.e.
|
double |
getDistance(Point2D p)
get the distance of the shape to the given point, or the distance of
point to the frontier of the shape in the case of a plain shape.
|
int |
getEdgeNumber()
Returns the number of edges of the polygon
|
Collection<LineSegment2D> |
getEdges()
Return the edges as line segments of the polygon
|
double |
getHeight() |
Collection<LinearRing2D> |
getRings()
Returns the set of rings comprising the boundary of this polygon.
|
double |
getSignedDistance(double x,
double y)
Get the signed distance of the shape to the given point : this distance
is positive if the point lies outside the shape, and is negative if the
point lies inside the shape.
|
double |
getSignedDistance(Point2D p)
Get the signed distance of the shape to the given point : this distance
is positive if the point lies outside the shape, and is negative if the
point lies inside the shape.
|
double |
getTheta() |
Point2D |
getVertex(int i)
Returns the i-th vertex of the polygon.
|
int |
getVertexNumber()
Return the number of vertices of the rectangle, which is 4.
|
Collection<Point2D> |
getVertices()
Returns the vertices of the rectangle as a collection of points.
|
double |
getWidth() |
double |
getX() |
double |
getY() |
boolean |
isBounded()
Always returns true, because a rectangle is always bounded.
|
boolean |
isEmpty()
Returns true if the shape does not contain any point.
|
void |
setRectangle(double x,
double y,
double width,
double height,
double theta)
Apply the characteristics of the given Rectangle to this object.
|
void |
setRectangle(Rectangle2D rect)
Apply the characteristics of the given Rectangle to this object.
|
void |
setRectangle(Rectangle2D rect)
Apply the characteristics of the given Rectangle to this object.
|
SimplePolygon2D |
transform(AffineTransform2D trans)
Return the new Polygon created by an affine transform of this polygon.
|
CirculinearDomain2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion.
|
protected double x0
protected double y0
protected double w
protected double h
protected double theta
public Rectangle2D(double x0,
double y0,
double w,
double h,
double theta)
public Rectangle2D()
public Rectangle2D(Rectangle2D rect)
public Rectangle2D(double x0,
double y0,
double w,
double h)
public Rectangle2D(Point2D point, double w, double h, double theta)
public Rectangle2D(Point2D point, double w, double h)
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public double getTheta()
public void setRectangle(Rectangle2D rect)
public void setRectangle(Rectangle2D rect)
public void setRectangle(double x,
double y,
double width,
double height,
double theta)
public Collection<Point2D> getVertices()
getVertices in interface Polygon2Dpublic Point2D getVertex(int i)
public int getVertexNumber()
getVertexNumber in interface Polygon2Dpublic Collection<LineSegment2D> getEdges()
Polygon2Dpublic int getEdgeNumber()
Polygon2DgetEdgeNumber in interface Polygon2Dpublic Collection<LinearRing2D> getRings()
Polygon2Dpublic CirculinearDomain2D transform(CircleInversion2D inv)
CirculinearShape2Dtransform in interface CirculinearDomain2Dtransform in interface CirculinearShape2Dinv - the circle inversionpublic CirculinearDomain2D getBuffer(double dist)
CirculinearShape2DgetBuffer in interface CirculinearShape2Ddist - the maximal distance between a point of the buffer and the
shapepublic CirculinearBoundarySet2D<LinearRing2D> getBoundary()
Domain2DThe returned curve is oriented, with an interior and an exterior.
getBoundary in interface CirculinearDomain2DgetBoundary in interface Domain2DgetBoundary in interface Polygon2Dpublic Polygon2D complement()
Polygon2Dcomplement in interface Domain2Dcomplement in interface Polygon2Dpublic boolean isBounded()
public boolean isEmpty()
Shape2Dpublic double getDistance(Point2D p)
Shape2DgetDistance in interface Shape2Dpublic double getDistance(double x,
double y)
Shape2DgetDistance in interface Shape2Dpublic double getSignedDistance(Point2D p)
public double getSignedDistance(double x,
double y)
public Box2D getBoundingBox()
getBoundingBox in interface Shape2Dpublic SimplePolygon2D transform(AffineTransform2D trans)
public boolean contains(Point2D point)
public boolean contains(double x,
double y)
Shape2Dpublic void draw(Graphics2D g2)
Shape2Dpublic void fill(Graphics2D g)
Domain2DCopyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.