edu.umd.cfar.lamp.viper.geometry
Class OrientedBox

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.geometry.PolyList
      extended byedu.umd.cfar.lamp.viper.geometry.ConvexPolygon
          extended byedu.umd.cfar.lamp.viper.geometry.OrientedBox
All Implemented Interfaces:
BoxInformation, java.lang.Cloneable, HasCentroid, Moveable

public class OrientedBox
extends ConvexPolygon
implements BoxInformation, HasCentroid, Moveable

An Oriented Box is a rectangle that is rotated about its bottom right corner.


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
OrientedBox()
          Constructs the empty oriented box
OrientedBox(int[] params)
          Constructs a new oriented box from the given set of five parameters
OrientedBox(int x, int y, int width, int height, int rotation)
          Creates a new oriented box with the specified parameters
OrientedBox(java.lang.String S)
          Creates a new Oriented Box from a string representation.
 
Method Summary
 java.lang.Object clone()
          Copies the box.
 Pnt getCentroid()
          Gets the approximate center of the box.
 int getHeight()
          Gets the height of the box.
 int getRotation()
          Gets the rotation around the origin.
 int getWidth()
          Gets the width of the box.
 int getX()
          Gets the x-coordinate of the box origin.
 int getY()
          Gets the y-coordinate of the box origin.
protected  void initPoly()
           
 Moveable move(int direction, int distance)
          Creates a new copy of this movable item, shifted in the given direction by the given number of pixels.
 void set(int x, int y, int width, int height, int rotation)
          Directly change the value of this oriented box.
 Moveable shift(int x, int y)
          Shifts the moveable by the given amount.
 java.lang.String toString()
          Gets a String representation of the oriented box
static OrientedBox valueOf(java.lang.String S)
          Creates a new Oriented Box from a string representation.
 
Methods inherited from class edu.umd.cfar.lamp.viper.geometry.ConvexPolygon
add, addVertex, area, clearPolygon, clip, contains, contains, equals, getIntersection, getNearIntersection, getPolys, initBbox, 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
 
Methods inherited from interface edu.umd.cfar.lamp.viper.geometry.BoxInformation
contains, getNearIntersection
 

Constructor Detail

OrientedBox

public OrientedBox()
Constructs the empty oriented box


OrientedBox

public OrientedBox(int[] params)
Constructs a new oriented box from the given set of five parameters

Parameters:
params - an integer array containing x and y coordinates of the box origin, width and height of the box, and angle of rotation in degrees, in that order.

OrientedBox

public OrientedBox(int x,
                   int y,
                   int width,
                   int height,
                   int rotation)
Creates a new oriented box with the specified parameters

Parameters:
x - the x-coordinate of the origin point.
y - the y-coordinate of the origin point
width - the width of the box
height - the height of the box
rotation - the angle of rotation, in degrees.

OrientedBox

public OrientedBox(java.lang.String S)
            throws BadDataException
Creates a new Oriented Box from a string representation.

Parameters:
S - a string representation
Throws:
BadDataException - when the string isn't in the valid form
Method Detail

valueOf

public static OrientedBox valueOf(java.lang.String S)
Creates a new Oriented Box from a string representation.

Parameters:
S - a string representation
Returns:
a new oriented box for the given string
Throws:
BadAttributeDataException - when the string isn't in the valid form

set

public void set(int x,
                int y,
                int width,
                int height,
                int rotation)
Directly change the value of this oriented box.

Parameters:
x - the x-coordinate of the origin
y - the y-coordinate of the origin
width - the width of the box
height - the height of the box
rotation - the orientation of the box

toString

public java.lang.String toString()
Gets a String representation of the oriented box

Overrides:
toString in class ConvexPolygon
Returns:
a space delimited string of integers

clone

public java.lang.Object clone()
Copies the box.

Specified by:
clone in interface BoxInformation
Overrides:
clone in class ConvexPolygon
Returns:
a new copy of the box.

initPoly

protected void initPoly()

getX

public int getX()
Gets the x-coordinate of the box origin.

Specified by:
getX in interface BoxInformation
Returns:
the x-coordinate of the box origin

getY

public int getY()
Gets the y-coordinate of the box origin.

Specified by:
getY in interface BoxInformation
Returns:
the y-coordinate of the box origin

getWidth

public int getWidth()
Gets the width of the box.

Specified by:
getWidth in interface BoxInformation
Returns:
the width of the box

getHeight

public int getHeight()
Gets the height of the box.

Specified by:
getHeight in interface BoxInformation
Returns:
the height of the box

getRotation

public int getRotation()
Gets the rotation around the origin.

Specified by:
getRotation in interface BoxInformation
Returns:
the rotation around the origin in degrees.

getCentroid

public Pnt getCentroid()
Gets the approximate center of the box.

Specified by:
getCentroid in interface BoxInformation
Overrides:
getCentroid in class ConvexPolygon
Returns:
a point pretty close to the center of the box

move

public Moveable move(int direction,
                     int distance)
Description copied from interface: Moveable
Creates a new copy of this movable item, shifted in the given direction by the given number of pixels.

Specified by:
move in interface Moveable
Parameters:
direction - the direction to move the item
distance - the distance to move it
Returns:
the new item, the same as the old one, but shifted
See Also:
Moveable.move(int, int)

shift

public Moveable shift(int x,
                      int y)
Description copied from interface: Moveable
Shifts the moveable by the given amount.

Specified by:
shift in interface Moveable
Parameters:
x -
y -
Returns:
See Also:
Moveable.shift(int, int)