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 Tick record defines how tick marks and label positioning/formatting
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 Andrew C. Oliver(acoliver at apache.org)
028: */
029: public class TickRecord extends Record {
030: public final static short sid = 0x101e;
031: private byte field_1_majorTickType;
032: private byte field_2_minorTickType;
033: private byte field_3_labelPosition;
034: private byte field_4_background;
035: private int field_5_labelColorRgb;
036: private int field_6_zero1;
037: private int field_7_zero2;
038: private int field_8_zero3;
039: private int field_9_zero4;
040: private short field_10_options;
041: private BitField autoTextColor = BitFieldFactory.getInstance(0x1);
042: private BitField autoTextBackground = BitFieldFactory
043: .getInstance(0x2);
044: private BitField rotation = BitFieldFactory.getInstance(0x1c);
045: private BitField autorotate = BitFieldFactory.getInstance(0x20);
046: private short field_11_tickColor;
047: private short field_12_zero5;
048:
049: public TickRecord() {
050:
051: }
052:
053: /**
054: * Constructs a Tick record and sets its fields appropriately.
055: *
056: * @param in the RecordInputstream to read the record from
057: */
058:
059: public TickRecord(RecordInputStream in) {
060: super (in);
061:
062: }
063:
064: /**
065: * Checks the sid matches the expected side for this record
066: *
067: * @param id the expected sid.
068: */
069: protected void validateSid(short id) {
070: if (id != sid) {
071: throw new RecordFormatException("Not a Tick record");
072: }
073: }
074:
075: protected void fillFields(RecordInputStream in) {
076:
077: field_1_majorTickType = in.readByte();
078: field_2_minorTickType = in.readByte();
079: field_3_labelPosition = in.readByte();
080: field_4_background = in.readByte();
081: field_5_labelColorRgb = in.readInt();
082: field_6_zero1 = in.readInt();
083: field_7_zero2 = in.readInt();
084: field_8_zero3 = in.readInt();
085: field_9_zero4 = in.readInt();
086:
087: field_10_options = in.readShort();
088: field_11_tickColor = in.readShort();
089: field_12_zero5 = in.readShort();
090: }
091:
092: public String toString() {
093: StringBuffer buffer = new StringBuffer();
094:
095: buffer.append("[TICK]\n");
096: buffer.append(" .majorTickType = ").append("0x")
097: .append(HexDump.toHex(getMajorTickType())).append(" (")
098: .append(getMajorTickType()).append(" )");
099: buffer.append(System.getProperty("line.separator"));
100: buffer.append(" .minorTickType = ").append("0x")
101: .append(HexDump.toHex(getMinorTickType())).append(" (")
102: .append(getMinorTickType()).append(" )");
103: buffer.append(System.getProperty("line.separator"));
104: buffer.append(" .labelPosition = ").append("0x")
105: .append(HexDump.toHex(getLabelPosition())).append(" (")
106: .append(getLabelPosition()).append(" )");
107: buffer.append(System.getProperty("line.separator"));
108: buffer.append(" .background = ").append("0x")
109: .append(HexDump.toHex(getBackground())).append(" (")
110: .append(getBackground()).append(" )");
111: buffer.append(System.getProperty("line.separator"));
112: buffer.append(" .labelColorRgb = ").append("0x")
113: .append(HexDump.toHex(getLabelColorRgb())).append(" (")
114: .append(getLabelColorRgb()).append(" )");
115: buffer.append(System.getProperty("line.separator"));
116: buffer.append(" .zero1 = ").append("0x")
117: .append(HexDump.toHex(getZero1())).append(" (").append(
118: getZero1()).append(" )");
119: buffer.append(System.getProperty("line.separator"));
120: buffer.append(" .zero2 = ").append("0x")
121: .append(HexDump.toHex(getZero2())).append(" (").append(
122: getZero2()).append(" )");
123: buffer.append(System.getProperty("line.separator"));
124: buffer.append(" .options = ").append("0x")
125: .append(HexDump.toHex(getOptions())).append(" (")
126: .append(getOptions()).append(" )");
127: buffer.append(System.getProperty("line.separator"));
128: buffer.append(" .autoTextColor = ").append(
129: isAutoTextColor()).append('\n');
130: buffer.append(" .autoTextBackground = ").append(
131: isAutoTextBackground()).append('\n');
132: buffer.append(" .rotation = ").append(
133: getRotation()).append('\n');
134: buffer.append(" .autorotate = ").append(
135: isAutorotate()).append('\n');
136: buffer.append(" .tickColor = ").append("0x")
137: .append(HexDump.toHex(getTickColor())).append(" (")
138: .append(getTickColor()).append(" )");
139: buffer.append(System.getProperty("line.separator"));
140: buffer.append(" .zero3 = ").append("0x")
141: .append(HexDump.toHex(getZero3())).append(" (").append(
142: getZero3()).append(" )");
143: buffer.append(System.getProperty("line.separator"));
144:
145: buffer.append("[/TICK]\n");
146: return buffer.toString();
147: }
148:
149: public int serialize(int offset, byte[] data) {
150: int pos = 0;
151:
152: LittleEndian.putShort(data, 0 + offset, sid);
153: LittleEndian.putShort(data, 2 + offset,
154: (short) (getRecordSize() - 4));
155:
156: data[4 + offset + pos] = field_1_majorTickType;
157: data[5 + offset + pos] = field_2_minorTickType;
158: data[6 + offset + pos] = field_3_labelPosition;
159: data[7 + offset + pos] = field_4_background;
160: LittleEndian.putInt(data, 8 + offset + pos,
161: field_5_labelColorRgb);
162: LittleEndian.putInt(data, 12 + offset + pos, field_6_zero1);
163: LittleEndian.putInt(data, 16 + offset + pos, field_7_zero2);
164: LittleEndian.putInt(data, 20 + offset + pos, field_8_zero3);
165: LittleEndian.putInt(data, 24 + offset + pos, field_9_zero4);
166: LittleEndian
167: .putShort(data, 28 + offset + pos, field_10_options);
168: LittleEndian.putShort(data, 30 + offset + pos,
169: field_11_tickColor);
170: LittleEndian.putShort(data, 32 + offset + pos, field_12_zero5);
171:
172: return getRecordSize();
173: }
174:
175: /**
176: * Size of record (exluding 4 byte header)
177: */
178: public int getRecordSize() {
179: return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2;
180: }
181:
182: public short getSid() {
183: return sid;
184: }
185:
186: public Object clone() {
187: TickRecord rec = new TickRecord();
188:
189: rec.field_1_majorTickType = field_1_majorTickType;
190: rec.field_2_minorTickType = field_2_minorTickType;
191: rec.field_3_labelPosition = field_3_labelPosition;
192: rec.field_4_background = field_4_background;
193: rec.field_5_labelColorRgb = field_5_labelColorRgb;
194: rec.field_6_zero1 = field_6_zero1;
195: rec.field_7_zero2 = field_7_zero2;
196: rec.field_8_zero3 = field_8_zero3;
197: rec.field_9_zero4 = field_9_zero4;
198: rec.field_10_options = field_10_options;
199: rec.field_11_tickColor = field_11_tickColor;
200: rec.field_12_zero5 = field_12_zero5;
201: return rec;
202: }
203:
204: /**
205: * Get the major tick type field for the Tick record.
206: */
207: public byte getMajorTickType() {
208: return field_1_majorTickType;
209: }
210:
211: /**
212: * Set the major tick type field for the Tick record.
213: */
214: public void setMajorTickType(byte field_1_majorTickType) {
215: this .field_1_majorTickType = field_1_majorTickType;
216: }
217:
218: /**
219: * Get the minor tick type field for the Tick record.
220: */
221: public byte getMinorTickType() {
222: return field_2_minorTickType;
223: }
224:
225: /**
226: * Set the minor tick type field for the Tick record.
227: */
228: public void setMinorTickType(byte field_2_minorTickType) {
229: this .field_2_minorTickType = field_2_minorTickType;
230: }
231:
232: /**
233: * Get the label position field for the Tick record.
234: */
235: public byte getLabelPosition() {
236: return field_3_labelPosition;
237: }
238:
239: /**
240: * Set the label position field for the Tick record.
241: */
242: public void setLabelPosition(byte field_3_labelPosition) {
243: this .field_3_labelPosition = field_3_labelPosition;
244: }
245:
246: /**
247: * Get the background field for the Tick record.
248: */
249: public byte getBackground() {
250: return field_4_background;
251: }
252:
253: /**
254: * Set the background field for the Tick record.
255: */
256: public void setBackground(byte field_4_background) {
257: this .field_4_background = field_4_background;
258: }
259:
260: /**
261: * Get the label color rgb field for the Tick record.
262: */
263: public int getLabelColorRgb() {
264: return field_5_labelColorRgb;
265: }
266:
267: /**
268: * Set the label color rgb field for the Tick record.
269: */
270: public void setLabelColorRgb(int field_5_labelColorRgb) {
271: this .field_5_labelColorRgb = field_5_labelColorRgb;
272: }
273:
274: /**
275: * Get the zero 1 field for the Tick record.
276: */
277: public int getZero1() {
278: return field_6_zero1;
279: }
280:
281: /**
282: * Set the zero 1 field for the Tick record.
283: */
284: public void setZero1(int field_6_zero1) {
285: this .field_6_zero1 = field_6_zero1;
286: }
287:
288: /**
289: * Get the zero 2 field for the Tick record.
290: */
291: public int getZero2() {
292: return field_7_zero2;
293: }
294:
295: /**
296: * Set the zero 2 field for the Tick record.
297: */
298: public void setZero2(int field_7_zero2) {
299: this .field_7_zero2 = field_7_zero2;
300: }
301:
302: /**
303: * Get the options field for the Tick record.
304: */
305: public short getOptions() {
306: return field_10_options;
307: }
308:
309: /**
310: * Set the options field for the Tick record.
311: */
312: public void setOptions(short field_10_options) {
313: this .field_10_options = field_10_options;
314: }
315:
316: /**
317: * Get the tick color field for the Tick record.
318: */
319: public short getTickColor() {
320: return field_11_tickColor;
321: }
322:
323: /**
324: * Set the tick color field for the Tick record.
325: */
326: public void setTickColor(short field_11_tickColor) {
327: this .field_11_tickColor = field_11_tickColor;
328: }
329:
330: /**
331: * Get the zero 3 field for the Tick record.
332: */
333: public short getZero3() {
334: return field_12_zero5;
335: }
336:
337: /**
338: * Set the zero 3 field for the Tick record.
339: */
340: public void setZero3(short field_12_zero3) {
341: this .field_12_zero5 = field_12_zero3;
342: }
343:
344: /**
345: * Sets the auto text color field value.
346: * use the quote unquote automatic color for text
347: */
348: public void setAutoTextColor(boolean value) {
349: field_10_options = autoTextColor.setShortBoolean(
350: field_10_options, value);
351: }
352:
353: /**
354: * use the quote unquote automatic color for text
355: * @return the auto text color field value.
356: */
357: public boolean isAutoTextColor() {
358: return autoTextColor.isSet(field_10_options);
359: }
360:
361: /**
362: * Sets the auto text background field value.
363: * use the quote unquote automatic color for text background
364: */
365: public void setAutoTextBackground(boolean value) {
366: field_10_options = autoTextBackground.setShortBoolean(
367: field_10_options, value);
368: }
369:
370: /**
371: * use the quote unquote automatic color for text background
372: * @return the auto text background field value.
373: */
374: public boolean isAutoTextBackground() {
375: return autoTextBackground.isSet(field_10_options);
376: }
377:
378: /**
379: * Sets the rotation field value.
380: * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
381: */
382: public void setRotation(short value) {
383: field_10_options = rotation.setShortValue(field_10_options,
384: value);
385: }
386:
387: /**
388: * rotate text (0=none, 1=normal, 2=90 degrees counterclockwise, 3=90 degrees clockwise)
389: * @return the rotation field value.
390: */
391: public short getRotation() {
392: return rotation.getShortValue(field_10_options);
393: }
394:
395: /**
396: * Sets the autorotate field value.
397: * automatically rotate the text
398: */
399: public void setAutorotate(boolean value) {
400: field_10_options = autorotate.setShortBoolean(field_10_options,
401: value);
402: }
403:
404: /**
405: * automatically rotate the text
406: * @return the autorotate field value.
407: */
408: public boolean isAutorotate() {
409: return autorotate.isSet(field_10_options);
410: }
411:
412: } // END OF CLASS
|