KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Describes the frozen and unfozen panes.
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 PaneRecord
34     extends Record
35 {
36     public final static short sid = 0x41;
37     private short field_1_x;
38     private short field_2_y;
39     private short field_3_topRow;
40     private short field_4_leftColumn;
41     private short field_5_activePane;
42     public final static short ACTIVE_PANE_LOWER_RIGHT = 0;
43     public final static short ACTIVE_PANE_UPPER_RIGHT = 1;
44     public final static short ACTIVE_PANE_LOWER_LEFT = 2;
45     public final static short ACTIVE_PANE_UPER_LEFT = 3;
46
47
48     public PaneRecord()
49     {
50
51     }
52
53     /**
54      * Constructs a Pane record and sets its fields appropriately.
55      *
56      * @param id id must be 0x41 or an exception
57      * will be throw upon validation
58      * @param size size the size of the data area of the record
59      * @param data data of the record (should not contain sid/len)
60      */

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

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

89     protected void validateSid(short id)
90     {
91         if (id != sid)
92         {
93             throw new RecordFormatException("Not a Pane record");
94         }
95     }
96
97     protected void fillFields(byte [] data, short size, int offset)
98     {
99
100         int pos = 0;
101         field_1_x = LittleEndian.getShort(data, pos + 0x0 + offset);
102         field_2_y = LittleEndian.getShort(data, pos + 0x2 + offset);
103         field_3_topRow = LittleEndian.getShort(data, pos + 0x4 + offset);
104         field_4_leftColumn = LittleEndian.getShort(data, pos + 0x6 + offset);
105         field_5_activePane = LittleEndian.getShort(data, pos + 0x8 + offset);
106
107     }
108
109     public String JavaDoc toString()
110     {
111         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
112
113         buffer.append("[PANE]\n");
114         buffer.append(" .x = ")
115             .append("0x").append(HexDump.toHex( getX ()))
116             .append(" (").append( getX() ).append(" )");
117         buffer.append(System.getProperty("line.separator"));
118         buffer.append(" .y = ")
119             .append("0x").append(HexDump.toHex( getY ()))
120             .append(" (").append( getY() ).append(" )");
121         buffer.append(System.getProperty("line.separator"));
122         buffer.append(" .topRow = ")
123             .append("0x").append(HexDump.toHex( getTopRow ()))
124             .append(" (").append( getTopRow() ).append(" )");
125         buffer.append(System.getProperty("line.separator"));
126         buffer.append(" .leftColumn = ")
127             .append("0x").append(HexDump.toHex( getLeftColumn ()))
128             .append(" (").append( getLeftColumn() ).append(" )");
129         buffer.append(System.getProperty("line.separator"));
130         buffer.append(" .activePane = ")
131             .append("0x").append(HexDump.toHex( getActivePane ()))
132             .append(" (").append( getActivePane() ).append(" )");
133         buffer.append(System.getProperty("line.separator"));
134
135         buffer.append("[/PANE]\n");
136         return buffer.toString();
137     }
138
139     public int serialize(int offset, byte[] data)
140     {
141         int pos = 0;
142
143         LittleEndian.putShort(data, 0 + offset, sid);
144         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
145
146         LittleEndian.putShort(data, 4 + offset + pos, field_1_x);
147         LittleEndian.putShort(data, 6 + offset + pos, field_2_y);
148         LittleEndian.putShort(data, 8 + offset + pos, field_3_topRow);
149         LittleEndian.putShort(data, 10 + offset + pos, field_4_leftColumn);
150         LittleEndian.putShort(data, 12 + offset + pos, field_5_activePane);
151
152         return getRecordSize();
153     }
154
155     /**
156      * Size of record (exluding 4 byte header)
157      */

158     public int getRecordSize()
159     {
160         return 4 + 2 + 2 + 2 + 2 + 2;
161     }
162
163     public short getSid()
164     {
165         return this.sid;
166     }
167
168     public Object JavaDoc clone() {
169         PaneRecord rec = new PaneRecord();
170     
171         rec.field_1_x = field_1_x;
172         rec.field_2_y = field_2_y;
173         rec.field_3_topRow = field_3_topRow;
174         rec.field_4_leftColumn = field_4_leftColumn;
175         rec.field_5_activePane = field_5_activePane;
176         return rec;
177     }
178
179
180
181
182     /**
183      * Get the x field for the Pane record.
184      */

185     public short getX()
186     {
187         return field_1_x;
188     }
189
190     /**
191      * Set the x field for the Pane record.
192      */

193     public void setX(short field_1_x)
194     {
195         this.field_1_x = field_1_x;
196     }
197
198     /**
199      * Get the y field for the Pane record.
200      */

201     public short getY()
202     {
203         return field_2_y;
204     }
205
206     /**
207      * Set the y field for the Pane record.
208      */

209     public void setY(short field_2_y)
210     {
211         this.field_2_y = field_2_y;
212     }
213
214     /**
215      * Get the top row field for the Pane record.
216      */

217     public short getTopRow()
218     {
219         return field_3_topRow;
220     }
221
222     /**
223      * Set the top row field for the Pane record.
224      */

225     public void setTopRow(short field_3_topRow)
226     {
227         this.field_3_topRow = field_3_topRow;
228     }
229
230     /**
231      * Get the left column field for the Pane record.
232      */

233     public short getLeftColumn()
234     {
235         return field_4_leftColumn;
236     }
237
238     /**
239      * Set the left column field for the Pane record.
240      */

241     public void setLeftColumn(short field_4_leftColumn)
242     {
243         this.field_4_leftColumn = field_4_leftColumn;
244     }
245
246     /**
247      * Get the active pane field for the Pane record.
248      *
249      * @return One of
250      * ACTIVE_PANE_LOWER_RIGHT
251      * ACTIVE_PANE_UPPER_RIGHT
252      * ACTIVE_PANE_LOWER_LEFT
253      * ACTIVE_PANE_UPER_LEFT
254      */

255     public short getActivePane()
256     {
257         return field_5_activePane;
258     }
259
260     /**
261      * Set the active pane field for the Pane record.
262      *
263      * @param field_5_activePane
264      * One of
265      * ACTIVE_PANE_LOWER_RIGHT
266      * ACTIVE_PANE_UPPER_RIGHT
267      * ACTIVE_PANE_LOWER_LEFT
268      * ACTIVE_PANE_UPER_LEFT
269      */

270     public void setActivePane(short field_5_activePane)
271     {
272         this.field_5_activePane = field_5_activePane;
273     }
274
275
276 } // END OF CLASS
277

278
279
280
281
Popular Tags