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 AreaRecord 34 extends Record 35 { 36 public final static short sid = 0x101A; 37 private short field_1_formatFlags; 38 private BitField stacked = new BitField(0x1); 39 private BitField displayAsPercentage = new BitField(0x2); 40 private BitField shadow = new BitField(0x4); 41 42 43 public AreaRecord() 44 { 45 46 } 47 48 56 57 public AreaRecord(short id, short size, byte [] data) 58 { 59 super(id, size, data); 60 61 } 62 63 72 73 public AreaRecord(short id, short size, byte [] data, int offset) 74 { 75 super(id, size, data, offset); 76 77 } 78 79 84 protected void validateSid(short id) 85 { 86 if (id != sid) 87 { 88 throw new RecordFormatException("Not a Area record"); 89 } 90 } 91 92 protected void fillFields(byte [] data, short size, int offset) 93 { 94 95 int pos = 0; 96 field_1_formatFlags = LittleEndian.getShort(data, pos + 0x0 + offset); 97 98 } 99 100 public String toString() 101 { 102 StringBuffer buffer = new StringBuffer (); 103 104 buffer.append("[AREA]\n"); 105 buffer.append(" .formatFlags = ") 106 .append("0x").append(HexDump.toHex( getFormatFlags ())) 107 .append(" (").append( getFormatFlags() ).append(" )"); 108 buffer.append(System.getProperty("line.separator")); 109 buffer.append(" .stacked = ").append(isStacked()).append('\n'); 110 buffer.append(" .displayAsPercentage = ").append(isDisplayAsPercentage()).append('\n'); 111 buffer.append(" .shadow = ").append(isShadow()).append('\n'); 112 113 buffer.append("[/AREA]\n"); 114 return buffer.toString(); 115 } 116 117 public int serialize(int offset, byte[] data) 118 { 119 int pos = 0; 120 121 LittleEndian.putShort(data, 0 + offset, sid); 122 LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4)); 123 124 LittleEndian.putShort(data, 4 + offset + pos, field_1_formatFlags); 125 126 return getRecordSize(); 127 } 128 129 132 public int getRecordSize() 133 { 134 return 4 + 2; 135 } 136 137 public short getSid() 138 { 139 return this.sid; 140 } 141 142 public Object clone() { 143 AreaRecord rec = new AreaRecord(); 144 145 rec.field_1_formatFlags = field_1_formatFlags; 146 return rec; 147 } 148 149 150 151 152 155 public short getFormatFlags() 156 { 157 return field_1_formatFlags; 158 } 159 160 163 public void setFormatFlags(short field_1_formatFlags) 164 { 165 this.field_1_formatFlags = field_1_formatFlags; 166 } 167 168 172 public void setStacked(boolean value) 173 { 174 field_1_formatFlags = stacked.setShortBoolean(field_1_formatFlags, value); 175 } 176 177 181 public boolean isStacked() 182 { 183 return stacked.isSet(field_1_formatFlags); 184 } 185 186 190 public void setDisplayAsPercentage(boolean value) 191 { 192 field_1_formatFlags = displayAsPercentage.setShortBoolean(field_1_formatFlags, value); 193 } 194 195 199 public boolean isDisplayAsPercentage() 200 { 201 return displayAsPercentage.isSet(field_1_formatFlags); 202 } 203 204 208 public void setShadow(boolean value) 209 { 210 field_1_formatFlags = shadow.setShortBoolean(field_1_formatFlags, value); 211 } 212 213 217 public boolean isShadow() 218 { 219 return shadow.isSet(field_1_formatFlags); 220 } 221 222 223 } 225 226 227 228 | Popular Tags |