001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.imaging.formats.tiff.photometricinterpreters.floatingpoint; 018 019import java.awt.Color; 020 021/** 022 * Defines an interface for specifying color assignments to floating point 023 * values. 024 */ 025public interface PaletteEntry { 026 027 /** 028 * Indicates that the entry covers exactly one unique value (including, 029 * potentially, Float.NaN). 030 * 031 * @return true if the entry covers exactly one unique value 032 */ 033 boolean coversSingleEntry(); 034 035 /** 036 * Indicates whether the indicated floating-point value is within the range 037 * covered by this palette entry and can be assigned a valid color by the 038 * implementation. 039 * 040 * @param f a valid floating point value, or a NaN. 041 * @return true if the entry can assign a color to the entry; otherwise, 042 * false. 043 */ 044 boolean isCovered(float f); 045 046 /** 047 * Gets the integer ARGB color assignment associated with the input value. 048 * If the input value is not within the covered range of this instance, the 049 * return value is undefined (though the value zero is often used). 050 * 051 * @param f valid floating point value, or a NaN. 052 * @return an integer value 053 */ 054 int getARGB(float f); 055 056 /** 057 * Gets the color assignment associated with the input value. If the input 058 * value is not within the covered range of this instance, the return value 059 * is undefined (though a null return is often used). 060 * 061 * @param f a valid floating point value, or a NaN. 062 * @return a valid color instance or, potentially, a null if the floating 063 * point input is not within the covered range. 064 */ 065 Color getColor(float f); 066 067 /** 068 * Gets the lower-bound value for the palette entry 069 * 070 * @return if defined, a valid floating point value; otherwise, a null. 071 */ 072 float getLowerBound(); 073 074 /** 075 * Gets the upper-bound value for the palette entry 076 * 077 * @return if defined, a valid floating point value; otherwise, a null. 078 */ 079 float getUpperBound(); 080}