jdk/src/share/classes/java/awt/Shape.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 8942 81db50f6cdfc
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.geom.PathIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.geom.Point2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.geom.Rectangle2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The <code>Shape</code> interface provides definitions for objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * that represent some form of geometric shape.  The <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * is described by a {@link PathIterator} object, which can express the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * outline of the <code>Shape</code> as well as a rule for determining
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * how the outline divides the 2D plane into interior and exterior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * points.  Each <code>Shape</code> object provides callbacks to get the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * bounding box of the geometry, determine whether points or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * rectangles lie partly or entirely within the interior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * of the <code>Shape</code>, and retrieve a <code>PathIterator</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * object that describes the trajectory path of the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * outline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <b>Definition of insideness:</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * A point is considered to lie inside a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <code>Shape</code> if and only if:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <li> it lies completely
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * inside the<code>Shape</code> boundary <i>or</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * it lies exactly on the <code>Shape</code> boundary <i>and</i> the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * space immediately adjacent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * point in the increasing <code>X</code> direction is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * entirely inside the boundary <i>or</i>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * it lies exactly on a horizontal boundary segment <b>and</b> the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * space immediately adjacent to the point in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * increasing <code>Y</code> direction is inside the boundary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>The <code>contains</code> and <code>intersects</code> methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * consider the interior of a <code>Shape</code> to be the area it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * encloses as if it were filled.  This means that these methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * consider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * unclosed shapes to be implicitly closed for the purpose of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * determining if a shape contains or intersects a rectangle or if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * shape contains a point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * @see java.awt.geom.PathIterator
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * @see java.awt.geom.AffineTransform
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * @see java.awt.geom.FlatteningPathIterator
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * @see java.awt.geom.GeneralPath
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * @author Jim Graham
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
public interface Shape {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Returns an integer {@link Rectangle} that completely encloses the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <code>Shape</code>.  Note that there is no guarantee that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * returned <code>Rectangle</code> is the smallest bounding box that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * encloses the <code>Shape</code>, only that the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * lies entirely within the indicated  <code>Rectangle</code>.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * returned <code>Rectangle</code> might also fail to completely
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * enclose the <code>Shape</code> if the <code>Shape</code> overflows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * the limited range of the integer data type.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * <code>getBounds2D</code> method generally returns a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * tighter bounding box due to its greater flexibility in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @return an integer <code>Rectangle</code> that completely encloses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *                 the <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see #getBounds2D
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public Rectangle getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Returns a high precision and more accurate bounding box of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * the <code>Shape</code> than the <code>getBounds</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Note that there is no guarantee that the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * {@link Rectangle2D} is the smallest bounding box that encloses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * the <code>Shape</code>, only that the <code>Shape</code> lies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * entirely within the indicated <code>Rectangle2D</code>.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * bounding box returned by this method is usually tighter than that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * returned by the <code>getBounds</code> method and never fails due
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * to overflow problems since the return value can be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * the <code>Rectangle2D</code> that uses double precision values to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * store the dimensions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @return an instance of <code>Rectangle2D</code> that is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *                 high-precision bounding box of the <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @see #getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public Rectangle2D getBounds2D();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Tests if the specified coordinates are inside the boundary of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param x the specified X coordinate to be tested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param y the specified Y coordinate to be tested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @return <code>true</code> if the specified coordinates are inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *         the <code>Shape</code> boundary; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *         otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public boolean contains(double x, double y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Tests if a specified {@link Point2D} is inside the boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * of the <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param p the specified <code>Point2D</code> to be tested
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return <code>true</code> if the specified <code>Point2D</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *          inside the boundary of the <code>Shape</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *          <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public boolean contains(Point2D p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Tests if the interior of the <code>Shape</code> intersects the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * interior of a specified rectangular area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * The rectangular area is considered to intersect the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * if any point is contained in both the interior of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <code>Shape</code> and the specified rectangular area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * The {@code Shape.intersects()} method allows a {@code Shape}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * implementation to conservatively return {@code true} when:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * there is a high probability that the rectangular area and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * <code>Shape</code> intersect, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * the calculations to accurately determine this intersection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * are prohibitively expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * This means that for some {@code Shapes} this method might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * return {@code true} even though the rectangular area does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * intersect the {@code Shape}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * The {@link java.awt.geom.Area Area} class performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * more accurate computations of geometric intersection than most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * {@code Shape} objects and therefore can be used if a more precise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * answer is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param x the X coordinate of the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *          of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param y the Y coordinate of the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *          of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param w the width of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param h the height of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @return <code>true</code> if the interior of the <code>Shape</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *          the interior of the rectangular area intersect, or are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *          both highly likely to intersect and intersection calculations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *          would be too expensive to perform; <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see java.awt.geom.Area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public boolean intersects(double x, double y, double w, double h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Tests if the interior of the <code>Shape</code> intersects the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * interior of a specified <code>Rectangle2D</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * The {@code Shape.intersects()} method allows a {@code Shape}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * implementation to conservatively return {@code true} when:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * there is a high probability that the <code>Rectangle2D</code> and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <code>Shape</code> intersect, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * the calculations to accurately determine this intersection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * are prohibitively expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * This means that for some {@code Shapes} this method might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * return {@code true} even though the {@code Rectangle2D} does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * intersect the {@code Shape}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * The {@link java.awt.geom.Area Area} class performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * more accurate computations of geometric intersection than most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * {@code Shape} objects and therefore can be used if a more precise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * answer is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @param r the specified <code>Rectangle2D</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @return <code>true</code> if the interior of the <code>Shape</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *          the interior of the specified <code>Rectangle2D</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *          intersect, or are both highly likely to intersect and intersection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *          calculations would be too expensive to perform; <code>false</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *          otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see #intersects(double, double, double, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public boolean intersects(Rectangle2D r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Tests if the interior of the <code>Shape</code> entirely contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * the specified rectangular area.  All coordinates that lie inside
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * the rectangular area must lie within the <code>Shape</code> for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * entire rectanglar area to be considered contained within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * The {@code Shape.contains()} method allows a {@code Shape}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * implementation to conservatively return {@code false} when:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * the <code>intersect</code> method returns <code>true</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * the calculations to determine whether or not the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * <code>Shape</code> entirely contains the rectangular area are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * prohibitively expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * This means that for some {@code Shapes} this method might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * return {@code false} even though the {@code Shape} contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * the rectangular area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * The {@link java.awt.geom.Area Area} class performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * more accurate geometric computations than most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * {@code Shape} objects and therefore can be used if a more precise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * answer is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @param x the X coordinate of the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @param y the Y coordinate of the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *          of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @param w the width of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @param h the height of the specified rectangular area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @return <code>true</code> if the interior of the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *          entirely contains the specified rectangular area;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *          <code>false</code> otherwise or, if the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *          contains the rectangular area and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *          <code>intersects</code> method returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *          and the containment calculations would be too expensive to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *          perform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @see java.awt.geom.Area
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @see #intersects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public boolean contains(double x, double y, double w, double h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Tests if the interior of the <code>Shape</code> entirely contains the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * specified <code>Rectangle2D</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * The {@code Shape.contains()} method allows a {@code Shape}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * implementation to conservatively return {@code false} when:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * the <code>intersect</code> method returns <code>true</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * the calculations to determine whether or not the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * <code>Shape</code> entirely contains the <code>Rectangle2D</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * are prohibitively expensive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * This means that for some {@code Shapes} this method might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * return {@code false} even though the {@code Shape} contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * the {@code Rectangle2D}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * The {@link java.awt.geom.Area Area} class performs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * more accurate geometric computations than most
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * {@code Shape} objects and therefore can be used if a more precise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * answer is required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @param r The specified <code>Rectangle2D</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @return <code>true</code> if the interior of the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *          entirely contains the <code>Rectangle2D</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *          <code>false</code> otherwise or, if the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *          contains the <code>Rectangle2D</code> and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *          <code>intersects</code> method returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *          and the containment calculations would be too expensive to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *          perform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @see #contains(double, double, double, double)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public boolean contains(Rectangle2D r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Returns an iterator object that iterates along the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * <code>Shape</code> boundary and provides access to the geometry of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * <code>Shape</code> outline.  If an optional {@link AffineTransform}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * is specified, the coordinates returned in the iteration are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * transformed accordingly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Each call to this method returns a fresh <code>PathIterator</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * object that traverses the geometry of the <code>Shape</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * independently from any other <code>PathIterator</code> objects in use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * at the same time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * It is recommended, but not guaranteed, that objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * implementing the <code>Shape</code> interface isolate iterations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * that are in process from any changes that might occur to the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * object's geometry during such iterations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param at an optional <code>AffineTransform</code> to be applied to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *          coordinates as they are returned in the iteration, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *          <code>null</code> if untransformed coordinates are desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @return a new <code>PathIterator</code> object, which independently
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *          traverses the geometry of the <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public PathIterator getPathIterator(AffineTransform at);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Returns an iterator object that iterates along the <code>Shape</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * boundary and provides access to a flattened view of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * <code>Shape</code> outline geometry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * returned by the iterator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * If an optional <code>AffineTransform</code> is specified,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * the coordinates returned in the iteration are transformed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * accordingly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * The amount of subdivision of the curved segments is controlled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * by the <code>flatness</code> parameter, which specifies the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * maximum distance that any point on the unflattened transformed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * curve can deviate from the returned flattened path segments.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Note that a limit on the accuracy of the flattened path might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * silently imposed, causing very small flattening parameters to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * treated as larger values.  This limit, if there is one, is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * defined by the particular implementation that is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * Each call to this method returns a fresh <code>PathIterator</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * object that traverses the <code>Shape</code> object geometry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * independently from any other <code>PathIterator</code> objects in use at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * the same time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * It is recommended, but not guaranteed, that objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * implementing the <code>Shape</code> interface isolate iterations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * that are in process from any changes that might occur to the original
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * object's geometry during such iterations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @param at an optional <code>AffineTransform</code> to be applied to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *          coordinates as they are returned in the iteration, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *          <code>null</code> if untransformed coordinates are desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @param flatness the maximum distance that the line segments used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *          approximate the curved segments are allowed to deviate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *          from any point on the original curve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @return a new <code>PathIterator</code> that independently traverses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *         a flattened view of the geometry of the  <code>Shape</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    public PathIterator getPathIterator(AffineTransform at, double flatness);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
}