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: * Describes a line format record. The line format record controls how a line on a chart appears.
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 LineFormatRecord extends Record {
030: public final static short sid = 0x1007;
031: private int field_1_lineColor;
032: private short field_2_linePattern;
033: public final static short LINE_PATTERN_SOLID = 0;
034: public final static short LINE_PATTERN_DASH = 1;
035: public final static short LINE_PATTERN_DOT = 2;
036: public final static short LINE_PATTERN_DASH_DOT = 3;
037: public final static short LINE_PATTERN_DASH_DOT_DOT = 4;
038: public final static short LINE_PATTERN_NONE = 5;
039: public final static short LINE_PATTERN_DARK_GRAY_PATTERN = 6;
040: public final static short LINE_PATTERN_MEDIUM_GRAY_PATTERN = 7;
041: public final static short LINE_PATTERN_LIGHT_GRAY_PATTERN = 8;
042: private short field_3_weight;
043: public final static short WEIGHT_HAIRLINE = -1;
044: public final static short WEIGHT_NARROW = 0;
045: public final static short WEIGHT_MEDIUM = 1;
046: public final static short WEIGHT_WIDE = 2;
047: private short field_4_format;
048: private BitField auto = BitFieldFactory.getInstance(0x1);
049: private BitField drawTicks = BitFieldFactory.getInstance(0x4);
050: private BitField unknown = BitFieldFactory.getInstance(0x4);
051: private short field_5_colourPaletteIndex;
052:
053: public LineFormatRecord() {
054:
055: }
056:
057: /**
058: * Constructs a LineFormat record and sets its fields appropriately.
059: *
060: * @param in the RecordInputstream to read the record from
061: */
062:
063: public LineFormatRecord(RecordInputStream in) {
064: super (in);
065:
066: }
067:
068: /**
069: * Checks the sid matches the expected side for this record
070: *
071: * @param id the expected sid.
072: */
073: protected void validateSid(short id) {
074: if (id != sid) {
075: throw new RecordFormatException("Not a LineFormat record");
076: }
077: }
078:
079: protected void fillFields(RecordInputStream in) {
080: field_1_lineColor = in.readInt();
081: field_2_linePattern = in.readShort();
082: field_3_weight = in.readShort();
083: field_4_format = in.readShort();
084: field_5_colourPaletteIndex = in.readShort();
085:
086: }
087:
088: public String toString() {
089: StringBuffer buffer = new StringBuffer();
090:
091: buffer.append("[LINEFORMAT]\n");
092: buffer.append(" .lineColor = ").append("0x")
093: .append(HexDump.toHex(getLineColor())).append(" (")
094: .append(getLineColor()).append(" )");
095: buffer.append(System.getProperty("line.separator"));
096: buffer.append(" .linePattern = ").append("0x")
097: .append(HexDump.toHex(getLinePattern())).append(" (")
098: .append(getLinePattern()).append(" )");
099: buffer.append(System.getProperty("line.separator"));
100: buffer.append(" .weight = ").append("0x")
101: .append(HexDump.toHex(getWeight())).append(" (")
102: .append(getWeight()).append(" )");
103: buffer.append(System.getProperty("line.separator"));
104: buffer.append(" .format = ").append("0x")
105: .append(HexDump.toHex(getFormat())).append(" (")
106: .append(getFormat()).append(" )");
107: buffer.append(System.getProperty("line.separator"));
108: buffer.append(" .auto = ").append(
109: isAuto()).append('\n');
110: buffer.append(" .drawTicks = ").append(
111: isDrawTicks()).append('\n');
112: buffer.append(" .unknown = ").append(
113: isUnknown()).append('\n');
114: buffer.append(" .colourPaletteIndex = ").append("0x")
115: .append(HexDump.toHex(getColourPaletteIndex())).append(
116: " (").append(getColourPaletteIndex()).append(
117: " )");
118: buffer.append(System.getProperty("line.separator"));
119:
120: buffer.append("[/LINEFORMAT]\n");
121: return buffer.toString();
122: }
123:
124: public int serialize(int offset, byte[] data) {
125: int pos = 0;
126:
127: LittleEndian.putShort(data, 0 + offset, sid);
128: LittleEndian.putShort(data, 2 + offset,
129: (short) (getRecordSize() - 4));
130:
131: LittleEndian.putInt(data, 4 + offset + pos, field_1_lineColor);
132: LittleEndian.putShort(data, 8 + offset + pos,
133: field_2_linePattern);
134: LittleEndian.putShort(data, 10 + offset + pos, field_3_weight);
135: LittleEndian.putShort(data, 12 + offset + pos, field_4_format);
136: LittleEndian.putShort(data, 14 + offset + pos,
137: field_5_colourPaletteIndex);
138:
139: return getRecordSize();
140: }
141:
142: /**
143: * Size of record (exluding 4 byte header)
144: */
145: public int getRecordSize() {
146: return 4 + 4 + 2 + 2 + 2 + 2;
147: }
148:
149: public short getSid() {
150: return sid;
151: }
152:
153: public Object clone() {
154: LineFormatRecord rec = new LineFormatRecord();
155:
156: rec.field_1_lineColor = field_1_lineColor;
157: rec.field_2_linePattern = field_2_linePattern;
158: rec.field_3_weight = field_3_weight;
159: rec.field_4_format = field_4_format;
160: rec.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
161: return rec;
162: }
163:
164: /**
165: * Get the line color field for the LineFormat record.
166: */
167: public int getLineColor() {
168: return field_1_lineColor;
169: }
170:
171: /**
172: * Set the line color field for the LineFormat record.
173: */
174: public void setLineColor(int field_1_lineColor) {
175: this .field_1_lineColor = field_1_lineColor;
176: }
177:
178: /**
179: * Get the line pattern field for the LineFormat record.
180: *
181: * @return One of
182: * LINE_PATTERN_SOLID
183: * LINE_PATTERN_DASH
184: * LINE_PATTERN_DOT
185: * LINE_PATTERN_DASH_DOT
186: * LINE_PATTERN_DASH_DOT_DOT
187: * LINE_PATTERN_NONE
188: * LINE_PATTERN_DARK_GRAY_PATTERN
189: * LINE_PATTERN_MEDIUM_GRAY_PATTERN
190: * LINE_PATTERN_LIGHT_GRAY_PATTERN
191: */
192: public short getLinePattern() {
193: return field_2_linePattern;
194: }
195:
196: /**
197: * Set the line pattern field for the LineFormat record.
198: *
199: * @param field_2_linePattern
200: * One of
201: * LINE_PATTERN_SOLID
202: * LINE_PATTERN_DASH
203: * LINE_PATTERN_DOT
204: * LINE_PATTERN_DASH_DOT
205: * LINE_PATTERN_DASH_DOT_DOT
206: * LINE_PATTERN_NONE
207: * LINE_PATTERN_DARK_GRAY_PATTERN
208: * LINE_PATTERN_MEDIUM_GRAY_PATTERN
209: * LINE_PATTERN_LIGHT_GRAY_PATTERN
210: */
211: public void setLinePattern(short field_2_linePattern) {
212: this .field_2_linePattern = field_2_linePattern;
213: }
214:
215: /**
216: * Get the weight field for the LineFormat record.
217: *
218: * @return One of
219: * WEIGHT_HAIRLINE
220: * WEIGHT_NARROW
221: * WEIGHT_MEDIUM
222: * WEIGHT_WIDE
223: */
224: public short getWeight() {
225: return field_3_weight;
226: }
227:
228: /**
229: * Set the weight field for the LineFormat record.
230: *
231: * @param field_3_weight
232: * One of
233: * WEIGHT_HAIRLINE
234: * WEIGHT_NARROW
235: * WEIGHT_MEDIUM
236: * WEIGHT_WIDE
237: */
238: public void setWeight(short field_3_weight) {
239: this .field_3_weight = field_3_weight;
240: }
241:
242: /**
243: * Get the format field for the LineFormat record.
244: */
245: public short getFormat() {
246: return field_4_format;
247: }
248:
249: /**
250: * Set the format field for the LineFormat record.
251: */
252: public void setFormat(short field_4_format) {
253: this .field_4_format = field_4_format;
254: }
255:
256: /**
257: * Get the colour palette index field for the LineFormat record.
258: */
259: public short getColourPaletteIndex() {
260: return field_5_colourPaletteIndex;
261: }
262:
263: /**
264: * Set the colour palette index field for the LineFormat record.
265: */
266: public void setColourPaletteIndex(short field_5_colourPaletteIndex) {
267: this .field_5_colourPaletteIndex = field_5_colourPaletteIndex;
268: }
269:
270: /**
271: * Sets the auto field value.
272: * automatic format
273: */
274: public void setAuto(boolean value) {
275: field_4_format = auto.setShortBoolean(field_4_format, value);
276: }
277:
278: /**
279: * automatic format
280: * @return the auto field value.
281: */
282: public boolean isAuto() {
283: return auto.isSet(field_4_format);
284: }
285:
286: /**
287: * Sets the draw ticks field value.
288: * draw tick marks
289: */
290: public void setDrawTicks(boolean value) {
291: field_4_format = drawTicks.setShortBoolean(field_4_format,
292: value);
293: }
294:
295: /**
296: * draw tick marks
297: * @return the draw ticks field value.
298: */
299: public boolean isDrawTicks() {
300: return drawTicks.isSet(field_4_format);
301: }
302:
303: /**
304: * Sets the unknown field value.
305: * book marks this as reserved = 0 but it seems to do something
306: */
307: public void setUnknown(boolean value) {
308: field_4_format = unknown.setShortBoolean(field_4_format, value);
309: }
310:
311: /**
312: * book marks this as reserved = 0 but it seems to do something
313: * @return the unknown field value.
314: */
315: public boolean isUnknown() {
316: return unknown.isSet(field_4_format);
317: }
318:
319: } // END OF CLASS
|