KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > image > LookupTable


1 /*
2  * @(#)LookupTable.java 1.26 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt.image;
9
10
11 /**
12  * This abstract class defines a lookup table object. ByteLookupTable
13  * and ShortLookupTable are subclasses, which
14  * contain byte and short data, respectively. A lookup table
15  * contains data arrays for one or more bands (or components) of an image
16  * (for example, separate arrays for R, G, and B),
17  * and it contains an offset which will be subtracted from the
18  * input values before indexing into the arrays. This allows an array
19  * smaller than the native data size to be provided for a
20  * constrained input. If there is only one array in the lookup
21  * table, it will be applied to all bands. All arrays must be the
22  * same size.
23  *
24  * @see ByteLookupTable
25  * @see ShortLookupTable
26  * @see LookupOp
27  * @version 10 Feb 1997
28  */

29 public abstract class LookupTable extends Object JavaDoc{
30
31     /**
32      * Constants
33      */

34  
35     int numComponents;
36     int offset;
37     int numEntries;
38
39     /**
40      * Constructs a new LookupTable from the number of components and an offset
41      * into the lookup table.
42      * @param offset the offset to subtract from input values before indexing
43      * into the data arrays for this <code>LookupTable</code>
44      * @param numComponents the number of data arrays in this
45      * <code>LookupTable</code>
46      * @throws IllegalArgumentException if <code>offset</code> is less than 0
47      * or if <code>numComponents</code> is less than 1
48      */

49     protected LookupTable(int offset, int numComponents) {
50         if (offset < 0) {
51             throw new
52                 IllegalArgumentException JavaDoc("Offset must be greater than 0");
53         }
54         if (numComponents < 1) {
55             throw new IllegalArgumentException JavaDoc("Number of components must "+
56                                                " be at least 1");
57         }
58         this.numComponents = numComponents;
59     this.offset = offset;
60     }
61
62     /**
63      * Returns the number of components in the lookup table.
64      * @return the number of components in this <code>LookupTable</code>.
65      */

66     public int getNumComponents() {
67         return numComponents;
68     }
69
70     /**
71      * Returns the offset.
72      * @return the offset of this <code>LookupTable</code>.
73      */

74     public int getOffset() {
75         return offset;
76     }
77
78     /**
79      * Returns an <code>int</code> array of components for
80      * one pixel. The <code>dest</code> array contains the
81      * result of the lookup and is returned. If dest is
82      * <code>null</code>, a new array is allocated. The
83      * source and destination can be equal.
84      * @param src the source array of components of one pixel
85      * @param dest the destination array of components for one pixel,
86      * translated with this <code>LookupTable</code>
87      * @return an <code>int</code> array of components for one
88      * pixel.
89      */

90     public abstract int[] lookupPixel(int[] src, int[] dest);
91     
92 }
93
Popular Tags