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 plot growth record specifies the scaling factors used when a font is scaled.
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 PlotGrowthRecord extends Record {
030: public final static short sid = 0x1064;
031: private int field_1_horizontalScale;
032: private int field_2_verticalScale;
033:
034: public PlotGrowthRecord() {
035:
036: }
037:
038: /**
039: * Constructs a PlotGrowth record and sets its fields appropriately.
040: *
041: * @param in the RecordInputstream to read the record from
042: */
043:
044: public PlotGrowthRecord(RecordInputStream in) {
045: super (in);
046:
047: }
048:
049: /**
050: * Checks the sid matches the expected side for this record
051: *
052: * @param id the expected sid.
053: */
054: protected void validateSid(short id) {
055: if (id != sid) {
056: throw new RecordFormatException("Not a PlotGrowth record");
057: }
058: }
059:
060: protected void fillFields(RecordInputStream in) {
061: field_1_horizontalScale = in.readInt();
062: field_2_verticalScale = in.readInt();
063:
064: }
065:
066: public String toString() {
067: StringBuffer buffer = new StringBuffer();
068:
069: buffer.append("[PLOTGROWTH]\n");
070: buffer.append(" .horizontalScale = ").append("0x")
071: .append(HexDump.toHex(getHorizontalScale())).append(
072: " (").append(getHorizontalScale()).append(" )");
073: buffer.append(System.getProperty("line.separator"));
074: buffer.append(" .verticalScale = ").append("0x")
075: .append(HexDump.toHex(getVerticalScale())).append(" (")
076: .append(getVerticalScale()).append(" )");
077: buffer.append(System.getProperty("line.separator"));
078:
079: buffer.append("[/PLOTGROWTH]\n");
080: return buffer.toString();
081: }
082:
083: public int serialize(int offset, byte[] data) {
084: int pos = 0;
085:
086: LittleEndian.putShort(data, 0 + offset, sid);
087: LittleEndian.putShort(data, 2 + offset,
088: (short) (getRecordSize() - 4));
089:
090: LittleEndian.putInt(data, 4 + offset + pos,
091: field_1_horizontalScale);
092: LittleEndian.putInt(data, 8 + offset + pos,
093: field_2_verticalScale);
094:
095: return getRecordSize();
096: }
097:
098: /**
099: * Size of record (exluding 4 byte header)
100: */
101: public int getRecordSize() {
102: return 4 + 4 + 4;
103: }
104:
105: public short getSid() {
106: return sid;
107: }
108:
109: public Object clone() {
110: PlotGrowthRecord rec = new PlotGrowthRecord();
111:
112: rec.field_1_horizontalScale = field_1_horizontalScale;
113: rec.field_2_verticalScale = field_2_verticalScale;
114: return rec;
115: }
116:
117: /**
118: * Get the horizontalScale field for the PlotGrowth record.
119: */
120: public int getHorizontalScale() {
121: return field_1_horizontalScale;
122: }
123:
124: /**
125: * Set the horizontalScale field for the PlotGrowth record.
126: */
127: public void setHorizontalScale(int field_1_horizontalScale) {
128: this .field_1_horizontalScale = field_1_horizontalScale;
129: }
130:
131: /**
132: * Get the verticalScale field for the PlotGrowth record.
133: */
134: public int getVerticalScale() {
135: return field_2_verticalScale;
136: }
137:
138: /**
139: * Set the verticalScale field for the PlotGrowth record.
140: */
141: public void setVerticalScale(int field_2_verticalScale) {
142: this .field_2_verticalScale = field_2_verticalScale;
143: }
144:
145: } // END OF CLASS
|