1 /
55
56
57 package org.apache.poi.hssf.record;
58
59
60
61 import org.apache.poi.util.*;
62
63
70 public class LineFormatRecord
71 extends Record
72 {
73 public final static short sid = 0x1007;
74 private int field_1_lineColor;
75 private short field_2_linePattern;
76 public final static short LINE_PATTERN_SOLID = 0;
77 public final static short LINE_PATTERN_DASH = 1;
78 public final static short LINE_PATTERN_DOT = 2;
79 public final static short LINE_PATTERN_DASH_DOT = 3;
80 public final static short LINE_PATTERN_DASH_DOT_DOT = 4;
81 public final static short LINE_PATTERN_NONE = 5;
82 public final static short LINE_PATTERN_DARK_GRAY_PATTERN = 6;
83 public final static short LINE_PATTERN_MEDIUM_GRAY_PATTERN = 7;
84 public final static short LINE_PATTERN_LIGHT_GRAY_PATTERN = 8;
85 private short field_3_weight;
86 public final static short WEIGHT_HAIRLINE = -1;
87 public final static short WEIGHT_NARROW = 0;
88 public final static short WEIGHT_MEDIUM = 1;
89 public final static short WEIGHT_WIDE = 2;
90 private short field_4_format;
91 private BitField auto = new BitField(0x1);
92 private BitField drawTicks = new BitField(0x4);
93 private BitField unknown = new BitField(0x4);
94 private short field_5_colourPaletteIndex;
95
96
97 public LineFormatRecord()
98 {
99
100 }
101
102
110
111 public LineFormatRecord(short id, short size, byte [] data)
112 {
113 super(id, size, data);
114 }
115
116
125
126 public LineFormatRecord(short id, short size, byte [] data, int offset)
127 {
128 super(id, size, data, offset);
129 }
130
131
136 protected void validateSid(short id)
137 {
138 if (id != sid)
139 {
140 throw new RecordFormatException("Not a LineFormat record");
141 }
142 }
143
144 protected void fillFields(byte [] data, short size, int offset)
145 {
146 field_1_lineColor = LittleEndian.getInt(data, 0x0 + offset);
147 field_2_linePattern = LittleEndian.getShort(data, 0x4 + offset);
148 field_3_weight = LittleEndian.getShort(data, 0x6 + offset);
149 field_4_format = LittleEndian.getShort(data, 0x8 + offset);
150 field_5_colourPaletteIndex = LittleEndian.getShort(data, 0xa + offset);
151
152 }
153
154 public String toString()
155 {
156 StringBuffer buffer = new StringBuffer();
157
158 buffer.append("[LineFormat]\n");
159
160 buffer.append(" .lineColor = ")
161 .append("0x")
162 .append(HexDump.toHex((int)getLineColor()))
163 .append(" (").append(getLineColor()).append(" )\n");
164
165 buffer.append(" .linePattern = ")
166 .append("0x")
167 .append(HexDump.toHex((short)getLinePattern()))
168 .append(" (").append(getLinePattern()).append(" )\n");
169
170 buffer.append(" .weight = ")
171 .append("0x")
172 .append(HexDump.toHex((short)getWeight()))
173 .append(" (").append(getWeight()).append(" )\n");
174
175 buffer.append(" .format = ")
176 .append("0x")
177 .append(HexDump.toHex((short)getFormat()))
178 .append(" (").append(getFormat()).append(" )\n");
179 buffer.append(" .auto = ").append(isAuto ()).append('\n');
180 buffer.append(" .drawTicks = ").append(isDrawTicks ()).append('\n');
181 buffer.append(" .unknown = ").append(isUnknown ()).append('\n');
182
183 buffer.append(" .colourPaletteIndex = ")
184 .append("0x")
185 .append(HexDump.toHex((short)getColourPaletteIndex()))
186 .append(" (").append(getColourPaletteIndex()).append(" )\n");
187
188 buffer.append("[/LineFormat]\n");
189 return buffer.toString();
190 }
191
192 public int serialize(int offset, byte[] data)
193 {
194 LittleEndian.putShort(data, 0 + offset, sid);
195 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
196
197 LittleEndian.putInt(data, 4 + offset, field_1_lineColor);
198 LittleEndian.putShort(data, 8 + offset, field_2_linePattern);
199 LittleEndian.putShort(data, 10 + offset, field_3_weight);
200 LittleEndian.putShort(data, 12 + offset, field_4_format);
201 LittleEndian.putShort(data, 14 + offset, field_5_colourPaletteIndex);
202
203 return getRecordSize();
204 }
205
206
209 public int getRecordSize()
210 {
211 return 4 + 4 + 2 + 2 + 2 + 2;
212 }
213
214 public short getSid()
215 {
216 return this.sid;
217 }
218
219 public Object clone() {
220 LineFormatRecord rec = new LineFormatRecord();
221
222 rec.field_1_lineColor = field_1_lineColor;
223 rec.field_2_linePattern = field_2_linePattern;
224 rec.field_3_weight = field_3_weight;
225 rec.field_4_format = field_4_format;
226 rec.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
227
228 return rec;
229 }
230
231
232
235 public int getLineColor()
236 {
237 return field_1_lineColor;
238 }
239
240
243 public void setLineColor(int field_1_lineColor)
244 {
245 this.field_1_lineColor = field_1_lineColor;
246 }
247
248
262 public short getLinePattern()
263 {
264 return field_2_linePattern;
265 }
266
267
282 public void setLinePattern(short field_2_linePattern)
283 {
284 this.field_2_linePattern = field_2_linePattern;
285 }
286
287
296 public short getWeight()
297 {
298 return field_3_weight;
299 }
300
301
311 public void setWeight(short field_3_weight)
312 {
313 this.field_3_weight = field_3_weight;
314 }
315
316
319 public short getFormat()
320 {
321 return field_4_format;
322 }
323
324
327 public void setFormat(short field_4_format)
328 {
329 this.field_4_format = field_4_format;
330 }
331
332
335 public short getColourPaletteIndex()
336 {
337 return field_5_colourPaletteIndex;
338 }
339
340
343 public void setColourPaletteIndex(short field_5_colourPaletteIndex)
344 {
345 this.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
346 }
347
348
352 public void setAuto(boolean value)
353 {
354 field_4_format = auto.setShortBoolean(field_4_format, value);
355 }
356
357
361 public boolean isAuto()
362 {
363 return auto.isSet(field_4_format);
364 }
365
366
370 public void setDrawTicks(boolean value)
371 {
372 field_4_format = drawTicks.setShortBoolean(field_4_format, value);
373 }
374
375
379 public boolean isDrawTicks()
380 {
381 return drawTicks.isSet(field_4_format);
382 }
383
384
388 public void setUnknown(boolean value)
389 {
390 field_4_format = unknown.setShortBoolean(field_4_format, value);
391 }
392
393
397 public boolean isUnknown()
398 {
399 return unknown.isSet(field_4_format);
400 }
401
402
403 }
404
405
406
407
408