| 2 | |
| 3 | //javadoc:Size_ |
| 4 | public class Size { |
| 5 | |
| 6 | public double width, height; |
| 7 | |
| 8 | public Size(double width, double height) { |
| 9 | this.width = width; |
| 10 | this.height = height; |
| 11 | } |
| 12 | |
| 13 | public Size() { |
| 14 | this(0, 0); |
| 15 | } |
| 16 | |
| 17 | public Size(Point p) { |
| 18 | width = p.x; |
| 19 | height = p.y; |
| 20 | } |
| 21 | |
| 22 | public Size(double[] vals) { |
| 23 | set(vals); |
| 24 | } |
| 25 | |
| 26 | public void set(double[] vals) { |
| 27 | if (vals != null) { |
| 28 | width = vals.length > 0 ? vals[0] : 0; |
| 29 | height = vals.length > 1 ? vals[1] : 0; |
| 30 | } else { |
| 31 | width = 0; |
| 32 | height = 0; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | public double area() { |
| 37 | return width * height; |
| 38 | } |
| 39 | |
| 40 | public boolean empty() { |
| 41 | return width <= 0 || height <= 0; |
| 42 | } |
| 43 | |
| 44 | public Size clone() { |
| 45 | return new Size(width, height); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public int hashCode() { |
| 50 | final int prime = 31; |
| 51 | int result = 1; |
| 52 | long temp; |
| 53 | temp = Double.doubleToLongBits(height); |
| 54 | result = prime * result + (int) (temp ^ (temp >>> 32)); |
| 55 | temp = Double.doubleToLongBits(width); |
| 56 | result = prime * result + (int) (temp ^ (temp >>> 32)); |
| 57 | return result; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public boolean equals(Object obj) { |
no outgoing calls