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 text record is used to define text stored on a chart.
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 TextRecord extends Record {
030: public final static short sid = 0x1025;
031: private byte field_1_horizontalAlignment;
032: public final static byte HORIZONTAL_ALIGNMENT_LEFT = 1;
033: public final static byte HORIZONTAL_ALIGNMENT_CENTER = 2;
034: public final static byte HORIZONTAL_ALIGNMENT_BOTTOM = 3;
035: public final static byte HORIZONTAL_ALIGNMENT_JUSTIFY = 4;
036: private byte field_2_verticalAlignment;
037: public final static byte VERTICAL_ALIGNMENT_TOP = 1;
038: public final static byte VERTICAL_ALIGNMENT_CENTER = 2;
039: public final static byte VERTICAL_ALIGNMENT_BOTTOM = 3;
040: public final static byte VERTICAL_ALIGNMENT_JUSTIFY = 4;
041: private short field_3_displayMode;
042: public final static short DISPLAY_MODE_TRANSPARENT = 1;
043: public final static short DISPLAY_MODE_OPAQUE = 2;
044: private int field_4_rgbColor;
045: private int field_5_x;
046: private int field_6_y;
047: private int field_7_width;
048: private int field_8_height;
049: private short field_9_options1;
050: private BitField autoColor = BitFieldFactory.getInstance(0x1);
051: private BitField showKey = BitFieldFactory.getInstance(0x2);
052: private BitField showValue = BitFieldFactory.getInstance(0x4);
053: private BitField vertical = BitFieldFactory.getInstance(0x8);
054: private BitField autoGeneratedText = BitFieldFactory
055: .getInstance(0x10);
056: private BitField generated = BitFieldFactory.getInstance(0x20);
057: private BitField autoLabelDeleted = BitFieldFactory
058: .getInstance(0x40);
059: private BitField autoBackground = BitFieldFactory.getInstance(0x80);
060: private BitField rotation = BitFieldFactory.getInstance(0x0700);
061: public final static short ROTATION_NONE = 0;
062: public final static short ROTATION_TOP_TO_BOTTOM = 1;
063: public final static short ROTATION_ROTATED_90_DEGREES = 2;
064: public final static short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
065: private BitField showCategoryLabelAsPercentage = BitFieldFactory
066: .getInstance(0x800);
067: private BitField showValueAsPercentage = BitFieldFactory
068: .getInstance(0x1000);
069: private BitField showBubbleSizes = BitFieldFactory
070: .getInstance(0x2000);
071: private BitField showLabel = BitFieldFactory.getInstance(0x4000);
072: private short field_10_indexOfColorValue;
073: private short field_11_options2;
074: private BitField dataLabelPlacement = BitFieldFactory
075: .getInstance(0x000F);
076: public final static short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
077: public final static short DATA_LABEL_PLACEMENT_OUTSIDE = 1;
078: public final static short DATA_LABEL_PLACEMENT_INSIDE = 2;
079: public final static short DATA_LABEL_PLACEMENT_CENTER = 3;
080: public final static short DATA_LABEL_PLACEMENT_AXIS = 4;
081: public final static short DATA_LABEL_PLACEMENT_ABOVE = 5;
082: public final static short DATA_LABEL_PLACEMENT_BELOW = 6;
083: public final static short DATA_LABEL_PLACEMENT_LEFT = 7;
084: public final static short DATA_LABEL_PLACEMENT_RIGHT = 8;
085: public final static short DATA_LABEL_PLACEMENT_AUTO = 9;
086: public final static short DATA_LABEL_PLACEMENT_USER_MOVED = 10;
087: private short field_12_textRotation;
088:
089: public TextRecord() {
090:
091: }
092:
093: /**
094: * Constructs a Text record and sets its fields appropriately.
095: *
096: * @param in the RecordInputstream to read the record from
097: */
098:
099: public TextRecord(RecordInputStream in) {
100: super (in);
101:
102: }
103:
104: /**
105: * Checks the sid matches the expected side for this record
106: *
107: * @param id the expected sid.
108: */
109: protected void validateSid(short id) {
110: if (id != sid) {
111: throw new RecordFormatException("Not a Text record");
112: }
113: }
114:
115: protected void fillFields(RecordInputStream in) {
116: field_1_horizontalAlignment = in.readByte();
117: field_2_verticalAlignment = in.readByte();
118: field_3_displayMode = in.readShort();
119: field_4_rgbColor = in.readInt();
120: field_5_x = in.readInt();
121: field_6_y = in.readInt();
122: field_7_width = in.readInt();
123: field_8_height = in.readInt();
124: field_9_options1 = in.readShort();
125: field_10_indexOfColorValue = in.readShort();
126: field_11_options2 = in.readShort();
127: field_12_textRotation = in.readShort();
128: }
129:
130: public String toString() {
131: StringBuffer buffer = new StringBuffer();
132:
133: buffer.append("[TEXT]\n");
134: buffer.append(" .horizontalAlignment = ").append("0x")
135: .append(HexDump.toHex(getHorizontalAlignment()))
136: .append(" (").append(getHorizontalAlignment()).append(
137: " )");
138: buffer.append(System.getProperty("line.separator"));
139: buffer.append(" .verticalAlignment = ").append("0x")
140: .append(HexDump.toHex(getVerticalAlignment())).append(
141: " (").append(getVerticalAlignment()).append(
142: " )");
143: buffer.append(System.getProperty("line.separator"));
144: buffer.append(" .displayMode = ").append("0x")
145: .append(HexDump.toHex(getDisplayMode())).append(" (")
146: .append(getDisplayMode()).append(" )");
147: buffer.append(System.getProperty("line.separator"));
148: buffer.append(" .rgbColor = ").append("0x")
149: .append(HexDump.toHex(getRgbColor())).append(" (")
150: .append(getRgbColor()).append(" )");
151: buffer.append(System.getProperty("line.separator"));
152: buffer.append(" .x = ").append("0x")
153: .append(HexDump.toHex(getX())).append(" (").append(
154: getX()).append(" )");
155: buffer.append(System.getProperty("line.separator"));
156: buffer.append(" .y = ").append("0x")
157: .append(HexDump.toHex(getY())).append(" (").append(
158: getY()).append(" )");
159: buffer.append(System.getProperty("line.separator"));
160: buffer.append(" .width = ").append("0x")
161: .append(HexDump.toHex(getWidth())).append(" (").append(
162: getWidth()).append(" )");
163: buffer.append(System.getProperty("line.separator"));
164: buffer.append(" .height = ").append("0x")
165: .append(HexDump.toHex(getHeight())).append(" (")
166: .append(getHeight()).append(" )");
167: buffer.append(System.getProperty("line.separator"));
168: buffer.append(" .options1 = ").append("0x")
169: .append(HexDump.toHex(getOptions1())).append(" (")
170: .append(getOptions1()).append(" )");
171: buffer.append(System.getProperty("line.separator"));
172: buffer.append(" .autoColor = ").append(
173: isAutoColor()).append('\n');
174: buffer.append(" .showKey = ").append(
175: isShowKey()).append('\n');
176: buffer.append(" .showValue = ").append(
177: isShowValue()).append('\n');
178: buffer.append(" .vertical = ").append(
179: isVertical()).append('\n');
180: buffer.append(" .autoGeneratedText = ").append(
181: isAutoGeneratedText()).append('\n');
182: buffer.append(" .generated = ").append(
183: isGenerated()).append('\n');
184: buffer.append(" .autoLabelDeleted = ").append(
185: isAutoLabelDeleted()).append('\n');
186: buffer.append(" .autoBackground = ").append(
187: isAutoBackground()).append('\n');
188: buffer.append(" .rotation = ").append(
189: getRotation()).append('\n');
190: buffer.append(" .showCategoryLabelAsPercentage = ")
191: .append(isShowCategoryLabelAsPercentage()).append('\n');
192: buffer.append(" .showValueAsPercentage = ").append(
193: isShowValueAsPercentage()).append('\n');
194: buffer.append(" .showBubbleSizes = ").append(
195: isShowBubbleSizes()).append('\n');
196: buffer.append(" .showLabel = ").append(
197: isShowLabel()).append('\n');
198: buffer.append(" .indexOfColorValue = ").append("0x")
199: .append(HexDump.toHex(getIndexOfColorValue())).append(
200: " (").append(getIndexOfColorValue()).append(
201: " )");
202: buffer.append(System.getProperty("line.separator"));
203: buffer.append(" .options2 = ").append("0x")
204: .append(HexDump.toHex(getOptions2())).append(" (")
205: .append(getOptions2()).append(" )");
206: buffer.append(System.getProperty("line.separator"));
207: buffer.append(" .dataLabelPlacement = ").append(
208: getDataLabelPlacement()).append('\n');
209: buffer.append(" .textRotation = ").append("0x")
210: .append(HexDump.toHex(getTextRotation())).append(" (")
211: .append(getTextRotation()).append(" )");
212: buffer.append(System.getProperty("line.separator"));
213:
214: buffer.append("[/TEXT]\n");
215: return buffer.toString();
216: }
217:
218: public int serialize(int offset, byte[] data) {
219: int pos = 0;
220:
221: LittleEndian.putShort(data, 0 + offset, sid);
222: LittleEndian.putShort(data, 2 + offset,
223: (short) (getRecordSize() - 4));
224:
225: data[4 + offset + pos] = field_1_horizontalAlignment;
226: data[5 + offset + pos] = field_2_verticalAlignment;
227: LittleEndian.putShort(data, 6 + offset + pos,
228: field_3_displayMode);
229: LittleEndian.putInt(data, 8 + offset + pos, field_4_rgbColor);
230: LittleEndian.putInt(data, 12 + offset + pos, field_5_x);
231: LittleEndian.putInt(data, 16 + offset + pos, field_6_y);
232: LittleEndian.putInt(data, 20 + offset + pos, field_7_width);
233: LittleEndian.putInt(data, 24 + offset + pos, field_8_height);
234: LittleEndian
235: .putShort(data, 28 + offset + pos, field_9_options1);
236: LittleEndian.putShort(data, 30 + offset + pos,
237: field_10_indexOfColorValue);
238: LittleEndian.putShort(data, 32 + offset + pos,
239: field_11_options2);
240: LittleEndian.putShort(data, 34 + offset + pos,
241: field_12_textRotation);
242:
243: return getRecordSize();
244: }
245:
246: /**
247: * Size of record (exluding 4 byte header)
248: */
249: public int getRecordSize() {
250: return 4 + 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;
251: }
252:
253: public short getSid() {
254: return sid;
255: }
256:
257: public Object clone() {
258: TextRecord rec = new TextRecord();
259:
260: rec.field_1_horizontalAlignment = field_1_horizontalAlignment;
261: rec.field_2_verticalAlignment = field_2_verticalAlignment;
262: rec.field_3_displayMode = field_3_displayMode;
263: rec.field_4_rgbColor = field_4_rgbColor;
264: rec.field_5_x = field_5_x;
265: rec.field_6_y = field_6_y;
266: rec.field_7_width = field_7_width;
267: rec.field_8_height = field_8_height;
268: rec.field_9_options1 = field_9_options1;
269: rec.field_10_indexOfColorValue = field_10_indexOfColorValue;
270: rec.field_11_options2 = field_11_options2;
271: rec.field_12_textRotation = field_12_textRotation;
272: return rec;
273: }
274:
275: /**
276: * Get the horizontal alignment field for the Text record.
277: *
278: * @return One of
279: * HORIZONTAL_ALIGNMENT_LEFT
280: * HORIZONTAL_ALIGNMENT_CENTER
281: * HORIZONTAL_ALIGNMENT_BOTTOM
282: * HORIZONTAL_ALIGNMENT_JUSTIFY
283: */
284: public byte getHorizontalAlignment() {
285: return field_1_horizontalAlignment;
286: }
287:
288: /**
289: * Set the horizontal alignment field for the Text record.
290: *
291: * @param field_1_horizontalAlignment
292: * One of
293: * HORIZONTAL_ALIGNMENT_LEFT
294: * HORIZONTAL_ALIGNMENT_CENTER
295: * HORIZONTAL_ALIGNMENT_BOTTOM
296: * HORIZONTAL_ALIGNMENT_JUSTIFY
297: */
298: public void setHorizontalAlignment(byte field_1_horizontalAlignment) {
299: this .field_1_horizontalAlignment = field_1_horizontalAlignment;
300: }
301:
302: /**
303: * Get the vertical alignment field for the Text record.
304: *
305: * @return One of
306: * VERTICAL_ALIGNMENT_TOP
307: * VERTICAL_ALIGNMENT_CENTER
308: * VERTICAL_ALIGNMENT_BOTTOM
309: * VERTICAL_ALIGNMENT_JUSTIFY
310: */
311: public byte getVerticalAlignment() {
312: return field_2_verticalAlignment;
313: }
314:
315: /**
316: * Set the vertical alignment field for the Text record.
317: *
318: * @param field_2_verticalAlignment
319: * One of
320: * VERTICAL_ALIGNMENT_TOP
321: * VERTICAL_ALIGNMENT_CENTER
322: * VERTICAL_ALIGNMENT_BOTTOM
323: * VERTICAL_ALIGNMENT_JUSTIFY
324: */
325: public void setVerticalAlignment(byte field_2_verticalAlignment) {
326: this .field_2_verticalAlignment = field_2_verticalAlignment;
327: }
328:
329: /**
330: * Get the display mode field for the Text record.
331: *
332: * @return One of
333: * DISPLAY_MODE_TRANSPARENT
334: * DISPLAY_MODE_OPAQUE
335: */
336: public short getDisplayMode() {
337: return field_3_displayMode;
338: }
339:
340: /**
341: * Set the display mode field for the Text record.
342: *
343: * @param field_3_displayMode
344: * One of
345: * DISPLAY_MODE_TRANSPARENT
346: * DISPLAY_MODE_OPAQUE
347: */
348: public void setDisplayMode(short field_3_displayMode) {
349: this .field_3_displayMode = field_3_displayMode;
350: }
351:
352: /**
353: * Get the rgbColor field for the Text record.
354: */
355: public int getRgbColor() {
356: return field_4_rgbColor;
357: }
358:
359: /**
360: * Set the rgbColor field for the Text record.
361: */
362: public void setRgbColor(int field_4_rgbColor) {
363: this .field_4_rgbColor = field_4_rgbColor;
364: }
365:
366: /**
367: * Get the x field for the Text record.
368: */
369: public int getX() {
370: return field_5_x;
371: }
372:
373: /**
374: * Set the x field for the Text record.
375: */
376: public void setX(int field_5_x) {
377: this .field_5_x = field_5_x;
378: }
379:
380: /**
381: * Get the y field for the Text record.
382: */
383: public int getY() {
384: return field_6_y;
385: }
386:
387: /**
388: * Set the y field for the Text record.
389: */
390: public void setY(int field_6_y) {
391: this .field_6_y = field_6_y;
392: }
393:
394: /**
395: * Get the width field for the Text record.
396: */
397: public int getWidth() {
398: return field_7_width;
399: }
400:
401: /**
402: * Set the width field for the Text record.
403: */
404: public void setWidth(int field_7_width) {
405: this .field_7_width = field_7_width;
406: }
407:
408: /**
409: * Get the height field for the Text record.
410: */
411: public int getHeight() {
412: return field_8_height;
413: }
414:
415: /**
416: * Set the height field for the Text record.
417: */
418: public void setHeight(int field_8_height) {
419: this .field_8_height = field_8_height;
420: }
421:
422: /**
423: * Get the options1 field for the Text record.
424: */
425: public short getOptions1() {
426: return field_9_options1;
427: }
428:
429: /**
430: * Set the options1 field for the Text record.
431: */
432: public void setOptions1(short field_9_options1) {
433: this .field_9_options1 = field_9_options1;
434: }
435:
436: /**
437: * Get the index of color value field for the Text record.
438: */
439: public short getIndexOfColorValue() {
440: return field_10_indexOfColorValue;
441: }
442:
443: /**
444: * Set the index of color value field for the Text record.
445: */
446: public void setIndexOfColorValue(short field_10_indexOfColorValue) {
447: this .field_10_indexOfColorValue = field_10_indexOfColorValue;
448: }
449:
450: /**
451: * Get the options2 field for the Text record.
452: */
453: public short getOptions2() {
454: return field_11_options2;
455: }
456:
457: /**
458: * Set the options2 field for the Text record.
459: */
460: public void setOptions2(short field_11_options2) {
461: this .field_11_options2 = field_11_options2;
462: }
463:
464: /**
465: * Get the text rotation field for the Text record.
466: */
467: public short getTextRotation() {
468: return field_12_textRotation;
469: }
470:
471: /**
472: * Set the text rotation field for the Text record.
473: */
474: public void setTextRotation(short field_12_textRotation) {
475: this .field_12_textRotation = field_12_textRotation;
476: }
477:
478: /**
479: * Sets the auto color field value.
480: * true = automaticly selected colour, false = user-selected
481: */
482: public void setAutoColor(boolean value) {
483: field_9_options1 = autoColor.setShortBoolean(field_9_options1,
484: value);
485: }
486:
487: /**
488: * true = automaticly selected colour, false = user-selected
489: * @return the auto color field value.
490: */
491: public boolean isAutoColor() {
492: return autoColor.isSet(field_9_options1);
493: }
494:
495: /**
496: * Sets the show key field value.
497: * true = draw legend
498: */
499: public void setShowKey(boolean value) {
500: field_9_options1 = showKey.setShortBoolean(field_9_options1,
501: value);
502: }
503:
504: /**
505: * true = draw legend
506: * @return the show key field value.
507: */
508: public boolean isShowKey() {
509: return showKey.isSet(field_9_options1);
510: }
511:
512: /**
513: * Sets the show value field value.
514: * false = text is category label
515: */
516: public void setShowValue(boolean value) {
517: field_9_options1 = showValue.setShortBoolean(field_9_options1,
518: value);
519: }
520:
521: /**
522: * false = text is category label
523: * @return the show value field value.
524: */
525: public boolean isShowValue() {
526: return showValue.isSet(field_9_options1);
527: }
528:
529: /**
530: * Sets the vertical field value.
531: * true = text is vertical
532: */
533: public void setVertical(boolean value) {
534: field_9_options1 = vertical.setShortBoolean(field_9_options1,
535: value);
536: }
537:
538: /**
539: * true = text is vertical
540: * @return the vertical field value.
541: */
542: public boolean isVertical() {
543: return vertical.isSet(field_9_options1);
544: }
545:
546: /**
547: * Sets the auto generated text field value.
548: *
549: */
550: public void setAutoGeneratedText(boolean value) {
551: field_9_options1 = autoGeneratedText.setShortBoolean(
552: field_9_options1, value);
553: }
554:
555: /**
556: *
557: * @return the auto generated text field value.
558: */
559: public boolean isAutoGeneratedText() {
560: return autoGeneratedText.isSet(field_9_options1);
561: }
562:
563: /**
564: * Sets the generated field value.
565: *
566: */
567: public void setGenerated(boolean value) {
568: field_9_options1 = generated.setShortBoolean(field_9_options1,
569: value);
570: }
571:
572: /**
573: *
574: * @return the generated field value.
575: */
576: public boolean isGenerated() {
577: return generated.isSet(field_9_options1);
578: }
579:
580: /**
581: * Sets the auto label deleted field value.
582: *
583: */
584: public void setAutoLabelDeleted(boolean value) {
585: field_9_options1 = autoLabelDeleted.setShortBoolean(
586: field_9_options1, value);
587: }
588:
589: /**
590: *
591: * @return the auto label deleted field value.
592: */
593: public boolean isAutoLabelDeleted() {
594: return autoLabelDeleted.isSet(field_9_options1);
595: }
596:
597: /**
598: * Sets the auto background field value.
599: *
600: */
601: public void setAutoBackground(boolean value) {
602: field_9_options1 = autoBackground.setShortBoolean(
603: field_9_options1, value);
604: }
605:
606: /**
607: *
608: * @return the auto background field value.
609: */
610: public boolean isAutoBackground() {
611: return autoBackground.isSet(field_9_options1);
612: }
613:
614: /**
615: * Sets the rotation field value.
616: *
617: */
618: public void setRotation(short value) {
619: field_9_options1 = rotation.setShortValue(field_9_options1,
620: value);
621: }
622:
623: /**
624: *
625: * @return the rotation field value.
626: */
627: public short getRotation() {
628: return rotation.getShortValue(field_9_options1);
629: }
630:
631: /**
632: * Sets the show category label as percentage field value.
633: *
634: */
635: public void setShowCategoryLabelAsPercentage(boolean value) {
636: field_9_options1 = showCategoryLabelAsPercentage
637: .setShortBoolean(field_9_options1, value);
638: }
639:
640: /**
641: *
642: * @return the show category label as percentage field value.
643: */
644: public boolean isShowCategoryLabelAsPercentage() {
645: return showCategoryLabelAsPercentage.isSet(field_9_options1);
646: }
647:
648: /**
649: * Sets the show value as percentage field value.
650: *
651: */
652: public void setShowValueAsPercentage(boolean value) {
653: field_9_options1 = showValueAsPercentage.setShortBoolean(
654: field_9_options1, value);
655: }
656:
657: /**
658: *
659: * @return the show value as percentage field value.
660: */
661: public boolean isShowValueAsPercentage() {
662: return showValueAsPercentage.isSet(field_9_options1);
663: }
664:
665: /**
666: * Sets the show bubble sizes field value.
667: *
668: */
669: public void setShowBubbleSizes(boolean value) {
670: field_9_options1 = showBubbleSizes.setShortBoolean(
671: field_9_options1, value);
672: }
673:
674: /**
675: *
676: * @return the show bubble sizes field value.
677: */
678: public boolean isShowBubbleSizes() {
679: return showBubbleSizes.isSet(field_9_options1);
680: }
681:
682: /**
683: * Sets the show label field value.
684: *
685: */
686: public void setShowLabel(boolean value) {
687: field_9_options1 = showLabel.setShortBoolean(field_9_options1,
688: value);
689: }
690:
691: /**
692: *
693: * @return the show label field value.
694: */
695: public boolean isShowLabel() {
696: return showLabel.isSet(field_9_options1);
697: }
698:
699: /**
700: * Sets the data label placement field value.
701: *
702: */
703: public void setDataLabelPlacement(short value) {
704: field_11_options2 = dataLabelPlacement.setShortValue(
705: field_11_options2, value);
706: }
707:
708: /**
709: *
710: * @return the data label placement field value.
711: */
712: public short getDataLabelPlacement() {
713: return dataLabelPlacement.getShortValue(field_11_options2);
714: }
715:
716: } // END OF CLASS
|