The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | /** |
| 18 | * @author Alexey A. Petrenko |
| 19 | * @version $Revision$ |
| 20 | */ |
| 21 | package java.awt; |
| 22 | |
| 23 | import java.awt.geom.AffineTransform; |
| 24 | import java.awt.geom.PathIterator; |
| 25 | import java.awt.geom.Point2D; |
| 26 | import java.awt.geom.Rectangle2D; |
| 27 | |
| 28 | /** |
| 29 | * The Shape interface defines a geometric shape defined by a boundary |
| 30 | * (outline) path. The path outline can be accessed through a |
| 31 | * PathIterator object. The Shape |
| 32 | * interface provides methods for obtaining the bounding box (which is |
| 33 | * the smallest rectangle containing the shape and for obtaining a PathIterator |
| 34 | * object for current Shape, as well as utility methods which |
| 35 | * determine if the Shape contains or intersects a Rectangle or contains a Point. |
| 36 | */ |
| 37 | public interface Shape { |
| 38 | |
| 39 | /** |
| 40 | * Checks whether or not the point with specified coordinates lies inside |
| 41 | * the Shape. |
| 42 | * |
| 43 | * @param x the X coordinate. |
| 44 | * @param y the Y coordinate. |
| 45 | * |
| 46 | * @return true, if the specified coordinates lie inside the Shape, |
| 47 | * otherwise false. |
| 48 | */ |
| 49 | public boolean contains(double x, double y); |
| 50 | |
| 51 | /** |
| 52 | * Checks whether or not the rectangle with specified |
| 53 | * [x, y, width, height] parameters lies inside the Shape. |
| 54 | * |
| 55 | * @param x the X double coordinate of the rectangle's upper left |
| 56 | * corner. |
| 57 | * @param y the Y double coordinate of the rectangle's upper left |
| 58 | * corner. |
| 59 | * @param w the width of rectangle. |
| 60 | * @param h the height of rectangle. |
| 61 | * |
| 62 | * @return true, if the specified rectangle lies inside the Shape, |
| 63 | * otherwise false. |
| 64 | */ |
| 65 | public boolean contains(double x, double y, double w, double h); |
| 66 | |
| 67 | /** |
| 68 | * Checks whether or not the specified Point2D lies inside the Shape. |
| 69 | * |
| 70 | * @param point the Point2D object. |
| 71 | * |
| 72 | * @return true, if the specified Point2D lies inside the Shape, |
| 73 | * otherwise false. |
| 74 | */ |
| 75 | public boolean contains(Point2D point); |
| 76 | |
| 77 | /** |
| 78 | * Checks whether or not the specified rectangle lies inside the Shape. |
| 79 | * |
| 80 | * @param r the Rectangle2D object. |
| 81 | * |
| 82 | * @return true, if the specified rectangle lies inside the Shape, |
| 83 | * otherwise false. |
| 84 | */ |
| 85 | public boolean contains(Rectangle2D r); |
| 86 | |
| 87 | /** |
| 88 | * Gets the bounding rectangle of the Shape. The bounding rectangle |
| 89 | * is the smallest rectangle which contains the Shape. |
| 90 | * |
| 91 | * @return the bounding rectangle of the Shape. |
| 92 | */ |
| 93 | public Rectangle getBounds(); |
| 94 | |
| 95 | /** |
| 96 | * Gets the Rectangle2D which represents Shape bounds. |
| 97 | * The bounding rectangle is the smallest rectangle which contains |
| 98 | * the Shape. |
| 99 | * |
| 100 | * @return the bounding rectangle of the Shape. |
| 101 | */ |
| 102 | public Rectangle2D getBounds2D(); |
| 103 | |
| 104 | /** |
| 105 | * Gets the PathIterator object of the Shape which provides |
| 106 | * access to the shape's boundary modified |
| 107 | * by the specified AffineTransform. |
| 108 | * |
| 109 | * @param at the specified AffineTransform object, or null. |
| 110 | * |
| 111 | * @return PathIterator object for the Shape. |
| 112 | */ |
| 113 | public PathIterator getPathIterator(AffineTransform at); |
| 114 | |
| 115 | /** |
| 116 | * Gets the PathIterator object of the Shape which provides |
| 117 | * access to the coordinates of the shapes boundary modified |
| 118 | * by the specified AffineTransform. The flatness parameter |
| 119 | * defines the amount of subdivision of the curved segments and |
| 120 | * specifies the maximum distance which every point on the |
| 121 | * unflattened transformed curve can deviate from the returned |
| 122 | * flattened path segments. |
| 123 | * |
| 124 | * @param at the specified AffineTransform object, or null. |
| 125 | * @param flatness the maximum number of the control points for |
| 126 | * a given curve which varies from colinear before a subdivided |
| 127 | * curve is replaced by a straight line connecting the endpoints. |
| 128 | * |
| 129 | * @return PathIterator object for the Shape. |
| 130 | */ |
| 131 | public PathIterator getPathIterator(AffineTransform at, double flatness); |
| 132 | |
| 133 | /** |
| 134 | * Checks whether or not the interior of rectangular specified by |
| 135 | * [x, y, width, height] parameters intersects the interior of |
| 136 | * the Shape. |
| 137 | * |
| 138 | * @param x the X double coordinate of the rectangle's upper left |
| 139 | * corner. |
| 140 | * @param y the Y double coordinate of the rectangle's upper left |
| 141 | * corner. |
| 142 | * @param w the width of rectangle. |
| 143 | * @param h the height of rectangle. |
| 144 | * |
| 145 | * @return true, if the rectangle specified by |
| 146 | * [x, y, width, height] parameters intersects the interior of |
| 147 | * the Shape, otherwise false. |
| 148 | * |
| 149 | */ |
| 150 | public boolean intersects(double x, double y, double w, double h); |
| 151 | |
| 152 | /** |
| 153 | * Checks whether or not the interior of rectangl specified by |
| 154 | * Rectangle2D object intersects the interior of the Shape. |
| 155 | * |
| 156 | * @param r the Rectangle2D object. |
| 157 | * |
| 158 | * @return true, if the Rectangle2D intersects the interior of |
| 159 | * the Shape, otherwise false. |
| 160 | */ |
| 161 | public boolean intersects(Rectangle2D r); |
| 162 | } |