Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.geom.Rectangle2D

java.lang.Object
    |
    +----java.awt.geom.RectangularShape
            |
            +----java.awt.geom.Rectangle2D
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()
 
 

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)
Test if a given coordinate is inside the boundary of the shape.
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.
Rectangle2D  createIntersection(Rectangle2D r)
Return a new Rectangle2D object representing the intersection of this rectangle with the given rectangle.
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)
Return an iteration object that defines the boundary of the shape.
PathIterator  getPathIterator(AffineTransform at, double flatness)
Return an iteration object that defines the boundary of the flattened 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.
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  setBounds(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.
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, getBottom, getBounds, getCenterX, getCenterY, getHeight, getLeft, getPathIterator, getRight, getTop, getWidth, getX, getY, intersects, isEmpty, setBounds, setBounds, setBounds, setBoundsFromCenter, setBoundsFromCenter, setBoundsFromDiagonal, setBoundsFromDiagonal
 
Methods inherited from class java.lang.Object
 clone, equals, 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.

OUT_TOP

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

OUT_RIGHT

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

OUT_BOTTOM

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

Rectangle2D

protected Rectangle2D()
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.

setRect

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

intersectsLine

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

intersectsLine

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

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
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
See Also:
OUT_LEFT, OUT_TOP, OUT_RIGHT, OUT_BOTTOM

setBounds

public void setBounds(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:
setBounds in class RectangularShape

getBounds2D

public Rectangle2D getBounds2D()
Return the high precision bounding box of the shape.

contains

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

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.

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.

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

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

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.

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

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.

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.

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.

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

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

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

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

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.