|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmath.geom2d.Box2D
public class Box2D
This class defines bounds of a shape. It stores limits in each direction:
x
and y
. It also provides methods for clipping
others shapes, depending on their type.
Constructor Summary | |
---|---|
Box2D()
Empty constructor (size and position zero) |
|
Box2D(double x0,
double x1,
double y0,
double y1)
Main constructor, given bounds for x coord, then bounds for y coord. |
|
Box2D(Point2D point,
double w,
double h)
Constructor from a point, a width and an height |
|
Box2D(Point2D p1,
Point2D p2)
Constructor from 2 points, giving extreme coordinates of the box. |
|
Box2D(Rectangle2D rect)
Constructor from awt, to allow easy construction from existing apps. |
Method Summary | |
---|---|
Box2D |
clip(Box2D box)
Clip this bounding box such that after clipping, it is totally contained in the given box. |
Box2D |
clone()
|
boolean |
contains(double x,
double y)
|
boolean |
contains(Point2D point)
|
boolean |
containsBounds(Shape2D shape)
Test if the specified Shape is totally contained in this Box2D. |
static Box2D |
create(double xmin,
double xmax,
double ymin,
double ymax)
|
static Box2D |
create(Point2D p1,
Point2D p2)
|
void |
draw(Graphics2D g2)
|
boolean |
equals(Object obj)
Test if boxes are the same. |
void |
fill(Graphics2D g2)
|
Rectangle |
getAsAWTRectangle()
convert to AWT rectangle. |
Rectangle2D |
getAsAWTRectangle2D()
convert to AWT Rectangle2D. |
HRectangle2D |
getAsRectangle()
Converts to a rectangle. |
Boundary2D |
getBoundary()
Returns the boundary of this box. |
Box2D |
getBoundingBox()
|
Collection<StraightLine2D> |
getClippingLines()
Returns a set of straight of lines defining half-planes, that all contain the box. |
Collection<LinearShape2D> |
getEdges()
Returns the set of linear shapes that constitutes the boundary of this box. |
double |
getHeight()
|
double |
getMaxX()
|
double |
getMaxY()
|
double |
getMinX()
|
double |
getMinY()
|
int |
getVertexNumber()
Returns the number of vertices of the box. |
Collection<Point2D> |
getVertices()
|
double |
getWidth()
|
Box2D |
intersection(Box2D box)
Returns the Box2D which is contained both by this box and by the specified box. |
boolean |
isBounded()
Returns true if all bounds are finite. |
Box2D |
merge(Box2D box)
Changes the bounds of this box to also include bounds of the argument. |
String |
toString()
|
Box2D |
transform(AffineTransform2D trans)
Return the new domain created by an affine transform of this box. |
Box2D |
union(Box2D box)
Returns the Box2D which contains both this box and the specified box. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Box2D()
public Box2D(double x0, double x1, double y0, double y1)
public Box2D(Rectangle2D rect)
public Box2D(Point2D p1, Point2D p2)
public Box2D(Point2D point, double w, double h)
Method Detail |
---|
public static final Box2D create(double xmin, double xmax, double ymin, double ymax)
public static final Box2D create(Point2D p1, Point2D p2)
public double getMinX()
public double getMinY()
public double getMaxX()
public double getMaxY()
public double getWidth()
public double getHeight()
public boolean isBounded()
public boolean contains(Point2D point)
public boolean contains(double x, double y)
public boolean containsBounds(Shape2D shape)
public Collection<StraightLine2D> getClippingLines()
public Collection<LinearShape2D> getEdges()
public Boundary2D getBoundary()
public Collection<Point2D> getVertices()
public int getVertexNumber()
public Box2D union(Box2D box)
box
- the bounding box to include
public Box2D intersection(Box2D box)
box
- the bounding box to include
public Box2D merge(Box2D box)
box
- the bounding box to include
public Box2D clip(Box2D box)
public Box2D transform(AffineTransform2D trans)
public Rectangle getAsAWTRectangle()
public Rectangle2D getAsAWTRectangle2D()
public HRectangle2D getAsRectangle()
public void draw(Graphics2D g2)
public void fill(Graphics2D g2)
public Box2D getBoundingBox()
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
public Box2D clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |