/[classpath]/classpath/java/awt/image/DataBufferShort.java
ViewVC logotype

Diff of /classpath/java/awt/image/DataBufferShort.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by brawer, Thu Apr 15 07:44:09 2004 UTC revision 1.2 by mark, Thu Sep 9 17:52:46 2004 UTC
# Line 54  public final class DataBufferShort exten Line 54  public final class DataBufferShort exten
54    private short[] data;    private short[] data;
55    private short[][] bankData;    private short[][] bankData;
56        
57      /**
58       * Creates a new data buffer with a single data bank containing the
59       * specified number of <code>short</code> elements.
60       *
61       * @param size the number of elements in the data bank.
62       */
63    public DataBufferShort(int size)    public DataBufferShort(int size)
64    {    {
65      super(TYPE_SHORT, size);      super(TYPE_SHORT, size);
66      data = new short[size];      data = new short[size];
67    }    }
68    
69      /**
70       * Creates a new data buffer with the specified number of data banks,
71       * each containing the specified number of <code>short</code> elements.
72       *
73       * @param size the number of elements in the data bank.
74       * @param numBanks the number of data banks.
75       */
76    public DataBufferShort(int size, int numBanks)    public DataBufferShort(int size, int numBanks)
77    {    {
78      super(TYPE_SHORT, size, numBanks);      super(TYPE_SHORT, size, numBanks);
# Line 67  public final class DataBufferShort exten Line 80  public final class DataBufferShort exten
80      data = bankData[0];      data = bankData[0];
81    }    }
82    
83      /**
84       * Creates a new data buffer backed by the specified data bank.
85       * <p>
86       * Note: there is no exception when <code>dataArray</code> is
87       * <code>null</code>, but in that case an exception will be thrown
88       * later if you attempt to access the data buffer.
89       *
90       * @param dataArray the data bank.
91       * @param size the number of elements in the data bank.
92       */
93    public DataBufferShort(short[] dataArray, int size)    public DataBufferShort(short[] dataArray, int size)
94    {    {
95      super(TYPE_SHORT, size);      super(TYPE_SHORT, size);
96      data = dataArray;      data = dataArray;
97    }    }
98            
99      /**
100       * Creates a new data buffer backed by the specified data bank, with
101       * the specified offset to the first element.
102       * <p>
103       * Note: there is no exception when <code>dataArray</code> is
104       * <code>null</code>, but in that case an exception will be thrown
105       * later if you attempt to access the data buffer.
106       *
107       * @param dataArray the data bank.
108       * @param size the number of elements in the data bank.
109       * @param offset the offset to the first element in the array.
110       */
111    public DataBufferShort(short[] dataArray, int size, int offset)    public DataBufferShort(short[] dataArray, int size, int offset)
112    {    {
113      super(TYPE_SHORT, size, 1, offset);      super(TYPE_SHORT, size, 1, offset);
114      data = dataArray;      data = dataArray;
115    }    }
116    
117      /**
118       * Creates a new data buffer backed by the specified data banks.
119       *
120       * @param dataArray the data banks.
121       * @param size the number of elements in the data bank.
122       *
123       * @throws NullPointerException if <code>dataArray</code> is
124       *         <code>null</code>.
125       */
126    public DataBufferShort(short[][] dataArray, int size)    public DataBufferShort(short[][] dataArray, int size)
127    {    {
128      super(TYPE_SHORT, size, dataArray.length);      super(TYPE_SHORT, size, dataArray.length);
# Line 86  public final class DataBufferShort exten Line 130  public final class DataBufferShort exten
130      data = bankData[0];      data = bankData[0];
131    }    }
132    
133      /**
134       * Creates a new data buffer backed by the specified data banks, with
135       * the specified offsets to the first element in each bank.
136       *
137       * @param dataArray the data banks.
138       * @param size the number of elements in the data bank.
139       * @param offsets the offsets to the first element in each data bank.
140       *
141       * @throws NullPointerException if <code>dataArray</code> is
142       *         <code>null</code>.
143       */
144    public DataBufferShort(short[][] dataArray, int size, int[] offsets)    public DataBufferShort(short[][] dataArray, int size, int[] offsets)
145    {    {
146      super(TYPE_SHORT, size, dataArray.length, offsets);      super(TYPE_SHORT, size, dataArray.length, offsets);
# Line 93  public final class DataBufferShort exten Line 148  public final class DataBufferShort exten
148      data = bankData[0];      data = bankData[0];
149    }    }
150    
151      /**
152       * Returns the first data bank.
153       *
154       * @return The first data bank.
155       */
156    public short[] getData()    public short[] getData()
157    {    {
158      return data;      return data;
159    }    }
160            
161      /**
162       * Returns a data bank.
163       *
164       * @param bank the bank index.
165       * @return A data bank.
166       */
167    public short[] getData(int bank)    public short[] getData(int bank)
168    {    {
169      return bankData[bank];      return bankData[bank];
170    }    }
171            
172      /**
173       * Returns the array underlying this <code>DataBuffer</code>.
174       *
175       * @return The data banks.
176       */
177    public short[][] getBankData()    public short[][] getBankData()
178    {    {
179      return bankData;      return bankData;
180    }    }
181        
182      /**
183       * Returns an element from the first data bank.  The offset (specified in
184       * the constructor) is added to <code>i</code> before accessing the
185       * underlying data array.
186       *
187       * @param i the element index.
188       * @return The element.
189       */
190    public int getElem(int i)    public int getElem(int i)
191    {    {
192      return data[i+offset];      return data[i+offset];
193    }    }
194    
195      /**
196       * Returns an element from a particular data bank.  The offset (specified in
197       * the constructor) is added to <code>i</code> before accessing the
198       * underlying data array.
199       *
200       * @param bank the bank index.
201       * @param i the element index.
202       * @return The element.
203       */
204    public int getElem(int bank, int i)    public int getElem(int bank, int i)
205    {    {
206      return bankData[bank][i+offsets[bank]];      return bankData[bank][i+offsets[bank]];
207    }    }
208    
209      /**
210       * Sets an element in the first data bank.  The offset (specified in the
211       * constructor) is added to <code>i</code> before updating the underlying
212       * data array.
213       *
214       * @param i the element index.
215       * @param val the new element value.
216       */
217    public void setElem(int i, int val)    public void setElem(int i, int val)
218    {    {
219      data[i+offset] = (short) val;      data[i+offset] = (short) val;
220    }    }
221    
222      /**
223       * Sets an element in a particular data bank.  The offset (specified in the
224       * constructor) is added to <code>i</code> before updating the underlying
225       * data array.
226       *
227       * @param bank the data bank index.
228       * @param i the element index.
229       * @param val the new element value.
230       */
231    public void setElem(int bank, int i, int val)    public void setElem(int bank, int i, int val)
232    {    {
233      bankData[bank][i+offsets[bank]] = (short) val;      bankData[bank][i+offsets[bank]] = (short) val;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26