01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Igor V. Stolyarov
19: * @version $Revision$
20: */package java.awt.image;
21:
22: public final class DataBufferInt extends DataBuffer {
23:
24: int data[][];
25:
26: public DataBufferInt(int dataArrays[][], int size, int offsets[]) {
27: super (TYPE_INT, size, dataArrays.length, offsets);
28: data = dataArrays.clone();
29: }
30:
31: public DataBufferInt(int dataArrays[][], int size) {
32: super (TYPE_INT, size, dataArrays.length);
33: data = dataArrays.clone();
34: }
35:
36: public DataBufferInt(int dataArray[], int size, int offset) {
37: super (TYPE_INT, size, 1, offset);
38: data = new int[1][];
39: data[0] = dataArray;
40: }
41:
42: public DataBufferInt(int dataArray[], int size) {
43: super (TYPE_INT, size);
44: data = new int[1][];
45: data[0] = dataArray;
46: }
47:
48: public DataBufferInt(int size, int numBanks) {
49: super (TYPE_INT, size, numBanks);
50: data = new int[numBanks][];
51: int i = 0;
52: while (i < numBanks) {
53: data[i++] = new int[size];
54: }
55: }
56:
57: public DataBufferInt(int size) {
58: super (TYPE_INT, size);
59: data = new int[1][];
60: data[0] = new int[size];
61: }
62:
63: @Override
64: public void setElem(int bank, int i, int val) {
65: data[bank][offsets[bank] + i] = val;
66: notifyChanged();
67: }
68:
69: @Override
70: public void setElem(int i, int val) {
71: data[0][offset + i] = val;
72: notifyChanged();
73: }
74:
75: @Override
76: public int getElem(int bank, int i) {
77: return data[bank][offsets[bank] + i];
78: }
79:
80: public int[] getData(int bank) {
81: notifyTaken();
82: return data[bank];
83: }
84:
85: @Override
86: public int getElem(int i) {
87: return data[0][offset + i];
88: }
89:
90: public int[][] getBankData() {
91: notifyTaken();
92: return data.clone();
93: }
94:
95: public int[] getData() {
96: notifyTaken();
97: return data[0];
98: }
99: }
|