blob: 59bc623b8161cbcfec3a733f526509f42dbc5068 [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
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 Projecte09fd9e2008-12-17 18:05:43 -080021
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070022package java.awt;
23
24import java.awt.geom.AffineTransform;
25import java.awt.geom.PathIterator;
26import java.awt.geom.Point2D;
27import java.awt.geom.Rectangle2D;
28
29/**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080030 * 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 Project7c1b96a2008-10-21 07:00:00 -070038 */
39public interface Shape {
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080040
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070041 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080042 * Checks whether or not the point with specified coordinates lies inside
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070043 * the Shape.
44 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080045 * @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 Project7c1b96a2008-10-21 07:00:00 -070051 */
52 public boolean contains(double x, double y);
53
54 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080055 * Checks whether or not the rectangle with specified [x, y, width, height]
56 * parameters lies inside the Shape.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070057 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080058 * @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 Project7c1b96a2008-10-21 07:00:00 -070068 */
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 Projecte09fd9e2008-12-17 18:05:43 -080074 * @param point
75 * the Point2D object.
76 * @return true, if the specified Point2D lies inside the Shape, false
77 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070078 */
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 Projecte09fd9e2008-12-17 18:05:43 -080084 * @param r
85 * the Rectangle2D object.
86 * @return true, if the specified rectangle lies inside the Shape, false
87 * otherwise.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070088 */
89 public boolean contains(Rectangle2D r);
90
91 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080092 * Gets the bounding rectangle of the Shape. The bounding rectangle is the
93 * smallest rectangle which contains the Shape.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070094 *
95 * @return the bounding rectangle of the Shape.
96 */
97 public Rectangle getBounds();
98
99 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800100 * Gets the Rectangle2D which represents Shape bounds. The bounding
101 * rectangle is the smallest rectangle which contains the Shape.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700102 *
103 * @return the bounding rectangle of the Shape.
104 */
105 public Rectangle2D getBounds2D();
106
107 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800108 * 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 Project7c1b96a2008-10-21 07:00:00 -0700110 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800111 * @param at
112 * the specified AffineTransform object or null.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700113 * @return PathIterator object for the Shape.
114 */
115 public PathIterator getPathIterator(AffineTransform at);
116
117 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800118 * 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 Project7c1b96a2008-10-21 07:00:00 -0700124 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800125 * @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 Project7c1b96a2008-10-21 07:00:00 -0700131 * @return PathIterator object for the Shape.
132 */
133 public PathIterator getPathIterator(AffineTransform at, double flatness);
134
135 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800136 * 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 Project7c1b96a2008-10-21 07:00:00 -0700138 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800139 * @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 Project7c1b96a2008-10-21 07:00:00 -0700149 */
150 public boolean intersects(double x, double y, double w, double h);
151
152 /**
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800153 * Checks whether or not the interior of rectangle specified by Rectangle2D
154 * object intersects the interior of the Shape.
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -0700155 *
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -0800156 * @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 Project7c1b96a2008-10-21 07:00:00 -0700160 */
161 public boolean intersects(Rectangle2D r);
162}