KickJava   Java API By Example, From Geeks To Geeks.

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


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 frame record indicates whether there is a border around the displayed text of a 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 FrameRecord
34     extends Record
35 {
36     public final static short sid = 0x1032;
37     private short field_1_borderType;
38     public final static short BORDER_TYPE_REGULAR = 0;
39     public final static short BORDER_TYPE_SHADOW = 1;
40     private short field_2_options;
41     private BitField autoSize = new BitField(0x1);
42     private BitField autoPosition = new BitField(0x2);
43
44
45     public FrameRecord()
46     {
47
48     }
49
50     /**
51      * Constructs a Frame record and sets its fields appropriately.
52      *
53      * @param id id must be 0x1032 or an exception
54      * will be throw upon validation
55      * @param size size the size of the data area of the record
56      * @param data data of the record (should not contain sid/len)
57      */

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

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

86     protected void validateSid(short id)
87     {
88         if (id != sid)
89         {
90             throw new RecordFormatException("Not a Frame record");
91         }
92     }
93
94     protected void fillFields(byte [] data, short size, int offset)
95     {
96
97         int pos = 0;
98         field_1_borderType = LittleEndian.getShort(data, pos + 0x0 + offset);
99         field_2_options = LittleEndian.getShort(data, pos + 0x2 + offset);
100
101     }
102
103     public String JavaDoc toString()
104     {
105         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
106
107         buffer.append("[FRAME]\n");
108         buffer.append(" .borderType = ")
109             .append("0x").append(HexDump.toHex( getBorderType ()))
110             .append(" (").append( getBorderType() ).append(" )");
111         buffer.append(System.getProperty("line.separator"));
112         buffer.append(" .options = ")
113             .append("0x").append(HexDump.toHex( getOptions ()))
114             .append(" (").append( getOptions() ).append(" )");
115         buffer.append(System.getProperty("line.separator"));
116         buffer.append(" .autoSize = ").append(isAutoSize()).append('\n');
117         buffer.append(" .autoPosition = ").append(isAutoPosition()).append('\n');
118
119         buffer.append("[/FRAME]\n");
120         return buffer.toString();
121     }
122
123     public int serialize(int offset, byte[] data)
124     {
125         int pos = 0;
126
127         LittleEndian.putShort(data, 0 + offset, sid);
128         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
129
130         LittleEndian.putShort(data, 4 + offset + pos, field_1_borderType);
131         LittleEndian.putShort(data, 6 + offset + pos, field_2_options);
132
133         return getRecordSize();
134     }
135
136     /**
137      * Size of record (exluding 4 byte header)
138      */

139     public int getRecordSize()
140     {
141         return 4 + 2 + 2;
142     }
143
144     public short getSid()
145     {
146         return this.sid;
147     }
148
149     public Object JavaDoc clone() {
150         FrameRecord rec = new FrameRecord();
151     
152         rec.field_1_borderType = field_1_borderType;
153         rec.field_2_options = field_2_options;
154         return rec;
155     }
156
157
158
159
160     /**
161      * Get the border type field for the Frame record.
162      *
163      * @return One of
164      * BORDER_TYPE_REGULAR
165      * BORDER_TYPE_SHADOW
166      */

167     public short getBorderType()
168     {
169         return field_1_borderType;
170     }
171
172     /**
173      * Set the border type field for the Frame record.
174      *
175      * @param field_1_borderType
176      * One of
177      * BORDER_TYPE_REGULAR
178      * BORDER_TYPE_SHADOW
179      */

180     public void setBorderType(short field_1_borderType)
181     {
182         this.field_1_borderType = field_1_borderType;
183     }
184
185     /**
186      * Get the options field for the Frame record.
187      */

188     public short getOptions()
189     {
190         return field_2_options;
191     }
192
193     /**
194      * Set the options field for the Frame record.
195      */

196     public void setOptions(short field_2_options)
197     {
198         this.field_2_options = field_2_options;
199     }
200
201     /**
202      * Sets the auto size field value.
203      * excel calculates the size automatically if true
204      */

205     public void setAutoSize(boolean value)
206     {
207         field_2_options = autoSize.setShortBoolean(field_2_options, value);
208     }
209
210     /**
211      * excel calculates the size automatically if true
212      * @return the auto size field value.
213      */

214     public boolean isAutoSize()
215     {
216         return autoSize.isSet(field_2_options);
217     }
218
219     /**
220      * Sets the auto position field value.
221      * excel calculates the position automatically
222      */

223     public void setAutoPosition(boolean value)
224     {
225         field_2_options = autoPosition.setShortBoolean(field_2_options, value);
226     }
227
228     /**
229      * excel calculates the position automatically
230      * @return the auto position field value.
231      */

232     public boolean isAutoPosition()
233     {
234         return autoPosition.isSet(field_2_options);
235     }
236
237
238 } // END OF CLASS
239

240
241
242
243
Popular Tags