1 43 44 package org.jfree.ui; 45 46 import java.awt.geom.Dimension2D ; 47 import java.io.Serializable ; 48 49 54 public class FloatDimension extends Dimension2D 55 implements Serializable { 56 57 58 private static final long serialVersionUID = 5367882923248086744L; 59 60 61 private float width; 62 63 64 private float height; 65 66 69 public FloatDimension() { 70 this.width = 0.0f; 71 this.height = 0.0f; 72 } 73 74 79 public FloatDimension(final FloatDimension fd) { 80 this.width = fd.width; 81 this.height = fd.height; 82 } 83 84 90 public FloatDimension(final float width, final float height) { 91 this.width = width; 92 this.height = height; 93 } 94 95 100 public double getWidth() { 101 return this.width; 102 } 103 104 109 public double getHeight() { 110 return this.height; 111 } 112 113 118 public void setWidth(final double width) { 119 this.width = (float) width; 120 } 121 122 127 public void setHeight(final double height) { 128 this.height = (float) height; 129 } 130 131 140 public void setSize(final double width, final double height) { 141 setHeight((float) height); 142 setWidth((float) width); 143 } 144 145 151 public Object clone() { 152 return super.clone(); 153 } 154 155 165 public String toString() { 166 return getClass().getName() + ":={width=" + getWidth() + ", height=" 167 + getHeight() + "}"; 168 } 169 170 177 public boolean equals(final Object o) { 178 if (this == o) { 179 return true; 180 } 181 if (!(o instanceof FloatDimension)) { 182 return false; 183 } 184 185 final FloatDimension floatDimension = (FloatDimension) o; 186 187 if (this.height != floatDimension.height) { 188 return false; 189 } 190 if (this.width != floatDimension.width) { 191 return false; 192 } 193 194 return true; 195 } 196 197 202 public int hashCode() { 203 int result; 204 result = Float.floatToIntBits(this.width); 205 result = 29 * result + Float.floatToIntBits(this.height); 206 return result; 207 } 208 } 209 210 | Popular Tags |