View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.imaging.formats.tiff.photometricinterpreters.floatingpoint;
18  
19  import java.awt.Color;
20  
21  /**
22   * Defines an interface for specifying color assignments to floating point values.
23   */
24  public interface PaletteEntry {
25  
26      /**
27       * Indicates that the entry covers exactly one unique value (including, potentially, Float.NaN).
28       *
29       * @return true if the entry covers exactly one unique value
30       */
31      boolean coversSingleEntry();
32  
33      /**
34       * Gets the integer ARGB color assignment associated with the input value. If the input value is not within the covered range of this instance, the return
35       * value is undefined (though the value zero is often used).
36       *
37       * @param f valid floating point value, or a NaN.
38       * @return an integer value
39       */
40      int getArgb(float f);
41  
42      /**
43       * Gets the color assignment associated with the input value. If the input value is not within the covered range of this instance, the return value is
44       * undefined (though a null return is often used).
45       *
46       * @param f a valid floating point value, or a NaN.
47       * @return a valid color instance or, potentially, a null if the floating point input is not within the covered range.
48       */
49      Color getColor(float f);
50  
51      /**
52       * Gets the lower-bound value for the palette entry
53       *
54       * @return if defined, a valid floating point value; otherwise, a null.
55       */
56      float getLowerBound();
57  
58      /**
59       * Gets the upper-bound value for the palette entry
60       *
61       * @return if defined, a valid floating point value; otherwise, a null.
62       */
63      float getUpperBound();
64  
65      /**
66       * Indicates whether the indicated floating-point value is within the range covered by this palette entry and can be assigned a valid color by the
67       * implementation.
68       *
69       * @param f a valid floating point value, or a NaN.
70       * @return true if the entry can assign a color to the entry; otherwise, false.
71       */
72      boolean isCovered(float f);
73  }