1 46 47 package org.jfree.chart.axis; 48 49 import java.io.Serializable ; 50 51 import org.jfree.text.TextBlockAnchor; 52 import org.jfree.ui.RectangleAnchor; 53 import org.jfree.ui.TextAnchor; 54 55 60 public class CategoryLabelPosition implements Serializable { 61 62 63 private static final long serialVersionUID = 5168681143844183864L; 64 65 66 private RectangleAnchor categoryAnchor; 67 68 69 private TextBlockAnchor labelAnchor; 70 71 72 private TextAnchor rotationAnchor; 73 74 75 private double angle; 76 77 78 private CategoryLabelWidthType widthType; 79 80 84 private float widthRatio; 85 86 89 public CategoryLabelPosition() { 90 this( 91 RectangleAnchor.CENTER, TextBlockAnchor.BOTTOM_CENTER, 92 TextAnchor.CENTER, 0.0, CategoryLabelWidthType.CATEGORY, 0.95f 93 ); 94 } 95 96 103 public CategoryLabelPosition(RectangleAnchor categoryAnchor, 104 TextBlockAnchor labelAnchor) { 105 this( 107 categoryAnchor, labelAnchor, TextAnchor.CENTER, 0.0, 108 CategoryLabelWidthType.CATEGORY, 0.95f 109 ); 110 } 111 112 122 public CategoryLabelPosition(RectangleAnchor categoryAnchor, 123 TextBlockAnchor labelAnchor, 124 CategoryLabelWidthType widthType, 125 float widthRatio) { 126 this( 128 categoryAnchor, labelAnchor, TextAnchor.CENTER, 129 0.0, widthType, widthRatio 130 ); 131 } 132 133 149 public CategoryLabelPosition(RectangleAnchor categoryAnchor, 150 TextBlockAnchor labelAnchor, 151 TextAnchor rotationAnchor, 152 double angle, 153 CategoryLabelWidthType widthType, 154 float widthRatio) { 155 156 if (categoryAnchor == null) { 157 throw new IllegalArgumentException ( 158 "Null 'categoryAnchor' argument." 159 ); 160 } 161 if (labelAnchor == null) { 162 throw new IllegalArgumentException ( 163 "Null 'labelAnchor' argument." 164 ); 165 } 166 if (rotationAnchor == null) { 167 throw new IllegalArgumentException ( 168 "Null 'rotationAnchor' argument." 169 ); 170 } 171 if (widthType == null) { 172 throw new IllegalArgumentException ("Null 'widthType' argument."); 173 } 174 175 this.categoryAnchor = categoryAnchor; 176 this.labelAnchor = labelAnchor; 177 this.rotationAnchor = rotationAnchor; 178 this.angle = angle; 179 this.widthType = widthType; 180 this.widthRatio = widthRatio; 181 182 } 183 184 189 public RectangleAnchor getCategoryAnchor() { 190 return this.categoryAnchor; 191 } 192 193 198 public TextBlockAnchor getLabelAnchor() { 199 return this.labelAnchor; 200 } 201 202 207 public TextAnchor getRotationAnchor() { 208 return this.rotationAnchor; 209 } 210 211 216 public double getAngle() { 217 return this.angle; 218 } 219 220 225 public CategoryLabelWidthType getWidthType() { 226 return this.widthType; 227 } 228 229 234 public float getWidthRatio() { 235 return this.widthRatio; 236 } 237 238 245 public boolean equals(Object obj) { 246 if (obj == this) { 247 return true; 248 } 249 if (!(obj instanceof CategoryLabelPosition)) { 250 return false; 251 } 252 CategoryLabelPosition that = (CategoryLabelPosition) obj; 253 if (!this.categoryAnchor.equals(that.categoryAnchor)) { 254 return false; 255 } 256 if (!this.labelAnchor.equals(that.labelAnchor)) { 257 return false; 258 } 259 if (!this.rotationAnchor.equals(that.rotationAnchor)) { 260 return false; 261 } 262 if (this.angle != that.angle) { 263 return false; 264 } 265 if (this.widthType != that.widthType) { 266 return false; 267 } 268 if (this.widthRatio != that.widthRatio) { 269 return false; 270 } 271 return true; 272 } 273 274 279 public int hashCode() { 280 int result = 19; 281 result = 37 * result + this.categoryAnchor.hashCode(); 282 result = 37 * result + this.labelAnchor.hashCode(); 283 result = 37 * result + this.rotationAnchor.hashCode(); 284 return result; 285 } 286 287 } 288 | Popular Tags |