|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.umd.cfar.lamp.viper.geometry.PolyList edu.umd.cfar.lamp.viper.geometry.ConvexPolygon edu.umd.cfar.lamp.viper.geometry.BoundingBox
This class reprsents a rectangle aligned with the coordinate axes or a set of such rectangles.
Field Summary |
Fields inherited from class edu.umd.cfar.lamp.viper.geometry.PolyList |
area, bbox, CARVE_POLYS, composed, originals, polys |
Fields inherited from interface edu.umd.cfar.lamp.viper.geometry.Moveable |
EAST, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, WEST |
Constructor Summary | |
BoundingBox()
Construct the empty bounding box. |
|
BoundingBox(double leftEdge,
double bottomEdge,
double width,
double height)
Creates a bounding box in double coordinates. |
|
BoundingBox(int[] dimensions)
Construct a bounding box with the given origin, width and height. |
|
BoundingBox(int leftEdge,
int bottomEdge,
int width,
int height)
Construct a rectangle with the given parameters. |
|
BoundingBox(java.awt.Rectangle dimensions)
Creates a new bounding box from the given java.awt.Rectangle . |
|
BoundingBox(java.lang.String S)
Creates a new Box from a string representation. |
Method Summary | |
Rational |
area()
Calculates the area of the box(es) |
java.lang.Object |
clone()
Copies the box(es). |
boolean |
contains(Pnt point)
Tests to see if any of the boxes contains the specified point |
BoundingBox |
copy()
Like clone, but returns the right type. |
boolean |
equals(java.lang.Object o)
Checks to see if the shapes are equal. |
void |
extendToContain(BoundingBox other)
Unions this with the specified box(es) and sets this to that union. |
Pnt |
getCentroid()
Gets the center of the box. |
int |
getHeight()
Gets the height of the box. |
Pnt |
getNearIntersection(Pnt q1)
Of the two points on the line between this box's centroid and q1 that instersect this box, this returns the one closer to q1. |
java.util.Iterator |
getPolys()
The getPolys iterator returns a set of non-overlapping polygons that, together, cover the same region as this set of boxes. |
java.awt.Rectangle |
getRectangle()
Gets the original rectangle |
int |
getRotation()
Gets the rotation |
int |
getWidth()
Gets the width of the box. |
int |
getX()
Gets the x-coordinate of the box's origin. |
int |
getY()
Gets the y-coordinate of the box's origin. |
protected void |
initBbox()
Creates a BoundingBox around this, for use by getBoundingBox, etc. |
static BoundingBox |
intersection(BoundingBox A,
BoundingBox B)
This creates a new box that represents the area shared by two boxes. |
boolean |
intersects(BoundingBox other)
Tests whether this box intersects the specified box. |
Moveable |
move(int direction,
int distance)
Gets a copy of the box, shifted by the given amount in the specified direction. |
void |
set(int x,
int y,
int width,
int height)
Sets this to refer to only the given bounding box. |
BoundingBox |
setTo(BoundingBox other)
Like an overloaded '='. |
Moveable |
shift(int x,
int y)
Shifts the moveable by the given amount. |
java.lang.String |
toString()
Gets a parsable, human readable version of the box(es). |
static BoundingBox |
union(BoundingBox A,
BoundingBox B)
Gets a set of boxes which covers all and only the pixels covered by A and B . |
static BoundingBox |
valueOf(java.lang.String S)
Creates a new Box from a string representation. |
Methods inherited from class edu.umd.cfar.lamp.viper.geometry.ConvexPolygon |
add, addVertex, clearPolygon, clip, contains, getIntersection, intersection, isInside, subtract, toStringListOfPoints |
Methods inherited from class edu.umd.cfar.lamp.viper.geometry.PolyList |
addPoly, clearPolyList, getBoundingBox, getConvexPolygonArray, getFragmentationCount, getOriginals, getPoints, hashCode, intersection, intersects, union |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public BoundingBox()
public BoundingBox(int[] dimensions)
dimensions
- int array in the form {x, y, width, height}public BoundingBox(int leftEdge, int bottomEdge, int width, int height)
leftEdge
- the distance of the box from the y axisbottomEdge
- the distance of the box from the x axis (in screen
coordinates, a more appropriate name would be topEdge
width
- the width of the boxheight
- the height of the boxpublic BoundingBox(java.awt.Rectangle dimensions)
java.awt.Rectangle
.
dimensions
- the box to usepublic BoundingBox(double leftEdge, double bottomEdge, double width, double height)
leftEdge
- the left edgebottomEdge
- the bottom edge (top in screen coordinates)width
- the width of the boxheight
- the height of the boxpublic BoundingBox(java.lang.String S) throws BadDataException
S
- a string representation, a series of 4 numbers representing
the bottom left corner, width, and height
BadDataException
- if the String is malformedMethod Detail |
public static BoundingBox intersection(BoundingBox A, BoundingBox B)
A
- a box to intersectB
- a box to intersect
public boolean intersects(BoundingBox other)
this
box intersects the specified box.
other
- the other box to test against
true
iff a pixel is shared between the twopublic static BoundingBox valueOf(java.lang.String S)
S
- a string representation, a series of 4 numbers representing
the bottom left corner, width, and height
BoundingBox
represented by the string
BadAttributeDataException
- if the String is malformedpublic BoundingBox setTo(BoundingBox other)
other
- the box(es) to union with this bbox set
this
public void set(int x, int y, int width, int height)
this
to refer to only the given bounding box.
x
- the x coordinate of the box origin pointy
- the y coordinate of the box origin pointwidth
- the width of the boxheight
- the height of the boxpublic BoundingBox copy()
this
public java.lang.Object clone()
clone
in interface BoxInformation
clone
in class ConvexPolygon
public boolean contains(Pnt point)
contains
in interface BoxInformation
contains
in class ConvexPolygon
point
- the point to check for
true
iff at least one of the boxes in this set
contains pointprotected void initBbox()
PolyList
initBbox
in class ConvexPolygon
public java.lang.String toString()
toString
in class ConvexPolygon
public Rational area()
area
in class ConvexPolygon
public boolean equals(java.lang.Object o)
equals
in class ConvexPolygon
o
- the shape to check. Works for most children of
PolyList
.
true
if the given shape covers the same pixels as
this set of boxespublic static BoundingBox union(BoundingBox A, BoundingBox B)
A
and B
.
A
- a set of boxes to union withB
- a set of boxes to union with
public void extendToContain(BoundingBox other)
other
- The box(es) to add to this setpublic java.util.Iterator getPolys()
getPolys
in class ConvexPolygon
public int getX()
getX
in interface BoxInformation
java.lang.ArithmeticException
- if the set of boxes is not a singletonpublic int getY()
getY
in interface BoxInformation
java.lang.ArithmeticException
- if the set of boxes is not a singletonpublic int getWidth()
getWidth
in interface BoxInformation
java.lang.ArithmeticException
- if the set of boxes is not a singletonpublic int getHeight()
getHeight
in interface BoxInformation
java.lang.ArithmeticException
- if the set of boxes is not a singletonpublic java.awt.Rectangle getRectangle()
public int getRotation()
getRotation
in interface BoxInformation
public Pnt getCentroid()
getCentroid
in interface BoxInformation
getCentroid
in class ConvexPolygon
java.lang.ArithmeticException
- if the set of boxes is not a singletonpublic Pnt getNearIntersection(Pnt q1)
getNearIntersection
in interface BoxInformation
getNearIntersection
in class ConvexPolygon
q1
- a point different from the centroid.
public Moveable move(int direction, int distance)
move
in interface Moveable
direction
- the direction to remove the box, e.g. Moveable.NORTH
distance
- the distance to move the box
public Moveable shift(int x, int y)
Moveable
shift
in interface Moveable
x
- y
-
Moveable.shift(int, int)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |