public class Category extends Object implements Serializable
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.
GridSampleDimension
,
Serialized FormModifier and Type | Field and Description |
---|---|
static Category |
FALSE
A default category for the boolean "
false " value. |
static Category |
NODATA
A default category for "no data" values.
|
static Category |
TRUE
A default category for the boolean "
true " value. |
Constructor and Description |
---|
Category(CharSequence name,
Color[] colors,
int lower,
int upper)
Constructs a quantitative category for sample values ranging from
lower inclusive to
upper exclusive. |
Category(CharSequence name,
Color[] colors,
NumberRange sampleValueRange)
Constructs a quantitative category for sample values in the specified range.
|
Category(CharSequence name,
Color[] colors,
NumberRange 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 value
sample . |
Category(CharSequence name,
Color color,
int sample)
Constructs a qualitative category for sample value
sample . |
Category(CharSequence name,
Color color,
int sample,
boolean isQuantitative)
Constructs a qualitative category for sample value
sample . |
Category(CharSequence name,
Color color,
NumberRange<?> sampleValueRange)
Constructs a quantitative category for samples in the specified range.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Compares the specified object with this category for equality.
|
Color[] |
getColors()
Returns the set of colors for this category.
|
InternationalString |
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 |
isQuantitative()
Returns
true if this category is quantitative. |
Category |
recolor(Color[] colors)
Returns a category for the same range of sample values but a different color palette.
|
String |
toString()
Returns a string representation of this category.
|
public static final Category NODATA
Float.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.public static final Category FALSE
public static final Category TRUE
public Category(CharSequence name, Color color, boolean sample)
name
- The category name as a String
or InternationalString
object.color
- The category color, or null
for a default color.sample
- The sample value as a boolean.public Category(CharSequence name, Color color, int sample)
sample
.name
- The category name as a String
or InternationalString
object.color
- The category color, or null
for a default color.sample
- The sample value as an integer, usually in the range 0 to 255.public Category(CharSequence name, Color color, int sample, boolean isQuantitative)
sample
.name
- The category name as a String
or InternationalString
object.color
- The category color, or null
for a default color.sample
- The sample value as an integer, usually in the range 0 to 255.public Category(CharSequence name, Color color, double sample)
sample
.name
- The category name as a String
or InternationalString
object.color
- The category color, or null
for a default color.sample
- The sample value as a double. May be one of NaN
values.public Category(CharSequence name, Color color, NumberRange<?> sampleValueRange) throws IllegalArgumentException
name
- The category name as a String
or InternationalString
object.color
- The category color, or null
for a default color.sampleValueRange
- The range of sample values for this category. Element class is
usually Integer
, but Float
and Double
are accepted as well.IllegalArgumentException
- If the given range is invalid.public Category(CharSequence name, Color[] colors, int lower, int upper) throws IllegalArgumentException
lower
inclusive to
upper
exclusive.name
- The category name as a String
or InternationalString
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 a null
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.IllegalArgumentException
- if lower
is not smaller than upper
, or if
scale
or offset
are not real numbers.public Category(CharSequence name, Color[] colors, NumberRange sampleValueRange) throws IllegalArgumentException
name
- The category name as a String
or InternationalString
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 a null
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
usually Integer
, but Float
and Double
are accepted as well.IllegalArgumentException
- if lower
is not smaller than upper
, or if
scale
or offset
are not real numbers.public Category(CharSequence name, Color[] colors, NumberRange sampleValueRange, boolean isQuantitative) throws IllegalArgumentException
name
- The category name as a String
or InternationalString
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 a null
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
usually Integer
, but Float
and Double
are accepted as well.ClassCastException
- if the range element class is not a Number
subclass.IllegalArgumentException
- if the range is invalid.public InternationalString getName()
public Color[] getColors()
GridSampleDimension.getColorModel()
public NumberRange<? extends Number> getRange()
NumberRange.getMinimum(boolean)
,
NumberRange.getMaximum(boolean)
,
GridSampleDimension.getMinimumValue()
,
GridSampleDimension.getMaximumValue()
public boolean isQuantitative()
true
if this category is quantitative.true
if this category is quantitative, or false
if this category is
qualitative.public Category recolor(Color[] colors)
null
array means that some default colors should be used (usually a
gradient from opaque black to opaque white).colors
- A set of colors for the new category.this
if the new colors are
identical to the current ones.org.geotools.coverage.processing.ColorMap#recolor
public int hashCode()
public boolean equals(Object object)
Copyright © 1996–2019 Geotools. All rights reserved.