KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > geom > RectangularShape


1 /*
2    SwingWT
3    Copyright(c)2003-2004, R. Rawson-Tetley
4
5    For more information on distributing and using this program, please
6    see the accompanying "COPYING" file.
7
8    Contact me by electronic mail: bobintetley@users.sourceforge.net
9
10    $Log: RectangularShape.java,v $
11    Revision 1.4 2004/04/21 10:44:31 bobintetley
12    Code cleanup and native build script fix
13
14    Revision 1.3 2004/04/20 16:36:14 bobintetley
15    Code cleanup
16
17
18 */

19
20 package swingwt.awt.geom;
21
22 import swingwt.awt.*;
23
24 public abstract class RectangularShape implements Shape, Cloneable JavaDoc {
25
26     protected RectangularShape() { }
27
28     public abstract double getX();
29     public abstract double getY();
30     public abstract double getWidth();
31     public abstract double getHeight();
32     public double getMinX() { return getX(); }
33     public double getMinY() { return getY(); }
34     public double getMaxX() { return getX() + getWidth(); }
35     public double getMaxY() { return getY() + getHeight(); }
36     public double getCenterX() { return getX() + getWidth() / 2.0; }
37     public double getCenterY() { return getY() + getHeight() / 2.0; }
38     public Rectangle2D getFrame() { return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight()); }
39     public abstract boolean isEmpty();
40     public abstract void setFrame(double x, double y, double w, double h);
41     public void setFrame(Point2D loc, Dimension2D size) { }
42     public void setFrame(Rectangle2D r) { }
43     public void setFrameFromDiagonal(double x1, double y1,
44                      double x2, double y2) {
45
46     }
47     public void setFrameFromDiagonal(Point2D p1, Point2D p2) {
48     }
49     public void setFrameFromCenter(double centerX, double centerY,
50                    double cornerX, double cornerY) {
51
52     }
53     public void setFrameFromCenter(Point2D center, Point2D corner) {
54     }
55     public boolean contains(Point2D p) {
56     // FIXME: Implement
57
return false;
58     }
59     public boolean intersects(Rectangle2D r) {
60     // FIXME: Implement
61
return false;
62     }
63     public boolean contains(Rectangle2D r) {
64     // FIXME: Implement
65
return false;
66     }
67     public Rectangle getBounds() {
68     double width = getWidth();
69     double height = getHeight();
70     if (width < 0 || height < 0) {
71         return new Rectangle();
72     }
73     double x = getX();
74     double y = getY();
75     double x1 = Math.floor(x);
76     double y1 = Math.floor(y);
77     double x2 = Math.ceil(x + width);
78     double y2 = Math.ceil(y + height);
79     return new Rectangle((int) x1, (int) y1, (int) (x2 - x1), (int) (y2 - y1));
80     }
81     public PathIterator getPathIterator(AffineTransform at, double flatness) {
82     // FIXME: Implement
83
return null;
84     }
85     public Object JavaDoc clone() {
86     try {
87         return super.clone();
88     }
89         catch (CloneNotSupportedException JavaDoc e) {
90             throw new InternalError JavaDoc();
91     }
92     }
93     
94     public abstract Rectangle2D getBounds2D();
95     public abstract PathIterator getPathIterator(AffineTransform at);
96     
97 }
98
Popular Tags