1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import org.apache.poi.util.LittleEndian; 22 import org.apache.poi.util.BitField; 23 24 31 32 public class ChartFormatRecord 33 extends Record 34 { 35 public static final short sid = 0x1014; 36 37 private int field1_x_position; private int field2_y_position; private int field3_width; 41 private int field4_height; 42 private short field5_grbit; 43 private BitField varyDisplayPattern = new BitField(0x01); 44 45 public ChartFormatRecord() 46 { 47 } 48 49 56 57 public ChartFormatRecord(short id, short size, byte [] data) 58 { 59 super(id, size, data); 60 } 61 62 70 71 public ChartFormatRecord(short id, short size, byte [] data, int offset) 72 { 73 super(id, size, data, offset); 74 } 75 76 protected void validateSid(short id) 77 { 78 if (id != sid) 79 { 80 throw new RecordFormatException("NOT A CHARTFORMAT RECORD"); 81 } 82 } 83 84 protected void fillFields(byte [] data, short size, int offset) 85 { 86 field1_x_position = LittleEndian.getInt(data, 0 + offset); 87 field2_y_position = LittleEndian.getInt(data, 4 + offset); 88 field3_width = LittleEndian.getInt(data, 8 + offset); 89 field4_height = LittleEndian.getInt(data, 12 + offset); 90 field5_grbit = LittleEndian.getShort(data, 16 + offset); 91 } 92 93 public String toString() 94 { 95 StringBuffer buffer = new StringBuffer (); 96 97 buffer.append("[CHARTFORMAT]\n"); 98 buffer.append(" .xPosition = ").append(getXPosition()) 99 .append("\n"); 100 buffer.append(" .yPosition = ").append(getYPosition()) 101 .append("\n"); 102 buffer.append(" .width = ").append(getWidth()) 103 .append("\n"); 104 buffer.append(" .height = ").append(getHeight()) 105 .append("\n"); 106 buffer.append(" .grBit = ") 107 .append(Integer.toHexString(field5_grbit)).append("\n"); 108 buffer.append("[/CHARTFORMAT]\n"); 109 return buffer.toString(); 110 } 111 112 public int serialize(int offset, byte [] data) 113 { 114 LittleEndian.putShort(data, 0 + offset, sid); 115 LittleEndian.putShort(data, 2 + offset, 116 (( short ) 22)); LittleEndian.putInt(data, 4 + offset, getXPosition()); 118 LittleEndian.putInt(data, 8 + offset, getYPosition()); 119 LittleEndian.putInt(data, 12 + offset, getWidth()); 120 LittleEndian.putInt(data, 16 + offset, getHeight()); 121 LittleEndian.putShort(data, 20 + offset, field5_grbit); 122 return getRecordSize(); 123 } 124 125 public int getRecordSize() 126 { 127 return 22; 128 } 129 130 public short getSid() 131 { 132 return this.sid; 133 } 134 135 public int getXPosition() 136 { 137 return field1_x_position; 138 } 139 140 public void setXPosition(int xPosition) 141 { 142 this.field1_x_position = xPosition; 143 } 144 145 public int getYPosition() 146 { 147 return field2_y_position; 148 } 149 150 public void setYPosition(int yPosition) 151 { 152 this.field2_y_position = yPosition; 153 } 154 155 public int getWidth() 156 { 157 return field3_width; 158 } 159 160 public void setWidth(int width) 161 { 162 this.field3_width = width; 163 } 164 165 public int getHeight() 166 { 167 return field4_height; 168 } 169 170 public void setHeight(int height) 171 { 172 this.field4_height = height; 173 } 174 175 public boolean getVaryDisplayPattern() 176 { 177 return varyDisplayPattern.isSet(field5_grbit); 178 } 179 180 public void setVaryDisplayPattern(boolean value) 181 { 182 field5_grbit = varyDisplayPattern.setShortBoolean(field5_grbit, 183 value); 184 } 185 } 186 | Popular Tags |