KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > swingwt > awt > Dimension


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: Dimension.java,v $
11    Revision 1.6 2004/01/15 15:20:29 bobintetley
12    Java2D work
13
14    Revision 1.5 2003/12/14 09:13:38 bobintetley
15    Added CVS log to source headers
16
17 */

18
19
20 package swingwt.awt;
21
22 import swingwt.awt.geom.*;
23
24 public class Dimension extends Dimension2D {
25     
26     public int width;
27     public int height;
28     public Dimension() {
29     this(0, 0);
30     }
31     public Dimension(Dimension d) {
32     this(d.width, d.height);
33     }
34     public Dimension(int width, int height) {
35     this.width = width;
36     this.height = height;
37     }
38     public double getWidth() {
39     return width;
40     }
41     public double getHeight() {
42     return height;
43     }
44     public void setSize(double width, double height) {
45     this.width = (int) Math.ceil(width);
46     this.height = (int) Math.ceil(height);
47     }
48     public Dimension getSize() {
49     return new Dimension(width, height);
50     }
51     public void setSize(Dimension d) {
52     setSize(d.width, d.height);
53     }
54     public void setSize(int width, int height) {
55         this.width = width;
56         this.height = height;
57     }
58     public boolean equals(Object JavaDoc obj) {
59     if (obj instanceof Dimension) {
60         Dimension d = (Dimension)obj;
61         return (width == d.width) && (height == d.height);
62     }
63     return false;
64     }
65     public String JavaDoc toString() {
66     return getClass().getName() + "[width=" + width + ",height=" + height + "]";
67     }
68 }
69
Popular Tags