computational.geometry
Class Rectangle

java.lang.Object
  extended by computational.geometry.Polygon
      extended by computational.geometry.SimplePolygon
          extended by computational.geometry.ConvexPolygon
              extended by computational.geometry.Rectangle
All Implemented Interfaces:
Shape, java.io.Serializable, java.lang.Cloneable

public class Rectangle
extends ConvexPolygon

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class computational.geometry.Polygon
Polygon.Edge, Polygon.Vertex
 
Field Summary
 
Fields inherited from class computational.geometry.Polygon
vertices
 
Constructor Summary
Rectangle()
           
Rectangle(int x, int y, int width, int height)
           
Rectangle(Point p, int width, int height)
           
Rectangle(Point p0, Point p1)
           
 
Method Summary
 double area()
          POLYGON AREA
 Rectangle boundingBox()
          Shape Implementation
 boolean contains(Point p)
          POINT IN POLYGON TEST
 Point getBottomRight()
           
 Point getTopLeft()
           
 double perimeter()
          POLYGON PERIMETER
 java.lang.String toString()
          Returns a string representation of this rectangle.
 
Methods inherited from class computational.geometry.ConvexPolygon
addVertex, addVertex, deleteVertex, deleteVertex, moveVertex, moveVertex
 
Methods inherited from class computational.geometry.SimplePolygon
diagonal, diagonal, ear
 
Methods inherited from class computational.geometry.Polygon
clear, clone, draw, drawLabels, drawPoints, equals, getBottomVertex, getEdge, getEdges, getFirstVertex, getIndices, getLabel, getLeftVertex, getNext, getPoints, getPrevious, getRightVertex, getTopVertex, getVertex, getVertices, indexOf, isClockwiseOriented, isConvex, isSimple, restore, setLabel, size, translate, updateExtremeVertices
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rectangle

public Rectangle()

Rectangle

public Rectangle(int x,
                 int y,
                 int width,
                 int height)
Parameters:
x - the X-coordinate of the Rectangle's top-left corner.
y - the Y-coordinate of the Rectangle's top-left corner.
width - the width of the Rectangle.
height - the height of the Rectangle.

Rectangle

public Rectangle(Point p,
                 int width,
                 int height)
Parameters:
p0 - the top-left corner of the Rectangle.
width - the width of the Rectangle.
height - the height of the Rectangle.

Rectangle

public Rectangle(Point p0,
                 Point p1)
Parameters:
p0 - the first corner of the Rectangle.
p1 - the second corner of the Rectangle.
Method Detail

area

public double area()
Description copied from class: Polygon
POLYGON AREA

Overrides:
area in class Polygon

boundingBox

public Rectangle boundingBox()
Shape Implementation

Overrides:
boundingBox in class Polygon

contains

public boolean contains(Point p)
Description copied from class: ConvexPolygon
POINT IN POLYGON TEST

Specified by:
contains in interface Shape
Overrides:
contains in class ConvexPolygon
Parameters:
p - the point we test for encloseness.
Returns:
true iff the point is enclosed in the shape.

getBottomRight

public Point getBottomRight()

getTopLeft

public Point getTopLeft()

perimeter

public double perimeter()
Description copied from class: Polygon
POLYGON PERIMETER

Overrides:
perimeter in class Polygon

toString

public java.lang.String toString()
Returns a string representation of this rectangle. The string is composed of the rectangle label (if any), and the rectangle [topleft,bottomRight] vertices.

Overrides:
toString in class Polygon
Returns:
a string representation of this rectangle.