< prev index next >

src/java.desktop/share/classes/java/awt/geom/Rectangle2D.java

Print this page

        

*** 26,36 **** package java.awt.geom; import java.io.Serializable; /** ! * The <code>Rectangle2D</code> class describes a rectangle * defined by a location {@code (x,y)} and dimension * {@code (w x h)}. * <p> * This class is only the abstract superclass for all objects that * store a 2D rectangle. --- 26,36 ---- package java.awt.geom; import java.io.Serializable; /** ! * The {@code Rectangle2D} class describes a rectangle * defined by a location {@code (x,y)} and dimension * {@code (w x h)}. * <p> * This class is only the abstract superclass for all objects that * store a 2D rectangle.
*** 41,130 **** * @since 1.2 */ public abstract class Rectangle2D extends RectangularShape { /** * The bitmask that indicates that a point lies to the left of ! * this <code>Rectangle2D</code>. * @since 1.2 */ public static final int OUT_LEFT = 1; /** * The bitmask that indicates that a point lies above ! * this <code>Rectangle2D</code>. * @since 1.2 */ public static final int OUT_TOP = 2; /** * The bitmask that indicates that a point lies to the right of ! * this <code>Rectangle2D</code>. * @since 1.2 */ public static final int OUT_RIGHT = 4; /** * The bitmask that indicates that a point lies below ! * this <code>Rectangle2D</code>. * @since 1.2 */ public static final int OUT_BOTTOM = 8; /** ! * The <code>Float</code> class defines a rectangle specified in float * coordinates. * @since 1.2 */ public static class Float extends Rectangle2D implements Serializable { /** ! * The X coordinate of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public float x; /** ! * The Y coordinate of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public float y; /** ! * The width of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public float width; /** ! * The height of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public float height; /** ! * Constructs a new <code>Rectangle2D</code>, initialized to * location (0.0,&nbsp;0.0) and size (0.0,&nbsp;0.0). * @since 1.2 */ public Float() { } /** ! * Constructs and initializes a <code>Rectangle2D</code> ! * from the specified <code>float</code> coordinates. * * @param x the X coordinate of the upper-left corner ! * of the newly constructed <code>Rectangle2D</code> * @param y the Y coordinate of the upper-left corner ! * of the newly constructed <code>Rectangle2D</code> * @param w the width of the newly constructed ! * <code>Rectangle2D</code> * @param h the height of the newly constructed ! * <code>Rectangle2D</code> * @since 1.2 */ public Float(float x, float y, float w, float h) { setRect(x, y, w, h); } --- 41,130 ---- * @since 1.2 */ public abstract class Rectangle2D extends RectangularShape { /** * The bitmask that indicates that a point lies to the left of ! * this {@code Rectangle2D}. * @since 1.2 */ public static final int OUT_LEFT = 1; /** * The bitmask that indicates that a point lies above ! * this {@code Rectangle2D}. * @since 1.2 */ public static final int OUT_TOP = 2; /** * The bitmask that indicates that a point lies to the right of ! * this {@code Rectangle2D}. * @since 1.2 */ public static final int OUT_RIGHT = 4; /** * The bitmask that indicates that a point lies below ! * this {@code Rectangle2D}. * @since 1.2 */ public static final int OUT_BOTTOM = 8; /** ! * The {@code Float} class defines a rectangle specified in float * coordinates. * @since 1.2 */ public static class Float extends Rectangle2D implements Serializable { /** ! * The X coordinate of this {@code Rectangle2D}. * @since 1.2 * @serial */ public float x; /** ! * The Y coordinate of this {@code Rectangle2D}. * @since 1.2 * @serial */ public float y; /** ! * The width of this {@code Rectangle2D}. * @since 1.2 * @serial */ public float width; /** ! * The height of this {@code Rectangle2D}. * @since 1.2 * @serial */ public float height; /** ! * Constructs a new {@code Rectangle2D}, initialized to * location (0.0,&nbsp;0.0) and size (0.0,&nbsp;0.0). * @since 1.2 */ public Float() { } /** ! * Constructs and initializes a {@code Rectangle2D} ! * from the specified {@code float} coordinates. * * @param x the X coordinate of the upper-left corner ! * of the newly constructed {@code Rectangle2D} * @param y the Y coordinate of the upper-left corner ! * of the newly constructed {@code Rectangle2D} * @param w the width of the newly constructed ! * {@code Rectangle2D} * @param h the height of the newly constructed ! * {@code Rectangle2D} * @since 1.2 */ public Float(float x, float y, float w, float h) { setRect(x, y, w, h); }
*** 168,186 **** public boolean isEmpty() { return (width <= 0.0f) || (height <= 0.0f); } /** ! * Sets the location and size of this <code>Rectangle2D</code> ! * to the specified <code>float</code> values. * * @param x the X coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> * @param y the Y coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> ! * @param w the width of this <code>Rectangle2D</code> ! * @param h the height of this <code>Rectangle2D</code> * @since 1.2 */ public void setRect(float x, float y, float w, float h) { this.x = x; this.y = y; --- 168,186 ---- public boolean isEmpty() { return (width <= 0.0f) || (height <= 0.0f); } /** ! * Sets the location and size of this {@code Rectangle2D} ! * to the specified {@code float} values. * * @param x the X coordinate of the upper-left corner ! * of this {@code Rectangle2D} * @param y the Y coordinate of the upper-left corner ! * of this {@code Rectangle2D} ! * @param w the width of this {@code Rectangle2D} ! * @param h the height of this {@code Rectangle2D} * @since 1.2 */ public void setRect(float x, float y, float w, float h) { this.x = x; this.y = y;
*** 280,293 **** Rectangle2D.union(this, r, dest); return dest; } /** ! * Returns the <code>String</code> representation of this ! * <code>Rectangle2D</code>. ! * @return a <code>String</code> representing this ! * <code>Rectangle2D</code>. * @since 1.2 */ public String toString() { return getClass().getName() + "[x=" + x + --- 280,293 ---- Rectangle2D.union(this, r, dest); return dest; } /** ! * Returns the {@code String} representation of this ! * {@code Rectangle2D}. ! * @return a {@code String} representing this ! * {@code Rectangle2D}. * @since 1.2 */ public String toString() { return getClass().getName() + "[x=" + x +
*** 301,363 **** */ private static final long serialVersionUID = 3798716824173675777L; } /** ! * The <code>Double</code> class defines a rectangle specified in * double coordinates. * @since 1.2 */ public static class Double extends Rectangle2D implements Serializable { /** ! * The X coordinate of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public double x; /** ! * The Y coordinate of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public double y; /** ! * The width of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public double width; /** ! * The height of this <code>Rectangle2D</code>. * @since 1.2 * @serial */ public double height; /** ! * Constructs a new <code>Rectangle2D</code>, initialized to * location (0,&nbsp;0) and size (0,&nbsp;0). * @since 1.2 */ public Double() { } /** ! * Constructs and initializes a <code>Rectangle2D</code> ! * from the specified <code>double</code> coordinates. * * @param x the X coordinate of the upper-left corner ! * of the newly constructed <code>Rectangle2D</code> * @param y the Y coordinate of the upper-left corner ! * of the newly constructed <code>Rectangle2D</code> * @param w the width of the newly constructed ! * <code>Rectangle2D</code> * @param h the height of the newly constructed ! * <code>Rectangle2D</code> * @since 1.2 */ public Double(double x, double y, double w, double h) { setRect(x, y, w, h); } --- 301,363 ---- */ private static final long serialVersionUID = 3798716824173675777L; } /** ! * The {@code Double} class defines a rectangle specified in * double coordinates. * @since 1.2 */ public static class Double extends Rectangle2D implements Serializable { /** ! * The X coordinate of this {@code Rectangle2D}. * @since 1.2 * @serial */ public double x; /** ! * The Y coordinate of this {@code Rectangle2D}. * @since 1.2 * @serial */ public double y; /** ! * The width of this {@code Rectangle2D}. * @since 1.2 * @serial */ public double width; /** ! * The height of this {@code Rectangle2D}. * @since 1.2 * @serial */ public double height; /** ! * Constructs a new {@code Rectangle2D}, initialized to * location (0,&nbsp;0) and size (0,&nbsp;0). * @since 1.2 */ public Double() { } /** ! * Constructs and initializes a {@code Rectangle2D} ! * from the specified {@code double} coordinates. * * @param x the X coordinate of the upper-left corner ! * of the newly constructed {@code Rectangle2D} * @param y the Y coordinate of the upper-left corner ! * of the newly constructed {@code Rectangle2D} * @param w the width of the newly constructed ! * {@code Rectangle2D} * @param h the height of the newly constructed ! * {@code Rectangle2D} * @since 1.2 */ public Double(double x, double y, double w, double h) { setRect(x, y, w, h); }
*** 474,487 **** Rectangle2D.union(this, r, dest); return dest; } /** ! * Returns the <code>String</code> representation of this ! * <code>Rectangle2D</code>. ! * @return a <code>String</code> representing this ! * <code>Rectangle2D</code>. * @since 1.2 */ public String toString() { return getClass().getName() + "[x=" + x + --- 474,487 ---- Rectangle2D.union(this, r, dest); return dest; } /** ! * Returns the {@code String} representation of this ! * {@code Rectangle2D}. ! * @return a {@code String} representing this ! * {@code Rectangle2D}. * @since 1.2 */ public String toString() { return getClass().getName() + "[x=" + x +
*** 510,556 **** */ protected Rectangle2D() { } /** ! * Sets the location and size of this <code>Rectangle2D</code> ! * to the specified <code>double</code> values. * * @param x the X coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> * @param y the Y coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> ! * @param w the width of this <code>Rectangle2D</code> ! * @param h the height of this <code>Rectangle2D</code> * @since 1.2 */ public abstract void setRect(double x, double y, double w, double h); /** ! * Sets this <code>Rectangle2D</code> to be the same as the specified ! * <code>Rectangle2D</code>. ! * @param r the specified <code>Rectangle2D</code> * @since 1.2 */ public void setRect(Rectangle2D r) { setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } /** * Tests if the specified line segment intersects the interior of this ! * <code>Rectangle2D</code>. * * @param x1 the X coordinate of the start point of the specified * line segment * @param y1 the Y coordinate of the start point of the specified * line segment * @param x2 the X coordinate of the end point of the specified * line segment * @param y2 the Y coordinate of the end point of the specified * line segment ! * @return <code>true</code> if the specified line segment intersects ! * the interior of this <code>Rectangle2D</code>; <code>false</code> * otherwise. * @since 1.2 */ public boolean intersectsLine(double x1, double y1, double x2, double y2) { int out1, out2; --- 510,556 ---- */ protected Rectangle2D() { } /** ! * Sets the location and size of this {@code Rectangle2D} ! * to the specified {@code double} values. * * @param x the X coordinate of the upper-left corner ! * of this {@code Rectangle2D} * @param y the Y coordinate of the upper-left corner ! * of this {@code Rectangle2D} ! * @param w the width of this {@code Rectangle2D} ! * @param h the height of this {@code Rectangle2D} * @since 1.2 */ public abstract void setRect(double x, double y, double w, double h); /** ! * Sets this {@code Rectangle2D} to be the same as the specified ! * {@code Rectangle2D}. ! * @param r the specified {@code Rectangle2D} * @since 1.2 */ public void setRect(Rectangle2D r) { setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight()); } /** * Tests if the specified line segment intersects the interior of this ! * {@code Rectangle2D}. * * @param x1 the X coordinate of the start point of the specified * line segment * @param y1 the Y coordinate of the start point of the specified * line segment * @param x2 the X coordinate of the end point of the specified * line segment * @param y2 the Y coordinate of the end point of the specified * line segment ! * @return {@code true} if the specified line segment intersects ! * the interior of this {@code Rectangle2D}; {@code false} * otherwise. * @since 1.2 */ public boolean intersectsLine(double x1, double y1, double x2, double y2) { int out1, out2;
*** 580,608 **** return true; } /** * Tests if the specified line segment intersects the interior of this ! * <code>Rectangle2D</code>. * @param l the specified {@link Line2D} to test for intersection ! * with the interior of this <code>Rectangle2D</code> ! * @return <code>true</code> if the specified <code>Line2D</code> ! * intersects the interior of this <code>Rectangle2D</code>; ! * <code>false</code> otherwise. * @since 1.2 */ public boolean intersectsLine(Line2D l) { return intersectsLine(l.getX1(), l.getY1(), l.getX2(), l.getY2()); } /** * Determines where the specified coordinates lie with respect ! * to this <code>Rectangle2D</code>. * This method computes a binary OR of the appropriate mask values ! * indicating, for each side of this <code>Rectangle2D</code>, * whether or not the specified coordinates are on the same side ! * of the edge as the rest of this <code>Rectangle2D</code>. * @param x the specified X coordinate * @param y the specified Y coordinate * @return the logical OR of all appropriate out codes. * @see #OUT_LEFT * @see #OUT_TOP --- 580,608 ---- return true; } /** * Tests if the specified line segment intersects the interior of this ! * {@code Rectangle2D}. * @param l the specified {@link Line2D} to test for intersection ! * with the interior of this {@code Rectangle2D} ! * @return {@code true} if the specified {@code Line2D} ! * intersects the interior of this {@code Rectangle2D}; ! * {@code false} otherwise. * @since 1.2 */ public boolean intersectsLine(Line2D l) { return intersectsLine(l.getX1(), l.getY1(), l.getX2(), l.getY2()); } /** * Determines where the specified coordinates lie with respect ! * to this {@code Rectangle2D}. * This method computes a binary OR of the appropriate mask values ! * indicating, for each side of this {@code Rectangle2D}, * whether or not the specified coordinates are on the same side ! * of the edge as the rest of this {@code Rectangle2D}. * @param x the specified X coordinate * @param y the specified Y coordinate * @return the logical OR of all appropriate out codes. * @see #OUT_LEFT * @see #OUT_TOP
*** 612,627 **** */ public abstract int outcode(double x, double y); /** * Determines where the specified {@link Point2D} lies with ! * respect to this <code>Rectangle2D</code>. * This method computes a binary OR of the appropriate mask values ! * indicating, for each side of this <code>Rectangle2D</code>, ! * whether or not the specified <code>Point2D</code> is on the same ! * side of the edge as the rest of this <code>Rectangle2D</code>. ! * @param p the specified <code>Point2D</code> * @return the logical OR of all appropriate out codes. * @see #OUT_LEFT * @see #OUT_TOP * @see #OUT_RIGHT * @see #OUT_BOTTOM --- 612,627 ---- */ public abstract int outcode(double x, double y); /** * Determines where the specified {@link Point2D} lies with ! * respect to this {@code Rectangle2D}. * This method computes a binary OR of the appropriate mask values ! * indicating, for each side of this {@code Rectangle2D}, ! * whether or not the specified {@code Point2D} is on the same ! * side of the edge as the rest of this {@code Rectangle2D}. ! * @param p the specified {@code Point2D} * @return the logical OR of all appropriate out codes. * @see #OUT_LEFT * @see #OUT_TOP * @see #OUT_RIGHT * @see #OUT_BOTTOM
*** 631,648 **** return outcode(p.getX(), p.getY()); } /** * Sets the location and size of the outer bounds of this ! * <code>Rectangle2D</code> to the specified rectangular values. * * @param x the X coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> * @param y the Y coordinate of the upper-left corner ! * of this <code>Rectangle2D</code> ! * @param w the width of this <code>Rectangle2D</code> ! * @param h the height of this <code>Rectangle2D</code> * @since 1.2 */ public void setFrame(double x, double y, double w, double h) { setRect(x, y, w, h); } --- 631,648 ---- return outcode(p.getX(), p.getY()); } /** * Sets the location and size of the outer bounds of this ! * {@code Rectangle2D} to the specified rectangular values. * * @param x the X coordinate of the upper-left corner ! * of this {@code Rectangle2D} * @param y the Y coordinate of the upper-left corner ! * of this {@code Rectangle2D} ! * @param w the width of this {@code Rectangle2D} ! * @param h the height of this {@code Rectangle2D} * @since 1.2 */ public void setFrame(double x, double y, double w, double h) { setRect(x, y, w, h); }
*** 699,734 **** (x + w) <= x0 + getWidth() && (y + h) <= y0 + getHeight()); } /** ! * Returns a new <code>Rectangle2D</code> object representing the ! * intersection of this <code>Rectangle2D</code> with the specified ! * <code>Rectangle2D</code>. ! * @param r the <code>Rectangle2D</code> to be intersected with ! * this <code>Rectangle2D</code> ! * @return the largest <code>Rectangle2D</code> contained in both ! * the specified <code>Rectangle2D</code> and in this ! * <code>Rectangle2D</code>. * @since 1.2 */ public abstract Rectangle2D createIntersection(Rectangle2D r); /** ! * Intersects the pair of specified source <code>Rectangle2D</code> * objects and puts the result into the specified destination ! * <code>Rectangle2D</code> 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. ! * @param src1 the first of a pair of <code>Rectangle2D</code> * objects to be intersected with each other ! * @param src2 the second of a pair of <code>Rectangle2D</code> * objects to be intersected with each other ! * @param dest the <code>Rectangle2D</code> that holds the ! * results of the intersection of <code>src1</code> and ! * <code>src2</code> * @since 1.2 */ public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) { --- 699,734 ---- (x + w) <= x0 + getWidth() && (y + h) <= y0 + getHeight()); } /** ! * Returns a new {@code Rectangle2D} object representing the ! * intersection of this {@code Rectangle2D} with the specified ! * {@code Rectangle2D}. ! * @param r the {@code Rectangle2D} to be intersected with ! * this {@code Rectangle2D} ! * @return the largest {@code Rectangle2D} contained in both ! * the specified {@code Rectangle2D} and in this ! * {@code Rectangle2D}. * @since 1.2 */ public abstract Rectangle2D createIntersection(Rectangle2D r); /** ! * Intersects the pair of specified source {@code Rectangle2D} * objects and puts the result into the specified destination ! * {@code 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. ! * @param src1 the first of a pair of {@code Rectangle2D} * objects to be intersected with each other ! * @param src2 the second of a pair of {@code Rectangle2D} * objects to be intersected with each other ! * @param dest the {@code Rectangle2D} that holds the ! * results of the intersection of {@code src1} and ! * {@code src2} * @since 1.2 */ public static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) {
*** 738,773 **** double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); dest.setFrame(x1, y1, x2-x1, y2-y1); } /** ! * Returns a new <code>Rectangle2D</code> object representing the ! * union of this <code>Rectangle2D</code> with the specified ! * <code>Rectangle2D</code>. ! * @param r the <code>Rectangle2D</code> to be combined with ! * this <code>Rectangle2D</code> ! * @return the smallest <code>Rectangle2D</code> containing both ! * the specified <code>Rectangle2D</code> and this ! * <code>Rectangle2D</code>. * @since 1.2 */ public abstract Rectangle2D createUnion(Rectangle2D r); /** ! * Unions the pair of source <code>Rectangle2D</code> objects * and puts the result into the specified destination ! * <code>Rectangle2D</code> 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. ! * @param src1 the first of a pair of <code>Rectangle2D</code> * objects to be combined with each other ! * @param src2 the second of a pair of <code>Rectangle2D</code> * objects to be combined with each other ! * @param dest the <code>Rectangle2D</code> that holds the ! * results of the union of <code>src1</code> and ! * <code>src2</code> * @since 1.2 */ public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) { --- 738,773 ---- double y2 = Math.min(src1.getMaxY(), src2.getMaxY()); dest.setFrame(x1, y1, x2-x1, y2-y1); } /** ! * Returns a new {@code Rectangle2D} object representing the ! * union of this {@code Rectangle2D} with the specified ! * {@code Rectangle2D}. ! * @param r the {@code Rectangle2D} to be combined with ! * this {@code Rectangle2D} ! * @return the smallest {@code Rectangle2D} containing both ! * the specified {@code Rectangle2D} and this ! * {@code Rectangle2D}. * @since 1.2 */ public abstract Rectangle2D createUnion(Rectangle2D r); /** ! * Unions the pair of source {@code Rectangle2D} objects * and puts the result into the specified destination ! * {@code 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. ! * @param src1 the first of a pair of {@code Rectangle2D} * objects to be combined with each other ! * @param src2 the second of a pair of {@code Rectangle2D} * objects to be combined with each other ! * @param dest the {@code Rectangle2D} that holds the ! * results of the union of {@code src1} and ! * {@code src2} * @since 1.2 */ public static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) {
*** 778,800 **** dest.setFrameFromDiagonal(x1, y1, x2, y2); } /** * Adds a point, specified by the double precision arguments ! * <code>newx</code> and <code>newy</code>, to this ! * <code>Rectangle2D</code>. The resulting <code>Rectangle2D</code> ! * is the smallest <code>Rectangle2D</code> that ! * contains both the original <code>Rectangle2D</code> and the * specified point. * <p> ! * After adding a point, a call to <code>contains</code> with the * added point as an argument does not necessarily return ! * <code>true</code>. The <code>contains</code> method does not ! * return <code>true</code> 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, ! * <code>contains</code> returns <code>false</code> for that point. * @param newx the X coordinate of the new point * @param newy the Y coordinate of the new point * @since 1.2 */ public void add(double newx, double newy) { --- 778,800 ---- dest.setFrameFromDiagonal(x1, y1, x2, y2); } /** * Adds a point, specified by the double precision arguments ! * {@code newx} and {@code newy}, to this ! * {@code Rectangle2D}. The resulting {@code Rectangle2D} ! * is the smallest {@code Rectangle2D} that ! * contains both the original {@code Rectangle2D} and the * specified point. * <p> ! * After adding a point, a call to {@code contains} with the * added point as an argument does not necessarily return ! * {@code true}. The {@code contains} method does not ! * return {@code 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, ! * {@code contains} returns {@code false} for that point. * @param newx the X coordinate of the new point * @param newy the Y coordinate of the new point * @since 1.2 */ public void add(double newx, double newy) {
*** 804,840 **** double y2 = Math.max(getMaxY(), newy); setRect(x1, y1, x2 - x1, y2 - y1); } /** ! * Adds the <code>Point2D</code> object <code>pt</code> to this ! * <code>Rectangle2D</code>. ! * The resulting <code>Rectangle2D</code> is the smallest ! * <code>Rectangle2D</code> that contains both the original ! * <code>Rectangle2D</code> and the specified <code>Point2D</code>. * <p> ! * After adding a point, a call to <code>contains</code> with the * added point as an argument does not necessarily return ! * <code>true</code>. The <code>contains</code> ! * method does not return <code>true</code> 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, ! * <code>contains</code> returns <code>false</code> for that point. ! * @param pt the new <code>Point2D</code> to add to this ! * <code>Rectangle2D</code>. * @since 1.2 */ public void add(Point2D pt) { add(pt.getX(), pt.getY()); } /** ! * Adds a <code>Rectangle2D</code> object to this ! * <code>Rectangle2D</code>. The resulting <code>Rectangle2D</code> ! * is the union of the two <code>Rectangle2D</code> objects. ! * @param r the <code>Rectangle2D</code> to add to this ! * <code>Rectangle2D</code>. * @since 1.2 */ public void add(Rectangle2D r) { double x1 = Math.min(getMinX(), r.getMinX()); double x2 = Math.max(getMaxX(), r.getMaxX()); --- 804,840 ---- double y2 = Math.max(getMaxY(), newy); setRect(x1, y1, x2 - x1, y2 - y1); } /** ! * Adds the {@code Point2D} object {@code pt} to this ! * {@code Rectangle2D}. ! * The resulting {@code Rectangle2D} is the smallest ! * {@code Rectangle2D} that contains both the original ! * {@code Rectangle2D} and the specified {@code Point2D}. * <p> ! * After adding a point, a call to {@code contains} with the * added point as an argument does not necessarily return ! * {@code true}. The {@code contains} ! * method does not return {@code 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, ! * {@code contains} returns {@code false} for that point. ! * @param pt the new {@code Point2D} to add to this ! * {@code Rectangle2D}. * @since 1.2 */ public void add(Point2D pt) { add(pt.getX(), pt.getY()); } /** ! * Adds a {@code Rectangle2D} object to this ! * {@code Rectangle2D}. The resulting {@code Rectangle2D} ! * is the union of the two {@code Rectangle2D} objects. ! * @param r the {@code Rectangle2D} to add to this ! * {@code Rectangle2D}. * @since 1.2 */ public void add(Rectangle2D r) { double x1 = Math.min(getMinX(), r.getMinX()); double x2 = Math.max(getMaxX(), r.getMaxX());
*** 843,898 **** setRect(x1, y1, x2 - x1, y2 - y1); } /** * Returns an iteration object that defines the boundary of this ! * <code>Rectangle2D</code>. * The iterator for this class is multi-threaded safe, which means ! * that this <code>Rectangle2D</code> class guarantees that ! * modifications to the geometry of this <code>Rectangle2D</code> * object do not affect any iterations of that geometry that * are already in process. ! * @param at an optional <code>AffineTransform</code> to be applied to * the coordinates as they are returned in the iteration, or ! * <code>null</code> if untransformed coordinates are desired ! * @return the <code>PathIterator</code> object that returns the * geometry of the outline of this ! * <code>Rectangle2D</code>, one segment at a time. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at) { return new RectIterator(this, at); } /** * Returns an iteration object that defines the boundary of the ! * flattened <code>Rectangle2D</code>. Since rectangles are already ! * flat, the <code>flatness</code> parameter is ignored. * The iterator for this class is multi-threaded safe, which means ! * that this <code>Rectangle2D</code> class guarantees that ! * modifications to the geometry of this <code>Rectangle2D</code> * object do not affect any iterations of that geometry that * are already in process. ! * @param at an optional <code>AffineTransform</code> to be applied to * the coordinates as they are returned in the iteration, or ! * <code>null</code> if untransformed coordinates are desired * @param flatness 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 <code>flatness</code> parameter is ignored. ! * @return the <code>PathIterator</code> object that returns the * geometry of the outline of this ! * <code>Rectangle2D</code>, one segment at a time. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at, double flatness) { return new RectIterator(this, at); } /** ! * Returns the hashcode for this <code>Rectangle2D</code>. ! * @return the hashcode for this <code>Rectangle2D</code>. * @since 1.2 */ public int hashCode() { long bits = java.lang.Double.doubleToLongBits(getX()); bits += java.lang.Double.doubleToLongBits(getY()) * 37; --- 843,898 ---- setRect(x1, y1, x2 - x1, y2 - y1); } /** * Returns an iteration object that defines the boundary of this ! * {@code Rectangle2D}. * The iterator for this class is multi-threaded safe, which means ! * that this {@code Rectangle2D} class guarantees that ! * modifications to the geometry of this {@code Rectangle2D} * object do not affect any iterations of that geometry that * are already in process. ! * @param at an optional {@code AffineTransform} to be applied to * the coordinates as they are returned in the iteration, or ! * {@code null} if untransformed coordinates are desired ! * @return the {@code PathIterator} object that returns the * geometry of the outline of this ! * {@code Rectangle2D}, one segment at a time. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at) { return new RectIterator(this, at); } /** * Returns an iteration object that defines the boundary of the ! * flattened {@code Rectangle2D}. Since rectangles are already ! * flat, the {@code flatness} parameter is ignored. * The iterator for this class is multi-threaded safe, which means ! * that this {@code Rectangle2D} class guarantees that ! * modifications to the geometry of this {@code Rectangle2D} * object do not affect any iterations of that geometry that * are already in process. ! * @param at an optional {@code AffineTransform} to be applied to * the coordinates as they are returned in the iteration, or ! * {@code null} if untransformed coordinates are desired * @param flatness 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 {@code flatness} parameter is ignored. ! * @return the {@code PathIterator} object that returns the * geometry of the outline of this ! * {@code Rectangle2D}, one segment at a time. * @since 1.2 */ public PathIterator getPathIterator(AffineTransform at, double flatness) { return new RectIterator(this, at); } /** ! * Returns the hashcode for this {@code Rectangle2D}. ! * @return the hashcode for this {@code Rectangle2D}. * @since 1.2 */ public int hashCode() { long bits = java.lang.Double.doubleToLongBits(getX()); bits += java.lang.Double.doubleToLongBits(getY()) * 37;
*** 900,919 **** bits += java.lang.Double.doubleToLongBits(getHeight()) * 47; return (((int) bits) ^ ((int) (bits >> 32))); } /** ! * Determines whether or not the specified <code>Object</code> is ! * equal to this <code>Rectangle2D</code>. The specified ! * <code>Object</code> is equal to this <code>Rectangle2D</code> ! * if it is an instance of <code>Rectangle2D</code> and if its ! * location and size are the same as this <code>Rectangle2D</code>. ! * @param obj an <code>Object</code> to be compared with this ! * <code>Rectangle2D</code>. ! * @return <code>true</code> if <code>obj</code> is an instance ! * of <code>Rectangle2D</code> and has ! * the same values; <code>false</code> otherwise. * @since 1.2 */ public boolean equals(Object obj) { if (obj == this) { return true; --- 900,919 ---- bits += java.lang.Double.doubleToLongBits(getHeight()) * 47; return (((int) bits) ^ ((int) (bits >> 32))); } /** ! * Determines whether or not the specified {@code Object} is ! * equal to this {@code Rectangle2D}. The specified ! * {@code Object} is equal to this {@code Rectangle2D} ! * if it is an instance of {@code Rectangle2D} and if its ! * location and size are the same as this {@code Rectangle2D}. ! * @param obj an {@code Object} to be compared with this ! * {@code Rectangle2D}. ! * @return {@code true} if {@code obj} is an instance ! * of {@code Rectangle2D} and has ! * the same values; {@code false} otherwise. * @since 1.2 */ public boolean equals(Object obj) { if (obj == this) { return true;
< prev index next >