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 DataBufferShort extends DataBuffer {
023:
024: short data[][];
025:
026: public DataBufferShort(short dataArrays[][], int size,
027: int offsets[]) {
028: super (TYPE_SHORT, size, dataArrays.length, offsets);
029: data = dataArrays.clone();
030: }
031:
032: public DataBufferShort(short dataArrays[][], int size) {
033: super (TYPE_SHORT, size, dataArrays.length);
034: data = dataArrays.clone();
035: }
036:
037: public DataBufferShort(short dataArray[], int size, int offset) {
038: super (TYPE_SHORT, size, 1, offset);
039: data = new short[1][];
040: data[0] = dataArray;
041: }
042:
043: public DataBufferShort(short dataArray[], int size) {
044: super (TYPE_SHORT, size);
045: data = new short[1][];
046: data[0] = dataArray;
047: }
048:
049: public DataBufferShort(int size, int numBanks) {
050: super (TYPE_SHORT, size, numBanks);
051: data = new short[numBanks][];
052: int i = 0;
053: while (i < numBanks) {
054: data[i++] = new short[size];
055: }
056: }
057:
058: public DataBufferShort(int size) {
059: super (TYPE_SHORT, size);
060: data = new short[1][];
061: data[0] = new short[size];
062: }
063:
064: @Override
065: public void setElem(int bank, int i, int val) {
066: data[bank][offsets[bank] + i] = (short) val;
067: notifyChanged();
068: }
069:
070: @Override
071: public void setElem(int i, int val) {
072: data[0][offset + i] = (short) val;
073: notifyChanged();
074: }
075:
076: @Override
077: public int getElem(int bank, int i) {
078: return (data[bank][offsets[bank] + i]);
079: }
080:
081: public short[] getData(int bank) {
082: notifyTaken();
083: return data[bank];
084: }
085:
086: @Override
087: public int getElem(int i) {
088: return (data[0][offset + i]);
089: }
090:
091: public short[][] getBankData() {
092: notifyTaken();
093: return data.clone();
094: }
095:
096: public short[] getData() {
097: notifyTaken();
098: return data[0];
099: }
100: }
|