1. /*
  2. * @(#)LookupTable.java 1.22 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.awt.image;
  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{
  30. /**
  31. * Constants
  32. */
  33. int numComponents;
  34. int offset;
  35. int numEntries;
  36. /**
  37. * Constructs a new LookupTable from the number of components and an offset
  38. * into the lookup table.
  39. * @param offset the offset to subtract from input values before indexing
  40. * into the data arrays for this <code>LookupTable</code>
  41. * @param numComponents the number of data arrays in this
  42. * <code>LookupTable</code>
  43. * @throws IllegalArgumentException if <code>offset</code> is less than 0
  44. * or if <code>numComponents</code> is less than 1
  45. */
  46. protected LookupTable(int offset, int numComponents) {
  47. if (offset < 0) {
  48. throw new
  49. IllegalArgumentException("Offset must be greater than 0");
  50. }
  51. if (numComponents < 1) {
  52. throw new IllegalArgumentException("Number of components must "+
  53. " be at least 1");
  54. }
  55. this.numComponents = numComponents;
  56. this.offset = offset;
  57. }
  58. /**
  59. * Returns the number of components in the lookup table.
  60. */
  61. public int getNumComponents() {
  62. return numComponents;
  63. }
  64. /**
  65. * Returns the offset.
  66. */
  67. public int getOffset() {
  68. return offset;
  69. }
  70. /**
  71. * Returns an int array of components for one pixel. Source and
  72. * destination may be equal. The dest array is returned. If dest
  73. * is null, a new array will be allocated.
  74. */
  75. public abstract int[] lookupPixel(int[] src, int[] dest);
  76. }