1 /* Copyright (C) 2000, 2002 Free Software Foundation
3 This file is part of GNU Classpath.
5 GNU Classpath is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Classpath is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Classpath; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 As a special exception, if you link this library with other files to
21 produce an executable, this library does not by itself cause the
22 resulting executable to be covered by the GNU General Public License.
23 This exception does not however invalidate any other reasons why the
24 executable file might be covered by the GNU General Public License. */
26 package java.awt.image;
28 /* This is one of several classes that are nearly identical. Maybe we
29 should have a central template and generate all these files. This
30 is one of the cases where templates or macros would have been
31 useful to have in Java.
33 This file has been created using search-replace. My only fear is
34 that these classes will grow out-of-sync as of a result of changes
35 that are not propagated to the other files. As always, mirroring
36 code is a maintenance nightmare. */
39 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
41 public class DataBufferInt extends DataBuffer
44 private int[][] bankData;
46 public DataBufferInt(int size)
48 super(TYPE_INT, size);
52 public DataBufferInt(int size, int numBanks)
54 super(TYPE_INT, size, numBanks);
55 bankData = new int[numBanks][size];
59 public DataBufferInt(int[] dataArray, int size)
61 super(TYPE_INT, size);
65 public DataBufferInt(int[] dataArray, int size, int offset)
67 super(TYPE_INT, size, 1, offset);
71 public DataBufferInt(int[][] dataArray, int size)
73 super(TYPE_INT, size, dataArray.length);
78 public DataBufferInt(int[][] dataArray, int size, int[] offsets)
80 super(TYPE_INT, size, dataArray.length, offsets);
85 public int[] getData()
90 public int[] getData(int bank)
92 return bankData[bank];
95 public int[][] getBankData()
100 public int getElem(int i)
102 return data[i+offset];
105 public int getElem(int bank, int i)
107 // get unsigned int as int
108 return bankData[bank][i+offsets[bank]];
111 public void setElem(int i, int val)
113 data[i+offset] = (int) val;
116 public void setElem(int bank, int i, int val)
118 bankData[bank][i+offsets[bank]] = (int) val;