1    
2    /* ====================================================================
3     * The Apache Software License, Version 1.1
4     *
5     * Copyright (c) 2002 The Apache Software Foundation.  All rights
6     * reserved.
7     *
8     * Redistribution and use in source and binary forms, with or without
9     * modification, are permitted provided that the following conditions
10    * are met:
11    *
12    * 1. Redistributions of source code must retain the above copyright
13    *    notice, this list of conditions and the following disclaimer.
14    *
15    * 2. Redistributions in binary form must reproduce the above copyright
16    *    notice, this list of conditions and the following disclaimer in
17    *    the documentation and/or other materials provided with the
18    *    distribution.
19    *
20    * 3. The end-user documentation included with the redistribution,
21    *    if any, must include the following acknowledgment:
22    *       "This product includes software developed by the
23    *        Apache Software Foundation (http://www.apache.org/)."
24    *    Alternately, this acknowledgment may appear in the software itself,
25    *    if and wherever such third-party acknowledgments normally appear.
26    *
27    * 4. The names "Apache" and "Apache Software Foundation" and
28    *    "Apache POI" must not be used to endorse or promote products
29    *    derived from this software without prior written permission. For
30    *    written permission, please contact apache@apache.org.
31    *
32    * 5. Products derived from this software may not be called "Apache",
33    *    "Apache POI", nor may "Apache" appear in their name, without
34    *    prior written permission of the Apache Software Foundation.
35    *
36    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47    * SUCH DAMAGE.
48    * ====================================================================
49    *
50    * This software consists of voluntary contributions made by many
51    * individuals on behalf of the Apache Software Foundation.  For more
52    * information on the Apache Software Foundation, please see
53    * <http://www.apache.org/>.
54    */
55   
56   
57   package org.apache.poi.hssf.record;
58   
59   
60   
61   import org.apache.poi.util.*;
62   
63   /**
64    * The Tick record defines how tick marks and label positioning/formatting
65    * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
66    *       remove the record in src/records/definitions.
67   
68    * @author Andrew C. Oliver(acoliver at apache.org)
69    */
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       /**
96        * Constructs a Tick record and sets its fields appropriately.
97        *
98        * @param id    id must be 0x101e or an exception
99        *              will be throw upon validation
100       * @param size  size the size of the data area of the record
101       * @param data  data of the record (should not contain sid/len)
102       */
103  
104      public TickRecord(short id, short size, byte [] data)
105      {
106          super(id, size, data);
107      
108      }
109  
110      /**
111       * Constructs a Tick record and sets its fields appropriately.
112       *
113       * @param id    id must be 0x101e or an exception
114       *              will be throw upon validation
115       * @param size  size the size of the data area of the record
116       * @param data  data of the record (should not contain sid/len)
117       * @param offset of the record's data
118       */
119  
120      public TickRecord(short id, short size, byte [] data, int offset)
121      {
122          super(id, size, data, offset);
123      
124      }
125  
126      /**
127       * Checks the sid matches the expected side for this record
128       *
129       * @param id   the expected sid.
130       */
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      /**
232       * Size of record (exluding 4 byte header)
233       */
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      /**
264       * Get the major tick type field for the Tick record.
265       */
266      public byte getMajorTickType()
267      {
268          return field_1_majorTickType;
269      }
270  
271      /**
272       * Set the major tick type field for the Tick record.
273       */
274      public void setMajorTickType(byte field_1_majorTickType)
275      {
276          this.field_1_majorTickType = field_1_majorTickType;
277      }
278  
279      /**
280       * Get the minor tick type field for the Tick record.
281       */
282      public byte getMinorTickType()
283      {
284          return field_2_minorTickType;
285      }
286  
287      /**
288       * Set the minor tick type field for the Tick record.
289       */
290      public void setMinorTickType(byte field_2_minorTickType)
291      {
292          this.field_2_minorTickType = field_2_minorTickType;
293      }
294  
295      /**
296       * Get the label position field for the Tick record.
297       */
298      public byte getLabelPosition()
299      {
300          return field_3_labelPosition;
301      }
302  
303      /**
304       * Set the label position field for the Tick record.
305       */
306      public void setLabelPosition(byte field_3_labelPosition)
307      {
308          this.field_3_labelPosition = field_3_labelPosition;
309      }
310  
311      /**
312       * Get the background field for the Tick record.
313       */
314      public byte getBackground()
315      {
316          return field_4_background;
317      }
318  
319      /**
320       * Set the background field for the Tick record.
321       */
322      public void setBackground(byte field_4_background)
323      {
324          this.field_4_background = field_4_background;
325      }
326  
327      /**
328       * Get the label color rgb field for the Tick record.
329       */
330      public int getLabelColorRgb()
331      {
332          return field_5_labelColorRgb;
333      }
334  
335      /**
336       * Set the label color rgb field for the Tick record.
337       */
338      public void setLabelColorRgb(int field_5_labelColorRgb)
339      {
340          this.field_5_labelColorRgb = field_5_labelColorRgb;
341      }
342  
343      /**
344       * Get the zero 1 field for the Tick record.
345       */
346      public short getZero1()
347      {
348          return field_6_zero1;
349      }
350  
351      /**
352       * Set the zero 1 field for the Tick record.
353       */
354      public void setZero1(short field_6_zero1)
355      {
356          this.field_6_zero1 = field_6_zero1;
357      }
358  
359      /**
360       * Get the zero 2 field for the Tick record.
361       */
362      public short getZero2()
363      {
364          return field_7_zero2;
365      }
366  
367      /**
368       * Set the zero 2 field for the Tick record.
369       */
370      public void setZero2(short field_7_zero2)
371      {
372          this.field_7_zero2 = field_7_zero2;
373      }
374  
375      /**
376       * Get the options field for the Tick record.
377       */
378      public short getOptions()
379      {
380          return field_8_options;
381      }
382  
383      /**
384       * Set the options field for the Tick record.
385       */
386      public void setOptions(short field_8_options)
387      {
388          this.field_8_options = field_8_options;
389      }
390  
391      /**
392       * Get the tick color field for the Tick record.
393       */
394      public short getTickColor()
395      {
396          return field_9_tickColor;
397      }
398  
399      /**
400       * Set the tick color field for the Tick record.
401       */
402      public void setTickColor(short field_9_tickColor)
403      {
404          this.field_9_tickColor = field_9_tickColor;
405      }
406  
407      /**
408       * Get the zero 3 field for the Tick record.
409       */
410      public short getZero3()
411      {
412          return field_10_zero3;
413      }
414  
415      /**
416       * Set the zero 3 field for the Tick record.
417       */
418      public void setZero3(short field_10_zero3)
419      {
420          this.field_10_zero3 = field_10_zero3;
421      }
422  
423      /**
424       * Sets the auto text color field value.
425       * use the quote unquote automatic color for text
426       */
427      public void setAutoTextColor(boolean value)
428      {
429          field_8_options = autoTextColor.setShortBoolean(field_8_options, value);
430      }
431  
432      /**
433       * use the quote unquote automatic color for text
434       * @return  the auto text color field value.
435       */
436      public boolean isAutoTextColor()
437      {
438          return autoTextColor.isSet(field_8_options);
439      }
440  
441      /**
442       * Sets the auto text background field value.
443       * use the quote unquote automatic color for text background
444       */
445      public void setAutoTextBackground(boolean value)
446      {
447          field_8_options = autoTextBackground.setShortBoolean(field_8_options, value);
448      }
449  
450      /**
451       * use the quote unquote automatic color for text background
452       * @return  the auto text background field value.
453       */
454      public boolean isAutoTextBackground()
455      {
456          return autoTextBackground.isSet(field_8_options);
457      }
458  
459      /**
460       * Sets the rotation field value.
461       * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
462       */
463      public void setRotation(short value)
464      {
465          field_8_options = rotation.setShortValue(field_8_options, value);
466      }
467  
468      /**
469       * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
470       * @return  the rotation field value.
471       */
472      public short getRotation()
473      {
474          return rotation.getShortValue(field_8_options);
475      }
476  
477      /**
478       * Sets the autorotate field value.
479       * automatically rotate the text
480       */
481      public void setAutorotate(boolean value)
482      {
483          field_8_options = autorotate.setShortBoolean(field_8_options, value);
484      }
485  
486      /**
487       * automatically rotate the text
488       * @return  the autorotate field value.
489       */
490      public boolean isAutorotate()
491      {
492          return autorotate.isSet(field_8_options);
493      }
494  
495  
496  }  // END OF CLASS
497  
498  
499  
500  
501