Package org.geotools.parameter
Class MatrixParameterDescriptors
- Object
-
- Formattable
-
- AbstractIdentifiedObject
-
- AbstractParameterDescriptor
-
- DefaultParameterDescriptorGroup
-
- MatrixParameterDescriptors
-
- All Implemented Interfaces:
Serializable
,GeneralParameterDescriptor
,ParameterDescriptorGroup
,IdentifiedObject
public class MatrixParameterDescriptors extends DefaultParameterDescriptorGroup
A parameter group for matrix elements. The amount of parameter values is extensible, i.e. it can grown or shrink according the value of"num_row"
and"num_col"
parameters. The parameters format may vary according the information provided to the constructor, but it is typically as below:num_row num_col elt_0_0 elt_0_1 ... elt_0_<num_col-1> elt_1_0 elt_1_1 ... elt_<num_row-1>_<num_col-1>
- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
- See Also:
MatrixParameters
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MATRIX_SIZE
The default matrix size for the one-argument constructor.protected ParameterDescriptor<Integer>
numCol
The descriptor for the"num_col"
parameter.protected ParameterDescriptor<Integer>
numRow
The descriptor for the"num_row"
parameter.protected String
prefix
The prefix to insert in front of parameter name for each matrix elements.protected char
separator
The separator between the row and the column index in parameter names.-
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
-
Fields inherited from class Formattable
SINGLE_LINE
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
-
Constructor Summary
Constructors Constructor Description MatrixParameterDescriptors(Map<String,?> properties)
Constructs a parameter group with default name format matching Well Known Text usages.MatrixParameterDescriptors(Map<String,?> properties, ParameterDescriptor<?>[] parameters, String prefix, char separator)
Constructs a parameter group.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParameterValueGroup
createValue()
Creates a new instance of parameter values with elements initialized to the 1 on the diagonal, and 0 everywere else.ParameterDescriptor<Double>
descriptor(int row, int column)
Returns the parameter in this group for a matrix element at the specified index. row and column indices are 0 based.GeneralParameterDescriptor
descriptor(String name)
Returns the parameter in this group for the specified name.List<GeneralParameterDescriptor>
descriptors()
Returns the parameters in this group.boolean
equals(AbstractIdentifiedObject object, boolean compareMetadata)
Compares the specified object with this parameter group for equality.Matrix
getMatrix(ParameterValueGroup parameters)
Constructs a matrix from a group of parameters.int
hashCode()
Returns a hash value for this parameter.-
Methods inherited from class DefaultParameterDescriptorGroup
getMaximumOccurs
-
Methods inherited from class AbstractParameterDescriptor
formatWKT, getMinimumOccurs
-
Methods inherited from class AbstractIdentifiedObject
asSet, ensureAngularUnit, ensureLinearUnit, ensureNonNull, ensureNonNull, ensureTimeUnit, equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, nameMatches, nameMatches, nameMatches
-
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
Methods inherited from interface GeneralParameterDescriptor
getMinimumOccurs
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
-
-
-
Field Detail
-
DEFAULT_MATRIX_SIZE
public static final int DEFAULT_MATRIX_SIZE
The default matrix size for the one-argument constructor.- See Also:
- Constant Field Values
-
numRow
protected final ParameterDescriptor<Integer> numRow
The descriptor for the"num_row"
parameter.
-
numCol
protected final ParameterDescriptor<Integer> numCol
The descriptor for the"num_col"
parameter.
-
prefix
protected final String prefix
The prefix to insert in front of parameter name for each matrix elements.
-
separator
protected final char separator
The separator between the row and the column index in parameter names.
-
-
Constructor Detail
-
MatrixParameterDescriptors
public MatrixParameterDescriptors(Map<String,?> properties)
Constructs a parameter group with default name format matching Well Known Text usages.- Parameters:
properties
- Set of properties. Should contains at least"name"
.
-
MatrixParameterDescriptors
public MatrixParameterDescriptors(Map<String,?> properties, ParameterDescriptor<?>[] parameters, String prefix, char separator)
Constructs a parameter group. The properties map is given unchanged to the super-class constructor. Theparameters
array should contains parameters other than matrix elements. The first parameter is assumed to be the number of rows, and the second parameter the number of columns. All extra parameters are ignored.- Parameters:
properties
- Set of properties. Should contains at least"name"
.parameters
- The"num_row"
and"num_col"
parameters.prefix
- The prefix to insert in front of parameter name for each matrix elements.separator
- The separator between the row and the column index in parameter names.
-
-
Method Detail
-
descriptor
public final GeneralParameterDescriptor descriptor(String name) throws ParameterNotFoundException
Returns the parameter in this group for the specified name. The name can be a matrix element if it uses the following syntax:"elt_row_col"
where"elt_"
is the prefix for all matrix elements, and row and col are row and column indices respectively. For example"elt_2_1"
is the element name for the value at line 2 and row 1. The row and column index are 0 based.- Specified by:
descriptor
in interfaceParameterDescriptorGroup
- Overrides:
descriptor
in classDefaultParameterDescriptorGroup
- Parameters:
name
- The case insensitive name of the parameter to search for.- Returns:
- The parameter for the given name.
- Throws:
ParameterNotFoundException
- if there is no parameter for the given name.
-
descriptor
public final ParameterDescriptor<Double> descriptor(int row, int column) throws IndexOutOfBoundsException
Returns the parameter in this group for a matrix element at the specified index. row and column indices are 0 based. Indices must be lower that the maximum values given to thenumRow
andnumCol
parameters.- Parameters:
row
- The row indice.column
- The column indice- Returns:
- The parameter descriptor for the specified matrix element.
- Throws:
IndexOutOfBoundsException
- ifrow
orcolumn
is out of bounds.
-
descriptors
public final List<GeneralParameterDescriptor> descriptors()
Returns the parameters in this group. The number or elements is inferred from the default values given to thenumRow
andnumCol
parameters.- Specified by:
descriptors
in interfaceParameterDescriptorGroup
- Overrides:
descriptors
in classDefaultParameterDescriptorGroup
- Returns:
- The matrix parameters, including all elements.
-
createValue
public ParameterValueGroup createValue()
Creates a new instance of parameter values with elements initialized to the 1 on the diagonal, and 0 everywere else. The returned parameter group is extensible, i.e. the number of elements will depends upon the value associated to thenumRow
andnumCol
parameters.- Specified by:
createValue
in interfaceGeneralParameterDescriptor
- Specified by:
createValue
in interfaceParameterDescriptorGroup
- Overrides:
createValue
in classDefaultParameterDescriptorGroup
- Returns:
- A new parameter initialized to the default value.
-
getMatrix
public Matrix getMatrix(ParameterValueGroup parameters) throws InvalidParameterNameException
Constructs a matrix from a group of parameters.- Parameters:
parameters
- The group of parameters.- Returns:
- A matrix constructed from the specified group of parameters.
- Throws:
InvalidParameterNameException
- if a parameter name was not recognized.
-
equals
public boolean equals(AbstractIdentifiedObject object, boolean compareMetadata)
Compares the specified object with this parameter group for equality.- Overrides:
equals
in classDefaultParameterDescriptorGroup
- Parameters:
object
- The object to compare tothis
.compareMetadata
-true
for performing a strict comparaison, orfalse
for comparing only properties relevant to transformations.- Returns:
true
if both objects are equal.
-
hashCode
public int hashCode()
Returns a hash value for this parameter.- Overrides:
hashCode
in classDefaultParameterDescriptorGroup
- Returns:
- The hash code value. This value doesn't need to be the same in past or future versions of this class.
-
-