Class ColorsForRange
java.lang.Object
org.apache.sis.internal.coverage.j2d.ColorsForRange
- All Implemented Interfaces:
Comparable<ColorsForRange>
Colors to apply on a range of sample values. Instances of
.
ColorsForRange
are temporary, used only
the time needed for
invalid reference
ColorModelFactory#createColorModel(int, int, int, ColorsForRange[])
- Since:
- 1.1
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Color[]
The colors to apply on the range of sample values.(package private) final boolean
true
if this entry should be taken as data, orfalse
if it should be ignored.(package private) final CharSequence
A name identifying the range of values.(package private) NumberRange
<?> The range of sample values on which the colors will be applied. -
Constructor Summary
ConstructorsConstructorDescriptionColorsForRange
(CharSequence name, NumberRange<?> sampleRange, Color[] colors, boolean isData) Creates a new instance for the given range of values.ColorsForRange
(Category category, Function<Category, Color[]> colors) Creates a new instance for the given category. -
Method Summary
Modifier and TypeMethodDescription(package private) static void
appendColorRange
(StringBuilder buffer, int count, IntUnaryOperator colors) Appends the range of ARGB codes as hexadecimal values.int
compareTo
(ColorsForRange other) Comparator for sorting entries by their alpha value.private int
getAlpha()
Returns the maximal alpha value found in colors.(package private) static ColorsForRange[]
list
(Collection<Map.Entry<NumberRange<?>, Color[]>> colors) Converts map entries to an array ofColorsForRange
entries.(package private) final int[]
toARGB()
Returns the ARGB codes for the colors.toString()
Returns a string representation for debugging purposes.
-
Field Details
-
name
A name identifying the range of values. the category name is used if available, otherwise this is a string representation of the range. -
sampleRange
NumberRange<?> sampleRangeThe range of sample values on which the colors will be applied. Shall never be null. May be updated afterColorizer.compact()
mapped range of floating point values to range ofIndexColorModel
values. -
colors
The colors to apply on the range of sample values. A null or empty array means transparent. -
isData
final boolean isDatatrue
if this entry should be taken as data, orfalse
if it should be ignored. Entry to ignore are entries associated to NaN values.
-
-
Constructor Details
-
ColorsForRange
Creates a new instance for the given category.- Parameters:
category
- the category for which thisColorsForRange
is created, ornull
.colors
- colors to apply on the category.
-
ColorsForRange
ColorsForRange(CharSequence name, NumberRange<?> sampleRange, Color[] colors, boolean isData) Creates a new instance for the given range of values.- Parameters:
name
- a name identifying the range of values, ornull
for automatic.sampleRange
- range of sample values on which the colors will be applied.colors
- colors to apply on the range of sample values, ornull
for transparent.isData
- whether this entry should be taken as main data (not fill values).
-
-
Method Details
-
list
Converts map entries to an array ofColorsForRange
entries. Theinvalid reference
#category
- Parameters:
colors
- the colors to use for each range of sample values. Anull
entry value means transparent.- Returns:
- colors to use for each range of values in the source image. Never null and does not contain null elements.
-
toString
Returns a string representation for debugging purposes. -
appendColorRange
Appends the range of ARGB codes as hexadecimal values. If the count of ARGB codes is 0, then this method does nothing. If the count is 1, then this method formats the single value. If the count is 2 or more, then this method formats the first and last values.- Parameters:
buffer
- where to append the range of ARGB codes.count
- number of ARGB codes.colors
- providers of ARGB codes for given indices.
-
compareTo
Comparator for sorting entries by their alpha value. The intent is to have transparent colors first.- Specified by:
compareTo
in interfaceComparable<ColorsForRange>
- Parameters:
other
- the other instance to compare with this instance.- Returns:
- -1 if this instance if more transparent, +1 if the other instance is more transparent, 0 if equal.
-
getAlpha
private int getAlpha()Returns the maximal alpha value found in colors. -
toARGB
final int[] toARGB()Returns the ARGB codes for the colors. If all colors are transparent, returns an empty array.- Returns:
- ARGB codes for the given colors. Never
null
but may be empty.
-