|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.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.
Field Summary | |
---|---|
static Box2D |
INFINITE_BOX
The box corresponding to the the whole plane, with infinite bounds in each direction. |
static Box2D |
UNIT_SQUARE_BOX
The box corresponding to the unit square, with bounds [0 1] in each direction |
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(java.awt.geom.Rectangle2D rect)
Constructor from awt, to allow easy construction from existing apps. |
Method Summary | |
---|---|
boolean |
almostEquals(GeometricObject2D obj,
double eps)
Tests if boxes are the same. |
java.awt.Rectangle |
asAwtRectangle()
Converts to AWT rectangle. |
java.awt.geom.Rectangle2D |
asAwtRectangle2D()
Converts to AWT Rectangle2D. |
Polygon2D |
asRectangle()
Converts to a rectangle. |
Boundary2D |
boundary()
Returns the boundary of this box. |
Box2D |
boundingBox()
Deprecated. useless (0.11.1) |
Box2D |
clip(Box2D box)
Clip this bounding box such that after clipping, it is totally contained in the given box. |
java.util.Collection<StraightLine2D> |
clippingLines()
Returns a set of straight of lines defining half-planes, that all contain the box. |
Box2D |
clone()
|
boolean |
contains(double x,
double y)
Checks if this box contains the point defined by the given coordinates. |
boolean |
contains(Point2D point)
Checks if this box contains the given point. |
boolean |
containsBounds(Shape2D shape)
Tests if the specified Shape is totally contained in this Box2D. |
static Box2D |
create(double xmin,
double xmax,
double ymin,
double ymax)
Deprecated. since 0.11.1 |
static Box2D |
create(Point2D p1,
Point2D p2)
Deprecated. since 0.11.1 |
void |
draw(java.awt.Graphics2D g2)
Draws the boundary of the box on the specified graphics. |
java.util.Collection<LinearShape2D> |
edges()
Returns the set of linear shapes that constitutes the boundary of this box. |
boolean |
equals(java.lang.Object obj)
Test if boxes are the same. two boxes are the same if the have exactly the same bounds. |
void |
fill(java.awt.Graphics2D g2)
Fills the content of the box on the specified graphics. |
double |
getHeight()
|
double |
getMaxX()
|
double |
getMaxY()
|
double |
getMinX()
|
double |
getMinY()
|
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. |
java.lang.String |
toString()
|
Box2D |
transform(AffineTransform2D trans)
Returns the new box created by an affine transform of this box. |
Box2D |
union(Box2D box)
Returns the Box2D which contains both this box and the specified box. |
int |
vertexNumber()
Returns the number of vertices of the box. |
java.util.Collection<Point2D> |
vertices()
|
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Box2D UNIT_SQUARE_BOX
public static final Box2D INFINITE_BOX
Constructor Detail |
---|
public Box2D()
public Box2D(double x0, double x1, double y0, double y1)
public Box2D(java.awt.geom.Rectangle2D rect)
public Box2D(Point2D p1, Point2D p2)
public Box2D(Point2D point, double w, double h)
Method Detail |
---|
@Deprecated public static Box2D create(double xmin, double xmax, double ymin, double ymax)
@Deprecated public static 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 java.util.Collection<StraightLine2D> clippingLines()
public java.util.Collection<LinearShape2D> edges()
public Boundary2D boundary()
public java.util.Collection<Point2D> vertices()
public int vertexNumber()
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 java.awt.Rectangle asAwtRectangle()
public java.awt.geom.Rectangle2D asAwtRectangle2D()
public Polygon2D asRectangle()
public void draw(java.awt.Graphics2D g2)
g2
- the instance of graphics to draw in.
UnboundedBox2DException
- if the box is unboundedpublic void fill(java.awt.Graphics2D g2)
g2
- the instance of graphics to draw in.
UnboundedBox2DException
- if the box is unbounded@Deprecated public Box2D boundingBox()
public boolean almostEquals(GeometricObject2D obj, double eps)
almostEquals
in interface GeometricObject2D
obj
- the object to compareeps
- a threshold value, for example the minimal coordinate difference
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public Box2D clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |