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