1 /
55
56
57 package org.apache.poi.hssf.record;
58
59
60
61 import org.apache.poi.util.*;
62
63
70 public class TickRecord
71 extends Record
72 {
73 public final static short sid = 0x101e;
74 private byte field_1_majorTickType;
75 private byte field_2_minorTickType;
76 private byte field_3_labelPosition;
77 private byte field_4_background;
78 private int field_5_labelColorRgb;
79 private short field_6_zero1;
80 private short field_7_zero2;
81 private short field_8_options;
82 private BitField autoTextColor = new BitField(0x1);
83 private BitField autoTextBackground = new BitField(0x2);
84 private BitField rotation = new BitField(0x1c);
85 private BitField autorotate = new BitField(0x20);
86 private short field_9_tickColor;
87 private short field_10_zero3;
88
89
90 public TickRecord()
91 {
92
93 }
94
95
103
104 public TickRecord(short id, short size, byte [] data)
105 {
106 super(id, size, data);
107 }
108
109
118
119 public TickRecord(short id, short size, byte [] data, int offset)
120 {
121 super(id, size, data, offset);
122 }
123
124
129 protected void validateSid(short id)
130 {
131 if (id != sid)
132 {
133 throw new RecordFormatException("Not a Tick record");
134 }
135 }
136
137 protected void fillFields(byte [] data, short size, int offset)
138 {
139 field_1_majorTickType = data[ 0x0 + offset ];
140 field_2_minorTickType = data[ 0x1 + offset ];
141 field_3_labelPosition = data[ 0x2 + offset ];
142 field_4_background = data[ 0x3 + offset ];
143 field_5_labelColorRgb = LittleEndian.getInt(data, 0x4 + offset);
144 field_6_zero1 = LittleEndian.getShort(data, 0x8 + offset);
145 field_7_zero2 = LittleEndian.getShort(data, 0x10 + offset);
146 field_8_options = LittleEndian.getShort(data, 0x18 + offset);
147 field_9_tickColor = LittleEndian.getShort(data, 0x1a + offset);
148 field_10_zero3 = LittleEndian.getShort(data, 0x1c + offset);
149
150 }
151
152 public String toString()
153 {
154 StringBuffer buffer = new StringBuffer();
155
156 buffer.append("[Tick]\n");
157
158 buffer.append(" .majorTickType = ")
159 .append("0x")
160 .append(HexDump.toHex((byte)getMajorTickType()))
161 .append(" (").append(getMajorTickType()).append(" )\n");
162
163 buffer.append(" .minorTickType = ")
164 .append("0x")
165 .append(HexDump.toHex((byte)getMinorTickType()))
166 .append(" (").append(getMinorTickType()).append(" )\n");
167
168 buffer.append(" .labelPosition = ")
169 .append("0x")
170 .append(HexDump.toHex((byte)getLabelPosition()))
171 .append(" (").append(getLabelPosition()).append(" )\n");
172
173 buffer.append(" .background = ")
174 .append("0x")
175 .append(HexDump.toHex((byte)getBackground()))
176 .append(" (").append(getBackground()).append(" )\n");
177
178 buffer.append(" .labelColorRgb = ")
179 .append("0x")
180 .append(HexDump.toHex((int)getLabelColorRgb()))
181 .append(" (").append(getLabelColorRgb()).append(" )\n");
182
183 buffer.append(" .zero1 = ")
184 .append("0x")
185 .append(HexDump.toHex((short)getZero1()))
186 .append(" (").append(getZero1()).append(" )\n");
187
188 buffer.append(" .zero2 = ")
189 .append("0x")
190 .append(HexDump.toHex((short)getZero2()))
191 .append(" (").append(getZero2()).append(" )\n");
192
193 buffer.append(" .options = ")
194 .append("0x")
195 .append(HexDump.toHex((short)getOptions()))
196 .append(" (").append(getOptions()).append(" )\n");
197 buffer.append(" .autoTextColor = ").append(isAutoTextColor ()).append('\n');
198 buffer.append(" .autoTextBackground = ").append(isAutoTextBackground ()).append('\n');
199 buffer.append(" .rotation = ").append(getRotation ()).append('\n');
200 buffer.append(" .autorotate = ").append(isAutorotate ()).append('\n');
201
202 buffer.append(" .tickColor = ")
203 .append("0x")
204 .append(HexDump.toHex((short)getTickColor()))
205 .append(" (").append(getTickColor()).append(" )\n");
206
207 buffer.append(" .zero3 = ")
208 .append("0x")
209 .append(HexDump.toHex((short)getZero3()))
210 .append(" (").append(getZero3()).append(" )\n");
211
212 buffer.append("[/Tick]\n");
213 return buffer.toString();
214 }
215
216 public int serialize(int offset, byte[] data)
217 {
218 LittleEndian.putShort(data, 0 + offset, sid);
219 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
220
221 data[ 4 + offset ] = field_1_majorTickType;
222 data[ 5 + offset ] = field_2_minorTickType;
223 data[ 6 + offset ] = field_3_labelPosition;
224 data[ 7 + offset ] = field_4_background;
225 LittleEndian.putInt(data, 8 + offset, field_5_labelColorRgb);
226 LittleEndian.putShort(data, 12 + offset, field_6_zero1);
227 LittleEndian.putShort(data, 20 + offset, field_7_zero2);
228 LittleEndian.putShort(data, 28 + offset, field_8_options);
229 LittleEndian.putShort(data, 30 + offset, field_9_tickColor);
230 LittleEndian.putShort(data, 32 + offset, field_10_zero3);
231
232 return getRecordSize();
233 }
234
235
238 public int getRecordSize()
239 {
240 return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
241 }
242
243 public short getSid()
244 {
245 return this.sid;
246 }
247
248 public Object clone() {
249 TickRecord rec = new TickRecord();
250
251 rec.field_1_majorTickType = field_1_majorTickType;
252 rec.field_2_minorTickType = field_2_minorTickType;
253 rec.field_3_labelPosition = field_3_labelPosition;
254 rec.field_4_background = field_4_background;
255 rec.field_5_labelColorRgb = field_5_labelColorRgb;
256 rec.field_6_zero1 = field_6_zero1;
257 rec.field_7_zero2 = field_7_zero2;
258 rec.field_8_options = field_8_options;
259 rec.field_9_tickColor = field_9_tickColor;
260 rec.field_10_zero3 = field_10_zero3;
261
262 return rec;
263 }
264
265
266
269 public byte getMajorTickType()
270 {
271 return field_1_majorTickType;
272 }
273
274
277 public void setMajorTickType(byte field_1_majorTickType)
278 {
279 this.field_1_majorTickType = field_1_majorTickType;
280 }
281
282
285 public byte getMinorTickType()
286 {
287 return field_2_minorTickType;
288 }
289
290
293 public void setMinorTickType(byte field_2_minorTickType)
294 {
295 this.field_2_minorTickType = field_2_minorTickType;
296 }
297
298
301 public byte getLabelPosition()
302 {
303 return field_3_labelPosition;
304 }
305
306
309 public void setLabelPosition(byte field_3_labelPosition)
310 {
311 this.field_3_labelPosition = field_3_labelPosition;
312 }
313
314
317 public byte getBackground()
318 {
319 return field_4_background;
320 }
321
322
325 public void setBackground(byte field_4_background)
326 {
327 this.field_4_background = field_4_background;
328 }
329
330
333 public int getLabelColorRgb()
334 {
335 return field_5_labelColorRgb;
336 }
337
338
341 public void setLabelColorRgb(int field_5_labelColorRgb)
342 {
343 this.field_5_labelColorRgb = field_5_labelColorRgb;
344 }
345
346
349 public short getZero1()
350 {
351 return field_6_zero1;
352 }
353
354
357 public void setZero1(short field_6_zero1)
358 {
359 this.field_6_zero1 = field_6_zero1;
360 }
361
362
365 public short getZero2()
366 {
367 return field_7_zero2;
368 }
369
370
373 public void setZero2(short field_7_zero2)
374 {
375 this.field_7_zero2 = field_7_zero2;
376 }
377
378
381 public short getOptions()
382 {
383 return field_8_options;
384 }
385
386
389 public void setOptions(short field_8_options)
390 {
391 this.field_8_options = field_8_options;
392 }
393
394
397 public short getTickColor()
398 {
399 return field_9_tickColor;
400 }
401
402
405 public void setTickColor(short field_9_tickColor)
406 {
407 this.field_9_tickColor = field_9_tickColor;
408 }
409
410
413 public short getZero3()
414 {
415 return field_10_zero3;
416 }
417
418
421 public void setZero3(short field_10_zero3)
422 {
423 this.field_10_zero3 = field_10_zero3;
424 }
425
426
430 public void setAutoTextColor(boolean value)
431 {
432 field_8_options = autoTextColor.setShortBoolean(field_8_options, value);
433 }
434
435
439 public boolean isAutoTextColor()
440 {
441 return autoTextColor.isSet(field_8_options);
442 }
443
444
448 public void setAutoTextBackground(boolean value)
449 {
450 field_8_options = autoTextBackground.setShortBoolean(field_8_options, value);
451 }
452
453
457 public boolean isAutoTextBackground()
458 {
459 return autoTextBackground.isSet(field_8_options);
460 }
461
462
466 public void setRotation(short value)
467 {
468 field_8_options = rotation.setShortValue(field_8_options, value);
469 }
470
471
475 public short getRotation()
476 {
477 return rotation.getShortValue(field_8_options);
478 }
479
480
484 public void setAutorotate(boolean value)
485 {
486 field_8_options = autorotate.setShortBoolean(field_8_options, value);
487 }
488
489
493 public boolean isAutorotate()
494 {
495 return autorotate.isSet(field_8_options);
496 }
497
498
499 }
500
501
502
503
504