source: trunk/gcc/libjava/java/awt/geom/Ellipse2D.java

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.6 KB
Line 
1/* Ellipse2D.java -- represents an ellipse in 2-D space
2 Copyright (C) 2000, 2002 Free Software Foundation
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package java.awt.geom;
39
40/**
41 * @author Tom Tromey <tromey@cygnus.com>
42 * @author Eric Blake <ebb9@email.byu.edu>
43 * @since 1.2
44 * @status still needs documentation
45 */
46public abstract class Ellipse2D extends RectangularShape
47{
48 protected Ellipse2D()
49 {
50 }
51
52 public boolean contains(double x, double y)
53 {
54 double rx = getWidth() / 2;
55 double ry = getHeight() / 2;
56 double tx = (x - getCenterX()) / rx;
57 double ty = (y - getCenterY()) / ry;
58 return tx * tx + ty * ty <= 1.0;
59 }
60
61 public boolean contains(double x, double y, double w, double h)
62 {
63 double x2 = x + w;
64 double y2 = y + h;
65 return (contains(x, y) && contains(x, y2)
66 && contains(x2, y) && contains(x2, y2));
67 }
68
69 public PathIterator getPathIterator(AffineTransform at)
70 {
71 // An ellipse is just a complete arc.
72 return new Arc2D.ArcIterator(this, at);
73 }
74
75 public boolean intersects(double x, double y, double w, double h)
76 {
77 // fixme
78 return false;
79 }
80
81 public static class Double extends Ellipse2D
82 {
83 public double height;
84 public double width;
85 public double x;
86 public double y;
87
88 public Double()
89 {
90 }
91
92 public Double(double x, double y, double w, double h)
93 {
94 this.x = x;
95 this.y = y;
96 height = h;
97 width = w;
98 }
99
100 public Rectangle2D getBounds2D()
101 {
102 return new Rectangle2D.Double(x, y, width, height);
103 }
104
105 public double getHeight()
106 {
107 return height;
108 }
109
110 public double getWidth()
111 {
112 return width;
113 }
114
115 public double getX()
116 {
117 return x;
118 }
119
120 public double getY()
121 {
122 return y;
123 }
124
125 public boolean isEmpty()
126 {
127 return height <= 0 || width <= 0;
128 }
129
130 public void setFrame(double x, double y, double w, double h)
131 {
132 this.x = x;
133 this.y = y;
134 height = h;
135 width = w;
136 }
137 } // class Double
138
139 public static class Float extends Ellipse2D
140 {
141 public float height;
142 public float width;
143 public float x;
144 public float y;
145
146 public Float()
147 {
148 }
149
150 public Float(float x, float y, float w, float h)
151 {
152 this.x = x;
153 this.y = y;
154 this.height = h;
155 this.width = w;
156 }
157
158 public Rectangle2D getBounds2D()
159 {
160 return new Rectangle2D.Float(x, y, width, height);
161 }
162
163 public double getHeight()
164 {
165 return height;
166 }
167
168 public double getWidth()
169 {
170 return width;
171 }
172
173 public double getX()
174 {
175 return x;
176 }
177
178 public double getY()
179 {
180 return y;
181 }
182
183 public boolean isEmpty()
184 {
185 return height <= 0 || width <= 0;
186 }
187
188 public void setFrame(float x, float y, float w, float h)
189 {
190 this.x = x;
191 this.y = y;
192 height = h;
193 width = w;
194 }
195
196 public void setFrame(double x, double y, double w, double h)
197 {
198 this.x = (float) x;
199 this.y = (float) y;
200 height = (float) h;
201 width = (float) w;
202 }
203 } // class Float
204} // class Ellipse2D
Note: See TracBrowser for help on using the repository browser.