KickJava   Java API By Example, From Geeks To Geeks.

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


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 font basis record stores various font metrics.
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 FontBasisRecord
34     extends Record
35 {
36     public final static short sid = 0x1060;
37     private short field_1_xBasis;
38     private short field_2_yBasis;
39     private short field_3_heightBasis;
40     private short field_4_scale;
41     private short field_5_indexToFontTable;
42
43
44     public FontBasisRecord()
45     {
46
47     }
48
49     /**
50      * Constructs a FontBasis record and sets its fields appropriately.
51      *
52      * @param id id must be 0x1060 or an exception
53      * will be throw upon validation
54      * @param size size the size of the data area of the record
55      * @param data data of the record (should not contain sid/len)
56      */

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

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

85     protected void validateSid(short id)
86     {
87         if (id != sid)
88         {
89             throw new RecordFormatException("Not a FontBasis record");
90         }
91     }
92
93     protected void fillFields(byte [] data, short size, int offset)
94     {
95
96         int pos = 0;
97         field_1_xBasis = LittleEndian.getShort(data, pos + 0x0 + offset);
98         field_2_yBasis = LittleEndian.getShort(data, pos + 0x2 + offset);
99         field_3_heightBasis = LittleEndian.getShort(data, pos + 0x4 + offset);
100         field_4_scale = LittleEndian.getShort(data, pos + 0x6 + offset);
101         field_5_indexToFontTable = LittleEndian.getShort(data, pos + 0x8 + offset);
102
103     }
104
105     public String JavaDoc toString()
106     {
107         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
108
109         buffer.append("[FBI]\n");
110         buffer.append(" .xBasis = ")
111             .append("0x").append(HexDump.toHex( getXBasis ()))
112             .append(" (").append( getXBasis() ).append(" )");
113         buffer.append(System.getProperty("line.separator"));
114         buffer.append(" .yBasis = ")
115             .append("0x").append(HexDump.toHex( getYBasis ()))
116             .append(" (").append( getYBasis() ).append(" )");
117         buffer.append(System.getProperty("line.separator"));
118         buffer.append(" .heightBasis = ")
119             .append("0x").append(HexDump.toHex( getHeightBasis ()))
120             .append(" (").append( getHeightBasis() ).append(" )");
121         buffer.append(System.getProperty("line.separator"));
122         buffer.append(" .scale = ")
123             .append("0x").append(HexDump.toHex( getScale ()))
124             .append(" (").append( getScale() ).append(" )");
125         buffer.append(System.getProperty("line.separator"));
126         buffer.append(" .indexToFontTable = ")
127             .append("0x").append(HexDump.toHex( getIndexToFontTable ()))
128             .append(" (").append( getIndexToFontTable() ).append(" )");
129         buffer.append(System.getProperty("line.separator"));
130
131         buffer.append("[/FBI]\n");
132         return buffer.toString();
133     }
134
135     public int serialize(int offset, byte[] data)
136     {
137         int pos = 0;
138
139         LittleEndian.putShort(data, 0 + offset, sid);
140         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
141
142         LittleEndian.putShort(data, 4 + offset + pos, field_1_xBasis);
143         LittleEndian.putShort(data, 6 + offset + pos, field_2_yBasis);
144         LittleEndian.putShort(data, 8 + offset + pos, field_3_heightBasis);
145         LittleEndian.putShort(data, 10 + offset + pos, field_4_scale);
146         LittleEndian.putShort(data, 12 + offset + pos, field_5_indexToFontTable);
147
148         return getRecordSize();
149     }
150
151     /**
152      * Size of record (exluding 4 byte header)
153      */

154     public int getRecordSize()
155     {
156         return 4 + 2 + 2 + 2 + 2 + 2;
157     }
158
159     public short getSid()
160     {
161         return this.sid;
162     }
163
164     public Object JavaDoc clone() {
165         FontBasisRecord rec = new FontBasisRecord();
166     
167         rec.field_1_xBasis = field_1_xBasis;
168         rec.field_2_yBasis = field_2_yBasis;
169         rec.field_3_heightBasis = field_3_heightBasis;
170         rec.field_4_scale = field_4_scale;
171         rec.field_5_indexToFontTable = field_5_indexToFontTable;
172         return rec;
173     }
174
175
176
177
178     /**
179      * Get the x Basis field for the FontBasis record.
180      */

181     public short getXBasis()
182     {
183         return field_1_xBasis;
184     }
185
186     /**
187      * Set the x Basis field for the FontBasis record.
188      */

189     public void setXBasis(short field_1_xBasis)
190     {
191         this.field_1_xBasis = field_1_xBasis;
192     }
193
194     /**
195      * Get the y Basis field for the FontBasis record.
196      */

197     public short getYBasis()
198     {
199         return field_2_yBasis;
200     }
201
202     /**
203      * Set the y Basis field for the FontBasis record.
204      */

205     public void setYBasis(short field_2_yBasis)
206     {
207         this.field_2_yBasis = field_2_yBasis;
208     }
209
210     /**
211      * Get the height basis field for the FontBasis record.
212      */

213     public short getHeightBasis()
214     {
215         return field_3_heightBasis;
216     }
217
218     /**
219      * Set the height basis field for the FontBasis record.
220      */

221     public void setHeightBasis(short field_3_heightBasis)
222     {
223         this.field_3_heightBasis = field_3_heightBasis;
224     }
225
226     /**
227      * Get the scale field for the FontBasis record.
228      */

229     public short getScale()
230     {
231         return field_4_scale;
232     }
233
234     /**
235      * Set the scale field for the FontBasis record.
236      */

237     public void setScale(short field_4_scale)
238     {
239         this.field_4_scale = field_4_scale;
240     }
241
242     /**
243      * Get the index to font table field for the FontBasis record.
244      */

245     public short getIndexToFontTable()
246     {
247         return field_5_indexToFontTable;
248     }
249
250     /**
251      * Set the index to font table field for the FontBasis record.
252      */

253     public void setIndexToFontTable(short field_5_indexToFontTable)
254     {
255         this.field_5_indexToFontTable = field_5_indexToFontTable;
256     }
257
258
259 } // END OF CLASS
260

261
262
263
264
Popular Tags