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

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

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

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