KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Describes a line format record. The line format record controls how a line on a chart appears.
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 LineFormatRecord
34     extends Record
35 {
36     public final static short sid = 0x1007;
37     private int field_1_lineColor;
38     private short field_2_linePattern;
39     public final static short LINE_PATTERN_SOLID = 0;
40     public final static short LINE_PATTERN_DASH = 1;
41     public final static short LINE_PATTERN_DOT = 2;
42     public final static short LINE_PATTERN_DASH_DOT = 3;
43     public final static short LINE_PATTERN_DASH_DOT_DOT = 4;
44     public final static short LINE_PATTERN_NONE = 5;
45     public final static short LINE_PATTERN_DARK_GRAY_PATTERN = 6;
46     public final static short LINE_PATTERN_MEDIUM_GRAY_PATTERN = 7;
47     public final static short LINE_PATTERN_LIGHT_GRAY_PATTERN = 8;
48     private short field_3_weight;
49     public final static short WEIGHT_HAIRLINE = -1;
50     public final static short WEIGHT_NARROW = 0;
51     public final static short WEIGHT_MEDIUM = 1;
52     public final static short WEIGHT_WIDE = 2;
53     private short field_4_format;
54     private BitField auto = new BitField(0x1);
55     private BitField drawTicks = new BitField(0x4);
56     private BitField unknown = new BitField(0x4);
57     private short field_5_colourPaletteIndex;
58
59
60     public LineFormatRecord()
61     {
62
63     }
64
65     /**
66      * Constructs a LineFormat record and sets its fields appropriately.
67      *
68      * @param id id must be 0x1007 or an exception
69      * will be throw upon validation
70      * @param size size the size of the data area of the record
71      * @param data data of the record (should not contain sid/len)
72      */

73
74     public LineFormatRecord(short id, short size, byte [] data)
75     {
76         super(id, size, data);
77     
78     }
79
80     /**
81      * Constructs a LineFormat record and sets its fields appropriately.
82      *
83      * @param id id must be 0x1007 or an exception
84      * will be throw upon validation
85      * @param size size the size of the data area of the record
86      * @param data data of the record (should not contain sid/len)
87      * @param offset of the record's data
88      */

89
90     public LineFormatRecord(short id, short size, byte [] data, int offset)
91     {
92         super(id, size, data, offset);
93     
94     }
95
96     /**
97      * Checks the sid matches the expected side for this record
98      *
99      * @param id the expected sid.
100      */

101     protected void validateSid(short id)
102     {
103         if (id != sid)
104         {
105             throw new RecordFormatException("Not a LineFormat record");
106         }
107     }
108
109     protected void fillFields(byte [] data, short size, int offset)
110     {
111
112         int pos = 0;
113         field_1_lineColor = LittleEndian.getInt(data, pos + 0x0 + offset);
114         field_2_linePattern = LittleEndian.getShort(data, pos + 0x4 + offset);
115         field_3_weight = LittleEndian.getShort(data, pos + 0x6 + offset);
116         field_4_format = LittleEndian.getShort(data, pos + 0x8 + offset);
117         field_5_colourPaletteIndex = LittleEndian.getShort(data, pos + 0xa + offset);
118
119     }
120
121     public String JavaDoc toString()
122     {
123         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
124
125         buffer.append("[LINEFORMAT]\n");
126         buffer.append(" .lineColor = ")
127             .append("0x").append(HexDump.toHex( getLineColor ()))
128             .append(" (").append( getLineColor() ).append(" )");
129         buffer.append(System.getProperty("line.separator"));
130         buffer.append(" .linePattern = ")
131             .append("0x").append(HexDump.toHex( getLinePattern ()))
132             .append(" (").append( getLinePattern() ).append(" )");
133         buffer.append(System.getProperty("line.separator"));
134         buffer.append(" .weight = ")
135             .append("0x").append(HexDump.toHex( getWeight ()))
136             .append(" (").append( getWeight() ).append(" )");
137         buffer.append(System.getProperty("line.separator"));
138         buffer.append(" .format = ")
139             .append("0x").append(HexDump.toHex( getFormat ()))
140             .append(" (").append( getFormat() ).append(" )");
141         buffer.append(System.getProperty("line.separator"));
142         buffer.append(" .auto = ").append(isAuto()).append('\n');
143         buffer.append(" .drawTicks = ").append(isDrawTicks()).append('\n');
144         buffer.append(" .unknown = ").append(isUnknown()).append('\n');
145         buffer.append(" .colourPaletteIndex = ")
146             .append("0x").append(HexDump.toHex( getColourPaletteIndex ()))
147             .append(" (").append( getColourPaletteIndex() ).append(" )");
148         buffer.append(System.getProperty("line.separator"));
149
150         buffer.append("[/LINEFORMAT]\n");
151         return buffer.toString();
152     }
153
154     public int serialize(int offset, byte[] data)
155     {
156         int pos = 0;
157
158         LittleEndian.putShort(data, 0 + offset, sid);
159         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
160
161         LittleEndian.putInt(data, 4 + offset + pos, field_1_lineColor);
162         LittleEndian.putShort(data, 8 + offset + pos, field_2_linePattern);
163         LittleEndian.putShort(data, 10 + offset + pos, field_3_weight);
164         LittleEndian.putShort(data, 12 + offset + pos, field_4_format);
165         LittleEndian.putShort(data, 14 + offset + pos, field_5_colourPaletteIndex);
166
167         return getRecordSize();
168     }
169
170     /**
171      * Size of record (exluding 4 byte header)
172      */

173     public int getRecordSize()
174     {
175         return 4 + 4 + 2 + 2 + 2 + 2;
176     }
177
178     public short getSid()
179     {
180         return this.sid;
181     }
182
183     public Object JavaDoc clone() {
184         LineFormatRecord rec = new LineFormatRecord();
185     
186         rec.field_1_lineColor = field_1_lineColor;
187         rec.field_2_linePattern = field_2_linePattern;
188         rec.field_3_weight = field_3_weight;
189         rec.field_4_format = field_4_format;
190         rec.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
191         return rec;
192     }
193
194
195
196
197     /**
198      * Get the line color field for the LineFormat record.
199      */

200     public int getLineColor()
201     {
202         return field_1_lineColor;
203     }
204
205     /**
206      * Set the line color field for the LineFormat record.
207      */

208     public void setLineColor(int field_1_lineColor)
209     {
210         this.field_1_lineColor = field_1_lineColor;
211     }
212
213     /**
214      * Get the line pattern field for the LineFormat record.
215      *
216      * @return One of
217      * LINE_PATTERN_SOLID
218      * LINE_PATTERN_DASH
219      * LINE_PATTERN_DOT
220      * LINE_PATTERN_DASH_DOT
221      * LINE_PATTERN_DASH_DOT_DOT
222      * LINE_PATTERN_NONE
223      * LINE_PATTERN_DARK_GRAY_PATTERN
224      * LINE_PATTERN_MEDIUM_GRAY_PATTERN
225      * LINE_PATTERN_LIGHT_GRAY_PATTERN
226      */

227     public short getLinePattern()
228     {
229         return field_2_linePattern;
230     }
231
232     /**
233      * Set the line pattern field for the LineFormat record.
234      *
235      * @param field_2_linePattern
236      * One of
237      * LINE_PATTERN_SOLID
238      * LINE_PATTERN_DASH
239      * LINE_PATTERN_DOT
240      * LINE_PATTERN_DASH_DOT
241      * LINE_PATTERN_DASH_DOT_DOT
242      * LINE_PATTERN_NONE
243      * LINE_PATTERN_DARK_GRAY_PATTERN
244      * LINE_PATTERN_MEDIUM_GRAY_PATTERN
245      * LINE_PATTERN_LIGHT_GRAY_PATTERN
246      */

247     public void setLinePattern(short field_2_linePattern)
248     {
249         this.field_2_linePattern = field_2_linePattern;
250     }
251
252     /**
253      * Get the weight field for the LineFormat record.
254      *
255      * @return One of
256      * WEIGHT_HAIRLINE
257      * WEIGHT_NARROW
258      * WEIGHT_MEDIUM
259      * WEIGHT_WIDE
260      */

261     public short getWeight()
262     {
263         return field_3_weight;
264     }
265
266     /**
267      * Set the weight field for the LineFormat record.
268      *
269      * @param field_3_weight
270      * One of
271      * WEIGHT_HAIRLINE
272      * WEIGHT_NARROW
273      * WEIGHT_MEDIUM
274      * WEIGHT_WIDE
275      */

276     public void setWeight(short field_3_weight)
277     {
278         this.field_3_weight = field_3_weight;
279     }
280
281     /**
282      * Get the format field for the LineFormat record.
283      */

284     public short getFormat()
285     {
286         return field_4_format;
287     }
288
289     /**
290      * Set the format field for the LineFormat record.
291      */

292     public void setFormat(short field_4_format)
293     {
294         this.field_4_format = field_4_format;
295     }
296
297     /**
298      * Get the colour palette index field for the LineFormat record.
299      */

300     public short getColourPaletteIndex()
301     {
302         return field_5_colourPaletteIndex;
303     }
304
305     /**
306      * Set the colour palette index field for the LineFormat record.
307      */

308     public void setColourPaletteIndex(short field_5_colourPaletteIndex)
309     {
310         this.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
311     }
312
313     /**
314      * Sets the auto field value.
315      * automatic format
316      */

317     public void setAuto(boolean value)
318     {
319         field_4_format = auto.setShortBoolean(field_4_format, value);
320     }
321
322     /**
323      * automatic format
324      * @return the auto field value.
325      */

326     public boolean isAuto()
327     {
328         return auto.isSet(field_4_format);
329     }
330
331     /**
332      * Sets the draw ticks field value.
333      * draw tick marks
334      */

335     public void setDrawTicks(boolean value)
336     {
337         field_4_format = drawTicks.setShortBoolean(field_4_format, value);
338     }
339
340     /**
341      * draw tick marks
342      * @return the draw ticks field value.
343      */

344     public boolean isDrawTicks()
345     {
346         return drawTicks.isSet(field_4_format);
347     }
348
349     /**
350      * Sets the unknown field value.
351      * book marks this as reserved = 0 but it seems to do something
352      */

353     public void setUnknown(boolean value)
354     {
355         field_4_format = unknown.setShortBoolean(field_4_format, value);
356     }
357
358     /**
359      * book marks this as reserved = 0 but it seems to do something
360      * @return the unknown field value.
361      */

362     public boolean isUnknown()
363     {
364         return unknown.isSet(field_4_format);
365     }
366
367
368 } // END OF CLASS
369

370
371
372
373
Popular Tags