KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > AreaRecord


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19
20 package org.apache.poi.hssf.record;
21
22
23
24 import org.apache.poi.util.*;
25
26 /**
27  * The area record is used to define a area chart.
28  * NOTE: This source is automatically generated please do not modify this file. Either subclass or
29  * remove the record in src/records/definitions.
30
31  * @author Glen Stampoultzis (glens at apache.org)
32  */

33 public class AreaRecord
34     extends Record
35 {
36     public final static short sid = 0x101A;
37     private short field_1_formatFlags;
38     private BitField stacked = new BitField(0x1);
39     private BitField displayAsPercentage = new BitField(0x2);
40     private BitField shadow = new BitField(0x4);
41
42
43     public AreaRecord()
44     {
45
46     }
47
48     /**
49      * Constructs a Area record and sets its fields appropriately.
50      *
51      * @param id id must be 0x101A or an exception
52      * will be throw upon validation
53      * @param size size the size of the data area of the record
54      * @param data data of the record (should not contain sid/len)
55      */

56
57     public AreaRecord(short id, short size, byte [] data)
58     {
59         super(id, size, data);
60     
61     }
62
63     /**
64      * Constructs a Area record and sets its fields appropriately.
65      *
66      * @param id id must be 0x101A or an exception
67      * will be throw upon validation
68      * @param size size the size of the data area of the record
69      * @param data data of the record (should not contain sid/len)
70      * @param offset of the record's data
71      */

72
73     public AreaRecord(short id, short size, byte [] data, int offset)
74     {
75         super(id, size, data, offset);
76     
77     }
78
79     /**
80      * Checks the sid matches the expected side for this record
81      *
82      * @param id the expected sid.
83      */

84     protected void validateSid(short id)
85     {
86         if (id != sid)
87         {
88             throw new RecordFormatException("Not a Area record");
89         }
90     }
91
92     protected void fillFields(byte [] data, short size, int offset)
93     {
94
95         int pos = 0;
96         field_1_formatFlags = LittleEndian.getShort(data, pos + 0x0 + offset);
97
98     }
99
100     public String JavaDoc toString()
101     {
102         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
103
104         buffer.append("[AREA]\n");
105         buffer.append(" .formatFlags = ")
106             .append("0x").append(HexDump.toHex( getFormatFlags ()))
107             .append(" (").append( getFormatFlags() ).append(" )");
108         buffer.append(System.getProperty("line.separator"));
109         buffer.append(" .stacked = ").append(isStacked()).append('\n');
110         buffer.append(" .displayAsPercentage = ").append(isDisplayAsPercentage()).append('\n');
111         buffer.append(" .shadow = ").append(isShadow()).append('\n');
112
113         buffer.append("[/AREA]\n");
114         return buffer.toString();
115     }
116
117     public int serialize(int offset, byte[] data)
118     {
119         int pos = 0;
120
121         LittleEndian.putShort(data, 0 + offset, sid);
122         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
123
124         LittleEndian.putShort(data, 4 + offset + pos, field_1_formatFlags);
125
126         return getRecordSize();
127     }
128
129     /**
130      * Size of record (exluding 4 byte header)
131      */

132     public int getRecordSize()
133     {
134         return 4 + 2;
135     }
136
137     public short getSid()
138     {
139         return this.sid;
140     }
141
142     public Object JavaDoc clone() {
143         AreaRecord rec = new AreaRecord();
144     
145         rec.field_1_formatFlags = field_1_formatFlags;
146         return rec;
147     }
148
149
150
151
152     /**
153      * Get the format flags field for the Area record.
154      */

155     public short getFormatFlags()
156     {
157         return field_1_formatFlags;
158     }
159
160     /**
161      * Set the format flags field for the Area record.
162      */

163     public void setFormatFlags(short field_1_formatFlags)
164     {
165         this.field_1_formatFlags = field_1_formatFlags;
166     }
167
168     /**
169      * Sets the stacked field value.
170      * series is stacked
171      */

172     public void setStacked(boolean value)
173     {
174         field_1_formatFlags = stacked.setShortBoolean(field_1_formatFlags, value);
175     }
176
177     /**
178      * series is stacked
179      * @return the stacked field value.
180      */

181     public boolean isStacked()
182     {
183         return stacked.isSet(field_1_formatFlags);
184     }
185
186     /**
187      * Sets the display as percentage field value.
188      * results displayed as percentages
189      */

190     public void setDisplayAsPercentage(boolean value)
191     {
192         field_1_formatFlags = displayAsPercentage.setShortBoolean(field_1_formatFlags, value);
193     }
194
195     /**
196      * results displayed as percentages
197      * @return the display as percentage field value.
198      */

199     public boolean isDisplayAsPercentage()
200     {
201         return displayAsPercentage.isSet(field_1_formatFlags);
202     }
203
204     /**
205      * Sets the shadow field value.
206      * display a shadow for the chart
207      */

208     public void setShadow(boolean value)
209     {
210         field_1_formatFlags = shadow.setShortBoolean(field_1_formatFlags, value);
211     }
212
213     /**
214      * display a shadow for the chart
215      * @return the shadow field value.
216      */

217     public boolean isShadow()
218     {
219         return shadow.isSet(field_1_formatFlags);
220     }
221
222
223 } // END OF CLASS
224

225
226
227
228
Popular Tags