org.geotoolkit.gui.swing.coverage
Class CategoryRecord

Object
  extended by CategoryRecord
All Implemented Interfaces:
Serializable, Cloneable

public class CategoryRecord
extends Object
implements Cloneable, Serializable

A single row in a CategoryTable. A row contains the minimal and maximal sample values, together with the transfer function type and coefficients. Those informations can be inferred from an existing Category, edited, then used for creating a new Category.

The attributes in a CategoryRecord are interdependent. Invoking any setter method may have an effect on other attributes. For example if the scale factor is changed, then the range of values will be recomputed accordingly.

Since:
3.13
Version:
3.14
Author:
Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class

Constructor Summary
CategoryRecord()
          Creates a new row initialized to the [0 … 255] range of sample values, with no transfer function.
CategoryRecord(Category category, Locale locale)
          Creates a new row initialized to the values inferred from the given category.
 
Method Summary
 CategoryRecord clone()
          Returns a clone of this record.
 Category getCategory()
          Returns the category represented by this record.
 Double getCoefficient(int order)
          Returns a coefficient of the transfer function, or null if the category is not quantitative.
 String getName()
          Returns the category name.
 String getPaletteName()
          Returns the colors, as a palette name or as a RGB code.
 NumberRange<Integer> getSampleRange()
          Returns the range of sample values.
 TransferFunctionType getTransferFunctionType()
          Returns the transfer function type, or null if the category is not quantitative.
 NumberRange<Double> getValueRange()
          Returns the range of geophysics value, or null if there is no transfer function.
 boolean setCoefficient(int order, double coeff)
          Sets a coefficient of the transfer function.
 boolean setName(String name)
          Sets the category name.
 boolean setPaletteName(String name)
          Sets the colors, as a palette name or as a RGB code.
 boolean setSampleRange(Integer minimum, Integer maximum)
          Sets the range of sample values.
 boolean setTransferFunctionType(TransferFunctionType type)
          Sets the transfer function type.
 boolean setValueRange(Number minimum, Number maximum)
          Sets the range of geophysics values.
 String toString()
          Returns a string representation of this record, for debugging purpose.
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CategoryRecord

public CategoryRecord()
Creates a new row initialized to the [0 … 255] range of sample values, with no transfer function.


CategoryRecord

public CategoryRecord(Category category,
                      Locale locale)
Creates a new row initialized to the values inferred from the given category.

Parameters:
category - The category from which to infer the values.
locale - The locale to use for the localization of the category name, or null for an implementation-dependent default locale.
TODO:
Current implementation does not yet recognize logarithmic transfer function.
Method Detail

getCategory

public Category getCategory()
Returns the category represented by this record. If a category has been specified at construction time and no setter method changed the attributes, then that category is returned unchanged. Otherwise a new category is created and returned.

Returns:
The category represented by this record.

getName

public String getName()
Returns the category name.

Returns:
The cateogory name, or null if none.

setName

public boolean setName(String name)
Sets the category name.

Parameters:
name - The new category name.
Returns:
true if this object changed as a result of this method call.

getSampleRange

public NumberRange<Integer> getSampleRange()
Returns the range of sample values.

Returns:
The range of sample values (never null).

setSampleRange

public boolean setSampleRange(Integer minimum,
                              Integer maximum)
Sets the range of sample values.

Parameters:
minimum - The new minimal sample value, or null if unchanged.
maximum - The new maximal sample value, or null if unchanged.
Returns:
true if this object changed as a result of this method call.

getValueRange

public NumberRange<Double> getValueRange()
Returns the range of geophysics value, or null if there is no transfer function. If non-null, the returned range is computed from the range of sample values and the coefficients of the transfer function.

Returns:
The range of geophysics value, or null.

setValueRange

public boolean setValueRange(Number minimum,
                             Number maximum)
Sets the range of geophysics values. This method compute the offset and scale factors of the transfer function in order to match the given range.

Parameters:
minimum - The new minimal geophysics value, or null if unchanged.
maximum - The new maximal geophysics value, or null if unchanged.
Returns:
true if this object changed as a result of this method call.

getTransferFunctionType

public TransferFunctionType getTransferFunctionType()
Returns the transfer function type, or null if the category is not quantitative.

Returns:
The transfer function type, or null.

setTransferFunctionType

public boolean setTransferFunctionType(TransferFunctionType type)
Sets the transfer function type. IF the given argument is null ot an unknown code, then this method set the transfer function type to "none".

Parameters:
type - The new transfer function type, or null for a qualitative category.
Returns:
true if this object changed as a result of this method call.

getCoefficient

public Double getCoefficient(int order)
                      throws IllegalArgumentException
Returns a coefficient of the transfer function, or null if the category is not quantitative. The coefficient to fetch is determined by the order argument. Current implementation accepts only 0 (the offset) or 1 (the scale), but subclasses can add higher order.

Parameters:
order - 0 for the offset, or 1 for the scale factor.
Returns:
The requested coefficient of the transfer function, or null.
Throws:
IllegalArgumentException - If the order argument is out of bounds.

setCoefficient

public boolean setCoefficient(int order,
                              double coeff)
                       throws IllegalArgumentException
Sets a coefficient of the transfer function.

Parameters:
order - 0 for the offset, or 1 for the scale factor.
coeff - The new coefficient value.
Returns:
true if this object changed as a result of this method call.
Throws:
IllegalArgumentException - If the order argument is out of bounds.

getPaletteName

public String getPaletteName()
Returns the colors, as a palette name or as a RGB code. The syntax of the returned string is described in PaletteComboBox.getSelectedItem().

Returns:
The palette name or RGB code, or null if none.
Since:
3.14

setPaletteName

public boolean setPaletteName(String name)
Sets the colors, as a palette name or as a RGB code. The syntax of the string argument is described in PaletteComboBox.getSelectedItem().

A list of available palette names is provided by the PaletteFactory javadoc.

Parameters:
name - The palette name or RGB code, or null if none.
Returns:
true if this object changed as a result of this method call.
Since:
3.14

clone

public CategoryRecord clone()
Returns a clone of this record.

Overrides:
clone in class Object
Returns:
A copy of this object.
See Also:
Object.clone()

toString

public String toString()
Returns a string representation of this record, for debugging purpose. The current implementation formats the value in the same order than the column order documented in CategoryTable.

Overrides:
toString in class Object


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.