home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / image / LookupTable.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  2.4 KB  |  84 lines

  1. /*
  2.  * @(#)LookupTable.java    1.16 98/03/18
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.image;
  16.  
  17.  
  18. /**
  19.  * This abstract class defines a lookup table object.  The subclasses
  20.  * are ByteLookupTable and ShortLookupTable, which
  21.  * contain byte and short data, respectively.  A lookup table
  22.  * contains data for one or more tile channels or image components
  23.  * (for example, separate arrays for R, G, and B),
  24.  * and it contains an offset which will be subtracted from the
  25.  * input value before indexing into the array.  This allows an array
  26.  * smaller than the native data size to be provided for a
  27.  * constrained input.  If there is only one array in the lookup
  28.  * table, it will be applied to all channels.  All arrays must be the
  29.  * same size.
  30.  * 
  31.  * @see ByteLookupTable
  32.  * @see ShortLookupTable
  33.  * @see LookupOp
  34.  * @version 10 Feb 1997
  35.  */
  36. public abstract class LookupTable extends Object{
  37.  
  38.     /**
  39.      * Constants
  40.      */  
  41.  
  42.     int  numComponents;
  43.     int  offset;
  44.     int  numEntries;
  45.  
  46.     /**
  47.      * Creates a new LookupTable from the number of components and an offset
  48.      * into the lookup table.
  49.      */
  50.     protected LookupTable(int offset, int numComponents) {
  51.         if (offset < 0) {
  52.             throw new
  53.                 IllegalArgumentException("Offset must be greater than 0");
  54.         }
  55.         if (numComponents < 1) {
  56.             throw new IllegalArgumentException("Number of components must "+
  57.                                                " be at least 1");
  58.         }
  59.         this.numComponents = numComponents;
  60.     this.offset = offset;
  61.     }
  62.  
  63.     /**
  64.      * Returns the number of components in the lookup table.
  65.      */
  66.     public int getNumComponents() {
  67.         return numComponents;
  68.     }
  69.  
  70.     /**
  71.      * Returns the offset.  
  72.      */
  73.     public int getOffset() {
  74.         return offset;
  75.     }
  76.  
  77.     /**
  78.      * Returns an array of components for one pixel. Source and Destination
  79.      * could be equal. Destination could be NULL.
  80.      */
  81.     public abstract int[] lookupPixel(int[] src, int[] dest);
  82.     
  83. }
  84.