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 ColorModelFactory#createColorModel(int, int, int, ColorsForRange[]).- Since:
- 1.1
- Version:
- 1.3
- See Also:
-
ColorModelFactory#createColorModel(int, int, int, ColorsForRange[])
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Color[]The colors to apply on the range of sample values.(package private) final booleantrueif this entry should be taken as data, orfalseif it should be ignored.(package private) final CharSequenceA 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 voidappendColorRange(StringBuilder buffer, int count, IntUnaryOperator colors) Appends the range of ARGB codes as hexadecimal values.intcompareTo(ColorsForRange other) Comparator for sorting entries by their alpha value.private intgetAlpha()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 ofColorsForRangeentries.(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 ofIndexColorModelvalues. -
colors
The colors to apply on the range of sample values. A null or empty array means transparent. -
isData
final boolean isDatatrueif this entry should be taken as data, orfalseif 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 thisColorsForRangeis 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, ornullfor automatic.sampleRange- range of sample values on which the colors will be applied.colors- colors to apply on the range of sample values, ornullfor transparent.isData- whether this entry should be taken as main data (not fill values).
-
-
Method Details
-
list
Converts map entries to an array ofColorsForRangeentries. The#categoryof each entry is left to null.- Parameters:
colors- the colors to use for each range of sample values. Anullentry 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:
compareToin 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
nullbut may be empty.
-