1 /
55
56
57 package org.apache.poi.hssf.record;
58
59
60
61 import org.apache.poi.util.*;
62
63
70 public class LegendRecord
71 extends Record
72 {
73 public final static short sid = 0x1015;
74 private int field_1_xPosition;
75 private int field_2_yPosition;
76 private int field_3_xSize;
77 private int field_4_ySize;
78 private byte field_5_type;
79 public final static byte TYPE_BOTTOM = 0;
80 public final static byte TYPE_CORNER = 1;
81 public final static byte TYPE_TOP = 2;
82 public final static byte TYPE_RIGHT = 3;
83 public final static byte TYPE_LEFT = 4;
84 public final static byte TYPE_NOT_DOCKED = 7;
85 private byte field_6_spacing;
86 public final static byte SPACING_CLOSE = 0;
87 public final static byte SPACING_MEDIUM = 1;
88 public final static byte SPACING_OPEN = 2;
89 private short field_7_options;
90 private BitField autoPosition = new BitField(0x1);
91 private BitField autoSeries = new BitField(0x2);
92 private BitField autoPosX = new BitField(0x4);
93 private BitField autoPosY = new BitField(0x8);
94 private BitField vert = new BitField(0x10);
95 private BitField containsDataTable = new BitField(0x20);
96
97
98 public LegendRecord()
99 {
100
101 }
102
103
111
112 public LegendRecord(short id, short size, byte [] data)
113 {
114 super(id, size, data);
115 }
116
117
126
127 public LegendRecord(short id, short size, byte [] data, int offset)
128 {
129 super(id, size, data, offset);
130 }
131
132
137 protected void validateSid(short id)
138 {
139 if (id != sid)
140 {
141 throw new RecordFormatException("Not a Legend record");
142 }
143 }
144
145 protected void fillFields(byte [] data, short size, int offset)
146 {
147 field_1_xPosition = LittleEndian.getInt(data, 0x0 + offset);
148 field_2_yPosition = LittleEndian.getInt(data, 0x4 + offset);
149 field_3_xSize = LittleEndian.getInt(data, 0x8 + offset);
150 field_4_ySize = LittleEndian.getInt(data, 0xc + offset);
151 field_5_type = data[ 0x10 + offset ];
152 field_6_spacing = data[ 0x11 + offset ];
153 field_7_options = LittleEndian.getShort(data, 0x12 + offset);
154
155 }
156
157 public String toString()
158 {
159 StringBuffer buffer = new StringBuffer();
160
161 buffer.append("[Legend]\n");
162
163 buffer.append(" .xPosition = ")
164 .append("0x")
165 .append(HexDump.toHex((int)getXPosition()))
166 .append(" (").append(getXPosition()).append(" )\n");
167
168 buffer.append(" .yPosition = ")
169 .append("0x")
170 .append(HexDump.toHex((int)getYPosition()))
171 .append(" (").append(getYPosition()).append(" )\n");
172
173 buffer.append(" .xSize = ")
174 .append("0x")
175 .append(HexDump.toHex((int)getXSize()))
176 .append(" (").append(getXSize()).append(" )\n");
177
178 buffer.append(" .ySize = ")
179 .append("0x")
180 .append(HexDump.toHex((int)getYSize()))
181 .append(" (").append(getYSize()).append(" )\n");
182
183 buffer.append(" .type = ")
184 .append("0x")
185 .append(HexDump.toHex((byte)getType()))
186 .append(" (").append(getType()).append(" )\n");
187
188 buffer.append(" .spacing = ")
189 .append("0x")
190 .append(HexDump.toHex((byte)getSpacing()))
191 .append(" (").append(getSpacing()).append(" )\n");
192
193 buffer.append(" .options = ")
194 .append("0x")
195 .append(HexDump.toHex((short)getOptions()))
196 .append(" (").append(getOptions()).append(" )\n");
197 buffer.append(" .autoPosition = ").append(isAutoPosition ()).append('\n');
198 buffer.append(" .autoSeries = ").append(isAutoSeries ()).append('\n');
199 buffer.append(" .autoPosX = ").append(isAutoPosX ()).append('\n');
200 buffer.append(" .autoPosY = ").append(isAutoPosY ()).append('\n');
201 buffer.append(" .vert = ").append(isVert ()).append('\n');
202 buffer.append(" .containsDataTable = ").append(isContainsDataTable ()).append('\n');
203
204 buffer.append("[/Legend]\n");
205 return buffer.toString();
206 }
207
208 public int serialize(int offset, byte[] data)
209 {
210 LittleEndian.putShort(data, 0 + offset, sid);
211 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
212
213 LittleEndian.putInt(data, 4 + offset, field_1_xPosition);
214 LittleEndian.putInt(data, 8 + offset, field_2_yPosition);
215 LittleEndian.putInt(data, 12 + offset, field_3_xSize);
216 LittleEndian.putInt(data, 16 + offset, field_4_ySize);
217 data[ 20 + offset ] = field_5_type;
218 data[ 21 + offset ] = field_6_spacing;
219 LittleEndian.putShort(data, 22 + offset, field_7_options);
220
221 return getRecordSize();
222 }
223
224
227 public int getRecordSize()
228 {
229 return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
230 }
231
232 public short getSid()
233 {
234 return this.sid;
235 }
236
237
238
241 public int getXPosition()
242 {
243 return field_1_xPosition;
244 }
245
246
249 public void setXPosition(int field_1_xPosition)
250 {
251 this.field_1_xPosition = field_1_xPosition;
252 }
253
254
257 public int getYPosition()
258 {
259 return field_2_yPosition;
260 }
261
262
265 public void setYPosition(int field_2_yPosition)
266 {
267 this.field_2_yPosition = field_2_yPosition;
268 }
269
270
273 public int getXSize()
274 {
275 return field_3_xSize;
276 }
277
278
281 public void setXSize(int field_3_xSize)
282 {
283 this.field_3_xSize = field_3_xSize;
284 }
285
286
289 public int getYSize()
290 {
291 return field_4_ySize;
292 }
293
294
297 public void setYSize(int field_4_ySize)
298 {
299 this.field_4_ySize = field_4_ySize;
300 }
301
302
313 public byte getType()
314 {
315 return field_5_type;
316 }
317
318
330 public void setType(byte field_5_type)
331 {
332 this.field_5_type = field_5_type;
333 }
334
335
343 public byte getSpacing()
344 {
345 return field_6_spacing;
346 }
347
348
357 public void setSpacing(byte field_6_spacing)
358 {
359 this.field_6_spacing = field_6_spacing;
360 }
361
362
365 public short getOptions()
366 {
367 return field_7_options;
368 }
369
370
373 public void setOptions(short field_7_options)
374 {
375 this.field_7_options = field_7_options;
376 }
377
378
382 public void setAutoPosition(boolean value)
383 {
384 field_7_options = autoPosition.setShortBoolean(field_7_options, value);
385 }
386
387
391 public boolean isAutoPosition()
392 {
393 return autoPosition.isSet(field_7_options);
394 }
395
396
400 public void setAutoSeries(boolean value)
401 {
402 field_7_options = autoSeries.setShortBoolean(field_7_options, value);
403 }
404
405
409 public boolean isAutoSeries()
410 {
411 return autoSeries.isSet(field_7_options);
412 }
413
414
418 public void setAutoPosX(boolean value)
419 {
420 field_7_options = autoPosX.setShortBoolean(field_7_options, value);
421 }
422
423
427 public boolean isAutoPosX()
428 {
429 return autoPosX.isSet(field_7_options);
430 }
431
432
436 public void setAutoPosY(boolean value)
437 {
438 field_7_options = autoPosY.setShortBoolean(field_7_options, value);
439 }
440
441
445 public boolean isAutoPosY()
446 {
447 return autoPosY.isSet(field_7_options);
448 }
449
450
454 public void setVert(boolean value)
455 {
456 field_7_options = vert.setShortBoolean(field_7_options, value);
457 }
458
459
463 public boolean isVert()
464 {
465 return vert.isSet(field_7_options);
466 }
467
468
472 public void setContainsDataTable(boolean value)
473 {
474 field_7_options = containsDataTable.setShortBoolean(field_7_options, value);
475 }
476
477
481 public boolean isContainsDataTable()
482 {
483 return containsDataTable.isSet(field_7_options);
484 }
485
486
487 }
488
489
490
491
492