1 7 8 17 18 package java.awt.image; 19 20 23 24 25 public final class DataBufferShort extends DataBuffer 26 { 27 28 short data[]; 29 30 31 short bankdata[][]; 32 33 39 public DataBufferShort(int size) { 40 super(TYPE_SHORT,size); 41 data = new short[size]; 42 bankdata = new short[1][]; 43 bankdata[0] = data; 44 } 45 46 53 public DataBufferShort(int size, int numBanks) { 54 super(TYPE_SHORT,size,numBanks); 55 bankdata = new short[numBanks][]; 56 for (int i= 0; i < numBanks; i++) { 57 bankdata[i] = new short[size]; 58 } 59 data = bankdata[0]; 60 } 61 62 72 public DataBufferShort(short dataArray[], int size) { 73 super(TYPE_SHORT,size); 74 data = dataArray; 75 bankdata = new short[1][]; 76 bankdata[0] = data; 77 } 78 79 90 public DataBufferShort(short dataArray[], int size, int offset) { 91 super(TYPE_SHORT,size,1,offset); 92 data = dataArray; 93 bankdata = new short[1][]; 94 bankdata[0] = data; 95 } 96 97 106 public DataBufferShort(short dataArray[][], int size) { 107 super(TYPE_SHORT,size,dataArray.length); 108 bankdata = (short[][]) dataArray.clone(); 109 data = bankdata[0]; 110 } 111 112 126 public DataBufferShort(short dataArray[][], int size, int offsets[]) { 127 super(TYPE_SHORT,size,dataArray.length,offsets); 128 bankdata = (short[][]) dataArray.clone(); 129 data = bankdata[0]; 130 } 131 132 137 public short[] getData() { 138 return data; 139 } 140 141 147 public short[] getData(int bank) { 148 return bankdata[bank]; 149 } 150 151 155 public short[][] getBankData() { 156 return (short[][]) bankdata.clone(); 157 } 158 159 167 public int getElem(int i) { 168 return (int)(data[i+offset]); 169 } 170 171 180 public int getElem(int bank, int i) { 181 return (int)(bankdata[bank][i+offsets[bank]]); 182 } 183 184 193 public void setElem(int i, int val) { 194 data[i+offset] = (short)val; 195 } 196 197 206 public void setElem(int bank, int i, int val) { 207 bankdata[bank][i+offsets[bank]] = (short)val; 208 } 209 } 210 | Popular Tags |