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

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.geometry.Ellipse
All Implemented Interfaces:
java.lang.Cloneable, HasCentroid, Moveable

public class Ellipse
extends java.lang.Object
implements java.lang.Cloneable, HasCentroid, Moveable

An ellipse. It does not support the functions necessary for advanced comparison (union, etc.) yet.


Field Summary
 
Fields inherited from interface edu.umd.cfar.lamp.viper.geometry.Moveable
EAST, NORTH, NORTHEAST, NORTHWEST, SOUTH, SOUTHEAST, SOUTHWEST, WEST
 
Constructor Summary
Ellipse()
          Constructs a new null ellipse
Ellipse(Ellipse old)
          Copy constructor.
Ellipse(int x, int y, int width, int height, int rotation)
          Constructs a new ellipse with the given parameters
 
Method Summary
 double area()
          Approximates the area of the ellipse.
 java.lang.Object clone()
          Copies the ellipse.
 boolean contains(Pnt point)
          Tests to see if the point is within this ellipse.
 boolean equals(java.lang.Object o)
          Tests to see the two objects are equal.
 BoundingBox getBoundingBox()
          Gets the bounding box around the ellipse
 Pnt getCentroid()
          Gets a copy of the centroid.
 Rational getHeight()
          Gets the height of the ellipse
 int getRotation()
           
 Rational getWidth()
          Gets the width of the ellipse
 Rational getX()
          Gets the x-coordinate of the origin
 Rational getY()
          Gets the y-coordinate of the origin
 double intersectArea(Ellipse other)
          Computes the area shared between the two ellipses
 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.
 Moveable shift(int x, int y)
          Shifts the moveable by the given amount.
 java.lang.String toString()
          Prints out the circle in the ViPER format.
static Ellipse valueOf(java.lang.String S)
          Constructs a new ellipse from the given string
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ellipse

public Ellipse()
Constructs a new null ellipse


Ellipse

public Ellipse(int x,
               int y,
               int width,
               int height,
               int rotation)
Constructs a new ellipse with the given parameters

Parameters:
x - the x-coordinate of the ellipse's bounding box's origin
y - the y-coordinate of the ellipse's bounding box's origin
width - the width of the ellipse
height - the height of the ellipse
rotation -

Ellipse

public Ellipse(Ellipse old)
Copy constructor.

Parameters:
old - the ellipse to copy
Method Detail

equals

public boolean equals(java.lang.Object o)
Tests to see the two objects are equal.

Parameters:
o - the ellipse to check against
Returns:
true iff o is an Ellipse that represents the same shape

valueOf

public static Ellipse valueOf(java.lang.String S)
Constructs a new ellipse from the given string

Parameters:
S - the string to parse - a space delimited list of four integers
Returns:
the Ellipse represented by the string.
Throws:
BadAttributeDataException

toString

public java.lang.String toString()
Prints out the circle in the ViPER format.

Returns:
a space delimited list of four integers

clone

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

Returns:
a new copy of this ellipse

contains

public boolean contains(Pnt point)
Tests to see if the point is within this ellipse. At the moment, just throws an exception.

Parameters:
point - the point to test for
Returns:
true, if the point is in or on the ellipse

getBoundingBox

public BoundingBox getBoundingBox()
Gets the bounding box around the ellipse

Returns:
the closest box surrounding the ellipse

area

public double area()
Approximates the area of the ellipse. Currently not implemented.

Returns:
the area of the ellipse

intersectArea

public double intersectArea(Ellipse other)
Computes the area shared between the two ellipses

Parameters:
other - the area to intersect with
Returns:
the shared area

getX

public Rational getX()
Gets the x-coordinate of the origin

Returns:
the x-coordinate of the origin

getY

public Rational getY()
Gets the y-coordinate of the origin

Returns:
the y-coordinate of the origin

getWidth

public Rational getWidth()
Gets the width of the ellipse

Returns:
the width of the ellipse

getHeight

public Rational getHeight()
Gets the height of the ellipse

Returns:
the height of the ellipse

getRotation

public int getRotation()
Returns:

getCentroid

public Pnt getCentroid()
Description copied from interface: HasCentroid
Gets a copy of the centroid.

Specified by:
getCentroid in interface HasCentroid
Returns:
the centroid of the object
See Also:
HasCentroid.getCentroid()

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)