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      /**
112       * Constructs a ValueRange record and sets its fields appropriately.
113       *
114       * @param id    id must be 0x101f or an exception
115       *              will be throw upon validation
116       * @param size  size the size of the data area of the record
117       * @param data  data of the record (should not contain sid/len)
118       * @param offset of the record's data
119       */
120  
121      public ValueRangeRecord(short id, short size, byte [] data, int offset)
122      {
123          super(id, size, data, offset);
124      
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 ValueRange record");
137          }
138      }
139  
140      protected void fillFields(byte [] data, short size, int offset)
141      {
142  
143          int pos = 0;
144          field_1_minimumAxisValue       = LittleEndian.getDouble(data, pos + 0x0 + offset);
145          field_2_maximumAxisValue       = LittleEndian.getDouble(data, pos + 0x8 + offset);
146          field_3_majorIncrement         = LittleEndian.getDouble(data, pos + 0x10 + offset);
147          field_4_minorIncrement         = LittleEndian.getDouble(data, pos + 0x18 + offset);
148          field_5_categoryAxisCross      = LittleEndian.getDouble(data, pos + 0x20 + offset);
149          field_6_options                = LittleEndian.getShort(data, pos + 0x28 + offset);
150  
151      }
152  
153      public String toString()
154      {
155          StringBuffer buffer = new StringBuffer();
156  
157          buffer.append("[VALUERANGE]\n");
158          buffer.append("    .minimumAxisValue     = ")
159              .append(" (").append( getMinimumAxisValue() ).append(" )");
160          buffer.append(System.getProperty("line.separator")); 
161          buffer.append("    .maximumAxisValue     = ")
162              .append(" (").append( getMaximumAxisValue() ).append(" )");
163          buffer.append(System.getProperty("line.separator")); 
164          buffer.append("    .majorIncrement       = ")
165              .append(" (").append( getMajorIncrement() ).append(" )");
166          buffer.append(System.getProperty("line.separator")); 
167          buffer.append("    .minorIncrement       = ")
168              .append(" (").append( getMinorIncrement() ).append(" )");
169          buffer.append(System.getProperty("line.separator")); 
170          buffer.append("    .categoryAxisCross    = ")
171              .append(" (").append( getCategoryAxisCross() ).append(" )");
172          buffer.append(System.getProperty("line.separator")); 
173          buffer.append("    .options              = ")
174              .append("0x").append(HexDump.toHex(  getOptions ()))
175              .append(" (").append( getOptions() ).append(" )");
176          buffer.append(System.getProperty("line.separator")); 
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          int pos = 0;
194  
195          LittleEndian.putShort(data, 0 + offset, sid);
196          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
197  
198          LittleEndian.putDouble(data, 4 + offset + pos, field_1_minimumAxisValue);
199          LittleEndian.putDouble(data, 12 + offset + pos, field_2_maximumAxisValue);
200          LittleEndian.putDouble(data, 20 + offset + pos, field_3_majorIncrement);
201          LittleEndian.putDouble(data, 28 + offset + pos, field_4_minorIncrement);
202          LittleEndian.putDouble(data, 36 + offset + pos, field_5_categoryAxisCross);
203          LittleEndian.putShort(data, 44 + offset + pos, field_6_options);
204  
205          return getRecordSize();
206      }
207  
208      /**
209       * Size of record (exluding 4 byte header)
210       */
211      public int getRecordSize()
212      {
213          return 4  + 8 + 8 + 8 + 8 + 8 + 2;
214      }
215  
216      public short getSid()
217      {
218          return this.sid;
219      }
220  
221      public Object clone() {
222          ValueRangeRecord rec = new ValueRangeRecord();
223      
224          rec.field_1_minimumAxisValue = field_1_minimumAxisValue;
225          rec.field_2_maximumAxisValue = field_2_maximumAxisValue;
226          rec.field_3_majorIncrement = field_3_majorIncrement;
227          rec.field_4_minorIncrement = field_4_minorIncrement;
228          rec.field_5_categoryAxisCross = field_5_categoryAxisCross;
229          rec.field_6_options = field_6_options;
230          return rec;
231      }
232  
233  
234  
235  
236      /**
237       * Get the minimum axis value field for the ValueRange record.
238       */
239      public double getMinimumAxisValue()
240      {
241          return field_1_minimumAxisValue;
242      }
243  
244      /**
245       * Set the minimum axis value field for the ValueRange record.
246       */
247      public void setMinimumAxisValue(double field_1_minimumAxisValue)
248      {
249          this.field_1_minimumAxisValue = field_1_minimumAxisValue;
250      }
251  
252      /**
253       * Get the maximum axis value field for the ValueRange record.
254       */
255      public double getMaximumAxisValue()
256      {
257          return field_2_maximumAxisValue;
258      }
259  
260      /**
261       * Set the maximum axis value field for the ValueRange record.
262       */
263      public void setMaximumAxisValue(double field_2_maximumAxisValue)
264      {
265          this.field_2_maximumAxisValue = field_2_maximumAxisValue;
266      }
267  
268      /**
269       * Get the major increment field for the ValueRange record.
270       */
271      public double getMajorIncrement()
272      {
273          return field_3_majorIncrement;
274      }
275  
276      /**
277       * Set the major increment field for the ValueRange record.
278       */
279      public void setMajorIncrement(double field_3_majorIncrement)
280      {
281          this.field_3_majorIncrement = field_3_majorIncrement;
282      }
283  
284      /**
285       * Get the minor increment field for the ValueRange record.
286       */
287      public double getMinorIncrement()
288      {
289          return field_4_minorIncrement;
290      }
291  
292      /**
293       * Set the minor increment field for the ValueRange record.
294       */
295      public void setMinorIncrement(double field_4_minorIncrement)
296      {
297          this.field_4_minorIncrement = field_4_minorIncrement;
298      }
299  
300      /**
301       * Get the category axis cross field for the ValueRange record.
302       */
303      public double getCategoryAxisCross()
304      {
305          return field_5_categoryAxisCross;
306      }
307  
308      /**
309       * Set the category axis cross field for the ValueRange record.
310       */
311      public void setCategoryAxisCross(double field_5_categoryAxisCross)
312      {
313          this.field_5_categoryAxisCross = field_5_categoryAxisCross;
314      }
315  
316      /**
317       * Get the options field for the ValueRange record.
318       */
319      public short getOptions()
320      {
321          return field_6_options;
322      }
323  
324      /**
325       * Set the options field for the ValueRange record.
326       */
327      public void setOptions(short field_6_options)
328      {
329          this.field_6_options = field_6_options;
330      }
331  
332      /**
333       * Sets the automatic minimum field value.
334       * automatic minimum value selected
335       */
336      public void setAutomaticMinimum(boolean value)
337      {
338          field_6_options = automaticMinimum.setShortBoolean(field_6_options, value);
339      }
340  
341      /**
342       * automatic minimum value selected
343       * @return  the automatic minimum field value.
344       */
345      public boolean isAutomaticMinimum()
346      {
347          return automaticMinimum.isSet(field_6_options);
348      }
349  
350      /**
351       * Sets the automatic maximum field value.
352       * automatic maximum value selected
353       */
354      public void setAutomaticMaximum(boolean value)
355      {
356          field_6_options = automaticMaximum.setShortBoolean(field_6_options, value);
357      }
358  
359      /**
360       * automatic maximum value selected
361       * @return  the automatic maximum field value.
362       */
363      public boolean isAutomaticMaximum()
364      {
365          return automaticMaximum.isSet(field_6_options);
366      }
367  
368      /**
369       * Sets the automatic major field value.
370       * automatic major unit selected
371       */
372      public void setAutomaticMajor(boolean value)
373      {
374          field_6_options = automaticMajor.setShortBoolean(field_6_options, value);
375      }
376  
377      /**
378       * automatic major unit selected
379       * @return  the automatic major field value.
380       */
381      public boolean isAutomaticMajor()
382      {
383          return automaticMajor.isSet(field_6_options);
384      }
385  
386      /**
387       * Sets the automatic minor field value.
388       * automatic minor unit selected
389       */
390      public void setAutomaticMinor(boolean value)
391      {
392          field_6_options = automaticMinor.setShortBoolean(field_6_options, value);
393      }
394  
395      /**
396       * automatic minor unit selected
397       * @return  the automatic minor field value.
398       */
399      public boolean isAutomaticMinor()
400      {
401          return automaticMinor.isSet(field_6_options);
402      }
403  
404      /**
405       * Sets the automatic category crossing field value.
406       * category crossing point is automatically selected
407       */
408      public void setAutomaticCategoryCrossing(boolean value)
409      {
410          field_6_options = automaticCategoryCrossing.setShortBoolean(field_6_options, value);
411      }
412  
413      /**
414       * category crossing point is automatically selected
415       * @return  the automatic category crossing field value.
416       */
417      public boolean isAutomaticCategoryCrossing()
418      {
419          return automaticCategoryCrossing.isSet(field_6_options);
420      }
421  
422      /**
423       * Sets the logarithmic scale field value.
424       * use logarithmic scale
425       */
426      public void setLogarithmicScale(boolean value)
427      {
428          field_6_options = logarithmicScale.setShortBoolean(field_6_options, value);
429      }
430  
431      /**
432       * use logarithmic scale
433       * @return  the logarithmic scale field value.
434       */
435      public boolean isLogarithmicScale()
436      {
437          return logarithmicScale.isSet(field_6_options);
438      }
439  
440      /**
441       * Sets the values in reverse field value.
442       * values are reverses in graph
443       */
444      public void setValuesInReverse(boolean value)
445      {
446          field_6_options = valuesInReverse.setShortBoolean(field_6_options, value);
447      }
448  
449      /**
450       * values are reverses in graph
451       * @return  the values in reverse field value.
452       */
453      public boolean isValuesInReverse()
454      {
455          return valuesInReverse.isSet(field_6_options);
456      }
457  
458      /**
459       * Sets the cross category axis at maximum field value.
460       * category axis to cross at maximum value
461       */
462      public void setCrossCategoryAxisAtMaximum(boolean value)
463      {
464          field_6_options = crossCategoryAxisAtMaximum.setShortBoolean(field_6_options, value);
465      }
466  
467      /**
468       * category axis to cross at maximum value
469       * @return  the cross category axis at maximum field value.
470       */
471      public boolean isCrossCategoryAxisAtMaximum()
472      {
473          return crossCategoryAxisAtMaximum.isSet(field_6_options);
474      }
475  
476      /**
477       * Sets the reserved field value.
478       * reserved, must equal 1 (excel dev. guide says otherwise)
479       */
480      public void setReserved(boolean value)
481      {
482          field_6_options = reserved.setShortBoolean(field_6_options, value);
483      }
484  
485      /**
486       * reserved, must equal 1 (excel dev. guide says otherwise)
487       * @return  the reserved field value.
488       */
489      public boolean isReserved()
490      {
491          return reserved.isSet(field_6_options);
492      }
493  
494  
495  }  // END OF CLASS
496  
497  
498  
499  
500