/[classpath]/classpath/java/awt/geom/Ellipse2D.java
ViewVC logotype

Diff of /classpath/java/awt/geom/Ellipse2D.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mark, Tue Jan 22 22:26:59 2002 UTC revision 1.3 by ericb, Fri Mar 22 16:54:31 2002 UTC
# Line 1  Line 1 
1  /* Copyright (C) 2000, 2002  Free Software Foundation  /* Ellipse2D.java -- represents an ellipse in 2-D space
2       Copyright (C) 2000, 2002 Free Software Foundation
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 38  package java.awt.geom; Line 39  package java.awt.geom;
39    
40  /**  /**
41   * @author Tom Tromey <tromey@cygnus.com>   * @author Tom Tromey <tromey@cygnus.com>
42   * @date April 16, 2000   * @author Eric Blake <ebb9@email.byu.edu>
43     * @since 1.2
44     * @status still needs documentation
45   */   */
   
46  public abstract class Ellipse2D extends RectangularShape  public abstract class Ellipse2D extends RectangularShape
47  {  {
48    protected Ellipse2D ()    protected Ellipse2D()
49    {    {
50    }    }
51    
52    public boolean contains (double x, double y)    public boolean contains(double x, double y)
53    {    {
54      double rx = getWidth () / 2;      double rx = getWidth() / 2;
55      double ry = getHeight () / 2;      double ry = getHeight() / 2;
56      double tx = (x - getCenterX ()) / rx;      double tx = (x - getCenterX()) / rx;
57      double ty = (y - getCenterY ()) / ry;      double ty = (y - getCenterY()) / ry;
58      return tx * tx + ty * ty <= 1.0;      return tx * tx + ty * ty <= 1.0;
59    }    }
60    
61    public boolean contains (double x, double y, double w, double h)    public boolean contains(double x, double y, double w, double h)
62    {    {
63      double x2 = x + w;      double x2 = x + w;
64      double y2 = y + h;      double y2 = y + h;
65      return (contains (x, y) && contains (x, y2)      return (contains(x, y) && contains(x, y2)
66              && contains (x2, y) && contains (x2, y2));              && contains(x2, y) && contains(x2, y2));
67    }    }
68    
69    public PathIterator getPathIterator (AffineTransform at)    public PathIterator getPathIterator(AffineTransform at)
70    {    {
71      // fixme;      // An ellipse is just a complete arc.
72      return null;      return new Arc2D.ArcIterator(this, at);
73    }    }
74    
75    public boolean intersects (double x, double y, double w, double h)    public boolean intersects(double x, double y, double w, double h)
76    {    {
77      // fixme      // fixme
78      return false;      return false;
# Line 83  public abstract class Ellipse2D extends Line 85  public abstract class Ellipse2D extends
85      public double x;      public double x;
86      public double y;      public double y;
87    
88      public Double ()      public Double()
89      {      {
       height = width = x = y = 0;  
90      }      }
91    
92      public Double (double x, double y, double w, double h)      public Double(double x, double y, double w, double h)
93      {      {
94        this.x = x;        this.x = x;
95        this.y = y;        this.y = y;
96        this.height = h;        height = h;
97        this.width = w;        width = w;
98      }      }
99    
100      public Rectangle2D getBounds2D ()      public Rectangle2D getBounds2D()
101      {      {
102        return new Rectangle2D.Double (x, y, width, height);        return new Rectangle2D.Double(x, y, width, height);
103      }      }
104    
105      public double getHeight ()      public double getHeight()
106      {      {
107        return height;        return height;
108      }      }
109    
110      public double getWidth ()      public double getWidth()
111      {      {
112        return width;        return width;
113      }      }
114    
115      public double getX ()      public double getX()
116      {      {
117        return x;        return x;
118      }      }
119    
120      public double getY ()      public double getY()
121      {      {
122        return y;        return y;
123      }      }
124    
125      public boolean isEmpty ()      public boolean isEmpty()
126      {      {
127        return height <= 0 || width <= 0;        return height <= 0 || width <= 0;
128      }      }
129    
130      public void setFrame (double x, double y, double w, double h)      public void setFrame(double x, double y, double w, double h)
131      {      {
132        this.x = x;        this.x = x;
133        this.y = y;        this.y = y;
134        this.height = h;        height = h;
135        this.width = w;        width = w;
136      }      }
137    }    } // class Double
138    
139    public static class Float extends Ellipse2D    public static class Float extends Ellipse2D
140    {    {
# Line 142  public abstract class Ellipse2D extends Line 143  public abstract class Ellipse2D extends
143      public float x;      public float x;
144      public float y;      public float y;
145    
146      public Float ()      public Float()
147      {      {
       height = width = x = y = 0;  
148      }      }
149    
150      public Float (float x, float y, float w, float h)      public Float(float x, float y, float w, float h)
151      {      {
152        this.x = x;        this.x = x;
153        this.y = y;        this.y = y;
# Line 155  public abstract class Ellipse2D extends Line 155  public abstract class Ellipse2D extends
155        this.width = w;        this.width = w;
156      }      }
157    
158      public Rectangle2D getBounds2D ()      public Rectangle2D getBounds2D()
159      {      {
160        return new Rectangle2D.Float (x, y, width, height);        return new Rectangle2D.Float(x, y, width, height);
161      }      }
162    
163      public double getHeight ()      public double getHeight()
164      {      {
165        return height;        return height;
166      }      }
167    
168      public double getWidth ()      public double getWidth()
169      {      {
170        return width;        return width;
171      }      }
172    
173      public double getX ()      public double getX()
174      {      {
175        return x;        return x;
176      }      }
177    
178      public double getY ()      public double getY()
179      {      {
180        return y;        return y;
181      }      }
182    
183      public boolean isEmpty ()      public boolean isEmpty()
184      {      {
185        return height <= 0 || width <= 0;        return height <= 0 || width <= 0;
186      }      }
187    
188      public void setFrame (float x, float y, float w, float h)      public void setFrame(float x, float y, float w, float h)
189      {      {
190        this.x = x;        this.x = x;
191        this.y = y;        this.y = y;
192        this.height = h;        height = h;
193        this.width = w;        width = w;
194      }      }
195    
196      public void setFrame (double x, double y, double w, double h)      public void setFrame(double x, double y, double w, double h)
197      {      {
198        this.x = (float) x;        this.x = (float) x;
199        this.y = (float) y;        this.y = (float) y;
200        this.height = (float) h;        height = (float) h;
201        this.width = (float) w;        width = (float) w;
202      }      }
203    }    } // class Float
204  }  } // class Ellipse2D

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26