1 /
55
56
57 package org.apache.poi.hssf.record;
58
59
60
61 import org.apache.poi.util.*;
62
63
70 public class ValueRangeRecord
71 extends Record
72 {
73 public final static short sid = 0x101f;
74 private double field_1_minimumAxisValue;
75 private double field_2_maximumAxisValue;
76 private double field_3_majorIncrement;
77 private double field_4_minorIncrement;
78 private double field_5_categoryAxisCross;
79 private short field_6_options;
80 private BitField automaticMinimum = new BitField(0x1);
81 private BitField automaticMaximum = new BitField(0x2);
82 private BitField automaticMajor = new BitField(0x4);
83 private BitField automaticMinor = new BitField(0x8);
84 private BitField automaticCategoryCrossing = new BitField(0x10);
85 private BitField logarithmicScale = new BitField(0x20);
86 private BitField valuesInReverse = new BitField(0x40);
87 private BitField crossCategoryAxisAtMaximum = new BitField(0x80);
88 private BitField reserved = new BitField(0x100);
89
90
91 public ValueRangeRecord()
92 {
93
94 }
95
96
104
105 public ValueRangeRecord(short id, short size, byte [] data)
106 {
107 super(id, size, data);
108
109 }
110
111
120
121 public ValueRangeRecord(short id, short size, byte [] data, int offset)
122 {
123 super(id, size, data, offset);
124
125 }
126
127
132 protected void validateSid(short id)
133 {
134 if (id != sid)
135 {
136 throw new RecordFormatException("Not a ValueRange record");
137 }
138 }
139
140 protected void fillFields(byte [] data, short size, int offset)
141 {
142
143 int pos = 0;
144 field_1_minimumAxisValue = LittleEndian.getDouble(data, pos + 0x0 + offset);
145 field_2_maximumAxisValue = LittleEndian.getDouble(data, pos + 0x8 + offset);
146 field_3_majorIncrement = LittleEndian.getDouble(data, pos + 0x10 + offset);
147 field_4_minorIncrement = LittleEndian.getDouble(data, pos + 0x18 + offset);
148 field_5_categoryAxisCross = LittleEndian.getDouble(data, pos + 0x20 + offset);
149 field_6_options = LittleEndian.getShort(data, pos + 0x28 + offset);
150
151 }
152
153 public String toString()
154 {
155 StringBuffer buffer = new StringBuffer();
156
157 buffer.append("[VALUERANGE]\n");
158 buffer.append(" .minimumAxisValue = ")
159 .append(" (").append( getMinimumAxisValue() ).append(" )");
160 buffer.append(System.getProperty("line.separator"));
161 buffer.append(" .maximumAxisValue = ")
162 .append(" (").append( getMaximumAxisValue() ).append(" )");
163 buffer.append(System.getProperty("line.separator"));
164 buffer.append(" .majorIncrement = ")
165 .append(" (").append( getMajorIncrement() ).append(" )");
166 buffer.append(System.getProperty("line.separator"));
167 buffer.append(" .minorIncrement = ")
168 .append(" (").append( getMinorIncrement() ).append(" )");
169 buffer.append(System.getProperty("line.separator"));
170 buffer.append(" .categoryAxisCross = ")
171 .append(" (").append( getCategoryAxisCross() ).append(" )");
172 buffer.append(System.getProperty("line.separator"));
173 buffer.append(" .options = ")
174 .append("0x").append(HexDump.toHex( getOptions ()))
175 .append(" (").append( getOptions() ).append(" )");
176 buffer.append(System.getProperty("line.separator"));
177 buffer.append(" .automaticMinimum = ").append(isAutomaticMinimum()).append('\n');
178 buffer.append(" .automaticMaximum = ").append(isAutomaticMaximum()).append('\n');
179 buffer.append(" .automaticMajor = ").append(isAutomaticMajor()).append('\n');
180 buffer.append(" .automaticMinor = ").append(isAutomaticMinor()).append('\n');
181 buffer.append(" .automaticCategoryCrossing = ").append(isAutomaticCategoryCrossing()).append('\n');
182 buffer.append(" .logarithmicScale = ").append(isLogarithmicScale()).append('\n');
183 buffer.append(" .valuesInReverse = ").append(isValuesInReverse()).append('\n');
184 buffer.append(" .crossCategoryAxisAtMaximum = ").append(isCrossCategoryAxisAtMaximum()).append('\n');
185 buffer.append(" .reserved = ").append(isReserved()).append('\n');
186
187 buffer.append("[/VALUERANGE]\n");
188 return buffer.toString();
189 }
190
191 public int serialize(int offset, byte[] data)
192 {
193 int pos = 0;
194
195 LittleEndian.putShort(data, 0 + offset, sid);
196 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
197
198 LittleEndian.putDouble(data, 4 + offset + pos, field_1_minimumAxisValue);
199 LittleEndian.putDouble(data, 12 + offset + pos, field_2_maximumAxisValue);
200 LittleEndian.putDouble(data, 20 + offset + pos, field_3_majorIncrement);
201 LittleEndian.putDouble(data, 28 + offset + pos, field_4_minorIncrement);
202 LittleEndian.putDouble(data, 36 + offset + pos, field_5_categoryAxisCross);
203 LittleEndian.putShort(data, 44 + offset + pos, field_6_options);
204
205 return getRecordSize();
206 }
207
208
211 public int getRecordSize()
212 {
213 return 4 + 8 + 8 + 8 + 8 + 8 + 2;
214 }
215
216 public short getSid()
217 {
218 return this.sid;
219 }
220
221 public Object clone() {
222 ValueRangeRecord rec = new ValueRangeRecord();
223
224 rec.field_1_minimumAxisValue = field_1_minimumAxisValue;
225 rec.field_2_maximumAxisValue = field_2_maximumAxisValue;
226 rec.field_3_majorIncrement = field_3_majorIncrement;
227 rec.field_4_minorIncrement = field_4_minorIncrement;
228 rec.field_5_categoryAxisCross = field_5_categoryAxisCross;
229 rec.field_6_options = field_6_options;
230 return rec;
231 }
232
233
234
235
236
239 public double getMinimumAxisValue()
240 {
241 return field_1_minimumAxisValue;
242 }
243
244
247 public void setMinimumAxisValue(double field_1_minimumAxisValue)
248 {
249 this.field_1_minimumAxisValue = field_1_minimumAxisValue;
250 }
251
252
255 public double getMaximumAxisValue()
256 {
257 return field_2_maximumAxisValue;
258 }
259
260
263 public void setMaximumAxisValue(double field_2_maximumAxisValue)
264 {
265 this.field_2_maximumAxisValue = field_2_maximumAxisValue;
266 }
267
268
271 public double getMajorIncrement()
272 {
273 return field_3_majorIncrement;
274 }
275
276
279 public void setMajorIncrement(double field_3_majorIncrement)
280 {
281 this.field_3_majorIncrement = field_3_majorIncrement;
282 }
283
284
287 public double getMinorIncrement()
288 {
289 return field_4_minorIncrement;
290 }
291
292
295 public void setMinorIncrement(double field_4_minorIncrement)
296 {
297 this.field_4_minorIncrement = field_4_minorIncrement;
298 }
299
300
303 public double getCategoryAxisCross()
304 {
305 return field_5_categoryAxisCross;
306 }
307
308
311 public void setCategoryAxisCross(double field_5_categoryAxisCross)
312 {
313 this.field_5_categoryAxisCross = field_5_categoryAxisCross;
314 }
315
316
319 public short getOptions()
320 {
321 return field_6_options;
322 }
323
324
327 public void setOptions(short field_6_options)
328 {
329 this.field_6_options = field_6_options;
330 }
331
332
336 public void setAutomaticMinimum(boolean value)
337 {
338 field_6_options = automaticMinimum.setShortBoolean(field_6_options, value);
339 }
340
341
345 public boolean isAutomaticMinimum()
346 {
347 return automaticMinimum.isSet(field_6_options);
348 }
349
350
354 public void setAutomaticMaximum(boolean value)
355 {
356 field_6_options = automaticMaximum.setShortBoolean(field_6_options, value);
357 }
358
359
363 public boolean isAutomaticMaximum()
364 {
365 return automaticMaximum.isSet(field_6_options);
366 }
367
368
372 public void setAutomaticMajor(boolean value)
373 {
374 field_6_options = automaticMajor.setShortBoolean(field_6_options, value);
375 }
376
377
381 public boolean isAutomaticMajor()
382 {
383 return automaticMajor.isSet(field_6_options);
384 }
385
386
390 public void setAutomaticMinor(boolean value)
391 {
392 field_6_options = automaticMinor.setShortBoolean(field_6_options, value);
393 }
394
395
399 public boolean isAutomaticMinor()
400 {
401 return automaticMinor.isSet(field_6_options);
402 }
403
404
408 public void setAutomaticCategoryCrossing(boolean value)
409 {
410 field_6_options = automaticCategoryCrossing.setShortBoolean(field_6_options, value);
411 }
412
413
417 public boolean isAutomaticCategoryCrossing()
418 {
419 return automaticCategoryCrossing.isSet(field_6_options);
420 }
421
422
426 public void setLogarithmicScale(boolean value)
427 {
428 field_6_options = logarithmicScale.setShortBoolean(field_6_options, value);
429 }
430
431
435 public boolean isLogarithmicScale()
436 {
437 return logarithmicScale.isSet(field_6_options);
438 }
439
440
444 public void setValuesInReverse(boolean value)
445 {
446 field_6_options = valuesInReverse.setShortBoolean(field_6_options, value);
447 }
448
449
453 public boolean isValuesInReverse()
454 {
455 return valuesInReverse.isSet(field_6_options);
456 }
457
458
462 public void setCrossCategoryAxisAtMaximum(boolean value)
463 {
464 field_6_options = crossCategoryAxisAtMaximum.setShortBoolean(field_6_options, value);
465 }
466
467
471 public boolean isCrossCategoryAxisAtMaximum()
472 {
473 return crossCategoryAxisAtMaximum.isSet(field_6_options);
474 }
475
476
480 public void setReserved(boolean value)
481 {
482 field_6_options = reserved.setShortBoolean(field_6_options, value);
483 }
484
485
489 public boolean isReserved()
490 {
491 return reserved.isSet(field_6_options);
492 }
493
494
495 }
496
497
498
499
500