Package org.geotools.coverage
Class Category
Object
Category
- All Implemented Interfaces:
Serializable
A category delimited by a range of values. A category may be either qualitative or quantitative.
For example, a classified image may have a qualitative category defining sample value
0
as water. An other
qualitative category may defines sample value 1
as forest, etc. An other image may define elevation data as
sample values in the range [0..100]
. The later is a quantitative category, because sample values are
related to some measurement in the real world. For example, elevation data may be related to an altitude in metres
through the following linear relation:
altitude = sample value×100.
Some image mixes both qualitative and quantitative categories. For example, images of Sea Surface Temperature (SST) may have a quantitative category for temperature with values ranging from 2 to 35°C, and three qualitative categories for cloud, land and ice.
All categories must have a human readable name.
All Category
objects are immutable and thread-safe.
- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCategory
(CharSequence name, Color[] colors, int lower, int upper) Constructs a quantitative category for sample values ranging fromlower
inclusive toupper
exclusive.Category
(CharSequence name, Color[] colors, NumberRange<? extends Number> sampleValueRange) Constructs a quantitative category for sample values in the specified range.Category
(CharSequence name, Color[] colors, NumberRange<? extends Number> sampleValueRange, boolean isQuantitative) Constructs a qualitative or quantitative category for samples in the specified range.Category
(CharSequence name, Color color, boolean sample) Constructs a qualitative category for a boolean value.Category
(CharSequence name, Color color, double sample) Constructs a qualitative category for sample valuesample
.Category
(CharSequence name, Color color, int sample) Constructs a qualitative category for sample valuesample
.Category
(CharSequence name, Color color, int sample, boolean isQuantitative) Constructs a qualitative category for sample valuesample
.Category
(CharSequence name, Color color, NumberRange<?> sampleValueRange) Constructs a quantitative category for samples in the specified range. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares the specified object with this category for equality.Color[]
Returns the set of colors for this category.getName()
Returns the category name.NumberRange<? extends Number>
getRange()
Returns the range of sample values occurring in this category.int
hashCode()
Returns a hash value for this category.boolean
Returnstrue
if this category is quantitative.Returns a category for the same range of sample values but a different color palette.toString()
Returns a string representation of this category.
-
Field Details
-
NODATA
A default category for "no data" values. This default qualitative category use sample value 0, which is mapped to geophysics valueFloat.NaN
for those who work with floating point images. The rendering color default to a fully transparent color and the name is "no data" localized to the requested locale. -
FALSE
-
TRUE
-
-
Constructor Details
-
Category
Constructs a qualitative category for a boolean value.- Parameters:
name
- The category name as aString
orInternationalString
object.color
- The category color, ornull
for a default color.sample
- The sample value as a boolean.
-
Category
Constructs a qualitative category for sample valuesample
.- Parameters:
name
- The category name as aString
orInternationalString
object.color
- The category color, ornull
for a default color.sample
- The sample value as an integer, usually in the range 0 to 255.
-
Category
Constructs a qualitative category for sample valuesample
.- Parameters:
name
- The category name as aString
orInternationalString
object.color
- The category color, ornull
for a default color.sample
- The sample value as an integer, usually in the range 0 to 255.
-
Category
Constructs a qualitative category for sample valuesample
.- Parameters:
name
- The category name as aString
orInternationalString
object.color
- The category color, ornull
for a default color.sample
- The sample value as a double. May be one ofNaN
values.
-
Category
public Category(CharSequence name, Color color, NumberRange<?> sampleValueRange) throws IllegalArgumentException Constructs a quantitative category for samples in the specified range.- Parameters:
name
- The category name as aString
orInternationalString
object.color
- The category color, ornull
for a default color.sampleValueRange
- The range of sample values for this category. Element class is usuallyInteger
, butFloat
andDouble
are accepted as well.- Throws:
IllegalArgumentException
- If the given range is invalid.
-
Category
public Category(CharSequence name, Color[] colors, int lower, int upper) throws IllegalArgumentException Constructs a quantitative category for sample values ranging fromlower
inclusive toupper
exclusive.- Parameters:
name
- The category name as aString
orInternationalString
object.colors
- A set of colors for this category. This array may have any length; colors will be interpolated as needed. An array of length 1 means that an uniform color should be used for all sample values. An array of length 0 or anull
array means that some default colors should be used (usually a gradient from opaque black to opaque white).lower
- The lower sample value, inclusive.upper
- The upper sample value, exclusive.- Throws:
IllegalArgumentException
- iflower
is not smaller thanupper
, or ifscale
oroffset
are not real numbers.
-
Category
public Category(CharSequence name, Color[] colors, NumberRange<? extends Number> sampleValueRange) throws IllegalArgumentException Constructs a quantitative category for sample values in the specified range.- Parameters:
name
- The category name as aString
orInternationalString
object.colors
- A set of colors for this category. This array may have any length; colors will be interpolated as needed. An array of length 1 means that an uniform color should be used for all sample values. An array of length 0 or anull
array means that some default colors should be used (usually a gradient from opaque black to opaque white).sampleValueRange
- The range of sample values for this category. Element class is usuallyInteger
, butFloat
andDouble
are accepted as well.- Throws:
IllegalArgumentException
- iflower
is not smaller thanupper
, or ifscale
oroffset
are not real numbers.
-
Category
public Category(CharSequence name, Color[] colors, NumberRange<? extends Number> sampleValueRange, boolean isQuantitative) throws IllegalArgumentException Constructs a qualitative or quantitative category for samples in the specified range.- Parameters:
name
- The category name as aString
orInternationalString
object.colors
- A set of colors for this category. This array may have any length; colors will be interpolated as needed. An array of length 1 means that an uniform color should be used for all sample values. An array of length 0 or anull
array means that some default colors should be used (usually a gradient from opaque black to opaque white).sampleValueRange
- The range of sample values for this category. Element class is usuallyInteger
, butFloat
andDouble
are accepted as well.- Throws:
ClassCastException
- if the range element class is not aNumber
subclass.IllegalArgumentException
- if the range is invalid.
-
-
Method Details
-
getName
Returns the category name.- Returns:
- The category name.
-
getColors
Returns the set of colors for this category. Change to the returned array will not affect this category.- Returns:
- The colors palette for this category.
- See Also:
-
getRange
Returns the range of sample values occurring in this category.- Returns:
- The range of sample values.
- See Also:
-
isQuantitative
public boolean isQuantitative()Returnstrue
if this category is quantitative.- Returns:
true
if this category is quantitative, orfalse
if this category is qualitative.
-
recolor
Returns a category for the same range of sample values but a different color palette. The array given in argument may have any length; colors will be interpolated as needed. An array of length 1 means that an uniform color should be used for all sample values. An array of length 0 or anull
array means that some default colors should be used (usually a gradient from opaque black to opaque white).- Parameters:
colors
- A set of colors for the new category.- Returns:
- A category with the new color palette, or
this
if the new colors are identical to the current ones. - See Also:
-
org.geotools.coverage.processing.ColorMap#recolor
-
hashCode
public int hashCode()Returns a hash value for this category. This value need not remain consistent between different implementations of the same class. -
equals
Compares the specified object with this category for equality. -
toString
Returns a string representation of this category. The returned string is implementation dependent. It is usually provided for debugging purposes.
-