001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * The font basis record stores various font metrics.
024: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
025: * remove the record in src/records/definitions.
026:
027: * @author Glen Stampoultzis (glens at apache.org)
028: */
029: public class FontBasisRecord extends Record {
030: public final static short sid = 0x1060;
031: private short field_1_xBasis;
032: private short field_2_yBasis;
033: private short field_3_heightBasis;
034: private short field_4_scale;
035: private short field_5_indexToFontTable;
036:
037: public FontBasisRecord() {
038:
039: }
040:
041: /**
042: * Constructs a FontBasis record and sets its fields appropriately.
043: *
044: * @param in the RecordInputstream to read the record from
045: */
046:
047: public FontBasisRecord(RecordInputStream in) {
048: super (in);
049:
050: }
051:
052: /**
053: * Checks the sid matches the expected side for this record
054: *
055: * @param id the expected sid.
056: */
057: protected void validateSid(short id) {
058: if (id != sid) {
059: throw new RecordFormatException("Not a FontBasis record");
060: }
061: }
062:
063: protected void fillFields(RecordInputStream in) {
064: field_1_xBasis = in.readShort();
065: field_2_yBasis = in.readShort();
066: field_3_heightBasis = in.readShort();
067: field_4_scale = in.readShort();
068: field_5_indexToFontTable = in.readShort();
069: }
070:
071: public String toString() {
072: StringBuffer buffer = new StringBuffer();
073:
074: buffer.append("[FBI]\n");
075: buffer.append(" .xBasis = ").append("0x")
076: .append(HexDump.toHex(getXBasis())).append(" (")
077: .append(getXBasis()).append(" )");
078: buffer.append(System.getProperty("line.separator"));
079: buffer.append(" .yBasis = ").append("0x")
080: .append(HexDump.toHex(getYBasis())).append(" (")
081: .append(getYBasis()).append(" )");
082: buffer.append(System.getProperty("line.separator"));
083: buffer.append(" .heightBasis = ").append("0x")
084: .append(HexDump.toHex(getHeightBasis())).append(" (")
085: .append(getHeightBasis()).append(" )");
086: buffer.append(System.getProperty("line.separator"));
087: buffer.append(" .scale = ").append("0x")
088: .append(HexDump.toHex(getScale())).append(" (").append(
089: getScale()).append(" )");
090: buffer.append(System.getProperty("line.separator"));
091: buffer.append(" .indexToFontTable = ").append("0x")
092: .append(HexDump.toHex(getIndexToFontTable())).append(
093: " (").append(getIndexToFontTable())
094: .append(" )");
095: buffer.append(System.getProperty("line.separator"));
096:
097: buffer.append("[/FBI]\n");
098: return buffer.toString();
099: }
100:
101: public int serialize(int offset, byte[] data) {
102: int pos = 0;
103:
104: LittleEndian.putShort(data, 0 + offset, sid);
105: LittleEndian.putShort(data, 2 + offset,
106: (short) (getRecordSize() - 4));
107:
108: LittleEndian.putShort(data, 4 + offset + pos, field_1_xBasis);
109: LittleEndian.putShort(data, 6 + offset + pos, field_2_yBasis);
110: LittleEndian.putShort(data, 8 + offset + pos,
111: field_3_heightBasis);
112: LittleEndian.putShort(data, 10 + offset + pos, field_4_scale);
113: LittleEndian.putShort(data, 12 + offset + pos,
114: field_5_indexToFontTable);
115:
116: return getRecordSize();
117: }
118:
119: /**
120: * Size of record (exluding 4 byte header)
121: */
122: public int getRecordSize() {
123: return 4 + 2 + 2 + 2 + 2 + 2;
124: }
125:
126: public short getSid() {
127: return sid;
128: }
129:
130: public Object clone() {
131: FontBasisRecord rec = new FontBasisRecord();
132:
133: rec.field_1_xBasis = field_1_xBasis;
134: rec.field_2_yBasis = field_2_yBasis;
135: rec.field_3_heightBasis = field_3_heightBasis;
136: rec.field_4_scale = field_4_scale;
137: rec.field_5_indexToFontTable = field_5_indexToFontTable;
138: return rec;
139: }
140:
141: /**
142: * Get the x Basis field for the FontBasis record.
143: */
144: public short getXBasis() {
145: return field_1_xBasis;
146: }
147:
148: /**
149: * Set the x Basis field for the FontBasis record.
150: */
151: public void setXBasis(short field_1_xBasis) {
152: this .field_1_xBasis = field_1_xBasis;
153: }
154:
155: /**
156: * Get the y Basis field for the FontBasis record.
157: */
158: public short getYBasis() {
159: return field_2_yBasis;
160: }
161:
162: /**
163: * Set the y Basis field for the FontBasis record.
164: */
165: public void setYBasis(short field_2_yBasis) {
166: this .field_2_yBasis = field_2_yBasis;
167: }
168:
169: /**
170: * Get the height basis field for the FontBasis record.
171: */
172: public short getHeightBasis() {
173: return field_3_heightBasis;
174: }
175:
176: /**
177: * Set the height basis field for the FontBasis record.
178: */
179: public void setHeightBasis(short field_3_heightBasis) {
180: this .field_3_heightBasis = field_3_heightBasis;
181: }
182:
183: /**
184: * Get the scale field for the FontBasis record.
185: */
186: public short getScale() {
187: return field_4_scale;
188: }
189:
190: /**
191: * Set the scale field for the FontBasis record.
192: */
193: public void setScale(short field_4_scale) {
194: this .field_4_scale = field_4_scale;
195: }
196:
197: /**
198: * Get the index to font table field for the FontBasis record.
199: */
200: public short getIndexToFontTable() {
201: return field_5_indexToFontTable;
202: }
203:
204: /**
205: * Set the index to font table field for the FontBasis record.
206: */
207: public void setIndexToFontTable(short field_5_indexToFontTable) {
208: this .field_5_indexToFontTable = field_5_indexToFontTable;
209: }
210:
211: } // END OF CLASS
|