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
249
252 public byte getMajorTickType()
253 {
254 return field_1_majorTickType;
255 }
256
257
260 public void setMajorTickType(byte field_1_majorTickType)
261 {
262 this.field_1_majorTickType = field_1_majorTickType;
263 }
264
265
268 public byte getMinorTickType()
269 {
270 return field_2_minorTickType;
271 }
272
273
276 public void setMinorTickType(byte field_2_minorTickType)
277 {
278 this.field_2_minorTickType = field_2_minorTickType;
279 }
280
281
284 public byte getLabelPosition()
285 {
286 return field_3_labelPosition;
287 }
288
289
292 public void setLabelPosition(byte field_3_labelPosition)
293 {
294 this.field_3_labelPosition = field_3_labelPosition;
295 }
296
297
300 public byte getBackground()
301 {
302 return field_4_background;
303 }
304
305
308 public void setBackground(byte field_4_background)
309 {
310 this.field_4_background = field_4_background;
311 }
312
313
316 public int getLabelColorRgb()
317 {
318 return field_5_labelColorRgb;
319 }
320
321
324 public void setLabelColorRgb(int field_5_labelColorRgb)
325 {
326 this.field_5_labelColorRgb = field_5_labelColorRgb;
327 }
328
329
332 public short getZero1()
333 {
334 return field_6_zero1;
335 }
336
337
340 public void setZero1(short field_6_zero1)
341 {
342 this.field_6_zero1 = field_6_zero1;
343 }
344
345
348 public short getZero2()
349 {
350 return field_7_zero2;
351 }
352
353
356 public void setZero2(short field_7_zero2)
357 {
358 this.field_7_zero2 = field_7_zero2;
359 }
360
361
364 public short getOptions()
365 {
366 return field_8_options;
367 }
368
369
372 public void setOptions(short field_8_options)
373 {
374 this.field_8_options = field_8_options;
375 }
376
377
380 public short getTickColor()
381 {
382 return field_9_tickColor;
383 }
384
385
388 public void setTickColor(short field_9_tickColor)
389 {
390 this.field_9_tickColor = field_9_tickColor;
391 }
392
393
396 public short getZero3()
397 {
398 return field_10_zero3;
399 }
400
401
404 public void setZero3(short field_10_zero3)
405 {
406 this.field_10_zero3 = field_10_zero3;
407 }
408
409
413 public void setAutoTextColor(boolean value)
414 {
415 field_8_options = autoTextColor.setShortBoolean(field_8_options, value);
416 }
417
418
422 public boolean isAutoTextColor()
423 {
424 return autoTextColor.isSet(field_8_options);
425 }
426
427
431 public void setAutoTextBackground(boolean value)
432 {
433 field_8_options = autoTextBackground.setShortBoolean(field_8_options, value);
434 }
435
436
440 public boolean isAutoTextBackground()
441 {
442 return autoTextBackground.isSet(field_8_options);
443 }
444
445
449 public void setRotation(short value)
450 {
451 field_8_options = rotation.setShortValue(field_8_options, value);
452 }
453
454
458 public short getRotation()
459 {
460 return rotation.getShortValue(field_8_options);
461 }
462
463
467 public void setAutorotate(boolean value)
468 {
469 field_8_options = autorotate.setShortBoolean(field_8_options, value);
470 }
471
472
476 public boolean isAutorotate()
477 {
478 return autorotate.isSet(field_8_options);
479 }
480
481
482 }
483
484
485
486
487