001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Igor V. Stolyarov
019: * @version $Revision$
020: */package java.awt.image;
021:
022: public final class DataBufferFloat extends DataBuffer {
023:
024: float data[][];
025:
026: public DataBufferFloat(float dataArrays[][], int size,
027: int offsets[]) {
028: super (TYPE_FLOAT, size, dataArrays.length, offsets);
029: data = dataArrays.clone();
030: }
031:
032: public DataBufferFloat(float dataArrays[][], int size) {
033: super (TYPE_FLOAT, size, dataArrays.length);
034: data = dataArrays.clone();
035: }
036:
037: public DataBufferFloat(float dataArray[], int size, int offset) {
038: super (TYPE_FLOAT, size, 1, offset);
039: data = new float[1][];
040: data[0] = dataArray;
041: }
042:
043: public DataBufferFloat(float dataArray[], int size) {
044: super (TYPE_FLOAT, size);
045: data = new float[1][];
046: data[0] = dataArray;
047: }
048:
049: public DataBufferFloat(int size, int numBanks) {
050: super (TYPE_FLOAT, size, numBanks);
051: data = new float[numBanks][];
052: int i = 0;
053: while (i < numBanks) {
054: data[i++] = new float[size];
055: }
056: }
057:
058: public DataBufferFloat(int size) {
059: super (TYPE_FLOAT, size);
060: data = new float[1][];
061: data[0] = new float[size];
062: }
063:
064: @Override
065: public void setElem(int bank, int i, int val) {
066: data[bank][offsets[bank] + i] = val;
067: notifyChanged();
068: }
069:
070: @Override
071: public void setElemFloat(int bank, int i, float val) {
072: data[bank][offsets[bank] + i] = val;
073: notifyChanged();
074: }
075:
076: @Override
077: public void setElemDouble(int bank, int i, double val) {
078: data[bank][offsets[bank] + i] = (float) val;
079: notifyChanged();
080: }
081:
082: @Override
083: public void setElem(int i, int val) {
084: data[0][offset + i] = val;
085: notifyChanged();
086: }
087:
088: @Override
089: public int getElem(int bank, int i) {
090: return (int) (data[bank][offsets[bank] + i]);
091: }
092:
093: @Override
094: public float getElemFloat(int bank, int i) {
095: return data[bank][offsets[bank] + i];
096: }
097:
098: @Override
099: public double getElemDouble(int bank, int i) {
100: return data[bank][offsets[bank] + i];
101: }
102:
103: @Override
104: public void setElemFloat(int i, float val) {
105: data[0][offset + i] = val;
106: notifyChanged();
107: }
108:
109: @Override
110: public void setElemDouble(int i, double val) {
111: data[0][offset + i] = (float) val;
112: notifyChanged();
113: }
114:
115: public float[] getData(int bank) {
116: notifyTaken();
117: return data[bank];
118: }
119:
120: @Override
121: public int getElem(int i) {
122: return (int) (data[0][offset + i]);
123: }
124:
125: @Override
126: public float getElemFloat(int i) {
127: return data[0][offset + i];
128: }
129:
130: @Override
131: public double getElemDouble(int i) {
132: return data[0][offset + i];
133: }
134:
135: public float[][] getBankData() {
136: notifyTaken();
137: return data.clone();
138: }
139:
140: public float[] getData() {
141: notifyTaken();
142: return data[0];
143: }
144: }
|