Java Platform 1.2
Beta 4

Class java.awt.geom.Rectangle2D

java.lang.Object
  |
  +--java.awt.geom.RectangularShape
        |
        +--java.awt.geom.Rectangle2D
Direct Known Subclasses:
Rectangle, Rectangle2D.Double, Rectangle2D.Float

public abstract class Rectangle2D
extends RectangularShape
A rectangle defined by a location (x, y) and dimension (w x h).

This class is only the abstract superclass for all objects which store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.


Inner Class Summary
static  Rectangle2D.Double
          A rectangle specified in double coordinates.
static  Rectangle2D.Float
          A rectangle specified in float coordinates.
 
Field Summary
static int OUT_BOTTOM
          The bitmask which indicates that a point lies below this Rectangle.
static int OUT_LEFT
          The bitmask which indicates that a point lies to the left of this Rectangle.
static int OUT_RIGHT
          The bitmask which indicates that a point lies to the right of this Rectangle.
static int OUT_TOP
          The bitmask which indicates that a point lies above this Rectangle.
 
Constructor Summary
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 newx and newy, to this rectangle.
 void add(Point2D pt)
          Adds the Point2D object pt to this rectangle.
 void add(Rectangle2D r)
          Adds a Rectangle2D object to this rectangle.
 boolean contains(double x, double y, double w, double h)
          Test if the interior of the Shape entirely contains the given set of rectangular coordinates.
 boolean contains(double x, double y)
          Test if a given coordinate is inside the boundary of the shape.
abstract  Rectangle2D createIntersection(Rectangle2D r)
          Return a new Rectangle2D object representing the intersection of this rectangle with the given rectangle.
abstract  Rectangle2D createUnion(Rectangle2D r)
          Return a new Rectangle2D object representing the union of this rectangle with the given rectangle.
 boolean equals(Object obj)
          Determines whether two rectangles are equal.
 Rectangle2D getBounds2D()
          Return the high precision bounding box of the shape.
 PathIterator getPathIterator(AffineTransform at, double flatness)
          Return an iteration object that defines the boundary of the flattened shape.
 PathIterator getPathIterator(AffineTransform at)
          Return an iteration object that defines the boundary of the shape.
static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)
          Intersect the pair of Rectangles and put the result into the indicated destination Rectangle2D object.
 boolean intersects(double x, double y, double w, double h)
          Test if the interior of the Shape intersects the interior of a given set of rectangular coordinates.
 boolean intersectsLine(double x1, double y1, double x2, double y2)
          Tests if the given line segment intersects the interior of this Rectangle.
 boolean intersectsLine(Line2D l)
          Tests if the given line segment intersects the interior of this Rectangle.
abstract  int outcode(double x, double y)
          Determines where the specified coordinates lie with respect to this Rectangle.
 int outcode(Point2D p)
          Determines where the specified point lies with respect to this Rectangle.
 void setFrame(double x, double y, double w, double h)
          Sets the location and size of the outer bounds of this shape to the specified rectangular values.
abstract  void setRect(double x, double y, double w, double h)
          Sets the location and size of this rectangle to the specified double values.
 void setRect(Rectangle2D r)
          Sets this rectangle to be the same as the specified Rectangle.
static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)
          Union the pair of Rectangles and put the result into the indicated destination Rectangle2D object.
 
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 , hashCode , notify , notifyAll , toString , wait , wait , wait
 

Field Detail

OUT_LEFT

public static final int OUT_LEFT
The bitmask which indicates that a point lies to the left of this Rectangle.
Since:
JDK1.2

OUT_TOP

public static final int OUT_TOP
The bitmask which indicates that a point lies above this Rectangle.
Since:
JDK1.2

OUT_RIGHT

public static final int OUT_RIGHT
The bitmask which indicates that a point lies to the right of this Rectangle.
Since:
JDK1.2

OUT_BOTTOM

public static final int OUT_BOTTOM
The bitmask which indicates that a point lies below this Rectangle.
Since:
JDK1.2
Constructor Detail

Rectangle2D

protected Rectangle2D()
This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.
See Also:
Rectangle2D.Float, Rectangle2D.Double, Rectangle
Method Detail

setRect

public abstract void setRect(double x,
                             double y,
                             double w,
                             double h)
Sets the location and size of this rectangle to the specified double values.
Since:
JDK1.2

setRect

public void setRect(Rectangle2D r)
Sets this rectangle to be the same as the specified Rectangle.
Since:
JDK1.2

intersectsLine

public boolean intersectsLine(double x1,
                              double y1,
                              double x2,
                              double y2)
Tests if the given line segment intersects the interior of this Rectangle.
Since:
JDK1.2

intersectsLine

public boolean intersectsLine(Line2D l)
Tests if the given line segment intersects the interior of this Rectangle.
Since:
JDK1.2

outcode

public abstract int outcode(double x,
                            double y)
Determines where the specified coordinates lie with respect to this Rectangle. This method computes a binary OR of the appropriate mask values indicating which sides of the rectangle the given point is outside of.
Returns:
the logical OR of all appropriate out codes
Since:
JDK1.2
See Also:
OUT_LEFT, OUT_TOP, OUT_RIGHT, OUT_BOTTOM

outcode

public int outcode(Point2D p)
Determines where the specified point lies with respect to this Rectangle. This method computes a binary OR of the appropriate mask values indicating which sides of the rectangle the given point is outside of.
Returns:
the logical OR of all appropriate out codes
Since:
JDK1.2
See Also:
OUT_LEFT, OUT_TOP, OUT_RIGHT, OUT_BOTTOM

setFrame

public void setFrame(double x,
                     double y,
                     double w,
                     double h)
Sets the location and size of the outer bounds of this shape to the specified rectangular values.
Overrides:
setFrame in class RectangularShape
Since:
JDK1.2

getBounds2D

public Rectangle2D getBounds2D()
Return the high precision bounding box of the shape.
Since:
JDK1.2

contains

public boolean contains(double x,
                        double y)
Test if a given coordinate is inside the boundary of the shape.
Since:
JDK1.2

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Test if the interior of the Shape intersects the interior of a given set of rectangular coordinates.
Since:
JDK1.2

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Test if the interior of the Shape entirely contains the given set of rectangular coordinates.
Since:
JDK1.2

createIntersection

public abstract Rectangle2D createIntersection(Rectangle2D r)
Return a new Rectangle2D object representing the intersection of this rectangle with the given rectangle.
Parameters:
r - the rectangle to be intersected with
Returns:
the largest rectangle contained in both the specified rectangle and in this rectangle
Since:
JDK1.2

intersect

public static void intersect(Rectangle2D src1,
                             Rectangle2D src2,
                             Rectangle2D dest)
Intersect the pair of Rectangles and put the result into the indicated destination Rectangle2D object.
Parameters:
src1 - the first rectangle to be intersected
src2 - the second rectangle to be intersected
dest - the rectangle to store the results in
Since:
JDK1.2

createUnion

public abstract Rectangle2D createUnion(Rectangle2D r)
Return a new Rectangle2D object representing the union of this rectangle with the given rectangle.
Parameters:
r - the rectangle to be combined with
Returns:
the smallest rectangle containing both the specified rectangle and this rectangle.
Since:
JDK1.2

union

public static void union(Rectangle2D src1,
                         Rectangle2D src2,
                         Rectangle2D dest)
Union the pair of Rectangles and put the result into the indicated destination Rectangle2D object.
Parameters:
src1 - the first rectangle to be combined
src2 - the second rectangle to be combined
dest - the rectangle to store the results in
Since:
JDK1.2

add

public void add(double newx,
                double newy)
Adds a point, specified by the double precision arguments newx and newy, to this rectangle. The resulting rectangle is the smallest rectangle that contains both the original rectangle and the specified point.

After adding a point, a call to contains with the added point as an argument will 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 will return false for that point.

Parameters:
newx - the x coordinate of the new point.
newy - the y coordinate of the new point.
Since:
JDK1.0

add

public void add(Point2D pt)
Adds the Point2D object pt to this rectangle. The resulting rectangle is the smallest rectangle that contains both the original rectangle and the specified point.

After adding a point, a call to contains with the added point as an argument will 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 will return false for that point.

Parameters:
pt - the new point to add to the rectangle.
Since:
JDK1.0

add

public void add(Rectangle2D r)
Adds a Rectangle2D object to this rectangle. The resulting rectangle is the union of the two rectangles.
Parameters:
a - rectangle.
Since:
JDK1.0

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Return an iteration object that defines the boundary of the shape.
Parameters:
at - the AffineTransform by which to transform the points
Since:
JDK1.2

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Return an iteration object that defines the boundary of the flattened shape.
Parameters:
at - the AffineTransform by which to transform the points
flatness - the maximum approximation error desired for the flattened path
Overrides:
getPathIterator in class RectangularShape
Since:
JDK1.2

equals

public boolean equals(Object obj)
Determines whether two rectangles are equal. Two instances of Rectangle2D are equal if their location and size are the same.
Parameters:
obj - an object to be compared with this rectangle.
Returns:
true if the object to be compared is an instance of Rectangle2D and has the same values; false otherwise.
Overrides:
equals in class Object
Since:
JDK1.2

Java Platform 1.2
Beta 4

Submit a bug or feature
Submit comments/suggestions about new javadoc look
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This documentation was generated with a post-Beta4 version of Javadoc.