|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectCategory
@Immutable public class Category
A category delimited by a range of sample 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. In addition, quantitative categories may define a transformation between sample values s and geophysics values x. This transformation is usually (but not always) a linear equation of the form:
x = offset + scale×s
More general equation are allowed. For example, SeaWiFS images use a logarithmic
transform. General transformations are expressed with a MathTransform1D object. In the
special case where the transformation is a linear one (as in the formula above), then a
Category object may be understood as the interval between two breakpoints in the JAI's
piecewise operation.
All Category objects are immutable and thread-safe.
GridSampleDimension,
CategoryRecord,
CategoryTable,
Serialized Form
| coverage/geotk-coverage (download) | View source code for this class |
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
Category(CharSequence name,
Color[] colors,
int lower,
int upper,
double scale,
double offset)
Constructs a quantitative category for sample values ranging from lower
inclusive to upper exclusive. |
|
Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
double scale,
double offset)
Constructs a quantitative category for sample values in the specified range. |
|
Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
MathTransform1D sampleToGeophysics)
Constructs a qualitative or quantitative category for samples in the specified range. |
|
Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
NumberRange<?> geophysicsValueRange)
Constructs a quantitative category mapping samples to geophysics values 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,
NumberRange<?> sampleValueRange)
Constructs a qualitative category for samples in the specified range. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object object)
Compares the specified object with this category for equality. |
Category |
geophysics(boolean geo)
Returns the geophysics or packed of this category. |
Color[] |
getColors()
Returns the set of colors for this category. |
InternationalString |
getName()
Returns the category name. |
NumberRange<?> |
getRange()
Returns the range of values occurring in this category. |
MathTransform1D |
getSampleToGeophysics()
Returns the transfer function from sample values to geophysics values. |
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. |
Category |
rescale(MathTransform1D sampleToGeophysics)
Changes the mapping from sample to geophysics values. |
String |
toString()
Returns a string representation of this category. |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
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
false" value. This default
identity category uses sample value 0, the color black and
the name "false" localized to the specified locale.
public static final Category TRUE
true" value. This default
identity category uses sample value 1, the color white
and the name "true" localized to the specified locale.
| Constructor Detail |
|---|
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,
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,
double scale,
double offset)
throws IllegalArgumentException
lower
inclusive to upper exclusive. Sample values are converted into geophysics
values using the following linear equation:
x = offset + scale×s
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.scale - The scale value which is
multiplied to sample values for this category. Must be different than zero.offset - The offset value to add
to sample values for this category.
IllegalArgumentException - if lower is not smaller than upper, or if scale or
offset are not real numbers, or if scale is zero.
public Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
double scale,
double offset)
throws IllegalArgumentException
x = offset + scale×s
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.scale - The scale value which is multiplied to
sample values for this category. Must be different than zero.offset - The offset value to add to sample values
for this category.
IllegalArgumentException - if lower is not smaller than upper, or if scale or
offset are not real numbers, or if scale is zero.
public Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
NumberRange<?> geophysicsValueRange)
throws IllegalArgumentException
sampleValueRange will be mapped to geophysics
values in the geophysicsValueRange through a linear equation of the form:
x = offset + scale×s
scale and offset coefficients are computed from the ranges supplied in
arguments.
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.geophysicsValueRange - The range of geophysics values for this category. Element class is usually
Float or Double.
ClassCastException - if the range element class is not a Number subclass.
IllegalArgumentException - if the range is invalid.
public Category(CharSequence name,
Color[] colors,
NumberRange<?> sampleValueRange,
MathTransform1D sampleToGeophysics)
throws IllegalArgumentException
sampleToGeophysics transform.
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.sampleToGeophysics - A transform from sample values to geophysics values,
or null if this category is not a quantitative one.
ClassCastException - if the range element class is not a Number subclass.
IllegalArgumentException - if the range is invalid.| Method Detail |
|---|
public InternationalString getName()
public Color[] getColors()
GridSampleDimension.getColorModel()public NumberRange<?> getRange()
GridSampleDimension.
Otherwise, the range are sample values than can be transformed into geophysics values
using the getSampleToGeophysics() transform.
NumberRange.getMinimum(boolean),
NumberRange.getMaximum(boolean),
GridSampleDimension.getMinimumValue(),
GridSampleDimension.getMaximumValue()public MathTransform1D getSampleToGeophysics()
null.
GridSampleDimension.getSampleToGeophysics()public boolean isQuantitative()
true if this category is quantitative. A quantitative category
has a non-null sampleToGeophysics transform.
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.ColorMap.recolor(org.geotoolkit.coverage.GridSampleDimension, int[])public Category rescale(MathTransform1D sampleToGeophysics)
Note about geophysics categories: The above rules are straightforward
when applied on non-geophysics category, but this method can be invoked on geophysics
category (as returned by geophysics(true)) as well.
Since geophysics categories are already the result of some "sample to geophysics"
transformation, invoking this method on those is equivalent to concatenate this "sample to geophysics" transform with the specified one.
sampleToGeophysics - The new sample to geophysics
transform.
getSampleToGeophysics(),
GridSampleDimension.rescale(double, double)public Category geophysics(boolean geo)
null if no
such transform existed in the first place. In other words, the range of sample values
in a geophysics category maps directly the "real world" values without the
need for any transformation.
Category objects live by pair: a
geophysics one (used for
computation) and a packed one
(used for storing data, usually as integers). The geo argument specifies which
object from the pair is wanted, regardless if this method is invoked on the geophysics or
packed instance of the pair.
Newly constructed categories are packed (i.e. a sample to geophysics transform must be applied in order to gets geophysics values).
geo - true to get a category with an identity
transform and a
range of values matching the
geophysics values, or
false to get the packed category (the one constructed with new Category(...)).
null, but may be this.GridSampleDimension.geophysics(boolean),
GridCoverage2D.view(org.geotoolkit.coverage.grid.ViewType)public int hashCode()
hashCode in class Objectpublic boolean equals(Object object)
equals in class Objectobject - The object to compare with.
true if the given object is equals to this category.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||