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 value range record defines the range of the value 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 Glen Stampoultzis (glens at apache.org)
69    */
70   public class ValueRangeRecord
71       extends Record
72   {
73       public final static short      sid                             = 0x101f;
74       private  double     field_1_minimumAxisValue;
75       private  double     field_2_maximumAxisValue;
76       private  double     field_3_majorIncrement;
77       private  double     field_4_minorIncrement;
78       private  double     field_5_categoryAxisCross;
79       private  short      field_6_options;
80       private  BitField   automaticMinimum                            = new BitField(0x1);
81       private  BitField   automaticMaximum                            = new BitField(0x2);
82       private  BitField   automaticMajor                              = new BitField(0x4);
83       private  BitField   automaticMinor                              = new BitField(0x8);
84       private  BitField   automaticCategoryCrossing                   = new BitField(0x10);
85       private  BitField   logarithmicScale                            = new BitField(0x20);
86       private  BitField   valuesInReverse                             = new BitField(0x40);
87       private  BitField   crossCategoryAxisAtMaximum                  = new BitField(0x80);
88       private  BitField   reserved                                    = new BitField(0x100);
89   
90   
91       public ValueRangeRecord()
92       {
93   
94       }
95   
96       /**
97        * Constructs a ValueRange record and sets its fields appropriately.
98        *
99        * @param id    id must be 0x101f or an exception
100       *              will be throw upon validation
101       * @param size  size the size of the data area of the record
102       * @param data  data of the record (should not contain sid/len)
103       */
104  
105      public ValueRangeRecord(short id, short size, byte [] data)
106      {
107          super(id, size, data);
108      }
109  
110      /**
111       * Constructs a ValueRange record and sets its fields appropriately.
112       *
113       * @param id    id must be 0x101f 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 ValueRangeRecord(short id, short size, byte [] data, int offset)
121      {
122          super(id, size, data, offset);
123      }
124  
125      /**
126       * Checks the sid matches the expected side for this record
127       *
128       * @param id   the expected sid.
129       */
130      protected void validateSid(short id)
131      {
132          if (id != sid)
133          {
134              throw new RecordFormatException("Not a ValueRange record");
135          }
136      }
137  
138      protected void fillFields(byte [] data, short size, int offset)
139      {
140          field_1_minimumAxisValue        = LittleEndian.getDouble(data, 0x0 + offset);
141          field_2_maximumAxisValue        = LittleEndian.getDouble(data, 0x8 + offset);
142          field_3_majorIncrement          = LittleEndian.getDouble(data, 0x10 + offset);
143          field_4_minorIncrement          = LittleEndian.getDouble(data, 0x18 + offset);
144          field_5_categoryAxisCross       = LittleEndian.getDouble(data, 0x20 + offset);
145          field_6_options                 = LittleEndian.getShort(data, 0x28 + offset);
146  
147      }
148  
149      public String toString()
150      {
151          StringBuffer buffer = new StringBuffer();
152  
153          buffer.append("[ValueRange]\n");
154  
155          buffer.append("    .minimumAxisValue     = ")
156              .append(" (").append(getMinimumAxisValue()).append(" )\n");
157  
158          buffer.append("    .maximumAxisValue     = ")
159              .append(" (").append(getMaximumAxisValue()).append(" )\n");
160  
161          buffer.append("    .majorIncrement       = ")
162              .append(" (").append(getMajorIncrement()).append(" )\n");
163  
164          buffer.append("    .minorIncrement       = ")
165              .append(" (").append(getMinorIncrement()).append(" )\n");
166  
167          buffer.append("    .categoryAxisCross    = ")
168              .append(" (").append(getCategoryAxisCross()).append(" )\n");
169  
170          buffer.append("    .options              = ")
171              .append("0x")
172              .append(HexDump.toHex((short)getOptions()))
173              .append(" (").append(getOptions()).append(" )\n");
174          buffer.append("         .automaticMinimum         = ").append(isAutomaticMinimum    ()).append('\n');
175          buffer.append("         .automaticMaximum         = ").append(isAutomaticMaximum    ()).append('\n');
176          buffer.append("         .automaticMajor           = ").append(isAutomaticMajor      ()).append('\n');
177          buffer.append("         .automaticMinor           = ").append(isAutomaticMinor      ()).append('\n');
178          buffer.append("         .automaticCategoryCrossing     = ").append(isAutomaticCategoryCrossing()).append('\n');
179          buffer.append("         .logarithmicScale         = ").append(isLogarithmicScale    ()).append('\n');
180          buffer.append("         .valuesInReverse          = ").append(isValuesInReverse     ()).append('\n');
181          buffer.append("         .crossCategoryAxisAtMaximum     = ").append(isCrossCategoryAxisAtMaximum()).append('\n');
182          buffer.append("         .reserved                 = ").append(isReserved            ()).append('\n');
183  
184          buffer.append("[/ValueRange]\n");
185          return buffer.toString();
186      }
187  
188      public int serialize(int offset, byte[] data)
189      {
190          LittleEndian.putShort(data, 0 + offset, sid);
191          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
192  
193          LittleEndian.putDouble(data, 4 + offset, field_1_minimumAxisValue);
194          LittleEndian.putDouble(data, 12 + offset, field_2_maximumAxisValue);
195          LittleEndian.putDouble(data, 20 + offset, field_3_majorIncrement);
196          LittleEndian.putDouble(data, 28 + offset, field_4_minorIncrement);
197          LittleEndian.putDouble(data, 36 + offset, field_5_categoryAxisCross);
198          LittleEndian.putShort(data, 44 + offset, field_6_options);
199  
200          return getRecordSize();
201      }
202  
203      /**
204       * Size of record (exluding 4 byte header)
205       */
206      public int getRecordSize()
207      {
208          return 4 + 8 + 8 + 8 + 8 + 8 + 2;
209      }
210  
211      public short getSid()
212      {
213          return this.sid;
214      }
215  
216  
217      /**
218       * Get the minimum axis value field for the ValueRange record.
219       */
220      public double getMinimumAxisValue()
221      {
222          return field_1_minimumAxisValue;
223      }
224  
225      /**
226       * Set the minimum axis value field for the ValueRange record.
227       */
228      public void setMinimumAxisValue(double field_1_minimumAxisValue)
229      {
230          this.field_1_minimumAxisValue = field_1_minimumAxisValue;
231      }
232  
233      /**
234       * Get the maximum axis value field for the ValueRange record.
235       */
236      public double getMaximumAxisValue()
237      {
238          return field_2_maximumAxisValue;
239      }
240  
241      /**
242       * Set the maximum axis value field for the ValueRange record.
243       */
244      public void setMaximumAxisValue(double field_2_maximumAxisValue)
245      {
246          this.field_2_maximumAxisValue = field_2_maximumAxisValue;
247      }
248  
249      /**
250       * Get the major increment field for the ValueRange record.
251       */
252      public double getMajorIncrement()
253      {
254          return field_3_majorIncrement;
255      }
256  
257      /**
258       * Set the major increment field for the ValueRange record.
259       */
260      public void setMajorIncrement(double field_3_majorIncrement)
261      {
262          this.field_3_majorIncrement = field_3_majorIncrement;
263      }
264  
265      /**
266       * Get the minor increment field for the ValueRange record.
267       */
268      public double getMinorIncrement()
269      {
270          return field_4_minorIncrement;
271      }
272  
273      /**
274       * Set the minor increment field for the ValueRange record.
275       */
276      public void setMinorIncrement(double field_4_minorIncrement)
277      {
278          this.field_4_minorIncrement = field_4_minorIncrement;
279      }
280  
281      /**
282       * Get the category axis cross field for the ValueRange record.
283       */
284      public double getCategoryAxisCross()
285      {
286          return field_5_categoryAxisCross;
287      }
288  
289      /**
290       * Set the category axis cross field for the ValueRange record.
291       */
292      public void setCategoryAxisCross(double field_5_categoryAxisCross)
293      {
294          this.field_5_categoryAxisCross = field_5_categoryAxisCross;
295      }
296  
297      /**
298       * Get the options field for the ValueRange record.
299       */
300      public short getOptions()
301      {
302          return field_6_options;
303      }
304  
305      /**
306       * Set the options field for the ValueRange record.
307       */
308      public void setOptions(short field_6_options)
309      {
310          this.field_6_options = field_6_options;
311      }
312  
313      /**
314       * Sets the automatic minimum field value.
315       * automatic minimum value selected
316       */
317      public void setAutomaticMinimum(boolean value)
318      {
319          field_6_options = automaticMinimum.setShortBoolean(field_6_options, value);
320      }
321  
322      /**
323       * automatic minimum value selected
324       * @return  the automatic minimum field value.
325       */
326      public boolean isAutomaticMinimum()
327      {
328          return automaticMinimum.isSet(field_6_options);
329      }
330  
331      /**
332       * Sets the automatic maximum field value.
333       * automatic maximum value selected
334       */
335      public void setAutomaticMaximum(boolean value)
336      {
337          field_6_options = automaticMaximum.setShortBoolean(field_6_options, value);
338      }
339  
340      /**
341       * automatic maximum value selected
342       * @return  the automatic maximum field value.
343       */
344      public boolean isAutomaticMaximum()
345      {
346          return automaticMaximum.isSet(field_6_options);
347      }
348  
349      /**
350       * Sets the automatic major field value.
351       * automatic major unit selected
352       */
353      public void setAutomaticMajor(boolean value)
354      {
355          field_6_options = automaticMajor.setShortBoolean(field_6_options, value);
356      }
357  
358      /**
359       * automatic major unit selected
360       * @return  the automatic major field value.
361       */
362      public boolean isAutomaticMajor()
363      {
364          return automaticMajor.isSet(field_6_options);
365      }
366  
367      /**
368       * Sets the automatic minor field value.
369       * automatic minor unit selected
370       */
371      public void setAutomaticMinor(boolean value)
372      {
373          field_6_options = automaticMinor.setShortBoolean(field_6_options, value);
374      }
375  
376      /**
377       * automatic minor unit selected
378       * @return  the automatic minor field value.
379       */
380      public boolean isAutomaticMinor()
381      {
382          return automaticMinor.isSet(field_6_options);
383      }
384  
385      /**
386       * Sets the automatic category crossing field value.
387       * category crossing point is automatically selected
388       */
389      public void setAutomaticCategoryCrossing(boolean value)
390      {
391          field_6_options = automaticCategoryCrossing.setShortBoolean(field_6_options, value);
392      }
393  
394      /**
395       * category crossing point is automatically selected
396       * @return  the automatic category crossing field value.
397       */
398      public boolean isAutomaticCategoryCrossing()
399      {
400          return automaticCategoryCrossing.isSet(field_6_options);
401      }
402  
403      /**
404       * Sets the logarithmic scale field value.
405       * use logarithmic scale
406       */
407      public void setLogarithmicScale(boolean value)
408      {
409          field_6_options = logarithmicScale.setShortBoolean(field_6_options, value);
410      }
411  
412      /**
413       * use logarithmic scale
414       * @return  the logarithmic scale field value.
415       */
416      public boolean isLogarithmicScale()
417      {
418          return logarithmicScale.isSet(field_6_options);
419      }
420  
421      /**
422       * Sets the values in reverse field value.
423       * values are reverses in graph
424       */
425      public void setValuesInReverse(boolean value)
426      {
427          field_6_options = valuesInReverse.setShortBoolean(field_6_options, value);
428      }
429  
430      /**
431       * values are reverses in graph
432       * @return  the values in reverse field value.
433       */
434      public boolean isValuesInReverse()
435      {
436          return valuesInReverse.isSet(field_6_options);
437      }
438  
439      /**
440       * Sets the cross category axis at maximum field value.
441       * category axis to cross at maximum value
442       */
443      public void setCrossCategoryAxisAtMaximum(boolean value)
444      {
445          field_6_options = crossCategoryAxisAtMaximum.setShortBoolean(field_6_options, value);
446      }
447  
448      /**
449       * category axis to cross at maximum value
450       * @return  the cross category axis at maximum field value.
451       */
452      public boolean isCrossCategoryAxisAtMaximum()
453      {
454          return crossCategoryAxisAtMaximum.isSet(field_6_options);
455      }
456  
457      /**
458       * Sets the reserved field value.
459       * reserved, must equal 1 (excel dev. guide says otherwise)
460       */
461      public void setReserved(boolean value)
462      {
463          field_6_options = reserved.setShortBoolean(field_6_options, value);
464      }
465  
466      /**
467       * reserved, must equal 1 (excel dev. guide says otherwise)
468       * @return  the reserved field value.
469       */
470      public boolean isReserved()
471      {
472          return reserved.isSet(field_6_options);
473      }
474  
475  
476  }  // END OF CLASS
477  
478  
479  
480  
481