KickJava   Java API By Example, From Geeks To Geeks.

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


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 plot growth record specifies the scaling factors used when a font is scaled.
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 PlotGrowthRecord
34     extends Record
35 {
36     public final static short sid = 0x1064;
37     private int field_1_horizontalScale;
38     private int field_2_verticalScale;
39
40
41     public PlotGrowthRecord()
42     {
43
44     }
45
46     /**
47      * Constructs a PlotGrowth record and sets its fields appropriately.
48      *
49      * @param id id must be 0x1064 or an exception
50      * will be throw upon validation
51      * @param size size the size of the data area of the record
52      * @param data data of the record (should not contain sid/len)
53      */

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

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

82     protected void validateSid(short id)
83     {
84         if (id != sid)
85         {
86             throw new RecordFormatException("Not a PlotGrowth record");
87         }
88     }
89
90     protected void fillFields(byte [] data, short size, int offset)
91     {
92
93         int pos = 0;
94         field_1_horizontalScale = LittleEndian.getInt(data, pos + 0x0 + offset);
95         field_2_verticalScale = LittleEndian.getInt(data, pos + 0x4 + offset);
96
97     }
98
99     public String JavaDoc toString()
100     {
101         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
102
103         buffer.append("[PLOTGROWTH]\n");
104         buffer.append(" .horizontalScale = ")
105             .append("0x").append(HexDump.toHex( getHorizontalScale ()))
106             .append(" (").append( getHorizontalScale() ).append(" )");
107         buffer.append(System.getProperty("line.separator"));
108         buffer.append(" .verticalScale = ")
109             .append("0x").append(HexDump.toHex( getVerticalScale ()))
110             .append(" (").append( getVerticalScale() ).append(" )");
111         buffer.append(System.getProperty("line.separator"));
112
113         buffer.append("[/PLOTGROWTH]\n");
114         return buffer.toString();
115     }
116
117     public int serialize(int offset, byte[] data)
118     {
119         int pos = 0;
120
121         LittleEndian.putShort(data, 0 + offset, sid);
122         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
123
124         LittleEndian.putInt(data, 4 + offset + pos, field_1_horizontalScale);
125         LittleEndian.putInt(data, 8 + offset + pos, field_2_verticalScale);
126
127         return getRecordSize();
128     }
129
130     /**
131      * Size of record (exluding 4 byte header)
132      */

133     public int getRecordSize()
134     {
135         return 4 + 4 + 4;
136     }
137
138     public short getSid()
139     {
140         return this.sid;
141     }
142
143     public Object JavaDoc clone() {
144         PlotGrowthRecord rec = new PlotGrowthRecord();
145     
146         rec.field_1_horizontalScale = field_1_horizontalScale;
147         rec.field_2_verticalScale = field_2_verticalScale;
148         return rec;
149     }
150
151
152
153
154     /**
155      * Get the horizontalScale field for the PlotGrowth record.
156      */

157     public int getHorizontalScale()
158     {
159         return field_1_horizontalScale;
160     }
161
162     /**
163      * Set the horizontalScale field for the PlotGrowth record.
164      */

165     public void setHorizontalScale(int field_1_horizontalScale)
166     {
167         this.field_1_horizontalScale = field_1_horizontalScale;
168     }
169
170     /**
171      * Get the verticalScale field for the PlotGrowth record.
172      */

173     public int getVerticalScale()
174     {
175         return field_2_verticalScale;
176     }
177
178     /**
179      * Set the verticalScale field for the PlotGrowth record.
180      */

181     public void setVerticalScale(int field_2_verticalScale)
182     {
183         this.field_2_verticalScale = field_2_verticalScale;
184     }
185
186
187 } // END OF CLASS
188

189
190
191
192
Popular Tags