2362N/A * Copyright (c) 1996, 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>Shape</code> interface provides definitions for objects 0N/A * that represent some form of geometric shape. The <code>Shape</code> 0N/A * is described by a {@link PathIterator} object, which can express the 0N/A * outline of the <code>Shape</code> as well as a rule for determining 0N/A * how the outline divides the 2D plane into interior and exterior 0N/A * points. Each <code>Shape</code> object provides callbacks to get the 0N/A * bounding box of the geometry, determine whether points or 0N/A * rectangles lie partly or entirely within the interior 0N/A * of the <code>Shape</code>, and retrieve a <code>PathIterator</code> 0N/A * object that describes the trajectory path of the <code>Shape</code> 3816N/A * <a name="def_insideness"><b>Definition of insideness:</b></a> 0N/A * A point is considered to lie inside a 0N/A * <code>Shape</code> if and only if: 0N/A * <li> it lies completely 0N/A * inside the<code>Shape</code> boundary <i>or</i> 0N/A * it lies exactly on the <code>Shape</code> boundary <i>and</i> the 0N/A * space immediately adjacent to the 0N/A * point in the increasing <code>X</code> direction is 0N/A * entirely inside the boundary <i>or</i> 0N/A * it lies exactly on a horizontal boundary segment <b>and</b> the 0N/A * space immediately adjacent to the point in the 0N/A * increasing <code>Y</code> direction is inside the boundary. 0N/A * <p>The <code>contains</code> and <code>intersects</code> methods 0N/A * consider the interior of a <code>Shape</code> to be the area it 0N/A * encloses as if it were filled. This means that these methods 0N/A * unclosed shapes to be implicitly closed for the purpose of 0N/A * determining if a shape contains or intersects a rectangle or if a 0N/A * shape contains a point. 0N/A * @see java.awt.geom.PathIterator 0N/A * @see java.awt.geom.AffineTransform 0N/A * @see java.awt.geom.FlatteningPathIterator 0N/A * @see java.awt.geom.GeneralPath 0N/A * @author Jim Graham 0N/A * Returns an integer {@link Rectangle} that completely encloses the 0N/A * <code>Shape</code>. Note that there is no guarantee that the 0N/A * returned <code>Rectangle</code> is the smallest bounding box that 0N/A * encloses the <code>Shape</code>, only that the <code>Shape</code> 0N/A * lies entirely within the indicated <code>Rectangle</code>. The 0N/A * returned <code>Rectangle</code> might also fail to completely 0N/A * enclose the <code>Shape</code> if the <code>Shape</code> overflows 0N/A * the limited range of the integer data type. The 0N/A * <code>getBounds2D</code> method generally returns a 0N/A * tighter bounding box due to its greater flexibility in 3816N/A * definition of insideness</a> can lead to situations where points 3816N/A * on the defining outline of the {@code shape} may not be considered 3816N/A * contained in the returned {@code bounds} object, but only in cases 3816N/A * where those points are also not considered contained in the original 3816N/A * If a {@code point} is inside the {@code shape} according to the 3816N/A * {@link #contains(double x, double y) contains(point)} method, then 3816N/A * it must be inside the returned {@code Rectangle} bounds object 3816N/A * according to the {@link #contains(double x, double y) contains(point)} 3816N/A * method of the {@code bounds}. Specifically: 3816N/A * {@code shape.contains(x,y)} requires {@code bounds.contains(x,y)} 3816N/A * If a {@code point} is not inside the {@code shape}, then it might 3816N/A * still be contained in the {@code bounds} object: 3816N/A * {@code bounds.contains(x,y)} does not imply {@code shape.contains(x,y)} 0N/A * @return an integer <code>Rectangle</code> that completely encloses 0N/A * the <code>Shape</code>. 0N/A * Returns a high precision and more accurate bounding box of 0N/A * the <code>Shape</code> than the <code>getBounds</code> method. 0N/A * Note that there is no guarantee that the returned 0N/A * {@link Rectangle2D} is the smallest bounding box that encloses 0N/A * the <code>Shape</code>, only that the <code>Shape</code> lies 0N/A * entirely within the indicated <code>Rectangle2D</code>. The 0N/A * bounding box returned by this method is usually tighter than that 0N/A * returned by the <code>getBounds</code> method and never fails due 0N/A * to overflow problems since the return value can be an instance of 0N/A * the <code>Rectangle2D</code> that uses double precision values to 0N/A * store the dimensions. 3816N/A * definition of insideness</a> can lead to situations where points 3816N/A * on the defining outline of the {@code shape} may not be considered 3816N/A * contained in the returned {@code bounds} object, but only in cases 3816N/A * where those points are also not considered contained in the original 3816N/A * If a {@code point} is inside the {@code shape} according to the 3816N/A * {@link #contains(Point2D p) contains(point)} method, then it must 3816N/A * be inside the returned {@code Rectangle2D} bounds object according 3816N/A * to the {@link #contains(Point2D p) contains(point)} method of the 3816N/A * {@code bounds}. Specifically: 3816N/A * {@code shape.contains(p)} requires {@code bounds.contains(p)} 3816N/A * If a {@code point} is not inside the {@code shape}, then it might 3816N/A * still be contained in the {@code bounds} object: 3816N/A * {@code bounds.contains(p)} does not imply {@code shape.contains(p)} 0N/A * @return an instance of <code>Rectangle2D</code> that is a 0N/A * high-precision bounding box of the <code>Shape</code>. 0N/A * Tests if the specified coordinates are inside the boundary of the 3816N/A * <code>Shape</code>, as described by the 3816N/A * definition of insideness</a>. 0N/A * @param x the specified X coordinate to be tested 0N/A * @param y the specified Y coordinate to be tested 0N/A * @return <code>true</code> if the specified coordinates are inside 0N/A * the <code>Shape</code> boundary; <code>false</code> 0N/A * Tests if a specified {@link Point2D} is inside the boundary 3816N/A * of the <code>Shape</code>, as described by the 3816N/A * definition of insideness</a>. 0N/A * @param p the specified <code>Point2D</code> to be tested 0N/A * @return <code>true</code> if the specified <code>Point2D</code> is 0N/A * inside the boundary of the <code>Shape</code>; 0N/A * <code>false</code> otherwise. 0N/A * Tests if the interior of the <code>Shape</code> intersects the 0N/A * interior of a specified rectangular area. 0N/A * The rectangular area is considered to intersect the <code>Shape</code> 0N/A * if any point is contained in both the interior of the 0N/A * <code>Shape</code> and the specified rectangular area. 0N/A * The {@code Shape.intersects()} method allows a {@code Shape} 0N/A * implementation to conservatively return {@code true} when: 0N/A * there is a high probability that the rectangular area and the 0N/A * <code>Shape</code> intersect, but 0N/A * the calculations to accurately determine this intersection 0N/A * are prohibitively expensive. 0N/A * This means that for some {@code Shapes} this method might 0N/A * return {@code true} even though the rectangular area does not 0N/A * intersect the {@code Shape}. 0N/A * The {@link java.awt.geom.Area Area} class performs 0N/A * more accurate computations of geometric intersection than most 0N/A * {@code Shape} objects and therefore can be used if a more precise 0N/A * answer is required. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of the specified rectangular area 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of the specified rectangular area 0N/A * @param w the width of the specified rectangular area 0N/A * @param h the height of the specified rectangular area 0N/A * @return <code>true</code> if the interior of the <code>Shape</code> and 0N/A * the interior of the rectangular area intersect, or are 0N/A * both highly likely to intersect and intersection calculations 0N/A * would be too expensive to perform; <code>false</code> otherwise. 0N/A * @see java.awt.geom.Area 0N/A public boolean intersects(
double x,
double y,
double w,
double h);
0N/A * Tests if the interior of the <code>Shape</code> intersects the 0N/A * interior of a specified <code>Rectangle2D</code>. 0N/A * The {@code Shape.intersects()} method allows a {@code Shape} 0N/A * implementation to conservatively return {@code true} when: 0N/A * there is a high probability that the <code>Rectangle2D</code> and the 0N/A * <code>Shape</code> intersect, but 0N/A * the calculations to accurately determine this intersection 0N/A * are prohibitively expensive. 0N/A * This means that for some {@code Shapes} this method might 0N/A * return {@code true} even though the {@code Rectangle2D} does not 0N/A * intersect the {@code Shape}. 0N/A * The {@link java.awt.geom.Area Area} class performs 0N/A * more accurate computations of geometric intersection than most 0N/A * {@code Shape} objects and therefore can be used if a more precise 0N/A * answer is required. 0N/A * @param r the specified <code>Rectangle2D</code> 0N/A * @return <code>true</code> if the interior of the <code>Shape</code> and 0N/A * the interior of the specified <code>Rectangle2D</code> 0N/A * intersect, or are both highly likely to intersect and intersection 0N/A * calculations would be too expensive to perform; <code>false</code> 0N/A * @see #intersects(double, double, double, double) 0N/A * Tests if the interior of the <code>Shape</code> entirely contains 0N/A * the specified rectangular area. All coordinates that lie inside 0N/A * the rectangular area must lie within the <code>Shape</code> for the 0N/A * entire rectanglar area to be considered contained within the 0N/A * <code>Shape</code>. 0N/A * The {@code Shape.contains()} method allows a {@code Shape} 0N/A * implementation to conservatively return {@code false} when: 0N/A * the <code>intersect</code> method returns <code>true</code> and 0N/A * the calculations to determine whether or not the 0N/A * <code>Shape</code> entirely contains the rectangular area are 0N/A * prohibitively expensive. 0N/A * This means that for some {@code Shapes} this method might 0N/A * return {@code false} even though the {@code Shape} contains 0N/A * the rectangular area. 0N/A * The {@link java.awt.geom.Area Area} class performs 0N/A * more accurate geometric computations than most 0N/A * {@code Shape} objects and therefore can be used if a more precise 0N/A * answer is required. 0N/A * @param x the X coordinate of the upper-left corner 0N/A * of the specified rectangular area 0N/A * @param y the Y coordinate of the upper-left corner 0N/A * of the specified rectangular area 0N/A * @param w the width of the specified rectangular area 0N/A * @param h the height of the specified rectangular area 0N/A * @return <code>true</code> if the interior of the <code>Shape</code> 0N/A * entirely contains the specified rectangular area; 0N/A * <code>false</code> otherwise or, if the <code>Shape</code> 0N/A * contains the rectangular area and the 0N/A * <code>intersects</code> method returns <code>true</code> 0N/A * and the containment calculations would be too expensive to 0N/A * @see java.awt.geom.Area 0N/A public boolean contains(
double x,
double y,
double w,
double h);
0N/A * Tests if the interior of the <code>Shape</code> entirely contains the 0N/A * specified <code>Rectangle2D</code>. 0N/A * The {@code Shape.contains()} method allows a {@code Shape} 0N/A * implementation to conservatively return {@code false} when: 0N/A * the <code>intersect</code> method returns <code>true</code> and 0N/A * the calculations to determine whether or not the 0N/A * <code>Shape</code> entirely contains the <code>Rectangle2D</code> 0N/A * are prohibitively expensive. 0N/A * This means that for some {@code Shapes} this method might 0N/A * return {@code false} even though the {@code Shape} contains 0N/A * the {@code Rectangle2D}. 0N/A * The {@link java.awt.geom.Area Area} class performs 0N/A * more accurate geometric computations than most 0N/A * {@code Shape} objects and therefore can be used if a more precise 0N/A * answer is required. 0N/A * @param r The specified <code>Rectangle2D</code> 0N/A * @return <code>true</code> if the interior of the <code>Shape</code> 0N/A * entirely contains the <code>Rectangle2D</code>; 0N/A * <code>false</code> otherwise or, if the <code>Shape</code> 0N/A * contains the <code>Rectangle2D</code> and the 0N/A * <code>intersects</code> method returns <code>true</code> 0N/A * and the containment calculations would be too expensive to 0N/A * @see #contains(double, double, double, double) 0N/A * Returns an iterator object that iterates along the 0N/A * <code>Shape</code> boundary and provides access to the geometry of the 0N/A * <code>Shape</code> outline. If an optional {@link AffineTransform} 0N/A * is specified, the coordinates returned in the iteration are 0N/A * transformed accordingly. 0N/A * Each call to this method returns a fresh <code>PathIterator</code> 0N/A * object that traverses the geometry of the <code>Shape</code> object 0N/A * independently from any other <code>PathIterator</code> objects in use 0N/A * It is recommended, but not guaranteed, that objects 0N/A * implementing the <code>Shape</code> interface isolate iterations 0N/A * that are in process from any changes that might occur to the original 0N/A * object's geometry during such iterations. 0N/A * @param at an optional <code>AffineTransform</code> to be applied to the 0N/A * coordinates as they are returned in the iteration, or 0N/A * <code>null</code> if untransformed coordinates are desired 0N/A * @return a new <code>PathIterator</code> object, which independently 0N/A * traverses the geometry of the <code>Shape</code>. 0N/A * Returns an iterator object that iterates along the <code>Shape</code> 0N/A * boundary and provides access to a flattened view of the 0N/A * <code>Shape</code> outline geometry. 0N/A * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are 0N/A * returned by the iterator. 0N/A * If an optional <code>AffineTransform</code> is specified, 0N/A * the coordinates returned in the iteration are transformed 0N/A * The amount of subdivision of the curved segments is controlled 0N/A * by the <code>flatness</code> parameter, which specifies the 0N/A * maximum distance that any point on the unflattened transformed 0N/A * curve can deviate from the returned flattened path segments. 0N/A * Note that a limit on the accuracy of the flattened path might be 0N/A * silently imposed, causing very small flattening parameters to be 0N/A * treated as larger values. This limit, if there is one, is 0N/A * defined by the particular implementation that is used. 0N/A * Each call to this method returns a fresh <code>PathIterator</code> 0N/A * object that traverses the <code>Shape</code> object geometry 0N/A * independently from any other <code>PathIterator</code> objects in use at 0N/A * It is recommended, but not guaranteed, that objects 0N/A * implementing the <code>Shape</code> interface isolate iterations 0N/A * that are in process from any changes that might occur to the original 0N/A * object's geometry during such iterations. 0N/A * @param at an optional <code>AffineTransform</code> to be applied to the 0N/A * 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 0N/A * from any point on the original curve 0N/A * @return a new <code>PathIterator</code> that independently traverses 0N/A * a flattened view of the geometry of the <code>Shape</code>.