KickJava   Java API By Example, From Geeks To Geeks.

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


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 axis size and location
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 AxisParentRecord
34     extends Record
35 {
36     public final static short sid = 0x1041;
37     private short field_1_axisType;
38     public final static short AXIS_TYPE_MAIN = 0;
39     public final static short AXIS_TYPE_SECONDARY = 1;
40     private int field_2_x;
41     private int field_3_y;
42     private int field_4_width;
43     private int field_5_height;
44
45
46     public AxisParentRecord()
47     {
48
49     }
50
51     /**
52      * Constructs a AxisParent record and sets its fields appropriately.
53      *
54      * @param id id must be 0x1041 or an exception
55      * will be throw upon validation
56      * @param size size the size of the data area of the record
57      * @param data data of the record (should not contain sid/len)
58      */

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

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

87     protected void validateSid(short id)
88     {
89         if (id != sid)
90         {
91             throw new RecordFormatException("Not a AxisParent record");
92         }
93     }
94
95     protected void fillFields(byte [] data, short size, int offset)
96     {
97
98         int pos = 0;
99         field_1_axisType = LittleEndian.getShort(data, pos + 0x0 + offset);
100         field_2_x = LittleEndian.getInt(data, pos + 0x2 + offset);
101         field_3_y = LittleEndian.getInt(data, pos + 0x6 + offset);
102         field_4_width = LittleEndian.getInt(data, pos + 0xa + offset);
103         field_5_height = LittleEndian.getInt(data, pos + 0xe + offset);
104
105     }
106
107     public String JavaDoc toString()
108     {
109         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
110
111         buffer.append("[AXISPARENT]\n");
112         buffer.append(" .axisType = ")
113             .append("0x").append(HexDump.toHex( getAxisType ()))
114             .append(" (").append( getAxisType() ).append(" )");
115         buffer.append(System.getProperty("line.separator"));
116         buffer.append(" .x = ")
117             .append("0x").append(HexDump.toHex( getX ()))
118             .append(" (").append( getX() ).append(" )");
119         buffer.append(System.getProperty("line.separator"));
120         buffer.append(" .y = ")
121             .append("0x").append(HexDump.toHex( getY ()))
122             .append(" (").append( getY() ).append(" )");
123         buffer.append(System.getProperty("line.separator"));
124         buffer.append(" .width = ")
125             .append("0x").append(HexDump.toHex( getWidth ()))
126             .append(" (").append( getWidth() ).append(" )");
127         buffer.append(System.getProperty("line.separator"));
128         buffer.append(" .height = ")
129             .append("0x").append(HexDump.toHex( getHeight ()))
130             .append(" (").append( getHeight() ).append(" )");
131         buffer.append(System.getProperty("line.separator"));
132
133         buffer.append("[/AXISPARENT]\n");
134         return buffer.toString();
135     }
136
137     public int serialize(int offset, byte[] data)
138     {
139         int pos = 0;
140
141         LittleEndian.putShort(data, 0 + offset, sid);
142         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
143
144         LittleEndian.putShort(data, 4 + offset + pos, field_1_axisType);
145         LittleEndian.putInt(data, 6 + offset + pos, field_2_x);
146         LittleEndian.putInt(data, 10 + offset + pos, field_3_y);
147         LittleEndian.putInt(data, 14 + offset + pos, field_4_width);
148         LittleEndian.putInt(data, 18 + offset + pos, field_5_height);
149
150         return getRecordSize();
151     }
152
153     /**
154      * Size of record (exluding 4 byte header)
155      */

156     public int getRecordSize()
157     {
158         return 4 + 2 + 4 + 4 + 4 + 4;
159     }
160
161     public short getSid()
162     {
163         return this.sid;
164     }
165
166     public Object JavaDoc clone() {
167         AxisParentRecord rec = new AxisParentRecord();
168     
169         rec.field_1_axisType = field_1_axisType;
170         rec.field_2_x = field_2_x;
171         rec.field_3_y = field_3_y;
172         rec.field_4_width = field_4_width;
173         rec.field_5_height = field_5_height;
174         return rec;
175     }
176
177
178
179
180     /**
181      * Get the axis type field for the AxisParent record.
182      *
183      * @return One of
184      * AXIS_TYPE_MAIN
185      * AXIS_TYPE_SECONDARY
186      */

187     public short getAxisType()
188     {
189         return field_1_axisType;
190     }
191
192     /**
193      * Set the axis type field for the AxisParent record.
194      *
195      * @param field_1_axisType
196      * One of
197      * AXIS_TYPE_MAIN
198      * AXIS_TYPE_SECONDARY
199      */

200     public void setAxisType(short field_1_axisType)
201     {
202         this.field_1_axisType = field_1_axisType;
203     }
204
205     /**
206      * Get the x field for the AxisParent record.
207      */

208     public int getX()
209     {
210         return field_2_x;
211     }
212
213     /**
214      * Set the x field for the AxisParent record.
215      */

216     public void setX(int field_2_x)
217     {
218         this.field_2_x = field_2_x;
219     }
220
221     /**
222      * Get the y field for the AxisParent record.
223      */

224     public int getY()
225     {
226         return field_3_y;
227     }
228
229     /**
230      * Set the y field for the AxisParent record.
231      */

232     public void setY(int field_3_y)
233     {
234         this.field_3_y = field_3_y;
235     }
236
237     /**
238      * Get the width field for the AxisParent record.
239      */

240     public int getWidth()
241     {
242         return field_4_width;
243     }
244
245     /**
246      * Set the width field for the AxisParent record.
247      */

248     public void setWidth(int field_4_width)
249     {
250         this.field_4_width = field_4_width;
251     }
252
253     /**
254      * Get the height field for the AxisParent record.
255      */

256     public int getHeight()
257     {
258         return field_5_height;
259     }
260
261     /**
262      * Set the height field for the AxisParent record.
263      */

264     public void setHeight(int field_5_height)
265     {
266         this.field_5_height = field_5_height;
267     }
268
269
270 } // END OF CLASS
271

272
273
274
275
Popular Tags