1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class ValueRangeRecord 34 extends Record 35 { 36 public final static short sid = 0x101f; 37 private double field_1_minimumAxisValue; 38 private double field_2_maximumAxisValue; 39 private double field_3_majorIncrement; 40 private double field_4_minorIncrement; 41 private double field_5_categoryAxisCross; 42 private short field_6_options; 43 private BitField automaticMinimum = new BitField(0x1); 44 private BitField automaticMaximum = new BitField(0x2); 45 private BitField automaticMajor = new BitField(0x4); 46 private BitField automaticMinor = new BitField(0x8); 47 private BitField automaticCategoryCrossing = new BitField(0x10); 48 private BitField logarithmicScale = new BitField(0x20); 49 private BitField valuesInReverse = new BitField(0x40); 50 private BitField crossCategoryAxisAtMaximum = new BitField(0x80); 51 private BitField reserved = new BitField(0x100); 52 53 54 public ValueRangeRecord() 55 { 56 57 } 58 59 67 68 public ValueRangeRecord(short id, short size, byte [] data) 69 { 70 super(id, size, data); 71 72 } 73 74 83 84 public ValueRangeRecord(short id, short size, byte [] data, int offset) 85 { 86 super(id, size, data, offset); 87 88 } 89 90 95 protected void validateSid(short id) 96 { 97 if (id != sid) 98 { 99 throw new RecordFormatException("Not a ValueRange record"); 100 } 101 } 102 103 protected void fillFields(byte [] data, short size, int offset) 104 { 105 106 int pos = 0; 107 field_1_minimumAxisValue = LittleEndian.getDouble(data, pos + 0x0 + offset); 108 field_2_maximumAxisValue = LittleEndian.getDouble(data, pos + 0x8 + offset); 109 field_3_majorIncrement = LittleEndian.getDouble(data, pos + 0x10 + offset); 110 field_4_minorIncrement = LittleEndian.getDouble(data, pos + 0x18 + offset); 111 field_5_categoryAxisCross = LittleEndian.getDouble(data, pos + 0x20 + offset); 112 field_6_options = LittleEndian.getShort(data, pos + 0x28 + offset); 113 114 } 115 116 public String toString() 117 { 118 StringBuffer buffer = new StringBuffer (); 119 120 buffer.append("[VALUERANGE]\n"); 121 buffer.append(" .minimumAxisValue = ") 122 .append(" (").append( getMinimumAxisValue() ).append(" )"); 123 buffer.append(System.getProperty("line.separator")); 124 buffer.append(" .maximumAxisValue = ") 125 .append(" (").append( getMaximumAxisValue() ).append(" )"); 126 buffer.append(System.getProperty("line.separator")); 127 buffer.append(" .majorIncrement = ") 128 .append(" (").append( getMajorIncrement() ).append(" )"); 129 buffer.append(System.getProperty("line.separator")); 130 buffer.append(" .minorIncrement = ") 131 .append(" (").append( getMinorIncrement() ).append(" )"); 132 buffer.append(System.getProperty("line.separator")); 133 buffer.append(" .categoryAxisCross = ") 134 .append(" (").append( getCategoryAxisCross() ).append(" )"); 135 buffer.append(System.getProperty("line.separator")); 136 buffer.append(" .options = ") 137 .append("0x").append(HexDump.toHex( getOptions ())) 138 .append(" (").append( getOptions() ).append(" )"); 139 buffer.append(System.getProperty("line.separator")); 140 buffer.append(" .automaticMinimum = ").append(isAutomaticMinimum()).append('\n'); 141 buffer.append(" .automaticMaximum = ").append(isAutomaticMaximum()).append('\n'); 142 buffer.append(" .automaticMajor = ").append(isAutomaticMajor()).append('\n'); 143 buffer.append(" .automaticMinor = ").append(isAutomaticMinor()).append('\n'); 144 buffer.append(" .automaticCategoryCrossing = ").append(isAutomaticCategoryCrossing()).append('\n'); 145 buffer.append(" .logarithmicScale = ").append(isLogarithmicScale()).append('\n'); 146 buffer.append(" .valuesInReverse = ").append(isValuesInReverse()).append('\n'); 147 buffer.append(" .crossCategoryAxisAtMaximum = ").append(isCrossCategoryAxisAtMaximum()).append('\n'); 148 buffer.append(" .reserved = ").append(isReserved()).append('\n'); 149 150 buffer.append("[/VALUERANGE]\n"); 151 return buffer.toString(); 152 } 153 154 public int serialize(int offset, byte[] data) 155 { 156 int pos = 0; 157 158 LittleEndian.putShort(data, 0 + offset, sid); 159 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 160 161 LittleEndian.putDouble(data, 4 + offset + pos, field_1_minimumAxisValue); 162 LittleEndian.putDouble(data, 12 + offset + pos, field_2_maximumAxisValue); 163 LittleEndian.putDouble(data, 20 + offset + pos, field_3_majorIncrement); 164 LittleEndian.putDouble(data, 28 + offset + pos, field_4_minorIncrement); 165 LittleEndian.putDouble(data, 36 + offset + pos, field_5_categoryAxisCross); 166 LittleEndian.putShort(data, 44 + offset + pos, field_6_options); 167 168 return getRecordSize(); 169 } 170 171 174 public int getRecordSize() 175 { 176 return 4 + 8 + 8 + 8 + 8 + 8 + 2; 177 } 178 179 public short getSid() 180 { 181 return this.sid; 182 } 183 184 public Object clone() { 185 ValueRangeRecord rec = new ValueRangeRecord(); 186 187 rec.field_1_minimumAxisValue = field_1_minimumAxisValue; 188 rec.field_2_maximumAxisValue = field_2_maximumAxisValue; 189 rec.field_3_majorIncrement = field_3_majorIncrement; 190 rec.field_4_minorIncrement = field_4_minorIncrement; 191 rec.field_5_categoryAxisCross = field_5_categoryAxisCross; 192 rec.field_6_options = field_6_options; 193 return rec; 194 } 195 196 197 198 199 202 public double getMinimumAxisValue() 203 { 204 return field_1_minimumAxisValue; 205 } 206 207 210 public void setMinimumAxisValue(double field_1_minimumAxisValue) 211 { 212 this.field_1_minimumAxisValue = field_1_minimumAxisValue; 213 } 214 215 218 public double getMaximumAxisValue() 219 { 220 return field_2_maximumAxisValue; 221 } 222 223 226 public void setMaximumAxisValue(double field_2_maximumAxisValue) 227 { 228 this.field_2_maximumAxisValue = field_2_maximumAxisValue; 229 } 230 231 234 public double getMajorIncrement() 235 { 236 return field_3_majorIncrement; 237 } 238 239 242 public void setMajorIncrement(double field_3_majorIncrement) 243 { 244 this.field_3_majorIncrement = field_3_majorIncrement; 245 } 246 247 250 public double getMinorIncrement() 251 { 252 return field_4_minorIncrement; 253 } 254 255 258 public void setMinorIncrement(double field_4_minorIncrement) 259 { 260 this.field_4_minorIncrement = field_4_minorIncrement; 261 } 262 263 266 public double getCategoryAxisCross() 267 { 268 return field_5_categoryAxisCross; 269 } 270 271 274 public void setCategoryAxisCross(double field_5_categoryAxisCross) 275 { 276 this.field_5_categoryAxisCross = field_5_categoryAxisCross; 277 } 278 279 282 public short getOptions() 283 { 284 return field_6_options; 285 } 286 287 290 public void setOptions(short field_6_options) 291 { 292 this.field_6_options = field_6_options; 293 } 294 295 299 public void setAutomaticMinimum(boolean value) 300 { 301 field_6_options = automaticMinimum.setShortBoolean(field_6_options, value); 302 } 303 304 308 public boolean isAutomaticMinimum() 309 { 310 return automaticMinimum.isSet(field_6_options); 311 } 312 313 317 public void setAutomaticMaximum(boolean value) 318 { 319 field_6_options = automaticMaximum.setShortBoolean(field_6_options, value); 320 } 321 322 326 public boolean isAutomaticMaximum() 327 { 328 return automaticMaximum.isSet(field_6_options); 329 } 330 331 335 public void setAutomaticMajor(boolean value) 336 { 337 field_6_options = automaticMajor.setShortBoolean(field_6_options, value); 338 } 339 340 344 public boolean isAutomaticMajor() 345 { 346 return automaticMajor.isSet(field_6_options); 347 } 348 349 353 public void setAutomaticMinor(boolean value) 354 { 355 field_6_options = automaticMinor.setShortBoolean(field_6_options, value); 356 } 357 358 362 public boolean isAutomaticMinor() 363 { 364 return automaticMinor.isSet(field_6_options); 365 } 366 367 371 public void setAutomaticCategoryCrossing(boolean value) 372 { 373 field_6_options = automaticCategoryCrossing.setShortBoolean(field_6_options, value); 374 } 375 376 380 public boolean isAutomaticCategoryCrossing() 381 { 382 return automaticCategoryCrossing.isSet(field_6_options); 383 } 384 385 389 public void setLogarithmicScale(boolean value) 390 { 391 field_6_options = logarithmicScale.setShortBoolean(field_6_options, value); 392 } 393 394 398 public boolean isLogarithmicScale() 399 { 400 return logarithmicScale.isSet(field_6_options); 401 } 402 403 407 public void setValuesInReverse(boolean value) 408 { 409 field_6_options = valuesInReverse.setShortBoolean(field_6_options, value); 410 } 411 412 416 public boolean isValuesInReverse() 417 { 418 return valuesInReverse.isSet(field_6_options); 419 } 420 421 425 public void setCrossCategoryAxisAtMaximum(boolean value) 426 { 427 field_6_options = crossCategoryAxisAtMaximum.setShortBoolean(field_6_options, value); 428 } 429 430 434 public boolean isCrossCategoryAxisAtMaximum() 435 { 436 return crossCategoryAxisAtMaximum.isSet(field_6_options); 437 } 438 439 443 public void setReserved(boolean value) 444 { 445 field_6_options = reserved.setShortBoolean(field_6_options, value); 446 } 447 448 452 public boolean isReserved() 453 { 454 return reserved.isSet(field_6_options); 455 } 456 457 458 } 460 461 462 463 | Popular Tags |