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 axis options record provides unit information and other various tidbits about the axis.
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 AxisOptionsRecord
71       extends Record
72   {
73       public final static short      sid                             = 0x1062;
74       private  short      field_1_minimumCategory;
75       private  short      field_2_maximumCategory;
76       private  short      field_3_majorUnitValue;
77       private  short      field_4_majorUnit;
78       private  short      field_5_minorUnitValue;
79       private  short      field_6_minorUnit;
80       private  short      field_7_baseUnit;
81       private  short      field_8_crossingPoint;
82       private  short      field_9_options;
83       private  BitField   defaultMinimum                              = new BitField(0x1);
84       private  BitField   defaultMaximum                              = new BitField(0x2);
85       private  BitField   defaultMajor                                = new BitField(0x4);
86       private  BitField   defaultMinorUnit                            = new BitField(0x8);
87       private  BitField   isDate                                      = new BitField(0x10);
88       private  BitField   defaultBase                                 = new BitField(0x20);
89       private  BitField   defaultCross                                = new BitField(0x40);
90       private  BitField   defaultDateSettings                         = new BitField(0x80);
91   
92   
93       public AxisOptionsRecord()
94       {
95   
96       }
97   
98       /**
99        * Constructs a AxisOptions record and sets its fields appropriately.
100       *
101       * @param id    id must be 0x1062 or an exception
102       *              will be throw upon validation
103       * @param size  size the size of the data area of the record
104       * @param data  data of the record (should not contain sid/len)
105       */
106  
107      public AxisOptionsRecord(short id, short size, byte [] data)
108      {
109          super(id, size, data);
110      }
111  
112      /**
113       * Constructs a AxisOptions record and sets its fields appropriately.
114       *
115       * @param id    id must be 0x1062 or an exception
116       *              will be throw upon validation
117       * @param size  size the size of the data area of the record
118       * @param data  data of the record (should not contain sid/len)
119       * @param offset of the record's data
120       */
121  
122      public AxisOptionsRecord(short id, short size, byte [] data, int offset)
123      {
124          super(id, size, data, offset);
125      }
126  
127      /**
128       * Checks the sid matches the expected side for this record
129       *
130       * @param id   the expected sid.
131       */
132      protected void validateSid(short id)
133      {
134          if (id != sid)
135          {
136              throw new RecordFormatException("Not a AxisOptions record");
137          }
138      }
139  
140      protected void fillFields(byte [] data, short size, int offset)
141      {
142          field_1_minimumCategory         = LittleEndian.getShort(data, 0x0 + offset);
143          field_2_maximumCategory         = LittleEndian.getShort(data, 0x2 + offset);
144          field_3_majorUnitValue          = LittleEndian.getShort(data, 0x4 + offset);
145          field_4_majorUnit               = LittleEndian.getShort(data, 0x6 + offset);
146          field_5_minorUnitValue          = LittleEndian.getShort(data, 0x8 + offset);
147          field_6_minorUnit               = LittleEndian.getShort(data, 0xa + offset);
148          field_7_baseUnit                = LittleEndian.getShort(data, 0xc + offset);
149          field_8_crossingPoint           = LittleEndian.getShort(data, 0xe + offset);
150          field_9_options                 = LittleEndian.getShort(data, 0x10 + offset);
151  
152      }
153  
154      public String toString()
155      {
156          StringBuffer buffer = new StringBuffer();
157  
158          buffer.append("[AxisOptions]\n");
159  
160          buffer.append("    .minimumCategory      = ")
161              .append("0x")
162              .append(HexDump.toHex((short)getMinimumCategory()))
163              .append(" (").append(getMinimumCategory()).append(" )\n");
164  
165          buffer.append("    .maximumCategory      = ")
166              .append("0x")
167              .append(HexDump.toHex((short)getMaximumCategory()))
168              .append(" (").append(getMaximumCategory()).append(" )\n");
169  
170          buffer.append("    .majorUnitValue       = ")
171              .append("0x")
172              .append(HexDump.toHex((short)getMajorUnitValue()))
173              .append(" (").append(getMajorUnitValue()).append(" )\n");
174  
175          buffer.append("    .majorUnit            = ")
176              .append("0x")
177              .append(HexDump.toHex((short)getMajorUnit()))
178              .append(" (").append(getMajorUnit()).append(" )\n");
179  
180          buffer.append("    .minorUnitValue       = ")
181              .append("0x")
182              .append(HexDump.toHex((short)getMinorUnitValue()))
183              .append(" (").append(getMinorUnitValue()).append(" )\n");
184  
185          buffer.append("    .minorUnit            = ")
186              .append("0x")
187              .append(HexDump.toHex((short)getMinorUnit()))
188              .append(" (").append(getMinorUnit()).append(" )\n");
189  
190          buffer.append("    .baseUnit             = ")
191              .append("0x")
192              .append(HexDump.toHex((short)getBaseUnit()))
193              .append(" (").append(getBaseUnit()).append(" )\n");
194  
195          buffer.append("    .crossingPoint        = ")
196              .append("0x")
197              .append(HexDump.toHex((short)getCrossingPoint()))
198              .append(" (").append(getCrossingPoint()).append(" )\n");
199  
200          buffer.append("    .options              = ")
201              .append("0x")
202              .append(HexDump.toHex((short)getOptions()))
203              .append(" (").append(getOptions()).append(" )\n");
204          buffer.append("         .defaultMinimum           = ").append(isDefaultMinimum      ()).append('\n');
205          buffer.append("         .defaultMaximum           = ").append(isDefaultMaximum      ()).append('\n');
206          buffer.append("         .defaultMajor             = ").append(isDefaultMajor        ()).append('\n');
207          buffer.append("         .defaultMinorUnit         = ").append(isDefaultMinorUnit    ()).append('\n');
208          buffer.append("         .isDate                   = ").append(isIsDate              ()).append('\n');
209          buffer.append("         .defaultBase              = ").append(isDefaultBase         ()).append('\n');
210          buffer.append("         .defaultCross             = ").append(isDefaultCross        ()).append('\n');
211          buffer.append("         .defaultDateSettings      = ").append(isDefaultDateSettings ()).append('\n');
212  
213          buffer.append("[/AxisOptions]\n");
214          return buffer.toString();
215      }
216  
217      public int serialize(int offset, byte[] data)
218      {
219          LittleEndian.putShort(data, 0 + offset, sid);
220          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
221  
222          LittleEndian.putShort(data, 4 + offset, field_1_minimumCategory);
223          LittleEndian.putShort(data, 6 + offset, field_2_maximumCategory);
224          LittleEndian.putShort(data, 8 + offset, field_3_majorUnitValue);
225          LittleEndian.putShort(data, 10 + offset, field_4_majorUnit);
226          LittleEndian.putShort(data, 12 + offset, field_5_minorUnitValue);
227          LittleEndian.putShort(data, 14 + offset, field_6_minorUnit);
228          LittleEndian.putShort(data, 16 + offset, field_7_baseUnit);
229          LittleEndian.putShort(data, 18 + offset, field_8_crossingPoint);
230          LittleEndian.putShort(data, 20 + offset, field_9_options);
231  
232          return getRecordSize();
233      }
234  
235      /**
236       * Size of record (exluding 4 byte header)
237       */
238      public int getRecordSize()
239      {
240          return 4 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
241      }
242  
243      public short getSid()
244      {
245          return this.sid;
246      }
247  
248      public Object clone() {
249        AxisOptionsRecord rec = new AxisOptionsRecord();
250        
251        rec.field_1_minimumCategory = field_1_minimumCategory;
252        rec.field_2_maximumCategory = field_2_maximumCategory;
253        rec.field_3_majorUnitValue = field_3_majorUnitValue;
254        rec.field_4_majorUnit = field_4_majorUnit;
255        rec.field_5_minorUnitValue = field_5_minorUnitValue;
256        rec.field_6_minorUnit = field_6_minorUnit;
257        rec.field_7_baseUnit = field_7_baseUnit;
258        rec.field_8_crossingPoint = field_8_crossingPoint;
259        rec.field_9_options = field_9_options;
260  
261        return rec;
262      }
263  
264  
265      /**
266       * Get the minimum category field for the AxisOptions record.
267       */
268      public short getMinimumCategory()
269      {
270          return field_1_minimumCategory;
271      }
272  
273      /**
274       * Set the minimum category field for the AxisOptions record.
275       */
276      public void setMinimumCategory(short field_1_minimumCategory)
277      {
278          this.field_1_minimumCategory = field_1_minimumCategory;
279      }
280  
281      /**
282       * Get the maximum category field for the AxisOptions record.
283       */
284      public short getMaximumCategory()
285      {
286          return field_2_maximumCategory;
287      }
288  
289      /**
290       * Set the maximum category field for the AxisOptions record.
291       */
292      public void setMaximumCategory(short field_2_maximumCategory)
293      {
294          this.field_2_maximumCategory = field_2_maximumCategory;
295      }
296  
297      /**
298       * Get the major unit value field for the AxisOptions record.
299       */
300      public short getMajorUnitValue()
301      {
302          return field_3_majorUnitValue;
303      }
304  
305      /**
306       * Set the major unit value field for the AxisOptions record.
307       */
308      public void setMajorUnitValue(short field_3_majorUnitValue)
309      {
310          this.field_3_majorUnitValue = field_3_majorUnitValue;
311      }
312  
313      /**
314       * Get the major unit field for the AxisOptions record.
315       */
316      public short getMajorUnit()
317      {
318          return field_4_majorUnit;
319      }
320  
321      /**
322       * Set the major unit field for the AxisOptions record.
323       */
324      public void setMajorUnit(short field_4_majorUnit)
325      {
326          this.field_4_majorUnit = field_4_majorUnit;
327      }
328  
329      /**
330       * Get the minor unit value field for the AxisOptions record.
331       */
332      public short getMinorUnitValue()
333      {
334          return field_5_minorUnitValue;
335      }
336  
337      /**
338       * Set the minor unit value field for the AxisOptions record.
339       */
340      public void setMinorUnitValue(short field_5_minorUnitValue)
341      {
342          this.field_5_minorUnitValue = field_5_minorUnitValue;
343      }
344  
345      /**
346       * Get the minor unit field for the AxisOptions record.
347       */
348      public short getMinorUnit()
349      {
350          return field_6_minorUnit;
351      }
352  
353      /**
354       * Set the minor unit field for the AxisOptions record.
355       */
356      public void setMinorUnit(short field_6_minorUnit)
357      {
358          this.field_6_minorUnit = field_6_minorUnit;
359      }
360  
361      /**
362       * Get the base unit field for the AxisOptions record.
363       */
364      public short getBaseUnit()
365      {
366          return field_7_baseUnit;
367      }
368  
369      /**
370       * Set the base unit field for the AxisOptions record.
371       */
372      public void setBaseUnit(short field_7_baseUnit)
373      {
374          this.field_7_baseUnit = field_7_baseUnit;
375      }
376  
377      /**
378       * Get the crossing point field for the AxisOptions record.
379       */
380      public short getCrossingPoint()
381      {
382          return field_8_crossingPoint;
383      }
384  
385      /**
386       * Set the crossing point field for the AxisOptions record.
387       */
388      public void setCrossingPoint(short field_8_crossingPoint)
389      {
390          this.field_8_crossingPoint = field_8_crossingPoint;
391      }
392  
393      /**
394       * Get the options field for the AxisOptions record.
395       */
396      public short getOptions()
397      {
398          return field_9_options;
399      }
400  
401      /**
402       * Set the options field for the AxisOptions record.
403       */
404      public void setOptions(short field_9_options)
405      {
406          this.field_9_options = field_9_options;
407      }
408  
409      /**
410       * Sets the default minimum field value.
411       * use the default minimum category
412       */
413      public void setDefaultMinimum(boolean value)
414      {
415          field_9_options = defaultMinimum.setShortBoolean(field_9_options, value);
416      }
417  
418      /**
419       * use the default minimum category
420       * @return  the default minimum field value.
421       */
422      public boolean isDefaultMinimum()
423      {
424          return defaultMinimum.isSet(field_9_options);
425      }
426  
427      /**
428       * Sets the default maximum field value.
429       * use the default maximum category
430       */
431      public void setDefaultMaximum(boolean value)
432      {
433          field_9_options = defaultMaximum.setShortBoolean(field_9_options, value);
434      }
435  
436      /**
437       * use the default maximum category
438       * @return  the default maximum field value.
439       */
440      public boolean isDefaultMaximum()
441      {
442          return defaultMaximum.isSet(field_9_options);
443      }
444  
445      /**
446       * Sets the default major field value.
447       * use the default major unit
448       */
449      public void setDefaultMajor(boolean value)
450      {
451          field_9_options = defaultMajor.setShortBoolean(field_9_options, value);
452      }
453  
454      /**
455       * use the default major unit
456       * @return  the default major field value.
457       */
458      public boolean isDefaultMajor()
459      {
460          return defaultMajor.isSet(field_9_options);
461      }
462  
463      /**
464       * Sets the default minor unit field value.
465       * use the default minor unit
466       */
467      public void setDefaultMinorUnit(boolean value)
468      {
469          field_9_options = defaultMinorUnit.setShortBoolean(field_9_options, value);
470      }
471  
472      /**
473       * use the default minor unit
474       * @return  the default minor unit field value.
475       */
476      public boolean isDefaultMinorUnit()
477      {
478          return defaultMinorUnit.isSet(field_9_options);
479      }
480  
481      /**
482       * Sets the isDate field value.
483       * this is a date axis
484       */
485      public void setIsDate(boolean value)
486      {
487          field_9_options = isDate.setShortBoolean(field_9_options, value);
488      }
489  
490      /**
491       * this is a date axis
492       * @return  the isDate field value.
493       */
494      public boolean isIsDate()
495      {
496          return isDate.isSet(field_9_options);
497      }
498  
499      /**
500       * Sets the default base field value.
501       * use the default base unit
502       */
503      public void setDefaultBase(boolean value)
504      {
505          field_9_options = defaultBase.setShortBoolean(field_9_options, value);
506      }
507  
508      /**
509       * use the default base unit
510       * @return  the default base field value.
511       */
512      public boolean isDefaultBase()
513      {
514          return defaultBase.isSet(field_9_options);
515      }
516  
517      /**
518       * Sets the default cross field value.
519       * use the default crossing point
520       */
521      public void setDefaultCross(boolean value)
522      {
523          field_9_options = defaultCross.setShortBoolean(field_9_options, value);
524      }
525  
526      /**
527       * use the default crossing point
528       * @return  the default cross field value.
529       */
530      public boolean isDefaultCross()
531      {
532          return defaultCross.isSet(field_9_options);
533      }
534  
535      /**
536       * Sets the default date settings field value.
537       * use default date setttings for this axis
538       */
539      public void setDefaultDateSettings(boolean value)
540      {
541          field_9_options = defaultDateSettings.setShortBoolean(field_9_options, value);
542      }
543  
544      /**
545       * use default date setttings for this axis
546       * @return  the default date settings field value.
547       */
548      public boolean isDefaultDateSettings()
549      {
550          return defaultDateSettings.isSet(field_9_options);
551      }
552  
553  
554  }  // END OF CLASS
555  
556  
557  
558  
559