01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.lib.client.util;
15:
16: import org.jetbrains.annotations.NotNull;
17: import org.jetbrains.annotations.Nullable;
18:
19: import java.awt.geom.Dimension2D;
20:
21: /**
22: * User: Martin
23: * Date: 20.10.2005
24: * Time: 18:06:10
25: */
26: public class DoubleDimension extends Dimension2D {
27: private double width;
28: private double height;
29:
30: public DoubleDimension() {
31: this (0, 0);
32: }
33:
34: public DoubleDimension(@NotNull
35: DoubleDimension doubleDimension) {
36: this (doubleDimension.width, doubleDimension.height);
37: }
38:
39: public DoubleDimension(double width, double height) {
40: this .width = width;
41: this .height = height;
42: }
43:
44: public double getWidth() {
45: return width;
46: }
47:
48: public double getHeight() {
49: return height;
50: }
51:
52: public void setWidth(double width) {
53: this .width = width;
54: }
55:
56: public void setHeight(double height) {
57: this .height = height;
58: }
59:
60: public void setSize(double width, double height) {
61: this .width = width;
62: this .height = height;
63: }
64:
65: public boolean equals(@Nullable
66: Object o) {
67: if (this == o)
68: return true;
69: if (o == null || getClass() != o.getClass())
70: return false;
71:
72: final DoubleDimension that = (DoubleDimension) o;
73:
74: if (!MathUtils.approxEquals(that.height, height))
75: return false;
76: return MathUtils.approxEquals(that.width, width);
77: }
78:
79: public int hashCode() {
80: int result;
81: long temp;
82: temp = width != +0.0d ? Double.doubleToLongBits(width) : 0L;
83: result = (int) (temp ^ (temp >>> 32));
84: temp = height != +0.0d ? Double.doubleToLongBits(height) : 0L;
85: result = 29 * result + (int) (temp ^ (temp >>> 32));
86: return result;
87: }
88:
89: @NotNull
90: public String toString() {
91: return "DoubleDimension{" + "width=" + width + ", height="
92: + height + "}";
93: }
94: }
|