home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 4.7 KB | 160 lines |
- /*
- * @(#)DataBufferInt.java 1.8 98/03/18
- *
- * Copyright 1997 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- /* ****************************************************************
- ******************************************************************
- ******************************************************************
- *** COPYRIGHT (c) Eastman Kodak Company, 1997
- *** As an unpublished work pursuant to Title 17 of the United
- *** States Code. All rights reserved.
- ******************************************************************
- ******************************************************************
- ******************************************************************/
-
- package java.awt.image;
-
- /**
- * This class extends DataBuffer and stores data internally as ints.
- */
-
- public class DataBufferInt extends DataBuffer
- {
- /** The default data bank. */
- int data[];
-
- /** All data banks */
- int bankdata[][];
-
- /**
- * Construct an int based DataBuffer with specified size
- */
- public DataBufferInt(int size) {
- super(INT_DATA,size);
- data = new int[size];
- bankdata = new int[1][];
- bankdata[0] = data;
- }
-
- /**
- * Construct an int based DataBuffer with specified number of
- * banks all of which are the specified size.
- */
- public DataBufferInt(int size, int numBanks) {
- super(INT_DATA,size,numBanks);
- bankdata = new int[numBanks][];
- for (int i= 0; i < numBanks; i++) {
- bankdata[i] = new int[size];
- }
- data = bankdata[0];
- }
-
- /**
- * Construct an int based DataBuffer with specified array.
- * Only the first size elements are available for use by
- * this databuffer. dataArray.length must be large enough to
- * hold size elements.
- */
- public DataBufferInt(int dataArray[], int size) {
- super(INT_DATA,size);
- data = dataArray;
- bankdata = new int[1][];
- bankdata[0] = data;
- }
-
- /**
- * Construct an int based DataBuffer with specified array, size,
- * and offset. dataArray.length must be at least as large as
- * offset + size.
- */
- public DataBufferInt(int dataArray[], int size, int offset) {
- super(INT_DATA,size,1,offset);
- data = dataArray;
- bankdata = new int[1][];
- bankdata[0] = data;
- }
-
- /**
- * Construct an int based DataBuffer with specified array.
- * Only the first size elements are available for use by
- * this databuffer. dataArray.length must be large enough to
- * hold size elements.
- */
- public DataBufferInt(int dataArray[][], int size) {
- super(INT_DATA,dataArray.length,size);
- bankdata = dataArray;
- data = bankdata[0];
- }
-
- /**
- * Construct an int based DataBuffer with specified arrays/size/offsets.
- * The number of banks is equal to dataArray.length. Each array must
- * be at least as large as size + the corresponding offset. There must
- * be an entry in the offset array for each dataArray entry.
- */
- public DataBufferInt(int dataArray[][], int size, int offsets[]) {
- super(INT_DATA,size,dataArray.length,offsets);
- bankdata = dataArray;
- data = bankdata[0];
- }
-
- /**
- * Return the default (first) int data array int DataBuffer
- */
- public int[] getData() {
- return data;
- }
-
- /** Return the data array for the specified bank */
- public int[] getData(int bank) {
- return bankdata[bank];
- }
-
- /** Return the data array for all banks */
- public int[][] getBankData() {
- return bankdata;
- }
-
- /**
- * Returns the requested data array element from the first (default) bank
- * as an integer.
- */
- public int getElem(int i) {
- return data[i+offset];
- }
-
- /**
- * Returns the requested data array element from the specified bank
- * as an integer.
- */
- public int getElem(int bank, int i) {
- return bankdata[bank][i+offsets[bank]];
- }
-
- /**
- * Sets the requested data array element in the first (default) bank
- * from the given integer.
- */
- public void setElem(int i, int val) {
- data[i+offset] = val;
- }
-
- /**
- * Sets the requested data array element in the specified bank
- * from the given integer.
- */
- public void setElem(int bank, int i, int val) {
- bankdata[bank][i+offsets[bank]] = (int)val;
- }
- }
-