1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 24 import org.apache.poi.util.*; 25 26 33 public class TickRecord 34 extends Record 35 { 36 public final static short sid = 0x101e; 37 private byte field_1_majorTickType; 38 private byte field_2_minorTickType; 39 private byte field_3_labelPosition; 40 private byte field_4_background; 41 private int field_5_labelColorRgb; 42 private short field_6_zero1; 43 private short field_7_zero2; 44 private short field_8_options; 45 private BitField autoTextColor = new BitField(0x1); 46 private BitField autoTextBackground = new BitField(0x2); 47 private BitField rotation = new BitField(0x1c); 48 private BitField autorotate = new BitField(0x20); 49 private short field_9_tickColor; 50 private short field_10_zero3; 51 52 53 public TickRecord() 54 { 55 56 } 57 58 66 67 public TickRecord(short id, short size, byte [] data) 68 { 69 super(id, size, data); 70 71 } 72 73 82 83 public TickRecord(short id, short size, byte [] data, int offset) 84 { 85 super(id, size, data, offset); 86 87 } 88 89 94 protected void validateSid(short id) 95 { 96 if (id != sid) 97 { 98 throw new RecordFormatException("Not a Tick record"); 99 } 100 } 101 102 protected void fillFields(byte [] data, short size, int offset) 103 { 104 105 int pos = 0; 106 field_1_majorTickType = data[ pos + 0x0 + offset ]; 107 field_2_minorTickType = data[ pos + 0x1 + offset ]; 108 field_3_labelPosition = data[ pos + 0x2 + offset ]; 109 field_4_background = data[ pos + 0x3 + offset ]; 110 field_5_labelColorRgb = LittleEndian.getInt(data, pos + 0x4 + offset); 111 field_6_zero1 = LittleEndian.getShort(data, pos + 0x8 + offset); 112 field_7_zero2 = LittleEndian.getShort(data, pos + 0x10 + offset); 113 field_8_options = LittleEndian.getShort(data, pos + 0x18 + offset); 114 field_9_tickColor = LittleEndian.getShort(data, pos + 0x1a + offset); 115 field_10_zero3 = LittleEndian.getShort(data, pos + 0x1c + offset); 116 117 } 118 119 public String toString() 120 { 121 StringBuffer buffer = new StringBuffer (); 122 123 buffer.append("[TICK]\n"); 124 buffer.append(" .majorTickType = ") 125 .append("0x").append(HexDump.toHex( getMajorTickType ())) 126 .append(" (").append( getMajorTickType() ).append(" )"); 127 buffer.append(System.getProperty("line.separator")); 128 buffer.append(" .minorTickType = ") 129 .append("0x").append(HexDump.toHex( getMinorTickType ())) 130 .append(" (").append( getMinorTickType() ).append(" )"); 131 buffer.append(System.getProperty("line.separator")); 132 buffer.append(" .labelPosition = ") 133 .append("0x").append(HexDump.toHex( getLabelPosition ())) 134 .append(" (").append( getLabelPosition() ).append(" )"); 135 buffer.append(System.getProperty("line.separator")); 136 buffer.append(" .background = ") 137 .append("0x").append(HexDump.toHex( getBackground ())) 138 .append(" (").append( getBackground() ).append(" )"); 139 buffer.append(System.getProperty("line.separator")); 140 buffer.append(" .labelColorRgb = ") 141 .append("0x").append(HexDump.toHex( getLabelColorRgb ())) 142 .append(" (").append( getLabelColorRgb() ).append(" )"); 143 buffer.append(System.getProperty("line.separator")); 144 buffer.append(" .zero1 = ") 145 .append("0x").append(HexDump.toHex( getZero1 ())) 146 .append(" (").append( getZero1() ).append(" )"); 147 buffer.append(System.getProperty("line.separator")); 148 buffer.append(" .zero2 = ") 149 .append("0x").append(HexDump.toHex( getZero2 ())) 150 .append(" (").append( getZero2() ).append(" )"); 151 buffer.append(System.getProperty("line.separator")); 152 buffer.append(" .options = ") 153 .append("0x").append(HexDump.toHex( getOptions ())) 154 .append(" (").append( getOptions() ).append(" )"); 155 buffer.append(System.getProperty("line.separator")); 156 buffer.append(" .autoTextColor = ").append(isAutoTextColor()).append('\n'); 157 buffer.append(" .autoTextBackground = ").append(isAutoTextBackground()).append('\n'); 158 buffer.append(" .rotation = ").append(getRotation()).append('\n'); 159 buffer.append(" .autorotate = ").append(isAutorotate()).append('\n'); 160 buffer.append(" .tickColor = ") 161 .append("0x").append(HexDump.toHex( getTickColor ())) 162 .append(" (").append( getTickColor() ).append(" )"); 163 buffer.append(System.getProperty("line.separator")); 164 buffer.append(" .zero3 = ") 165 .append("0x").append(HexDump.toHex( getZero3 ())) 166 .append(" (").append( getZero3() ).append(" )"); 167 buffer.append(System.getProperty("line.separator")); 168 169 buffer.append("[/TICK]\n"); 170 return buffer.toString(); 171 } 172 173 public int serialize(int offset, byte[] data) 174 { 175 int pos = 0; 176 177 LittleEndian.putShort(data, 0 + offset, sid); 178 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 179 180 data[ 4 + offset + pos ] = field_1_majorTickType; 181 data[ 5 + offset + pos ] = field_2_minorTickType; 182 data[ 6 + offset + pos ] = field_3_labelPosition; 183 data[ 7 + offset + pos ] = field_4_background; 184 LittleEndian.putInt(data, 8 + offset + pos, field_5_labelColorRgb); 185 LittleEndian.putShort(data, 12 + offset + pos, field_6_zero1); 186 LittleEndian.putShort(data, 20 + offset + pos, field_7_zero2); 187 LittleEndian.putShort(data, 28 + offset + pos, field_8_options); 188 LittleEndian.putShort(data, 30 + offset + pos, field_9_tickColor); 189 LittleEndian.putShort(data, 32 + offset + pos, field_10_zero3); 190 191 return getRecordSize(); 192 } 193 194 197 public int getRecordSize() 198 { 199 return 4 + 1 + 1 + 1 + 1 + 4 + 8 + 8 + 2 + 2 + 2; 200 } 201 202 public short getSid() 203 { 204 return this.sid; 205 } 206 207 public Object clone() { 208 TickRecord rec = new TickRecord(); 209 210 rec.field_1_majorTickType = field_1_majorTickType; 211 rec.field_2_minorTickType = field_2_minorTickType; 212 rec.field_3_labelPosition = field_3_labelPosition; 213 rec.field_4_background = field_4_background; 214 rec.field_5_labelColorRgb = field_5_labelColorRgb; 215 rec.field_6_zero1 = field_6_zero1; 216 rec.field_7_zero2 = field_7_zero2; 217 rec.field_8_options = field_8_options; 218 rec.field_9_tickColor = field_9_tickColor; 219 rec.field_10_zero3 = field_10_zero3; 220 return rec; 221 } 222 223 224 225 226 229 public byte getMajorTickType() 230 { 231 return field_1_majorTickType; 232 } 233 234 237 public void setMajorTickType(byte field_1_majorTickType) 238 { 239 this.field_1_majorTickType = field_1_majorTickType; 240 } 241 242 245 public byte getMinorTickType() 246 { 247 return field_2_minorTickType; 248 } 249 250 253 public void setMinorTickType(byte field_2_minorTickType) 254 { 255 this.field_2_minorTickType = field_2_minorTickType; 256 } 257 258 261 public byte getLabelPosition() 262 { 263 return field_3_labelPosition; 264 } 265 266 269 public void setLabelPosition(byte field_3_labelPosition) 270 { 271 this.field_3_labelPosition = field_3_labelPosition; 272 } 273 274 277 public byte getBackground() 278 { 279 return field_4_background; 280 } 281 282 285 public void setBackground(byte field_4_background) 286 { 287 this.field_4_background = field_4_background; 288 } 289 290 293 public int getLabelColorRgb() 294 { 295 return field_5_labelColorRgb; 296 } 297 298 301 public void setLabelColorRgb(int field_5_labelColorRgb) 302 { 303 this.field_5_labelColorRgb = field_5_labelColorRgb; 304 } 305 306 309 public short getZero1() 310 { 311 return field_6_zero1; 312 } 313 314 317 public void setZero1(short field_6_zero1) 318 { 319 this.field_6_zero1 = field_6_zero1; 320 } 321 322 325 public short getZero2() 326 { 327 return field_7_zero2; 328 } 329 330 333 public void setZero2(short field_7_zero2) 334 { 335 this.field_7_zero2 = field_7_zero2; 336 } 337 338 341 public short getOptions() 342 { 343 return field_8_options; 344 } 345 346 349 public void setOptions(short field_8_options) 350 { 351 this.field_8_options = field_8_options; 352 } 353 354 357 public short getTickColor() 358 { 359 return field_9_tickColor; 360 } 361 362 365 public void setTickColor(short field_9_tickColor) 366 { 367 this.field_9_tickColor = field_9_tickColor; 368 } 369 370 373 public short getZero3() 374 { 375 return field_10_zero3; 376 } 377 378 381 public void setZero3(short field_10_zero3) 382 { 383 this.field_10_zero3 = field_10_zero3; 384 } 385 386 390 public void setAutoTextColor(boolean value) 391 { 392 field_8_options = autoTextColor.setShortBoolean(field_8_options, value); 393 } 394 395 399 public boolean isAutoTextColor() 400 { 401 return autoTextColor.isSet(field_8_options); 402 } 403 404 408 public void setAutoTextBackground(boolean value) 409 { 410 field_8_options = autoTextBackground.setShortBoolean(field_8_options, value); 411 } 412 413 417 public boolean isAutoTextBackground() 418 { 419 return autoTextBackground.isSet(field_8_options); 420 } 421 422 426 public void setRotation(short value) 427 { 428 field_8_options = rotation.setShortValue(field_8_options, value); 429 } 430 431 435 public short getRotation() 436 { 437 return rotation.getShortValue(field_8_options); 438 } 439 440 444 public void setAutorotate(boolean value) 445 { 446 field_8_options = autorotate.setShortBoolean(field_8_options, value); 447 } 448 449 453 public boolean isAutorotate() 454 { 455 return autorotate.isSet(field_8_options); 456 } 457 458 459 } 461 462 463 464 | Popular Tags |