computational.geometry
Class Rectangle
java.lang.Object
computational.geometry.Polygon
computational.geometry.SimplePolygon
computational.geometry.ConvexPolygon
computational.geometry.Rectangle
- All Implemented Interfaces:
- Shape, java.io.Serializable, java.lang.Cloneable
public class Rectangle
- extends ConvexPolygon
- See Also:
- Serialized Form
| 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 |
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.
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.