KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Defines a legend for a chart.
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 Andrew C. Oliver (acoliver at apache.org)
32  */

33 public class LegendRecord
34     extends Record
35 {
36     public final static short sid = 0x1015;
37     private int field_1_xAxisUpperLeft;
38     private int field_2_yAxisUpperLeft;
39     private int field_3_xSize;
40     private int field_4_ySize;
41     private byte field_5_type;
42     public final static byte TYPE_BOTTOM = 0;
43     public final static byte TYPE_CORNER = 1;
44     public final static byte TYPE_TOP = 2;
45     public final static byte TYPE_RIGHT = 3;
46     public final static byte TYPE_LEFT = 4;
47     public final static byte TYPE_UNDOCKED = 7;
48     private byte field_6_spacing;
49     public final static byte SPACING_CLOSE = 0;
50     public final static byte SPACING_MEDIUM = 1;
51     public final static byte SPACING_OPEN = 2;
52     private short field_7_options;
53     private BitField autoPosition = new BitField(0x1);
54     private BitField autoSeries = new BitField(0x2);
55     private BitField autoXPositioning = new BitField(0x4);
56     private BitField autoYPositioning = new BitField(0x8);
57     private BitField vertical = new BitField(0x10);
58     private BitField dataTable = new BitField(0x20);
59
60
61     public LegendRecord()
62     {
63
64     }
65
66     /**
67      * Constructs a Legend record and sets its fields appropriately.
68      *
69      * @param id id must be 0x1015 or an exception
70      * will be throw upon validation
71      * @param size size the size of the data area of the record
72      * @param data data of the record (should not contain sid/len)
73      */

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

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

102     protected void validateSid(short id)
103     {
104         if (id != sid)
105         {
106             throw new RecordFormatException("Not a Legend record");
107         }
108     }
109
110     protected void fillFields(byte [] data, short size, int offset)
111     {
112
113         int pos = 0;
114         field_1_xAxisUpperLeft = LittleEndian.getInt(data, pos + 0x0 + offset);
115         field_2_yAxisUpperLeft = LittleEndian.getInt(data, pos + 0x4 + offset);
116         field_3_xSize = LittleEndian.getInt(data, pos + 0x8 + offset);
117         field_4_ySize = LittleEndian.getInt(data, pos + 0xc + offset);
118         field_5_type = data[ pos + 0x10 + offset ];
119         field_6_spacing = data[ pos + 0x11 + offset ];
120         field_7_options = LittleEndian.getShort(data, pos + 0x12 + offset);
121
122     }
123
124     public String JavaDoc toString()
125     {
126         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
127
128         buffer.append("[LEGEND]\n");
129         buffer.append(" .xAxisUpperLeft = ")
130             .append("0x").append(HexDump.toHex( getXAxisUpperLeft ()))
131             .append(" (").append( getXAxisUpperLeft() ).append(" )");
132         buffer.append(System.getProperty("line.separator"));
133         buffer.append(" .yAxisUpperLeft = ")
134             .append("0x").append(HexDump.toHex( getYAxisUpperLeft ()))
135             .append(" (").append( getYAxisUpperLeft() ).append(" )");
136         buffer.append(System.getProperty("line.separator"));
137         buffer.append(" .xSize = ")
138             .append("0x").append(HexDump.toHex( getXSize ()))
139             .append(" (").append( getXSize() ).append(" )");
140         buffer.append(System.getProperty("line.separator"));
141         buffer.append(" .ySize = ")
142             .append("0x").append(HexDump.toHex( getYSize ()))
143             .append(" (").append( getYSize() ).append(" )");
144         buffer.append(System.getProperty("line.separator"));
145         buffer.append(" .type = ")
146             .append("0x").append(HexDump.toHex( getType ()))
147             .append(" (").append( getType() ).append(" )");
148         buffer.append(System.getProperty("line.separator"));
149         buffer.append(" .spacing = ")
150             .append("0x").append(HexDump.toHex( getSpacing ()))
151             .append(" (").append( getSpacing() ).append(" )");
152         buffer.append(System.getProperty("line.separator"));
153         buffer.append(" .options = ")
154             .append("0x").append(HexDump.toHex( getOptions ()))
155             .append(" (").append( getOptions() ).append(" )");
156         buffer.append(System.getProperty("line.separator"));
157         buffer.append(" .autoPosition = ").append(isAutoPosition()).append('\n');
158         buffer.append(" .autoSeries = ").append(isAutoSeries()).append('\n');
159         buffer.append(" .autoXPositioning = ").append(isAutoXPositioning()).append('\n');
160         buffer.append(" .autoYPositioning = ").append(isAutoYPositioning()).append('\n');
161         buffer.append(" .vertical = ").append(isVertical()).append('\n');
162         buffer.append(" .dataTable = ").append(isDataTable()).append('\n');
163
164         buffer.append("[/LEGEND]\n");
165         return buffer.toString();
166     }
167
168     public int serialize(int offset, byte[] data)
169     {
170         int pos = 0;
171
172         LittleEndian.putShort(data, 0 + offset, sid);
173         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
174
175         LittleEndian.putInt(data, 4 + offset + pos, field_1_xAxisUpperLeft);
176         LittleEndian.putInt(data, 8 + offset + pos, field_2_yAxisUpperLeft);
177         LittleEndian.putInt(data, 12 + offset + pos, field_3_xSize);
178         LittleEndian.putInt(data, 16 + offset + pos, field_4_ySize);
179         data[ 20 + offset + pos ] = field_5_type;
180         data[ 21 + offset + pos ] = field_6_spacing;
181         LittleEndian.putShort(data, 22 + offset + pos, field_7_options);
182
183         return getRecordSize();
184     }
185
186     /**
187      * Size of record (exluding 4 byte header)
188      */

189     public int getRecordSize()
190     {
191         return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
192     }
193
194     public short getSid()
195     {
196         return this.sid;
197     }
198
199     public Object JavaDoc clone() {
200         LegendRecord rec = new LegendRecord();
201     
202         rec.field_1_xAxisUpperLeft = field_1_xAxisUpperLeft;
203         rec.field_2_yAxisUpperLeft = field_2_yAxisUpperLeft;
204         rec.field_3_xSize = field_3_xSize;
205         rec.field_4_ySize = field_4_ySize;
206         rec.field_5_type = field_5_type;
207         rec.field_6_spacing = field_6_spacing;
208         rec.field_7_options = field_7_options;
209         return rec;
210     }
211
212
213
214
215     /**
216      * Get the x axis upper left field for the Legend record.
217      */

218     public int getXAxisUpperLeft()
219     {
220         return field_1_xAxisUpperLeft;
221     }
222
223     /**
224      * Set the x axis upper left field for the Legend record.
225      */

226     public void setXAxisUpperLeft(int field_1_xAxisUpperLeft)
227     {
228         this.field_1_xAxisUpperLeft = field_1_xAxisUpperLeft;
229     }
230
231     /**
232      * Get the y axis upper left field for the Legend record.
233      */

234     public int getYAxisUpperLeft()
235     {
236         return field_2_yAxisUpperLeft;
237     }
238
239     /**
240      * Set the y axis upper left field for the Legend record.
241      */

242     public void setYAxisUpperLeft(int field_2_yAxisUpperLeft)
243     {
244         this.field_2_yAxisUpperLeft = field_2_yAxisUpperLeft;
245     }
246
247     /**
248      * Get the x size field for the Legend record.
249      */

250     public int getXSize()
251     {
252         return field_3_xSize;
253     }
254
255     /**
256      * Set the x size field for the Legend record.
257      */

258     public void setXSize(int field_3_xSize)
259     {
260         this.field_3_xSize = field_3_xSize;
261     }
262
263     /**
264      * Get the y size field for the Legend record.
265      */

266     public int getYSize()
267     {
268         return field_4_ySize;
269     }
270
271     /**
272      * Set the y size field for the Legend record.
273      */

274     public void setYSize(int field_4_ySize)
275     {
276         this.field_4_ySize = field_4_ySize;
277     }
278
279     /**
280      * Get the type field for the Legend record.
281      *
282      * @return One of
283      * TYPE_BOTTOM
284      * TYPE_CORNER
285      * TYPE_TOP
286      * TYPE_RIGHT
287      * TYPE_LEFT
288      * TYPE_UNDOCKED
289      */

290     public byte getType()
291     {
292         return field_5_type;
293     }
294
295     /**
296      * Set the type field for the Legend record.
297      *
298      * @param field_5_type
299      * One of
300      * TYPE_BOTTOM
301      * TYPE_CORNER
302      * TYPE_TOP
303      * TYPE_RIGHT
304      * TYPE_LEFT
305      * TYPE_UNDOCKED
306      */

307     public void setType(byte field_5_type)
308     {
309         this.field_5_type = field_5_type;
310     }
311
312     /**
313      * Get the spacing field for the Legend record.
314      *
315      * @return One of
316      * SPACING_CLOSE
317      * SPACING_MEDIUM
318      * SPACING_OPEN
319      */

320     public byte getSpacing()
321     {
322         return field_6_spacing;
323     }
324
325     /**
326      * Set the spacing field for the Legend record.
327      *
328      * @param field_6_spacing
329      * One of
330      * SPACING_CLOSE
331      * SPACING_MEDIUM
332      * SPACING_OPEN
333      */

334     public void setSpacing(byte field_6_spacing)
335     {
336         this.field_6_spacing = field_6_spacing;
337     }
338
339     /**
340      * Get the options field for the Legend record.
341      */

342     public short getOptions()
343     {
344         return field_7_options;
345     }
346
347     /**
348      * Set the options field for the Legend record.
349      */

350     public void setOptions(short field_7_options)
351     {
352         this.field_7_options = field_7_options;
353     }
354
355     /**
356      * Sets the auto position field value.
357      * automatic positioning (1=docked)
358      */

359     public void setAutoPosition(boolean value)
360     {
361         field_7_options = autoPosition.setShortBoolean(field_7_options, value);
362     }
363
364     /**
365      * automatic positioning (1=docked)
366      * @return the auto position field value.
367      */

368     public boolean isAutoPosition()
369     {
370         return autoPosition.isSet(field_7_options);
371     }
372
373     /**
374      * Sets the auto series field value.
375      * excel 5 only (true)
376      */

377     public void setAutoSeries(boolean value)
378     {
379         field_7_options = autoSeries.setShortBoolean(field_7_options, value);
380     }
381
382     /**
383      * excel 5 only (true)
384      * @return the auto series field value.
385      */

386     public boolean isAutoSeries()
387     {
388         return autoSeries.isSet(field_7_options);
389     }
390
391     /**
392      * Sets the auto x positioning field value.
393      * position of legend on the x axis is automatic
394      */

395     public void setAutoXPositioning(boolean value)
396     {
397         field_7_options = autoXPositioning.setShortBoolean(field_7_options, value);
398     }
399
400     /**
401      * position of legend on the x axis is automatic
402      * @return the auto x positioning field value.
403      */

404     public boolean isAutoXPositioning()
405     {
406         return autoXPositioning.isSet(field_7_options);
407     }
408
409     /**
410      * Sets the auto y positioning field value.
411      * position of legend on the y axis is automatic
412      */

413     public void setAutoYPositioning(boolean value)
414     {
415         field_7_options = autoYPositioning.setShortBoolean(field_7_options, value);
416     }
417
418     /**
419      * position of legend on the y axis is automatic
420      * @return the auto y positioning field value.
421      */

422     public boolean isAutoYPositioning()
423     {
424         return autoYPositioning.isSet(field_7_options);
425     }
426
427     /**
428      * Sets the vertical field value.
429      * vertical or horizontal legend (1 or 0 respectively). Always 0 if not automatic.
430      */

431     public void setVertical(boolean value)
432     {
433         field_7_options = vertical.setShortBoolean(field_7_options, value);
434     }
435
436     /**
437      * vertical or horizontal legend (1 or 0 respectively). Always 0 if not automatic.
438      * @return the vertical field value.
439      */

440     public boolean isVertical()
441     {
442         return vertical.isSet(field_7_options);
443     }
444
445     /**
446      * Sets the data table field value.
447      * 1 if chart contains data table
448      */

449     public void setDataTable(boolean value)
450     {
451         field_7_options = dataTable.setShortBoolean(field_7_options, value);
452     }
453
454     /**
455      * 1 if chart contains data table
456      * @return the data table field value.
457      */

458     public boolean isDataTable()
459     {
460         return dataTable.isSet(field_7_options);
461     }
462
463
464 } // END OF CLASS
465

466
467
468
469
Popular Tags