KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > TickRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19
20 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * The Tick record defines how tick marks and label positioning/formatting
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Andrew C. Oliver(acoliver at apache.org)
32  */

33 public class TickRecord
34     extends Record
35 {
36     public final static short sid = 0x101e;
37     private byte field_1_majorTickType;
38     private byte field_2_minorTickType;
39     private byte field_3_labelPosition;
40     private byte field_4_background;
41     private int field_5_labelColorRgb;
42     private short field_6_zero1;
43     private short field_7_zero2;
44     private short field_8_options;
45     private BitField autoTextColor = new BitField(0x1);
46     private BitField autoTextBackground = new BitField(0x2);
47     private BitField rotation = new BitField(0x1c);
48     private BitField autorotate = new BitField(0x20);
49     private short field_9_tickColor;
50     private short field_10_zero3;
51
52
53     public TickRecord()
54     {
55
56     }
57
58     /**
59      * Constructs a Tick record and sets its fields appropriately.
60      *
61      * @param id id must be 0x101e or an exception
62      * will be throw upon validation
63      * @param size size the size of the data area of the record
64      * @param data data of the record (should not contain sid/len)
65      */

66
67     public TickRecord(short id, short size, byte [] data)
68     {
69         super(id, size, data);
70     
71     }
72
73     /**
74      * Constructs a Tick record and sets its fields appropriately.
75      *
76      * @param id id must be 0x101e or an exception
77      * will be throw upon validation
78      * @param size size the size of the data area of the record
79      * @param data data of the record (should not contain sid/len)
80      * @param offset of the record's data
81      */

82
83     public TickRecord(short id, short size, byte [] data, int offset)
84     {
85         super(id, size, data, offset);
86     
87     }
88
89     /**
90      * Checks the sid matches the expected side for this record
91      *
92      * @param id the expected sid.
93      */

94     protected void validateSid(short id)
95     {
96         if (id != sid)
97         {
98             throw new RecordFormatException("Not a Tick record");
99         }
100     }
101
102     protected void fillFields(byte [] data, short size, int offset)
103     {
104
105         int pos = 0;
106         field_1_majorTickType = data[ pos + 0x0 + offset ];
107         field_2_minorTickType = data[ pos + 0x1 + offset ];
108         field_3_labelPosition = data[ pos + 0x2 + offset ];
109         field_4_background = data[ pos + 0x3 + offset ];
110         field_5_labelColorRgb = LittleEndian.getInt(data, pos + 0x4 + offset);
111         field_6_zero1 = LittleEndian.getShort(data, pos + 0x8 + offset);
112         field_7_zero2 = LittleEndian.getShort(data, pos + 0x10 + offset);
113         field_8_options = LittleEndian.getShort(data, pos + 0x18 + offset);
114         field_9_tickColor = LittleEndian.getShort(data, pos + 0x1a + offset);
115         field_10_zero3 = LittleEndian.getShort(data, pos + 0x1c + offset);
116
117     }
118
119     public String JavaDoc toString()
120     {
121         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
122
123         buffer.append("[TICK]\n");
124         buffer.append(" .majorTickType = ")
125             .append("0x").append(HexDump.toHex( getMajorTickType ()))
126             .append(" (").append( getMajorTickType() ).append(" )");
127         buffer.append(System.getProperty("line.separator"));
128         buffer.append(" .minorTickType = ")
129             .append("0x").append(HexDump.toHex( getMinorTickType ()))
130             .append(" (").append( getMinorTickType() ).append(" )");
131         buffer.append(System.getProperty("line.separator"));
132         buffer.append(" .labelPosition = ")
133             .append("0x").append(HexDump.toHex( getLabelPosition ()))
134             .append(" (").append( getLabelPosition() ).append(" )");
135         buffer.append(System.getProperty("line.separator"));
136         buffer.append(" .background = ")
137             .append("0x").append(HexDump.toHex( getBackground ()))
138             .append(" (").append( getBackground() ).append(" )");
139         buffer.append(System.getProperty("line.separator"));
140         buffer.append(" .labelColorRgb = ")
141             .append("0x").append(HexDump.toHex( getLabelColorRgb ()))
142             .append(" (").append( getLabelColorRgb() ).append(" )");
143         buffer.append(System.getProperty("line.separator"));
144         buffer.append(" .zero1 = ")
145             .append("0x").append(HexDump.toHex( getZero1 ()))
146             .append(" (").append( getZero1() ).append(" )");
147         buffer.append(System.getProperty("line.separator"));
148         buffer.append(" .zero2 = ")
149             .append("0x").append(HexDump.toHex( getZero2 ()))
150             .append(" (").append( getZero2() ).append(" )");
151         buffer.append(System.getProperty("line.separator"));
152         buffer.append(" .options = ")
153             .append("0x").append(HexDump.toHex( getOptions ()))
154             .append(" (").append( getOptions() ).append(" )");
155         buffer.append(System.getProperty("line.separator"));
156         buffer.append(" .autoTextColor = ").append(isAutoTextColor()).append('\n');
157         buffer.append(" .autoTextBackground = ").append(isAutoTextBackground()).append('\n');
158             buffer.append(" .rotation = ").append(getRotation()).append('\n');
159         buffer.append(" .autorotate = ").append(isAutorotate()).append('\n');
160         buffer.append(" .tickColor = ")
161             .append("0x").append(HexDump.toHex( getTickColor ()))
162             .append(" (").append( getTickColor() ).append(" )");
163         buffer.append(System.getProperty("line.separator"));
164         buffer.append(" .zero3 = ")
165             .append("0x").append(HexDump.toHex( getZero3 ()))
166             .append(" (").append( getZero3() ).append(" )");
167         buffer.append(System.getProperty("line.separator"));
168
169         buffer.append("[/TICK]\n");
170         return buffer.toString();
171     }
172
173     public int serialize(int offset, byte[] data)
174     {
175         int pos = 0;
176
177         LittleEndian.putShort(data, 0 + offset, sid);
178         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
179
180         data[ 4 + offset + pos ] = field_1_majorTickType;
181         data[ 5 + offset + pos ] = field_2_minorTickType;
182         data[ 6 + offset + pos ] = field_3_labelPosition;
183         data[ 7 + offset + pos ] = field_4_background;
184         LittleEndian.putInt(data, 8 + offset + pos, field_5_labelColorRgb);
185         LittleEndian.putShort(data, 12 + offset + pos, field_6_zero1);
186         LittleEndian.putShort(data, 20 + offset + pos, field_7_zero2);
187         LittleEndian.putShort(data, 28 + offset + pos, field_8_options);
188         LittleEndian.putShort(data, 30 + offset + pos, field_9_tickColor);
189         LittleEndian.putShort(data, 32 + offset + pos, field_10_zero3);
190
191         return getRecordSize();
192     }
193
194     /**
195      * Size of record (exluding 4 byte header)
196      */

197     public int getRecordSize()
198     {
199         return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
200     }
201
202     public short getSid()
203     {
204         return this.sid;
205     }
206
207     public Object JavaDoc clone() {
208         TickRecord rec = new TickRecord();
209     
210         rec.field_1_majorTickType = field_1_majorTickType;
211         rec.field_2_minorTickType = field_2_minorTickType;
212         rec.field_3_labelPosition = field_3_labelPosition;
213         rec.field_4_background = field_4_background;
214         rec.field_5_labelColorRgb = field_5_labelColorRgb;
215         rec.field_6_zero1 = field_6_zero1;
216         rec.field_7_zero2 = field_7_zero2;
217         rec.field_8_options = field_8_options;
218         rec.field_9_tickColor = field_9_tickColor;
219         rec.field_10_zero3 = field_10_zero3;
220         return rec;
221     }
222
223
224
225
226     /**
227      * Get the major tick type field for the Tick record.
228      */

229     public byte getMajorTickType()
230     {
231         return field_1_majorTickType;
232     }
233
234     /**
235      * Set the major tick type field for the Tick record.
236      */

237     public void setMajorTickType(byte field_1_majorTickType)
238     {
239         this.field_1_majorTickType = field_1_majorTickType;
240     }
241
242     /**
243      * Get the minor tick type field for the Tick record.
244      */

245     public byte getMinorTickType()
246     {
247         return field_2_minorTickType;
248     }
249
250     /**
251      * Set the minor tick type field for the Tick record.
252      */

253     public void setMinorTickType(byte field_2_minorTickType)
254     {
255         this.field_2_minorTickType = field_2_minorTickType;
256     }
257
258     /**
259      * Get the label position field for the Tick record.
260      */

261     public byte getLabelPosition()
262     {
263         return field_3_labelPosition;
264     }
265
266     /**
267      * Set the label position field for the Tick record.
268      */

269     public void setLabelPosition(byte field_3_labelPosition)
270     {
271         this.field_3_labelPosition = field_3_labelPosition;
272     }
273
274     /**
275      * Get the background field for the Tick record.
276      */

277     public byte getBackground()
278     {
279         return field_4_background;
280     }
281
282     /**
283      * Set the background field for the Tick record.
284      */

285     public void setBackground(byte field_4_background)
286     {
287         this.field_4_background = field_4_background;
288     }
289
290     /**
291      * Get the label color rgb field for the Tick record.
292      */

293     public int getLabelColorRgb()
294     {
295         return field_5_labelColorRgb;
296     }
297
298     /**
299      * Set the label color rgb field for the Tick record.
300      */

301     public void setLabelColorRgb(int field_5_labelColorRgb)
302     {
303         this.field_5_labelColorRgb = field_5_labelColorRgb;
304     }
305
306     /**
307      * Get the zero 1 field for the Tick record.
308      */

309     public short getZero1()
310     {
311         return field_6_zero1;
312     }
313
314     /**
315      * Set the zero 1 field for the Tick record.
316      */

317     public void setZero1(short field_6_zero1)
318     {
319         this.field_6_zero1 = field_6_zero1;
320     }
321
322     /**
323      * Get the zero 2 field for the Tick record.
324      */

325     public short getZero2()
326     {
327         return field_7_zero2;
328     }
329
330     /**
331      * Set the zero 2 field for the Tick record.
332      */

333     public void setZero2(short field_7_zero2)
334     {
335         this.field_7_zero2 = field_7_zero2;
336     }
337
338     /**
339      * Get the options field for the Tick record.
340      */

341     public short getOptions()
342     {
343         return field_8_options;
344     }
345
346     /**
347      * Set the options field for the Tick record.
348      */

349     public void setOptions(short field_8_options)
350     {
351         this.field_8_options = field_8_options;
352     }
353
354     /**
355      * Get the tick color field for the Tick record.
356      */

357     public short getTickColor()
358     {
359         return field_9_tickColor;
360     }
361
362     /**
363      * Set the tick color field for the Tick record.
364      */

365     public void setTickColor(short field_9_tickColor)
366     {
367         this.field_9_tickColor = field_9_tickColor;
368     }
369
370     /**
371      * Get the zero 3 field for the Tick record.
372      */

373     public short getZero3()
374     {
375         return field_10_zero3;
376     }
377
378     /**
379      * Set the zero 3 field for the Tick record.
380      */

381     public void setZero3(short field_10_zero3)
382     {
383         this.field_10_zero3 = field_10_zero3;
384     }
385
386     /**
387      * Sets the auto text color field value.
388      * use the quote unquote automatic color for text
389      */

390     public void setAutoTextColor(boolean value)
391     {
392         field_8_options = autoTextColor.setShortBoolean(field_8_options, value);
393     }
394
395     /**
396      * use the quote unquote automatic color for text
397      * @return the auto text color field value.
398      */

399     public boolean isAutoTextColor()
400     {
401         return autoTextColor.isSet(field_8_options);
402     }
403
404     /**
405      * Sets the auto text background field value.
406      * use the quote unquote automatic color for text background
407      */

408     public void setAutoTextBackground(boolean value)
409     {
410         field_8_options = autoTextBackground.setShortBoolean(field_8_options, value);
411     }
412
413     /**
414      * use the quote unquote automatic color for text background
415      * @return the auto text background field value.
416      */

417     public boolean isAutoTextBackground()
418     {
419         return autoTextBackground.isSet(field_8_options);
420     }
421
422     /**
423      * Sets the rotation field value.
424      * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
425      */

426     public void setRotation(short value)
427     {
428         field_8_options = rotation.setShortValue(field_8_options, value);
429     }
430
431     /**
432      * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
433      * @return the rotation field value.
434      */

435     public short getRotation()
436     {
437         return rotation.getShortValue(field_8_options);
438     }
439
440     /**
441      * Sets the autorotate field value.
442      * automatically rotate the text
443      */

444     public void setAutorotate(boolean value)
445     {
446         field_8_options = autorotate.setShortBoolean(field_8_options, value);
447     }
448
449     /**
450      * automatically rotate the text
451      * @return the autorotate field value.
452      */

453     public boolean isAutorotate()
454     {
455         return autorotate.isSet(field_8_options);
456     }
457
458
459 } // END OF CLASS
460

461
462
463
464
Popular Tags