1 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 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 toString() { 66 return getClass().getName() + "[width=" + width + ",height=" + height + "]"; 67 } 68 } 69 | Popular Tags |