| 
 | JavaTM 2 Platform Standard Ed. 5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
public abstract class Rectangle2D
The Rectangle2D class describes a rectangle
 defined by a location (x, y) and dimension 
 (w x h).
 
This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.
| Nested Class Summary | |
|---|---|
| static class | Rectangle2D.DoubleThe Doubleclass defines a rectangle specified in
 double coordinates. | 
| static class | Rectangle2D.FloatThe Floatclass defines a rectangle specified in float
 coordinates. | 
| Field Summary | |
|---|---|
| static int | OUT_BOTTOMThe bitmask that indicates that a point lies below this Rectangle2D. | 
| static int | OUT_LEFTThe bitmask that indicates that a point lies to the left of this Rectangle2D. | 
| static int | OUT_RIGHTThe bitmask that indicates that a point lies to the right of this Rectangle2D. | 
| static int | OUT_TOPThe bitmask that indicates that a point lies above this Rectangle2D. | 
| Constructor Summary | |
|---|---|
| protected  | Rectangle2D()This is an abstract class that cannot be instantiated directly. | 
| Method Summary | |
|---|---|
|  void | add(double newx,
    double newy)Adds a point, specified by the double precision arguments newxandnewy, to thisRectangle2D. | 
|  void | add(Point2D pt)Adds the Point2Dobjectptto thisRectangle2D. | 
|  void | add(Rectangle2D r)Adds a Rectangle2Dobject to thisRectangle2D. | 
|  boolean | contains(double x,
         double y)Tests if a specified coordinate is inside the boundary of this Rectangle2D. | 
|  boolean | contains(double x,
         double y,
         double w,
         double h)Tests if the interior of this Rectangle2Dentirely
 contains the specified set of rectangular coordinates. | 
| abstract  Rectangle2D | createIntersection(Rectangle2D r)Returns a new Rectangle2Dobject representing the
 intersection of thisRectangle2Dwith the specifiedRectangle2D. | 
| abstract  Rectangle2D | createUnion(Rectangle2D r)Returns a new Rectangle2Dobject representing the
 union of thisRectangle2Dwith the specifiedRectangle2D. | 
|  boolean | equals(Object obj)Determines whether or not the specified Objectis
 equal to thisRectangle2D. | 
|  Rectangle2D | getBounds2D()Returns the high precision bounding box of this Rectangle2D. | 
|  PathIterator | getPathIterator(AffineTransform at)Returns an iteration object that defines the boundary of this Rectangle2D. | 
|  PathIterator | getPathIterator(AffineTransform at,
                double flatness)Returns an iteration object that defines the boundary of the flattened Rectangle2D. | 
|  int | hashCode()Returns the hashcode for this Rectangle2D. | 
| static void | intersect(Rectangle2D src1,
          Rectangle2D src2,
          Rectangle2D dest)Intersects the pair of specified source Rectangle2Dobjects and puts the result into the specified destinationRectangle2Dobject. | 
|  boolean | intersects(double x,
           double y,
           double w,
           double h)Tests if the interior of this Rectangle2Dintersects the interior of a specified set of rectangular 
 coordinates. | 
|  boolean | intersectsLine(double x1,
               double y1,
               double x2,
               double y2)Tests if the specified line segment intersects the interior of this Rectangle2D. | 
|  boolean | intersectsLine(Line2D l)Tests if the specified line segment intersects the interior of this Rectangle2D. | 
| abstract  int | outcode(double x,
        double y)Determines where the specified coordinates lie with respect to this Rectangle2D. | 
|  int | outcode(Point2D p)Determines where the specified Point2Dlies with 
 respect to thisRectangle2D. | 
|  void | setFrame(double x,
         double y,
         double w,
         double h)Sets the location and size of the outer bounds of this Rectangle2Dto the specified rectangular values. | 
| abstract  void | setRect(double x,
        double y,
        double w,
        double h)Sets the location and size of this Rectangle2Dto the specified double values. | 
|  void | setRect(Rectangle2D r)Sets this Rectangle2Dto be the same as the specifiedRectangle2D. | 
| static void | union(Rectangle2D src1,
      Rectangle2D src2,
      Rectangle2D dest)Unions the pair of source Rectangle2Dobjects 
 and puts the result into the specified destinationRectangle2Dobject. | 
| Methods inherited from class java.awt.geom.RectangularShape | 
|---|
| clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getHeight, getMaxX, getMaxY, getMinX, getMinY, getWidth, getX, getY, intersects, isEmpty, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal | 
| Methods inherited from class java.lang.Object | 
|---|
| finalize, getClass, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int OUT_LEFT
Rectangle2D.
public static final int OUT_TOP
Rectangle2D.
public static final int OUT_RIGHT
Rectangle2D.
public static final int OUT_BOTTOM
Rectangle2D.
| Constructor Detail | 
|---|
protected Rectangle2D()
Rectangle2D.Float, 
Rectangle2D.Double, 
Rectangle| Method Detail | 
|---|
public abstract void setRect(double x,
                             double y,
                             double w,
                             double h)
Rectangle2D
 to the specified double values.
x, y - the coordinates to which to set the
 location of the upper left corner of this
 Rectangle2Dw - the value to use to set the width of this
 Rectangle2Dh - the value to use to set the height of this
 Rectangle2Dpublic void setRect(Rectangle2D r)
Rectangle2D to be the same as the specified
 Rectangle2D.
r - the specified Rectangle2D
public boolean intersectsLine(double x1,
                              double y1,
                              double x2,
                              double y2)
Rectangle2D.
x1, y1 - the first endpoint of the specified
 line segmentx2, y2 - the second endpoint of the specified
 line segment
true if the specified line segment intersects
 the interior of this Rectangle2D; false
 otherwise.public boolean intersectsLine(Line2D l)
Rectangle2D.
l - the specified Line2D to test for intersection
 with the interior of this Rectangle2D
true if the specified Line2D
 intersects the interior of this Rectangle2D;
 false otherwise.
public abstract int outcode(double x,
                            double y)
Rectangle2D.
 This method computes a binary OR of the appropriate mask values
 indicating, for each side of this Rectangle2D,
 whether or not the specified coordinates are on the same side
 of the edge as the rest of this Rectangle2D.
x, y - the specified coordinates
OUT_LEFT, 
OUT_TOP, 
OUT_RIGHT, 
OUT_BOTTOMpublic int outcode(Point2D p)
Point2D lies with 
 respect to this Rectangle2D.
 This method computes a binary OR of the appropriate mask values
 indicating, for each side of this Rectangle2D,
 whether or not the specified Point2D is on the same
 side of the edge as the rest of this Rectangle2D.
p - the specified Point2D
OUT_LEFT, 
OUT_TOP, 
OUT_RIGHT, 
OUT_BOTTOM
public void setFrame(double x,
                     double y,
                     double w,
                     double h)
Rectangle2D to the specified rectangular values.
setFrame in class RectangularShapex, y - the coordinates to which to set the
 location of the upper left corner of the outer bounds of 
 this Rectangle2Dw - the value to use to set the width of the outer
 bounds of this Rectangle2Dh - the value to use to set the height of the outer
 bounds of this Rectangle2DRectangularShape.getFrame()public Rectangle2D getBounds2D()
Rectangle2D.
Rectangle2D.Shape.getBounds()
public boolean contains(double x,
                        double y)
Rectangle2D.
x, y - the coordinates to test
true if the specified coordinates are
 inside the boundary of this Rectangle2D;
 false otherwise.
public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Rectangle2D 
 intersects the interior of a specified set of rectangular 
 coordinates.
x, y - the coordinates of the upper left corner
 of the specified set of rectangular coordinatesw - the width of the specified set of rectangular
 coordinatesh - the height of the specified set of rectangular
 coordinates
true if this Rectangle2D
 intersects the interior of a specified set of rectangular
 coordinates; false otherwise.Area
public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Rectangle2D entirely
 contains the specified set of rectangular coordinates.
x, y - the coordinates of the upper left corner
 of the specified set of rectangular coordinatesw - the width of the specified set of rectangular
 coordinatesh - the height of the specified set of rectangular
 coordinates
true if this Rectangle2D
 entirely contains specified set of rectangular
 coordinates; false otherwise.Area, 
Shape.intersects(double, double, double, double)public abstract Rectangle2D createIntersection(Rectangle2D r)
Rectangle2D object representing the
 intersection of this Rectangle2D with the specified
 Rectangle2D.
r - the Rectangle2D to be intersected with
 this Rectangle2D
Rectangle2D contained in both 
                the specified Rectangle2D and in this
                Rectangle2D.
public static void intersect(Rectangle2D src1,
                             Rectangle2D src2,
                             Rectangle2D dest)
Rectangle2D
 objects and puts the result into the specified destination
 Rectangle2D object.  One of the source rectangles
 can also be the destination to avoid creating a third Rectangle2D
 object, but in this case the original points of this source
 rectangle will be overwritten by this method.
src1 - the first of a pair of Rectangle2D 
 objects to be intersected with each othersrc2 - the second of a pair of Rectangle2D
 objects to be intersected with each otherdest - the Rectangle2D that holds the
 results of the intersection of src1 and
 src2public abstract Rectangle2D createUnion(Rectangle2D r)
Rectangle2D object representing the
 union of this Rectangle2D with the specified
 Rectangle2D.
r - the Rectangle2D to be combined with
 this Rectangle2D
Rectangle2D containing both 
 the specified Rectangle2D and this 
 Rectangle2D.
public static void union(Rectangle2D src1,
                         Rectangle2D src2,
                         Rectangle2D dest)
Rectangle2D objects 
 and puts the result into the specified destination 
 Rectangle2D object.  One of the source rectangles
 can also be the destination to avoid creating a third Rectangle2D
 object, but in this case the original points of this source
 rectangle will be overwritten by this method.
src1 - the first of a pair of Rectangle2D
 objects to be combined with each othersrc2 - the second of a pair of Rectangle2D
 objects to be combined with each otherdest - the Rectangle2D that holds the
 results of the union of src1 and  
 src2
public void add(double newx,
                double newy)
newx and newy, to this 
 Rectangle2D.  The resulting Rectangle2D 
 is the smallest Rectangle2D that
 contains both the original Rectangle2D and the
 specified point.
 
 After adding a point, a call to contains with the 
 added point as an argument does not necessarily return 
 true. The contains method does not 
 return true for points on the right or bottom 
 edges of a rectangle. Therefore, if the added point falls on 
 the left or bottom edge of the enlarged rectangle, 
 contains returns false for that point.
newx, newy - the coordinates of the new pointpublic void add(Point2D pt)
Point2D object pt to this
 Rectangle2D.
 The resulting Rectangle2D is the smallest 
 Rectangle2D that contains both the original
 Rectangle2D and the specified Point2D.
 
 After adding a point, a call to contains with the 
 added point as an argument does not necessarily return
 true. The contains 
 method does not return true for points on the right 
 or bottom edges of a rectangle. Therefore, if the added point falls
 on the left or bottom edge of the enlarged rectangle, 
 contains returns false for that point.
pt - the new Point2D to add to this
 Rectangle2D.public void add(Rectangle2D r)
Rectangle2D object to this 
 Rectangle2D.  The resulting Rectangle2D
 is the union of the two Rectangle2D objects.
r - the Rectangle2D to add to this
 Rectangle2D.public PathIterator getPathIterator(AffineTransform at)
Rectangle2D.
 The iterator for this class is multi-threaded safe, which means
 that this Rectangle2D class guarantees that
 modifications to the geometry of this Rectangle2D
 object do not affect any iterations of that geometry that
 are already in process.
at - an optional AffineTransform to be applied to
 the coordinates as they are returned in the iteration, or
 null if untransformed coordinates are desired
PathIterator object that returns the
          geometry of the outline of this
          Rectangle2D, one segment at a time.
public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Rectangle2D.  Since rectangles are already
 flat, the flatness parameter is ignored.
 The iterator for this class is multi-threaded safe, which means
 that this Rectangle2D class guarantees that
 modifications to the geometry of this Rectangle2D
 object do not affect any iterations of that geometry that
 are already in process.
getPathIterator in interface ShapegetPathIterator in class RectangularShapeat - an optional AffineTransform to be applied to
 the coordinates as they are returned in the iteration, or
 null if untransformed coordinates are desiredflatness - the maximum distance that the line segments used to
 approximate the curved segments are allowed to deviate from any
 point on the original curve.  Since rectangles are already flat,
 the flatness parameter is ignored.
PathIterator object that returns the
          geometry of the outline of this
          Rectangle2D, one segment at a time.public int hashCode()
Rectangle2D.
hashCode in class ObjectRectangle2D.Object.equals(java.lang.Object), 
Hashtablepublic boolean equals(Object obj)
Object is
 equal to this Rectangle2D.  The specified 
 Object is equal to this Rectangle2D
 if it is an instance of Rectangle2D and if its
 location and size are the same as this Rectangle2D.
equals in class Objectobj - an Object to be compared with this
 Rectangle2D.
true if obj is an instance
                     of Rectangle2D and has
                     the same values; false otherwise.Object.hashCode(), 
Hashtable| 
 | JavaTM 2 Platform Standard Ed. 5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.