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  
249      /**
250       * Get the minimum category field for the AxisOptions record.
251       */
252      public short getMinimumCategory()
253      {
254          return field_1_minimumCategory;
255      }
256  
257      /**
258       * Set the minimum category field for the AxisOptions record.
259       */
260      public void setMinimumCategory(short field_1_minimumCategory)
261      {
262          this.field_1_minimumCategory = field_1_minimumCategory;
263      }
264  
265      /**
266       * Get the maximum category field for the AxisOptions record.
267       */
268      public short getMaximumCategory()
269      {
270          return field_2_maximumCategory;
271      }
272  
273      /**
274       * Set the maximum category field for the AxisOptions record.
275       */
276      public void setMaximumCategory(short field_2_maximumCategory)
277      {
278          this.field_2_maximumCategory = field_2_maximumCategory;
279      }
280  
281      /**
282       * Get the major unit value field for the AxisOptions record.
283       */
284      public short getMajorUnitValue()
285      {
286          return field_3_majorUnitValue;
287      }
288  
289      /**
290       * Set the major unit value field for the AxisOptions record.
291       */
292      public void setMajorUnitValue(short field_3_majorUnitValue)
293      {
294          this.field_3_majorUnitValue = field_3_majorUnitValue;
295      }
296  
297      /**
298       * Get the major unit field for the AxisOptions record.
299       */
300      public short getMajorUnit()
301      {
302          return field_4_majorUnit;
303      }
304  
305      /**
306       * Set the major unit field for the AxisOptions record.
307       */
308      public void setMajorUnit(short field_4_majorUnit)
309      {
310          this.field_4_majorUnit = field_4_majorUnit;
311      }
312  
313      /**
314       * Get the minor unit value field for the AxisOptions record.
315       */
316      public short getMinorUnitValue()
317      {
318          return field_5_minorUnitValue;
319      }
320  
321      /**
322       * Set the minor unit value field for the AxisOptions record.
323       */
324      public void setMinorUnitValue(short field_5_minorUnitValue)
325      {
326          this.field_5_minorUnitValue = field_5_minorUnitValue;
327      }
328  
329      /**
330       * Get the minor unit field for the AxisOptions record.
331       */
332      public short getMinorUnit()
333      {
334          return field_6_minorUnit;
335      }
336  
337      /**
338       * Set the minor unit field for the AxisOptions record.
339       */
340      public void setMinorUnit(short field_6_minorUnit)
341      {
342          this.field_6_minorUnit = field_6_minorUnit;
343      }
344  
345      /**
346       * Get the base unit field for the AxisOptions record.
347       */
348      public short getBaseUnit()
349      {
350          return field_7_baseUnit;
351      }
352  
353      /**
354       * Set the base unit field for the AxisOptions record.
355       */
356      public void setBaseUnit(short field_7_baseUnit)
357      {
358          this.field_7_baseUnit = field_7_baseUnit;
359      }
360  
361      /**
362       * Get the crossing point field for the AxisOptions record.
363       */
364      public short getCrossingPoint()
365      {
366          return field_8_crossingPoint;
367      }
368  
369      /**
370       * Set the crossing point field for the AxisOptions record.
371       */
372      public void setCrossingPoint(short field_8_crossingPoint)
373      {
374          this.field_8_crossingPoint = field_8_crossingPoint;
375      }
376  
377      /**
378       * Get the options field for the AxisOptions record.
379       */
380      public short getOptions()
381      {
382          return field_9_options;
383      }
384  
385      /**
386       * Set the options field for the AxisOptions record.
387       */
388      public void setOptions(short field_9_options)
389      {
390          this.field_9_options = field_9_options;
391      }
392  
393      /**
394       * Sets the default minimum field value.
395       * use the default minimum category
396       */
397      public void setDefaultMinimum(boolean value)
398      {
399          field_9_options = defaultMinimum.setShortBoolean(field_9_options, value);
400      }
401  
402      /**
403       * use the default minimum category
404       * @return  the default minimum field value.
405       */
406      public boolean isDefaultMinimum()
407      {
408          return defaultMinimum.isSet(field_9_options);
409      }
410  
411      /**
412       * Sets the default maximum field value.
413       * use the default maximum category
414       */
415      public void setDefaultMaximum(boolean value)
416      {
417          field_9_options = defaultMaximum.setShortBoolean(field_9_options, value);
418      }
419  
420      /**
421       * use the default maximum category
422       * @return  the default maximum field value.
423       */
424      public boolean isDefaultMaximum()
425      {
426          return defaultMaximum.isSet(field_9_options);
427      }
428  
429      /**
430       * Sets the default major field value.
431       * use the default major unit
432       */
433      public void setDefaultMajor(boolean value)
434      {
435          field_9_options = defaultMajor.setShortBoolean(field_9_options, value);
436      }
437  
438      /**
439       * use the default major unit
440       * @return  the default major field value.
441       */
442      public boolean isDefaultMajor()
443      {
444          return defaultMajor.isSet(field_9_options);
445      }
446  
447      /**
448       * Sets the default minor unit field value.
449       * use the default minor unit
450       */
451      public void setDefaultMinorUnit(boolean value)
452      {
453          field_9_options = defaultMinorUnit.setShortBoolean(field_9_options, value);
454      }
455  
456      /**
457       * use the default minor unit
458       * @return  the default minor unit field value.
459       */
460      public boolean isDefaultMinorUnit()
461      {
462          return defaultMinorUnit.isSet(field_9_options);
463      }
464  
465      /**
466       * Sets the isDate field value.
467       * this is a date axis
468       */
469      public void setIsDate(boolean value)
470      {
471          field_9_options = isDate.setShortBoolean(field_9_options, value);
472      }
473  
474      /**
475       * this is a date axis
476       * @return  the isDate field value.
477       */
478      public boolean isIsDate()
479      {
480          return isDate.isSet(field_9_options);
481      }
482  
483      /**
484       * Sets the default base field value.
485       * use the default base unit
486       */
487      public void setDefaultBase(boolean value)
488      {
489          field_9_options = defaultBase.setShortBoolean(field_9_options, value);
490      }
491  
492      /**
493       * use the default base unit
494       * @return  the default base field value.
495       */
496      public boolean isDefaultBase()
497      {
498          return defaultBase.isSet(field_9_options);
499      }
500  
501      /**
502       * Sets the default cross field value.
503       * use the default crossing point
504       */
505      public void setDefaultCross(boolean value)
506      {
507          field_9_options = defaultCross.setShortBoolean(field_9_options, value);
508      }
509  
510      /**
511       * use the default crossing point
512       * @return  the default cross field value.
513       */
514      public boolean isDefaultCross()
515      {
516          return defaultCross.isSet(field_9_options);
517      }
518  
519      /**
520       * Sets the default date settings field value.
521       * use default date setttings for this axis
522       */
523      public void setDefaultDateSettings(boolean value)
524      {
525          field_9_options = defaultDateSettings.setShortBoolean(field_9_options, value);
526      }
527  
528      /**
529       * use default date setttings for this axis
530       * @return  the default date settings field value.
531       */
532      public boolean isDefaultDateSettings()
533      {
534          return defaultDateSettings.isSet(field_9_options);
535      }
536  
537  
538  }  // END OF CLASS
539  
540  
541  
542  
543