2362N/A * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The <code>Rectangle2D</code> class describes a rectangle 0N/A * defined by a location {@code (x,y)} and dimension 0N/A * This class is only the abstract superclass for all objects that 0N/A * store a 2D rectangle. 0N/A * The actual storage representation of the coordinates is left to 0N/A * @author Jim Graham 0N/A * The bitmask that indicates that a point lies to the left of 0N/A * this <code>Rectangle2D</code>. 0N/A * The bitmask that indicates that a point lies above 0N/A * this <code>Rectangle2D</code>. 0N/A * The bitmask that indicates that a point lies to the right of 0N/A * this <code>Rectangle2D</code>. 0N/A * The bitmask that indicates that a point lies below 0N/A * this <code>Rectangle2D</code>. 0N/A * The <code>Float</code> class defines a rectangle specified in float 0N/A * The X coordinate of this <code>Rectangle2D</code>. 0N/A * The Y coordinate of this <code>Rectangle2D</code>. 0N/A * The width of this <code>Rectangle2D</code>. 0N/A * The height of this <code>Rectangle2D</code>. 0N/A * Constructs a new <code>Rectangle2D</code>, initialized to 0N/A * location (0.0, 0.0) and size (0.0, 0.0). 0N/A * Constructs and initializes a <code>Rectangle2D</code> 0N/A * from the specified <code>float</code> coordinates. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of the newly constructed <code>Rectangle2D</code> 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of the newly constructed <code>Rectangle2D</code> 0N/A * @param w the width of the newly constructed 0N/A * <code>Rectangle2D</code> 0N/A * @param h the height of the newly constructed 0N/A * <code>Rectangle2D</code> 0N/A public Float(
float x,
float y,
float w,
float h) {
0N/A * Sets the location and size of this <code>Rectangle2D</code> 0N/A * to the specified <code>float</code> values. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param w the width of this <code>Rectangle2D</code> 0N/A * @param h the height of this <code>Rectangle2D</code> 0N/A public void setRect(
float x,
float y,
float w,
float h) {
0N/A public void setRect(
double x,
double y,
double w,
double h) {
0N/A * Note on casts to double below. If the arithmetic of 0N/A * x+w or y+h is done in float, then some bits may be 0N/A * lost if the binary exponents of x/y and w/h are not 0N/A * similar. By converting to double before the addition 0N/A * we force the addition to be carried out in double to 0N/A * avoid rounding error in the comparison. 0N/A * See bug 4320890 for problems that this inaccuracy causes. 0N/A }
else if (x <
this.x) {
0N/A }
else if (x >
this.x + (
double)
this.
width) {
0N/A }
else if (y <
this.y) {
0N/A }
else if (y >
this.y + (
double)
this.
height) {
0N/A * Returns the <code>String</code> representation of this 0N/A * <code>Rectangle2D</code>. 0N/A * @return a <code>String</code> representing this 0N/A * <code>Rectangle2D</code>. 0N/A * JDK 1.6 serialVersionUID 0N/A * The <code>Double</code> class defines a rectangle specified in 0N/A * double coordinates. 0N/A * The X coordinate of this <code>Rectangle2D</code>. 0N/A * The Y coordinate of this <code>Rectangle2D</code>. 0N/A * The width of this <code>Rectangle2D</code>. 0N/A * The height of this <code>Rectangle2D</code>. 0N/A * Constructs a new <code>Rectangle2D</code>, initialized to 0N/A * location (0, 0) and size (0, 0). 0N/A * Constructs and initializes a <code>Rectangle2D</code> 0N/A * from the specified <code>double</code> coordinates. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of the newly constructed <code>Rectangle2D</code> 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of the newly constructed <code>Rectangle2D</code> 0N/A * @param w the width of the newly constructed 0N/A * <code>Rectangle2D</code> 0N/A * @param h the height of the newly constructed 0N/A * <code>Rectangle2D</code> 0N/A public Double(
double x,
double y,
double w,
double h) {
0N/A public void setRect(
double x,
double y,
double w,
double h) {
0N/A }
else if (x <
this.x) {
0N/A }
else if (y <
this.y) {
0N/A * Returns the <code>String</code> representation of this 0N/A * <code>Rectangle2D</code>. 0N/A * @return a <code>String</code> representing this 0N/A * <code>Rectangle2D</code>. 0N/A * JDK 1.6 serialVersionUID 0N/A * This is an abstract class that cannot be instantiated directly. 0N/A * Type-specific implementation subclasses are available for 0N/A * instantiation and provide a number of formats for storing 0N/A * the information necessary to satisfy the various accessor 0N/A * @see java.awt.geom.Rectangle2D.Float 0N/A * @see java.awt.geom.Rectangle2D.Double 0N/A * @see java.awt.Rectangle 0N/A * Sets the location and size of this <code>Rectangle2D</code> 0N/A * to the specified <code>double</code> values. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param w the width of this <code>Rectangle2D</code> 0N/A * @param h the height of this <code>Rectangle2D</code> 0N/A public abstract void setRect(
double x,
double y,
double w,
double h);
0N/A * Sets this <code>Rectangle2D</code> to be the same as the specified 0N/A * <code>Rectangle2D</code>. 0N/A * @param r the specified <code>Rectangle2D</code> 0N/A * Tests if the specified line segment intersects the interior of this 0N/A * <code>Rectangle2D</code>. 0N/A * @param x1 the X coordinate of the start point of the specified 0N/A * @param y1 the Y coordinate of the start point of the specified 0N/A * @param x2 the X coordinate of the end point of the specified 0N/A * @param y2 the Y coordinate of the end point of the specified 0N/A * @return <code>true</code> if the specified line segment intersects 0N/A * the interior of this <code>Rectangle2D</code>; <code>false</code> 0N/A * Tests if the specified line segment intersects the interior of this 0N/A * <code>Rectangle2D</code>. 0N/A * @param l the specified {@link Line2D} to test for intersection 0N/A * with the interior of this <code>Rectangle2D</code> 0N/A * @return <code>true</code> if the specified <code>Line2D</code> 0N/A * intersects the interior of this <code>Rectangle2D</code>; 0N/A * <code>false</code> otherwise. 0N/A * Determines where the specified coordinates lie with respect 0N/A * to this <code>Rectangle2D</code>. 0N/A * This method computes a binary OR of the appropriate mask values 0N/A * indicating, for each side of this <code>Rectangle2D</code>, 0N/A * whether or not the specified coordinates are on the same side 0N/A * of the edge as the rest of this <code>Rectangle2D</code>. 0N/A * @param x the specified X coordinate 0N/A * @param y the specified Y coordinate 0N/A * @return the logical OR of all appropriate out codes. 0N/A * Determines where the specified {@link Point2D} lies with 0N/A * respect to this <code>Rectangle2D</code>. 0N/A * This method computes a binary OR of the appropriate mask values 0N/A * indicating, for each side of this <code>Rectangle2D</code>, 0N/A * whether or not the specified <code>Point2D</code> is on the same 0N/A * side of the edge as the rest of this <code>Rectangle2D</code>. 0N/A * @param p the specified <code>Point2D</code> 0N/A * @return the logical OR of all appropriate out codes. 0N/A * Sets the location and size of the outer bounds of this 0N/A * <code>Rectangle2D</code> to the specified rectangular values. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of this <code>Rectangle2D</code> 0N/A * @param w the width of this <code>Rectangle2D</code> 0N/A * @param h the height of this <code>Rectangle2D</code> 0N/A public void setFrame(
double x,
double y,
double w,
double h) {
0N/A public boolean intersects(
double x,
double y,
double w,
double h) {
0N/A public boolean contains(
double x,
double y,
double w,
double h) {
0N/A * Returns a new <code>Rectangle2D</code> object representing the 0N/A * intersection of this <code>Rectangle2D</code> with the specified 0N/A * <code>Rectangle2D</code>. 0N/A * @param r the <code>Rectangle2D</code> to be intersected with 0N/A * this <code>Rectangle2D</code> 0N/A * @return the largest <code>Rectangle2D</code> contained in both 0N/A * the specified <code>Rectangle2D</code> and in this 0N/A * <code>Rectangle2D</code>. 0N/A * Intersects the pair of specified source <code>Rectangle2D</code> 0N/A * objects and puts the result into the specified destination 0N/A * <code>Rectangle2D</code> object. One of the source rectangles 0N/A * can also be the destination to avoid creating a third Rectangle2D 0N/A * object, but in this case the original points of this source 0N/A * rectangle will be overwritten by this method. 0N/A * @param src1 the first of a pair of <code>Rectangle2D</code> 0N/A * objects to be intersected with each other 0N/A * @param src2 the second of a pair of <code>Rectangle2D</code> 0N/A * objects to be intersected with each other 0N/A * @param dest the <code>Rectangle2D</code> that holds the 0N/A * results of the intersection of <code>src1</code> and 0N/A * Returns a new <code>Rectangle2D</code> object representing the 0N/A * union of this <code>Rectangle2D</code> with the specified 0N/A * <code>Rectangle2D</code>. 0N/A * @param r the <code>Rectangle2D</code> to be combined with 0N/A * this <code>Rectangle2D</code> 0N/A * @return the smallest <code>Rectangle2D</code> containing both 0N/A * the specified <code>Rectangle2D</code> and this 0N/A * <code>Rectangle2D</code>. 0N/A * Unions the pair of source <code>Rectangle2D</code> objects 0N/A * and puts the result into the specified destination 0N/A * <code>Rectangle2D</code> object. One of the source rectangles 0N/A * can also be the destination to avoid creating a third Rectangle2D 0N/A * object, but in this case the original points of this source 0N/A * rectangle will be overwritten by this method. 0N/A * @param src1 the first of a pair of <code>Rectangle2D</code> 0N/A * objects to be combined with each other 0N/A * @param src2 the second of a pair of <code>Rectangle2D</code> 0N/A * objects to be combined with each other 0N/A * @param dest the <code>Rectangle2D</code> that holds the 0N/A * results of the union of <code>src1</code> and 0N/A * Adds a point, specified by the double precision arguments 0N/A * <code>newx</code> and <code>newy</code>, to this 0N/A * <code>Rectangle2D</code>. The resulting <code>Rectangle2D</code> 0N/A * is the smallest <code>Rectangle2D</code> that 0N/A * contains both the original <code>Rectangle2D</code> and the 0N/A * After adding a point, a call to <code>contains</code> with the 0N/A * added point as an argument does not necessarily return 0N/A * <code>true</code>. The <code>contains</code> method does not 0N/A * return <code>true</code> for points on the right or bottom 0N/A * edges of a rectangle. Therefore, if the added point falls on 0N/A * the left or bottom edge of the enlarged rectangle, 0N/A * <code>contains</code> returns <code>false</code> for that point. 0N/A * @param newx the X coordinate of the new point 0N/A * @param newy the Y coordinate of the new point 0N/A * Adds the <code>Point2D</code> object <code>pt</code> to this 0N/A * <code>Rectangle2D</code>. 0N/A * The resulting <code>Rectangle2D</code> is the smallest 0N/A * <code>Rectangle2D</code> that contains both the original 0N/A * <code>Rectangle2D</code> and the specified <code>Point2D</code>. 0N/A * After adding a point, a call to <code>contains</code> with the 0N/A * added point as an argument does not necessarily return 0N/A * <code>true</code>. The <code>contains</code> 0N/A * method does not return <code>true</code> for points on the right 0N/A * or bottom edges of a rectangle. Therefore, if the added point falls 0N/A * on the left or bottom edge of the enlarged rectangle, 0N/A * <code>contains</code> returns <code>false</code> for that point. 0N/A * @param pt the new <code>Point2D</code> to add to this 0N/A * <code>Rectangle2D</code>. 0N/A * Adds a <code>Rectangle2D</code> object to this 0N/A * <code>Rectangle2D</code>. The resulting <code>Rectangle2D</code> 0N/A * is the union of the two <code>Rectangle2D</code> objects. 0N/A * @param r the <code>Rectangle2D</code> to add to this 0N/A * <code>Rectangle2D</code>. 0N/A * Returns an iteration object that defines the boundary of this 0N/A * <code>Rectangle2D</code>. 0N/A * The iterator for this class is multi-threaded safe, which means 0N/A * that this <code>Rectangle2D</code> class guarantees that 0N/A * modifications to the geometry of this <code>Rectangle2D</code> 0N/A * object do not affect any iterations of that geometry that 0N/A * are already in process. 0N/A * @param at an optional <code>AffineTransform</code> to be applied to 0N/A * the coordinates as they are returned in the iteration, or 0N/A * <code>null</code> if untransformed coordinates are desired 0N/A * @return the <code>PathIterator</code> object that returns the 0N/A * geometry of the outline of this 0N/A * <code>Rectangle2D</code>, one segment at a time. 0N/A * Returns an iteration object that defines the boundary of the 0N/A * flattened <code>Rectangle2D</code>. Since rectangles are already 0N/A * flat, the <code>flatness</code> parameter is ignored. 0N/A * The iterator for this class is multi-threaded safe, which means 0N/A * that this <code>Rectangle2D</code> class guarantees that 0N/A * modifications to the geometry of this <code>Rectangle2D</code> 0N/A * object do not affect any iterations of that geometry that 0N/A * are already in process. 0N/A * @param at an optional <code>AffineTransform</code> to be applied to 0N/A * the coordinates as they are returned in the iteration, or 0N/A * <code>null</code> if untransformed coordinates are desired 0N/A * @param flatness the maximum distance that the line segments used to 0N/A * approximate the curved segments are allowed to deviate from any 0N/A * point on the original curve. Since rectangles are already flat, 0N/A * the <code>flatness</code> parameter is ignored. 0N/A * @return the <code>PathIterator</code> object that returns the 0N/A * geometry of the outline of this 0N/A * <code>Rectangle2D</code>, one segment at a time. 0N/A * Returns the hashcode for this <code>Rectangle2D</code>. 0N/A * @return the hashcode for this <code>Rectangle2D</code>. 0N/A * Determines whether or not the specified <code>Object</code> is 0N/A * equal to this <code>Rectangle2D</code>. The specified 0N/A * <code>Object</code> is equal to this <code>Rectangle2D</code> 0N/A * if it is an instance of <code>Rectangle2D</code> and if its 0N/A * location and size are the same as this <code>Rectangle2D</code>. 0N/A * @param obj an <code>Object</code> to be compared with this 0N/A * <code>Rectangle2D</code>. 0N/A * @return <code>true</code> if <code>obj</code> is an instance 0N/A * of <code>Rectangle2D</code> and has 0N/A * the same values; <code>false</code> otherwise.