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 | */ |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 21 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 22 | package java.awt; |
| 23 | |
| 24 | import java.awt.geom.AffineTransform; |
| 25 | import java.awt.geom.PathIterator; |
| 26 | import java.awt.geom.Point2D; |
| 27 | import java.awt.geom.Rectangle2D; |
| 28 | |
| 29 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 30 | * The Shape interface defines a geometric shape defined by a boundary (outline) |
| 31 | * path. The path outline can be accessed through a PathIterator object. The |
| 32 | * Shape interface provides methods for obtaining the bounding box (which is the |
| 33 | * smallest rectangle containing the shape and for obtaining a PathIterator |
| 34 | * object for current Shape, as well as utility methods which determine if the |
| 35 | * Shape contains or intersects a Rectangle or contains a Point. |
| 36 | * |
| 37 | * @since Android 1.0 |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 38 | */ |
| 39 | public interface Shape { |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 40 | |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 41 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 42 | * Checks whether or not the point with specified coordinates lies inside |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 43 | * the Shape. |
| 44 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 45 | * @param x |
| 46 | * the X coordinate. |
| 47 | * @param y |
| 48 | * the Y coordinate. |
| 49 | * @return true, if the specified coordinates lie inside the Shape, false |
| 50 | * otherwise. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 51 | */ |
| 52 | public boolean contains(double x, double y); |
| 53 | |
| 54 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 55 | * Checks whether or not the rectangle with specified [x, y, width, height] |
| 56 | * parameters lies inside the Shape. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 57 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 58 | * @param x |
| 59 | * the X double coordinate of the rectangle's upper left corner. |
| 60 | * @param y |
| 61 | * the Y double coordinate of the rectangle's upper left corner. |
| 62 | * @param w |
| 63 | * the width of rectangle. |
| 64 | * @param h |
| 65 | * the height of rectangle. |
| 66 | * @return true, if the specified rectangle lies inside the Shape, false |
| 67 | * otherwise. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 68 | */ |
| 69 | public boolean contains(double x, double y, double w, double h); |
| 70 | |
| 71 | /** |
| 72 | * Checks whether or not the specified Point2D lies inside the Shape. |
| 73 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 74 | * @param point |
| 75 | * the Point2D object. |
| 76 | * @return true, if the specified Point2D lies inside the Shape, false |
| 77 | * otherwise. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 78 | */ |
| 79 | public boolean contains(Point2D point); |
| 80 | |
| 81 | /** |
| 82 | * Checks whether or not the specified rectangle lies inside the Shape. |
| 83 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 84 | * @param r |
| 85 | * the Rectangle2D object. |
| 86 | * @return true, if the specified rectangle lies inside the Shape, false |
| 87 | * otherwise. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 88 | */ |
| 89 | public boolean contains(Rectangle2D r); |
| 90 | |
| 91 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 92 | * Gets the bounding rectangle of the Shape. The bounding rectangle is the |
| 93 | * smallest rectangle which contains the Shape. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 94 | * |
| 95 | * @return the bounding rectangle of the Shape. |
| 96 | */ |
| 97 | public Rectangle getBounds(); |
| 98 | |
| 99 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 100 | * Gets the Rectangle2D which represents Shape bounds. The bounding |
| 101 | * rectangle is the smallest rectangle which contains the Shape. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 102 | * |
| 103 | * @return the bounding rectangle of the Shape. |
| 104 | */ |
| 105 | public Rectangle2D getBounds2D(); |
| 106 | |
| 107 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 108 | * Gets the PathIterator object of the Shape which provides access to the |
| 109 | * shape's boundary modified by the specified AffineTransform. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 110 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 111 | * @param at |
| 112 | * the specified AffineTransform object or null. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 113 | * @return PathIterator object for the Shape. |
| 114 | */ |
| 115 | public PathIterator getPathIterator(AffineTransform at); |
| 116 | |
| 117 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 118 | * Gets the PathIterator object of the Shape which provides access to the |
| 119 | * coordinates of the shapes boundary modified by the specified |
| 120 | * AffineTransform. The flatness parameter defines the amount of subdivision |
| 121 | * of the curved segments and specifies the maximum distance which every |
| 122 | * point on the unflattened transformed curve can deviate from the returned |
| 123 | * flattened path segments. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 124 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 125 | * @param at |
| 126 | * the specified AffineTransform object or null. |
| 127 | * @param flatness |
| 128 | * the maximum number of the control points for a given curve |
| 129 | * which varies from colinear before a subdivided curve is |
| 130 | * replaced by a straight line connecting the endpoints. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 131 | * @return PathIterator object for the Shape. |
| 132 | */ |
| 133 | public PathIterator getPathIterator(AffineTransform at, double flatness); |
| 134 | |
| 135 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 136 | * Checks whether or not the interior of rectangular specified by [x, y, |
| 137 | * width, height] parameters intersects the interior of the Shape. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 138 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 139 | * @param x |
| 140 | * the X double coordinate of the rectangle's upper left corner. |
| 141 | * @param y |
| 142 | * the Y double coordinate of the rectangle's upper left corner. |
| 143 | * @param w |
| 144 | * the width of rectangle. |
| 145 | * @param h |
| 146 | * the height of rectangle. |
| 147 | * @return true, if the rectangle specified by [x, y, width, height] |
| 148 | * parameters intersects the interior of the Shape, false otherwise. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 149 | */ |
| 150 | public boolean intersects(double x, double y, double w, double h); |
| 151 | |
| 152 | /** |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 153 | * Checks whether or not the interior of rectangle specified by Rectangle2D |
| 154 | * object intersects the interior of the Shape. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 155 | * |
The Android Open Source Project | e09fd9e | 2008-12-17 18:05:43 -0800 | [diff] [blame^] | 156 | * @param r |
| 157 | * the Rectangle2D object. |
| 158 | * @return true, if the Rectangle2D intersects the interior of the Shape, |
| 159 | * otherwise false. |
The Android Open Source Project | 7c1b96a | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 160 | */ |
| 161 | public boolean intersects(Rectangle2D r); |
| 162 | } |