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
110
119
120 public TickRecord(short id, short size, byte [] data, int offset)
121 {
122 super(id, size, data, offset);
123
124 }
125
126
131 protected void validateSid(short id)
132 {
133 if (id != sid)
134 {
135 throw new RecordFormatException("Not a Tick record");
136 }
137 }
138
139 protected void fillFields(byte [] data, short size, int offset)
140 {
141
142 int pos = 0;
143 field_1_majorTickType = data[ pos + 0x0 + offset ];
144 field_2_minorTickType = data[ pos + 0x1 + offset ];
145 field_3_labelPosition = data[ pos + 0x2 + offset ];
146 field_4_background = data[ pos + 0x3 + offset ];
147 field_5_labelColorRgb = LittleEndian.getInt(data, pos + 0x4 + offset);
148 field_6_zero1 = LittleEndian.getShort(data, pos + 0x8 + offset);
149 field_7_zero2 = LittleEndian.getShort(data, pos + 0x10 + offset);
150 field_8_options = LittleEndian.getShort(data, pos + 0x18 + offset);
151 field_9_tickColor = LittleEndian.getShort(data, pos + 0x1a + offset);
152 field_10_zero3 = LittleEndian.getShort(data, pos + 0x1c + offset);
153
154 }
155
156 public String toString()
157 {
158 StringBuffer buffer = new StringBuffer();
159
160 buffer.append("[TICK]\n");
161 buffer.append(" .majorTickType = ")
162 .append("0x").append(HexDump.toHex( getMajorTickType ()))
163 .append(" (").append( getMajorTickType() ).append(" )");
164 buffer.append(System.getProperty("line.separator"));
165 buffer.append(" .minorTickType = ")
166 .append("0x").append(HexDump.toHex( getMinorTickType ()))
167 .append(" (").append( getMinorTickType() ).append(" )");
168 buffer.append(System.getProperty("line.separator"));
169 buffer.append(" .labelPosition = ")
170 .append("0x").append(HexDump.toHex( getLabelPosition ()))
171 .append(" (").append( getLabelPosition() ).append(" )");
172 buffer.append(System.getProperty("line.separator"));
173 buffer.append(" .background = ")
174 .append("0x").append(HexDump.toHex( getBackground ()))
175 .append(" (").append( getBackground() ).append(" )");
176 buffer.append(System.getProperty("line.separator"));
177 buffer.append(" .labelColorRgb = ")
178 .append("0x").append(HexDump.toHex( getLabelColorRgb ()))
179 .append(" (").append( getLabelColorRgb() ).append(" )");
180 buffer.append(System.getProperty("line.separator"));
181 buffer.append(" .zero1 = ")
182 .append("0x").append(HexDump.toHex( getZero1 ()))
183 .append(" (").append( getZero1() ).append(" )");
184 buffer.append(System.getProperty("line.separator"));
185 buffer.append(" .zero2 = ")
186 .append("0x").append(HexDump.toHex( getZero2 ()))
187 .append(" (").append( getZero2() ).append(" )");
188 buffer.append(System.getProperty("line.separator"));
189 buffer.append(" .options = ")
190 .append("0x").append(HexDump.toHex( getOptions ()))
191 .append(" (").append( getOptions() ).append(" )");
192 buffer.append(System.getProperty("line.separator"));
193 buffer.append(" .autoTextColor = ").append(isAutoTextColor()).append('\n');
194 buffer.append(" .autoTextBackground = ").append(isAutoTextBackground()).append('\n');
195 buffer.append(" .rotation = ").append(getRotation()).append('\n');
196 buffer.append(" .autorotate = ").append(isAutorotate()).append('\n');
197 buffer.append(" .tickColor = ")
198 .append("0x").append(HexDump.toHex( getTickColor ()))
199 .append(" (").append( getTickColor() ).append(" )");
200 buffer.append(System.getProperty("line.separator"));
201 buffer.append(" .zero3 = ")
202 .append("0x").append(HexDump.toHex( getZero3 ()))
203 .append(" (").append( getZero3() ).append(" )");
204 buffer.append(System.getProperty("line.separator"));
205
206 buffer.append("[/TICK]\n");
207 return buffer.toString();
208 }
209
210 public int serialize(int offset, byte[] data)
211 {
212 int pos = 0;
213
214 LittleEndian.putShort(data, 0 + offset, sid);
215 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
216
217 data[ 4 + offset + pos ] = field_1_majorTickType;
218 data[ 5 + offset + pos ] = field_2_minorTickType;
219 data[ 6 + offset + pos ] = field_3_labelPosition;
220 data[ 7 + offset + pos ] = field_4_background;
221 LittleEndian.putInt(data, 8 + offset + pos, field_5_labelColorRgb);
222 LittleEndian.putShort(data, 12 + offset + pos, field_6_zero1);
223 LittleEndian.putShort(data, 20 + offset + pos, field_7_zero2);
224 LittleEndian.putShort(data, 28 + offset + pos, field_8_options);
225 LittleEndian.putShort(data, 30 + offset + pos, field_9_tickColor);
226 LittleEndian.putShort(data, 32 + offset + pos, field_10_zero3);
227
228 return getRecordSize();
229 }
230
231
234 public int getRecordSize()
235 {
236 return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
237 }
238
239 public short getSid()
240 {
241 return this.sid;
242 }
243
244 public Object clone() {
245 TickRecord rec = new TickRecord();
246
247 rec.field_1_majorTickType = field_1_majorTickType;
248 rec.field_2_minorTickType = field_2_minorTickType;
249 rec.field_3_labelPosition = field_3_labelPosition;
250 rec.field_4_background = field_4_background;
251 rec.field_5_labelColorRgb = field_5_labelColorRgb;
252 rec.field_6_zero1 = field_6_zero1;
253 rec.field_7_zero2 = field_7_zero2;
254 rec.field_8_options = field_8_options;
255 rec.field_9_tickColor = field_9_tickColor;
256 rec.field_10_zero3 = field_10_zero3;
257 return rec;
258 }
259
260
261
262
263
266 public byte getMajorTickType()
267 {
268 return field_1_majorTickType;
269 }
270
271
274 public void setMajorTickType(byte field_1_majorTickType)
275 {
276 this.field_1_majorTickType = field_1_majorTickType;
277 }
278
279
282 public byte getMinorTickType()
283 {
284 return field_2_minorTickType;
285 }
286
287
290 public void setMinorTickType(byte field_2_minorTickType)
291 {
292 this.field_2_minorTickType = field_2_minorTickType;
293 }
294
295
298 public byte getLabelPosition()
299 {
300 return field_3_labelPosition;
301 }
302
303
306 public void setLabelPosition(byte field_3_labelPosition)
307 {
308 this.field_3_labelPosition = field_3_labelPosition;
309 }
310
311
314 public byte getBackground()
315 {
316 return field_4_background;
317 }
318
319
322 public void setBackground(byte field_4_background)
323 {
324 this.field_4_background = field_4_background;
325 }
326
327
330 public int getLabelColorRgb()
331 {
332 return field_5_labelColorRgb;
333 }
334
335
338 public void setLabelColorRgb(int field_5_labelColorRgb)
339 {
340 this.field_5_labelColorRgb = field_5_labelColorRgb;
341 }
342
343
346 public short getZero1()
347 {
348 return field_6_zero1;
349 }
350
351
354 public void setZero1(short field_6_zero1)
355 {
356 this.field_6_zero1 = field_6_zero1;
357 }
358
359
362 public short getZero2()
363 {
364 return field_7_zero2;
365 }
366
367
370 public void setZero2(short field_7_zero2)
371 {
372 this.field_7_zero2 = field_7_zero2;
373 }
374
375
378 public short getOptions()
379 {
380 return field_8_options;
381 }
382
383
386 public void setOptions(short field_8_options)
387 {
388 this.field_8_options = field_8_options;
389 }
390
391
394 public short getTickColor()
395 {
396 return field_9_tickColor;
397 }
398
399
402 public void setTickColor(short field_9_tickColor)
403 {
404 this.field_9_tickColor = field_9_tickColor;
405 }
406
407
410 public short getZero3()
411 {
412 return field_10_zero3;
413 }
414
415
418 public void setZero3(short field_10_zero3)
419 {
420 this.field_10_zero3 = field_10_zero3;
421 }
422
423
427 public void setAutoTextColor(boolean value)
428 {
429 field_8_options = autoTextColor.setShortBoolean(field_8_options, value);
430 }
431
432
436 public boolean isAutoTextColor()
437 {
438 return autoTextColor.isSet(field_8_options);
439 }
440
441
445 public void setAutoTextBackground(boolean value)
446 {
447 field_8_options = autoTextBackground.setShortBoolean(field_8_options, value);
448 }
449
450
454 public boolean isAutoTextBackground()
455 {
456 return autoTextBackground.isSet(field_8_options);
457 }
458
459
463 public void setRotation(short value)
464 {
465 field_8_options = rotation.setShortValue(field_8_options, value);
466 }
467
468
472 public short getRotation()
473 {
474 return rotation.getShortValue(field_8_options);
475 }
476
477
481 public void setAutorotate(boolean value)
482 {
483 field_8_options = autorotate.setShortBoolean(field_8_options, value);
484 }
485
486
490 public boolean isAutorotate()
491 {
492 return autorotate.isSet(field_8_options);
493 }
494
495
496 }
497
498
499
500
501