KickJava   Java API By Example, From Geeks To Geeks.

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


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 text record is used to define text stored on 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 Glen Stampoultzis (glens at apache.org)
32  */

33 public class TextRecord
34     extends Record
35 {
36     public final static short sid = 0x1025;
37     private byte field_1_horizontalAlignment;
38     public final static byte HORIZONTAL_ALIGNMENT_LEFT = 1;
39     public final static byte HORIZONTAL_ALIGNMENT_CENTER = 2;
40     public final static byte HORIZONTAL_ALIGNMENT_BOTTOM = 3;
41     public final static byte HORIZONTAL_ALIGNMENT_JUSTIFY = 4;
42     private byte field_2_verticalAlignment;
43     public final static byte VERTICAL_ALIGNMENT_TOP = 1;
44     public final static byte VERTICAL_ALIGNMENT_CENTER = 2;
45     public final static byte VERTICAL_ALIGNMENT_BOTTOM = 3;
46     public final static byte VERTICAL_ALIGNMENT_JUSTIFY = 4;
47     private short field_3_displayMode;
48     public final static short DISPLAY_MODE_TRANSPARENT = 1;
49     public final static short DISPLAY_MODE_OPAQUE = 2;
50     private int field_4_rgbColor;
51     private int field_5_x;
52     private int field_6_y;
53     private int field_7_width;
54     private int field_8_height;
55     private short field_9_options1;
56     private BitField autoColor = new BitField(0x1);
57     private BitField showKey = new BitField(0x2);
58     private BitField showValue = new BitField(0x4);
59     private BitField vertical = new BitField(0x8);
60     private BitField autoGeneratedText = new BitField(0x10);
61     private BitField generated = new BitField(0x20);
62     private BitField autoLabelDeleted = new BitField(0x40);
63     private BitField autoBackground = new BitField(0x80);
64     private BitField rotation = new BitField(0x0700);
65     public final static short ROTATION_NONE = 0;
66     public final static short ROTATION_TOP_TO_BOTTOM = 1;
67     public final static short ROTATION_ROTATED_90_DEGREES = 2;
68     public final static short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
69     private BitField showCategoryLabelAsPercentage = new BitField(0x800);
70     private BitField showValueAsPercentage = new BitField(0x1000);
71     private BitField showBubbleSizes = new BitField(0x2000);
72     private BitField showLabel = new BitField(0x4000);
73     private short field_10_indexOfColorValue;
74     private short field_11_options2;
75     private BitField dataLabelPlacement = new BitField(0x000F);
76     public final static short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
77     public final static short DATA_LABEL_PLACEMENT_OUTSIDE = 1;
78     public final static short DATA_LABEL_PLACEMENT_INSIDE = 2;
79     public final static short DATA_LABEL_PLACEMENT_CENTER = 3;
80     public final static short DATA_LABEL_PLACEMENT_AXIS = 4;
81     public final static short DATA_LABEL_PLACEMENT_ABOVE = 5;
82     public final static short DATA_LABEL_PLACEMENT_BELOW = 6;
83     public final static short DATA_LABEL_PLACEMENT_LEFT = 7;
84     public final static short DATA_LABEL_PLACEMENT_RIGHT = 8;
85     public final static short DATA_LABEL_PLACEMENT_AUTO = 9;
86     public final static short DATA_LABEL_PLACEMENT_USER_MOVED = 10;
87     private short field_12_textRotation;
88
89
90     public TextRecord()
91     {
92
93     }
94
95     /**
96      * Constructs a Text record and sets its fields appropriately.
97      *
98      * @param id id must be 0x1025 or an exception
99      * will be throw upon validation
100      * @param size size the size of the data area of the record
101      * @param data data of the record (should not contain sid/len)
102      */

103
104     public TextRecord(short id, short size, byte [] data)
105     {
106         super(id, size, data);
107     
108     }
109
110     /**
111      * Constructs a Text record and sets its fields appropriately.
112      *
113      * @param id id must be 0x1025 or an exception
114      * will be throw upon validation
115      * @param size size the size of the data area of the record
116      * @param data data of the record (should not contain sid/len)
117      * @param offset of the record's data
118      */

119
120     public TextRecord(short id, short size, byte [] data, int offset)
121     {
122         super(id, size, data, offset);
123     
124     }
125
126     /**
127      * Checks the sid matches the expected side for this record
128      *
129      * @param id the expected sid.
130      */

131     protected void validateSid(short id)
132     {
133         if (id != sid)
134         {
135             throw new RecordFormatException("Not a Text record");
136         }
137     }
138
139     protected void fillFields(byte [] data, short size, int offset)
140     {
141
142         int pos = 0;
143         field_1_horizontalAlignment = data[ pos + 0x0 + offset ];
144         field_2_verticalAlignment = data[ pos + 0x1 + offset ];
145         field_3_displayMode = LittleEndian.getShort(data, pos + 0x2 + offset);
146         field_4_rgbColor = LittleEndian.getInt(data, pos + 0x4 + offset);
147         field_5_x = LittleEndian.getInt(data, pos + 0x8 + offset);
148         field_6_y = LittleEndian.getInt(data, pos + 0xc + offset);
149         field_7_width = LittleEndian.getInt(data, pos + 0x10 + offset);
150         field_8_height = LittleEndian.getInt(data, pos + 0x14 + offset);
151         field_9_options1 = LittleEndian.getShort(data, pos + 0x18 + offset);
152         field_10_indexOfColorValue = LittleEndian.getShort(data, pos + 0x1a + offset);
153         field_11_options2 = LittleEndian.getShort(data, pos + 0x1c + offset);
154         field_12_textRotation = LittleEndian.getShort(data, pos + 0x1e + offset);
155
156     }
157
158     public String JavaDoc toString()
159     {
160         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
161
162         buffer.append("[TEXT]\n");
163         buffer.append(" .horizontalAlignment = ")
164             .append("0x").append(HexDump.toHex( getHorizontalAlignment ()))
165             .append(" (").append( getHorizontalAlignment() ).append(" )");
166         buffer.append(System.getProperty("line.separator"));
167         buffer.append(" .verticalAlignment = ")
168             .append("0x").append(HexDump.toHex( getVerticalAlignment ()))
169             .append(" (").append( getVerticalAlignment() ).append(" )");
170         buffer.append(System.getProperty("line.separator"));
171         buffer.append(" .displayMode = ")
172             .append("0x").append(HexDump.toHex( getDisplayMode ()))
173             .append(" (").append( getDisplayMode() ).append(" )");
174         buffer.append(System.getProperty("line.separator"));
175         buffer.append(" .rgbColor = ")
176             .append("0x").append(HexDump.toHex( getRgbColor ()))
177             .append(" (").append( getRgbColor() ).append(" )");
178         buffer.append(System.getProperty("line.separator"));
179         buffer.append(" .x = ")
180             .append("0x").append(HexDump.toHex( getX ()))
181             .append(" (").append( getX() ).append(" )");
182         buffer.append(System.getProperty("line.separator"));
183         buffer.append(" .y = ")
184             .append("0x").append(HexDump.toHex( getY ()))
185             .append(" (").append( getY() ).append(" )");
186         buffer.append(System.getProperty("line.separator"));
187         buffer.append(" .width = ")
188             .append("0x").append(HexDump.toHex( getWidth ()))
189             .append(" (").append( getWidth() ).append(" )");
190         buffer.append(System.getProperty("line.separator"));
191         buffer.append(" .height = ")
192             .append("0x").append(HexDump.toHex( getHeight ()))
193             .append(" (").append( getHeight() ).append(" )");
194         buffer.append(System.getProperty("line.separator"));
195         buffer.append(" .options1 = ")
196             .append("0x").append(HexDump.toHex( getOptions1 ()))
197             .append(" (").append( getOptions1() ).append(" )");
198         buffer.append(System.getProperty("line.separator"));
199         buffer.append(" .autoColor = ").append(isAutoColor()).append('\n');
200         buffer.append(" .showKey = ").append(isShowKey()).append('\n');
201         buffer.append(" .showValue = ").append(isShowValue()).append('\n');
202         buffer.append(" .vertical = ").append(isVertical()).append('\n');
203         buffer.append(" .autoGeneratedText = ").append(isAutoGeneratedText()).append('\n');
204         buffer.append(" .generated = ").append(isGenerated()).append('\n');
205         buffer.append(" .autoLabelDeleted = ").append(isAutoLabelDeleted()).append('\n');
206         buffer.append(" .autoBackground = ").append(isAutoBackground()).append('\n');
207             buffer.append(" .rotation = ").append(getRotation()).append('\n');
208         buffer.append(" .showCategoryLabelAsPercentage = ").append(isShowCategoryLabelAsPercentage()).append('\n');
209         buffer.append(" .showValueAsPercentage = ").append(isShowValueAsPercentage()).append('\n');
210         buffer.append(" .showBubbleSizes = ").append(isShowBubbleSizes()).append('\n');
211         buffer.append(" .showLabel = ").append(isShowLabel()).append('\n');
212         buffer.append(" .indexOfColorValue = ")
213             .append("0x").append(HexDump.toHex( getIndexOfColorValue ()))
214             .append(" (").append( getIndexOfColorValue() ).append(" )");
215         buffer.append(System.getProperty("line.separator"));
216         buffer.append(" .options2 = ")
217             .append("0x").append(HexDump.toHex( getOptions2 ()))
218             .append(" (").append( getOptions2() ).append(" )");
219         buffer.append(System.getProperty("line.separator"));
220             buffer.append(" .dataLabelPlacement = ").append(getDataLabelPlacement()).append('\n');
221         buffer.append(" .textRotation = ")
222             .append("0x").append(HexDump.toHex( getTextRotation ()))
223             .append(" (").append( getTextRotation() ).append(" )");
224         buffer.append(System.getProperty("line.separator"));
225
226         buffer.append("[/TEXT]\n");
227         return buffer.toString();
228     }
229
230     public int serialize(int offset, byte[] data)
231     {
232         int pos = 0;
233
234         LittleEndian.putShort(data, 0 + offset, sid);
235         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
236
237         data[ 4 + offset + pos ] = field_1_horizontalAlignment;
238         data[ 5 + offset + pos ] = field_2_verticalAlignment;
239         LittleEndian.putShort(data, 6 + offset + pos, field_3_displayMode);
240         LittleEndian.putInt(data, 8 + offset + pos, field_4_rgbColor);
241         LittleEndian.putInt(data, 12 + offset + pos, field_5_x);
242         LittleEndian.putInt(data, 16 + offset + pos, field_6_y);
243         LittleEndian.putInt(data, 20 + offset + pos, field_7_width);
244         LittleEndian.putInt(data, 24 + offset + pos, field_8_height);
245         LittleEndian.putShort(data, 28 + offset + pos, field_9_options1);
246         LittleEndian.putShort(data, 30 + offset + pos, field_10_indexOfColorValue);
247         LittleEndian.putShort(data, 32 + offset + pos, field_11_options2);
248         LittleEndian.putShort(data, 34 + offset + pos, field_12_textRotation);
249
250         return getRecordSize();
251     }
252
253     /**
254      * Size of record (exluding 4 byte header)
255      */

256     public int getRecordSize()
257     {
258         return 4 + 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
259     }
260
261     public short getSid()
262     {
263         return this.sid;
264     }
265
266     public Object JavaDoc clone() {
267         TextRecord rec = new TextRecord();
268     
269         rec.field_1_horizontalAlignment = field_1_horizontalAlignment;
270         rec.field_2_verticalAlignment = field_2_verticalAlignment;
271         rec.field_3_displayMode = field_3_displayMode;
272         rec.field_4_rgbColor = field_4_rgbColor;
273         rec.field_5_x = field_5_x;
274         rec.field_6_y = field_6_y;
275         rec.field_7_width = field_7_width;
276         rec.field_8_height = field_8_height;
277         rec.field_9_options1 = field_9_options1;
278         rec.field_10_indexOfColorValue = field_10_indexOfColorValue;
279         rec.field_11_options2 = field_11_options2;
280         rec.field_12_textRotation = field_12_textRotation;
281         return rec;
282     }
283
284
285
286
287     /**
288      * Get the horizontal alignment field for the Text record.
289      *
290      * @return One of
291      * HORIZONTAL_ALIGNMENT_LEFT
292      * HORIZONTAL_ALIGNMENT_CENTER
293      * HORIZONTAL_ALIGNMENT_BOTTOM
294      * HORIZONTAL_ALIGNMENT_JUSTIFY
295      */

296     public byte getHorizontalAlignment()
297     {
298         return field_1_horizontalAlignment;
299     }
300
301     /**
302      * Set the horizontal alignment field for the Text record.
303      *
304      * @param field_1_horizontalAlignment
305      * One of
306      * HORIZONTAL_ALIGNMENT_LEFT
307      * HORIZONTAL_ALIGNMENT_CENTER
308      * HORIZONTAL_ALIGNMENT_BOTTOM
309      * HORIZONTAL_ALIGNMENT_JUSTIFY
310      */

311     public void setHorizontalAlignment(byte field_1_horizontalAlignment)
312     {
313         this.field_1_horizontalAlignment = field_1_horizontalAlignment;
314     }
315
316     /**
317      * Get the vertical alignment field for the Text record.
318      *
319      * @return One of
320      * VERTICAL_ALIGNMENT_TOP
321      * VERTICAL_ALIGNMENT_CENTER
322      * VERTICAL_ALIGNMENT_BOTTOM
323      * VERTICAL_ALIGNMENT_JUSTIFY
324      */

325     public byte getVerticalAlignment()
326     {
327         return field_2_verticalAlignment;
328     }
329
330     /**
331      * Set the vertical alignment field for the Text record.
332      *
333      * @param field_2_verticalAlignment
334      * One of
335      * VERTICAL_ALIGNMENT_TOP
336      * VERTICAL_ALIGNMENT_CENTER
337      * VERTICAL_ALIGNMENT_BOTTOM
338      * VERTICAL_ALIGNMENT_JUSTIFY
339      */

340     public void setVerticalAlignment(byte field_2_verticalAlignment)
341     {
342         this.field_2_verticalAlignment = field_2_verticalAlignment;
343     }
344
345     /**
346      * Get the display mode field for the Text record.
347      *
348      * @return One of
349      * DISPLAY_MODE_TRANSPARENT
350      * DISPLAY_MODE_OPAQUE
351      */

352     public short getDisplayMode()
353     {
354         return field_3_displayMode;
355     }
356
357     /**
358      * Set the display mode field for the Text record.
359      *
360      * @param field_3_displayMode
361      * One of
362      * DISPLAY_MODE_TRANSPARENT
363      * DISPLAY_MODE_OPAQUE
364      */

365     public void setDisplayMode(short field_3_displayMode)
366     {
367         this.field_3_displayMode = field_3_displayMode;
368     }
369
370     /**
371      * Get the rgbColor field for the Text record.
372      */

373     public int getRgbColor()
374     {
375         return field_4_rgbColor;
376     }
377
378     /**
379      * Set the rgbColor field for the Text record.
380      */

381     public void setRgbColor(int field_4_rgbColor)
382     {
383         this.field_4_rgbColor = field_4_rgbColor;
384     }
385
386     /**
387      * Get the x field for the Text record.
388      */

389     public int getX()
390     {
391         return field_5_x;
392     }
393
394     /**
395      * Set the x field for the Text record.
396      */

397     public void setX(int field_5_x)
398     {
399         this.field_5_x = field_5_x;
400     }
401
402     /**
403      * Get the y field for the Text record.
404      */

405     public int getY()
406     {
407         return field_6_y;
408     }
409
410     /**
411      * Set the y field for the Text record.
412      */

413     public void setY(int field_6_y)
414     {
415         this.field_6_y = field_6_y;
416     }
417
418     /**
419      * Get the width field for the Text record.
420      */

421     public int getWidth()
422     {
423         return field_7_width;
424     }
425
426     /**
427      * Set the width field for the Text record.
428      */

429     public void setWidth(int field_7_width)
430     {
431         this.field_7_width = field_7_width;
432     }
433
434     /**
435      * Get the height field for the Text record.
436      */

437     public int getHeight()
438     {
439         return field_8_height;
440     }
441
442     /**
443      * Set the height field for the Text record.
444      */

445     public void setHeight(int field_8_height)
446     {
447         this.field_8_height = field_8_height;
448     }
449
450     /**
451      * Get the options1 field for the Text record.
452      */

453     public short getOptions1()
454     {
455         return field_9_options1;
456     }
457
458     /**
459      * Set the options1 field for the Text record.
460      */

461     public void setOptions1(short field_9_options1)
462     {
463         this.field_9_options1 = field_9_options1;
464     }
465
466     /**
467      * Get the index of color value field for the Text record.
468      */

469     public short getIndexOfColorValue()
470     {
471         return field_10_indexOfColorValue;
472     }
473
474     /**
475      * Set the index of color value field for the Text record.
476      */

477     public void setIndexOfColorValue(short field_10_indexOfColorValue)
478     {
479         this.field_10_indexOfColorValue = field_10_indexOfColorValue;
480     }
481
482     /**
483      * Get the options2 field for the Text record.
484      */

485     public short getOptions2()
486     {
487         return field_11_options2;
488     }
489
490     /**
491      * Set the options2 field for the Text record.
492      */

493     public void setOptions2(short field_11_options2)
494     {
495         this.field_11_options2 = field_11_options2;
496     }
497
498     /**
499      * Get the text rotation field for the Text record.
500      */

501     public short getTextRotation()
502     {
503         return field_12_textRotation;
504     }
505
506     /**
507      * Set the text rotation field for the Text record.
508      */

509     public void setTextRotation(short field_12_textRotation)
510     {
511         this.field_12_textRotation = field_12_textRotation;
512     }
513
514     /**
515      * Sets the auto color field value.
516      * true = automaticly selected colour, false = user-selected
517      */

518     public void setAutoColor(boolean value)
519     {
520         field_9_options1 = autoColor.setShortBoolean(field_9_options1, value);
521     }
522
523     /**
524      * true = automaticly selected colour, false = user-selected
525      * @return the auto color field value.
526      */

527     public boolean isAutoColor()
528     {
529         return autoColor.isSet(field_9_options1);
530     }
531
532     /**
533      * Sets the show key field value.
534      * true = draw legend
535      */

536     public void setShowKey(boolean value)
537     {
538         field_9_options1 = showKey.setShortBoolean(field_9_options1, value);
539     }
540
541     /**
542      * true = draw legend
543      * @return the show key field value.
544      */

545     public boolean isShowKey()
546     {
547         return showKey.isSet(field_9_options1);
548     }
549
550     /**
551      * Sets the show value field value.
552      * false = text is category label
553      */

554     public void setShowValue(boolean value)
555     {
556         field_9_options1 = showValue.setShortBoolean(field_9_options1, value);
557     }
558
559     /**
560      * false = text is category label
561      * @return the show value field value.
562      */

563     public boolean isShowValue()
564     {
565         return showValue.isSet(field_9_options1);
566     }
567
568     /**
569      * Sets the vertical field value.
570      * true = text is vertical
571      */

572     public void setVertical(boolean value)
573     {
574         field_9_options1 = vertical.setShortBoolean(field_9_options1, value);
575     }
576
577     /**
578      * true = text is vertical
579      * @return the vertical field value.
580      */

581     public boolean isVertical()
582     {
583         return vertical.isSet(field_9_options1);
584     }
585
586     /**
587      * Sets the auto generated text field value.
588      *
589      */

590     public void setAutoGeneratedText(boolean value)
591     {
592         field_9_options1 = autoGeneratedText.setShortBoolean(field_9_options1, value);
593     }
594
595     /**
596      *
597      * @return the auto generated text field value.
598      */

599     public boolean isAutoGeneratedText()
600     {
601         return autoGeneratedText.isSet(field_9_options1);
602     }
603
604     /**
605      * Sets the generated field value.
606      *
607      */

608     public void setGenerated(boolean value)
609     {
610         field_9_options1 = generated.setShortBoolean(field_9_options1, value);
611     }
612
613     /**
614      *
615      * @return the generated field value.
616      */

617     public boolean isGenerated()
618     {
619         return generated.isSet(field_9_options1);
620     }
621
622     /**
623      * Sets the auto label deleted field value.
624      *
625      */

626     public void setAutoLabelDeleted(boolean value)
627     {
628         field_9_options1 = autoLabelDeleted.setShortBoolean(field_9_options1, value);
629     }
630
631     /**
632      *
633      * @return the auto label deleted field value.
634      */

635     public boolean isAutoLabelDeleted()
636     {
637         return autoLabelDeleted.isSet(field_9_options1);
638     }
639
640     /**
641      * Sets the auto background field value.
642      *
643      */

644     public void setAutoBackground(boolean value)
645     {
646         field_9_options1 = autoBackground.setShortBoolean(field_9_options1, value);
647     }
648
649     /**
650      *
651      * @return the auto background field value.
652      */

653     public boolean isAutoBackground()
654     {
655         return autoBackground.isSet(field_9_options1);
656     }
657
658     /**
659      * Sets the rotation field value.
660      *
661      */

662     public void setRotation(short value)
663     {
664         field_9_options1 = rotation.setShortValue(field_9_options1, value);
665     }
666
667     /**
668      *
669      * @return the rotation field value.
670      */

671     public short getRotation()
672     {
673         return rotation.getShortValue(field_9_options1);
674     }
675
676     /**
677      * Sets the show category label as percentage field value.
678      *
679      */

680     public void setShowCategoryLabelAsPercentage(boolean value)
681     {
682         field_9_options1 = showCategoryLabelAsPercentage.setShortBoolean(field_9_options1, value);
683     }
684
685     /**
686      *
687      * @return the show category label as percentage field value.
688      */

689     public boolean isShowCategoryLabelAsPercentage()
690     {
691         return showCategoryLabelAsPercentage.isSet(field_9_options1);
692     }
693
694     /**
695      * Sets the show value as percentage field value.
696      *
697      */

698     public void setShowValueAsPercentage(boolean value)
699     {
700         field_9_options1 = showValueAsPercentage.setShortBoolean(field_9_options1, value);
701     }
702
703     /**
704      *
705      * @return the show value as percentage field value.
706      */

707     public boolean isShowValueAsPercentage()
708     {
709         return showValueAsPercentage.isSet(field_9_options1);
710     }
711
712     /**
713      * Sets the show bubble sizes field value.
714      *
715      */

716     public void setShowBubbleSizes(boolean value)
717     {
718         field_9_options1 = showBubbleSizes.setShortBoolean(field_9_options1, value);
719     }
720
721     /**
722      *
723      * @return the show bubble sizes field value.
724      */

725     public boolean isShowBubbleSizes()
726     {
727         return showBubbleSizes.isSet(field_9_options1);
728     }
729
730     /**
731      * Sets the show label field value.
732      *
733      */

734     public void setShowLabel(boolean value)
735     {
736         field_9_options1 = showLabel.setShortBoolean(field_9_options1, value);
737     }
738
739     /**
740      *
741      * @return the show label field value.
742      */

743     public boolean isShowLabel()
744     {
745         return showLabel.isSet(field_9_options1);
746     }
747
748     /**
749      * Sets the data label placement field value.
750      *
751      */

752     public void setDataLabelPlacement(short value)
753     {
754         field_11_options2 = dataLabelPlacement.setShortValue(field_11_options2, value);
755     }
756
757     /**
758      *
759      * @return the data label placement field value.
760      */

761     public short getDataLabelPlacement()
762     {
763         return dataLabelPlacement.getShortValue(field_11_options2);
764     }
765
766
767 } // END OF CLASS
768

769
770
771
772
Popular Tags