org.starhope.appius.geometry
Class Rectangle

java.lang.Object
  extended by org.starhope.appius.geometry.Rectangle
All Implemented Interfaces:
PolygonPrimitive<Rectangle>

public class Rectangle
extends Object
implements PolygonPrimitive<Rectangle>

Rectangle special case of a general polygon. Useful for it's commonality

Author:
ewinkelman

Field Summary
protected  double height
          WRITEME: Document this brpocock@star-hope.org
protected  Coord2D origin
          WRITEME: Document this brpocock@star-hope.org
protected  Polygon polygon
          WRITEME: Document this brpocock@star-hope.org
protected  double width
          WRITEME: Document this brpocock@star-hope.org
 
Constructor Summary
Rectangle(Coord2D oneCorner, Coord2D otherCorner)
          WRITEME brpocock@star-hope.org
Rectangle(Coord2D ul, double w, double h)
          Creates a rectangle
 
Method Summary
 boolean contains(Coord2D coord2d)
          Determines if the polygon contains that point
 boolean contains(double x, double y)
          Determines if the polygon contains that point
private  void generateLineSegments()
          Generates the line segments for the rectangle on demand so that we delay generating them until later if they're not going to be used
 Coord2D getCenter()
           
 double getHeight()
           
 Coord2D getOrigin()
           
 double getWidth()
           
 Coord2D[] intersection(LineSeg2D lSeg2d)
          Finds the intersection points for the polygon with the line segment
 boolean intersects(LineSeg2D lSeg2d)
          Determines if the polygon intersects the line segment
 boolean intersects(PolygonPrimitive<?> otherPolygon)
          Determines if this polygon intersects with another one
 boolean intersectsCircle(Circle circle)
          Determines if the polygon intersects a circle
 boolean intersectsPoly(Polygon otherPolygon)
          Determines if the polygon intersects a polygon
 boolean intersectsRect(Rectangle rectangle)
          Determines if the polygon intersects a rectangle
 Rectangle scale(double sizeScalar)
          WRITEME: Document this method brpocock@star-hope.org
 Rectangle translate(Coord2D coord2d)
          WRITEME: Document this method brpocock@star-hope.org
 Rectangle translate(double x, double y)
          Translates the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

height

protected final double height
WRITEME: Document this brpocock@star-hope.org


origin

protected final Coord2D origin
WRITEME: Document this brpocock@star-hope.org


polygon

protected Polygon polygon
WRITEME: Document this brpocock@star-hope.org


width

protected final double width
WRITEME: Document this brpocock@star-hope.org

Constructor Detail

Rectangle

public Rectangle(Coord2D oneCorner,
                 Coord2D otherCorner)
WRITEME brpocock@star-hope.org

Parameters:
oneCorner - WRITEME
otherCorner - WRITEME

Rectangle

public Rectangle(Coord2D ul,
                 double w,
                 double h)
Creates a rectangle

Parameters:
ul - Upper left hand coordinate
w - Width
h - Height
Method Detail

contains

public boolean contains(Coord2D coord2d)
Description copied from interface: PolygonPrimitive
Determines if the polygon contains that point

Specified by:
contains in interface PolygonPrimitive<Rectangle>
Parameters:
coord2d - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.contains(org.starhope.appius.geometry.Coord2D)

contains

public boolean contains(double x,
                        double y)
Description copied from interface: PolygonPrimitive
Determines if the polygon contains that point

Specified by:
contains in interface PolygonPrimitive<Rectangle>
Parameters:
x - WRITEME
y - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.contains(double, double)

generateLineSegments

private void generateLineSegments()
Generates the line segments for the rectangle on demand so that we delay generating them until later if they're not going to be used


getCenter

public Coord2D getCenter()
Specified by:
getCenter in interface PolygonPrimitive<Rectangle>
Returns:
the center point
See Also:
PolygonPrimitive.getCenter()

getHeight

public double getHeight()
Returns:
the height

getOrigin

public Coord2D getOrigin()
Returns:
the origin

getWidth

public double getWidth()
Returns:
the width

intersection

public Coord2D[] intersection(LineSeg2D lSeg2d)
Description copied from interface: PolygonPrimitive
Finds the intersection points for the polygon with the line segment

Specified by:
intersection in interface PolygonPrimitive<Rectangle>
Parameters:
lSeg2d - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.intersection(org.starhope.appius.geometry.LineSeg2D)

intersects

public boolean intersects(LineSeg2D lSeg2d)
Description copied from interface: PolygonPrimitive
Determines if the polygon intersects the line segment

Specified by:
intersects in interface PolygonPrimitive<Rectangle>
Parameters:
lSeg2d - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.intersects(org.starhope.appius.geometry.LineSeg2D)

intersects

public boolean intersects(PolygonPrimitive<?> otherPolygon)
Determines if this polygon intersects with another one

XXX: There has to be a better way than this

Specified by:
intersects in interface PolygonPrimitive<Rectangle>
Parameters:
otherPolygon - WRITEME
Returns:
WRITEME

intersectsCircle

public boolean intersectsCircle(Circle circle)
Description copied from interface: PolygonPrimitive
Determines if the polygon intersects a circle

Specified by:
intersectsCircle in interface PolygonPrimitive<Rectangle>
Parameters:
circle - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.intersectsCircle(org.starhope.appius.geometry.Circle)

intersectsPoly

public boolean intersectsPoly(Polygon otherPolygon)
Description copied from interface: PolygonPrimitive
Determines if the polygon intersects a polygon

Specified by:
intersectsPoly in interface PolygonPrimitive<Rectangle>
Parameters:
otherPolygon - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.intersectsPoly(org.starhope.appius.geometry.Polygon)

intersectsRect

public boolean intersectsRect(Rectangle rectangle)
Description copied from interface: PolygonPrimitive
Determines if the polygon intersects a rectangle

Specified by:
intersectsRect in interface PolygonPrimitive<Rectangle>
Parameters:
rectangle - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.intersectsRect(org.starhope.appius.geometry.Rectangle)

scale

public Rectangle scale(double sizeScalar)
Description copied from interface: PolygonPrimitive
WRITEME: Document this method brpocock@star-hope.org

Specified by:
scale in interface PolygonPrimitive<Rectangle>
Parameters:
sizeScalar - WRITEME
Returns:
WRITEME
See Also:
PolygonPrimitive.scale(double)

translate

public Rectangle translate(Coord2D coord2d)
Description copied from interface: PolygonPrimitive
WRITEME: Document this method brpocock@star-hope.org

Specified by:
translate in interface PolygonPrimitive<Rectangle>
Parameters:
coord2d - The amount to move
Returns:
WRITEME
See Also:
PolygonPrimitive.translate(org.starhope.appius.geometry.Coord2D)

translate

public Rectangle translate(double x,
                           double y)
Description copied from interface: PolygonPrimitive
Translates the object

Specified by:
translate in interface PolygonPrimitive<Rectangle>
Parameters:
x - The amount to move on the x-axis
y - The amount to move on the y-axis
Returns:
WRITEME
See Also:
PolygonPrimitive.translate(double, double)