es.unex.sextante.core
Class ParametersSet

java.lang.Object
  extended by es.unex.sextante.core.ParametersSet

public class ParametersSet
extends java.lang.Object

Set of parameters needed by a GeoAlgorithm. This set is used to specify the requirements of the algorithm and to create a suitable GUI to get the required information from the user, among other tasks.

Author:
Victor Olaya volaya@unex.es

Constructor Summary
ParametersSet()
           
 
Method Summary
 void addBand(java.lang.String sName, java.lang.String sDescription, java.lang.String sParentParameterName)
          Adds a band to the set
 void addBoolean(java.lang.String sName, java.lang.String sDescription, boolean bDefault)
          Adds a boolean value to the set
 void addFilepath(java.lang.String sName, java.lang.String sDescription, boolean bFolder, boolean bOpenDialog, java.lang.String sExt)
          Adds a filepath to the set
 void addFixedTable(java.lang.String sName, java.lang.String sDescription, java.lang.String[] sColumnNames, int iRows, boolean bIsNumberOfRowsFixed)
          Adds a fixed table to the set
 void addInputRasterLayer(java.lang.String sName, java.lang.String sDescription, boolean bIsMandatory)
          Adds a raster layer to the parameter set
 void addInputTable(java.lang.String sName, java.lang.String sDescription, boolean bIsMandatory)
          Adds a table to the parameter set
 void addInputVectorLayer(java.lang.String sName, java.lang.String sDescription, int iShapeType, boolean bIsMandatory)
          Adds a vector layer to the parameter set
 void addMultipleInput(java.lang.String sName, java.lang.String sDescription, int iDataType, boolean bIsMandatory)
          Adds a multiple input the parameter set
 void addNumericalValue(java.lang.String sName, java.lang.String sDescription, double dDefaultValue, int iType)
          Adds a numerical value to the set.
 void addNumericalValue(java.lang.String sName, java.lang.String sDescription, int iType, double dDefaultValue, double dMinValue, double dMaxValue)
          Adds a numerical value to the set
 boolean addParameter(Parameter parameter)
          Adds a new parameter to the set
 void addPoint(java.lang.String sName, java.lang.String sDescription)
          Add a point to the set
 void addSelection(java.lang.String sName, java.lang.String sDescription, java.lang.String[] sValues)
          Add a selection index (to choose from a list) to the set
 void addString(java.lang.String sName, java.lang.String sDescription)
          Add a string to the set
 void addString(java.lang.String sName, java.lang.String sDescription, java.lang.String sDefaultString)
          Add a string to the set
 void addTableField(java.lang.String sName, java.lang.String sDescription, java.lang.String sParentParameterName)
          Adds a table field to the set
 boolean areParameterValuesCorrect()
          Returns true if all parameters in the set have valid values
 ParametersSet getNewInstance()
          Returns a new instance of the parameter set
 int getNumberOfLineVectorLayers()
           
 int getNumberOfParameters()
           
 int getNumberOfPointVectorLayers()
           
 int getNumberOfPolygonVectorLayers()
           
 int getNumberOfRasterLayers()
           
 int getNumberOfTables()
          Returns the number of parameters of type table.
 int getNumberOfVectorLayers()
          Returns the number of parameters of type vector layer.
 Parameter getParameter(int iIndex)
           
 Parameter getParameter(java.lang.String sParameterName)
           
 java.util.ArrayList getParametersOfType(java.lang.Class paramClass)
           
 java.util.ArrayList getParameterValueAsArrayList(java.lang.String sParameterName)
           
 boolean getParameterValueAsBoolean(java.lang.String sParameterName)
           
 double getParameterValueAsDouble(java.lang.String sParameterName)
           
 int getParameterValueAsInt(java.lang.String sParameterName)
           
 java.lang.Object getParameterValueAsObject(java.lang.String sParameterName)
           
 java.awt.geom.Point2D getParameterValueAsPoint(java.lang.String sParameterName)
           
 IRasterLayer getParameterValueAsRasterLayer(java.lang.String sParameterName)
           
 java.lang.String getParameterValueAsString(java.lang.String sParameterName)
           
 ITable getParameterValueAsTable(java.lang.String sParameterName)
           
 IVectorLayer getParameterValueAsVectorLayer(java.lang.String sParameterName)
           
 void removeParameter(Parameter parameter)
           
 void removeParameter(java.lang.String sParameterName)
           
 boolean requiresFixedTables()
          Returns true if the set contains fixed table parameters
 boolean requiresLineVectorLayers()
          Returns true if the set contains parameters requiring line vector layers
 boolean requiresMultipleRasterBands()
          Returns true if the set contains parameters requiring multiple raster bands
 boolean requiresMultipleRasterLayers()
          Returns true if the set contains parameters requiring multiple raster layers
 boolean requiresMultipleTables()
          Returns true if the set contains parameters requiring multiple tables
 boolean requiresMultipleVectorLayers()
          Returns true if the set contains parameters requiring multiple vector layers
 boolean requiresNonDataObjects()
          Returns true if the set contains parameters other than tables or layers
 boolean requiresPoints()
          Returns true if the set contains point parameters.
 boolean requiresPointVectorLayers()
          Returns true if the set contains parameters requiring point vector layers
 boolean requiresPolygonVectorLayers()
          Returns true if the set contains parameters requiring polygon vector layers
 boolean requiresRasterBands()
          Returns true if there is any parameter in the set requiring a single raster band
 boolean requiresRasterLayers()
          Returns true if the set contains parameters requiring raster layers
 boolean requiresTableFields()
          Returns true if the set contains table fields parameters
 boolean requiresTables()
          Returns true if the set contains parameters requiring tables
 boolean requiresVectorLayers()
          Returns true if the set contains parameters requiring vector layers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParametersSet

public ParametersSet()
Method Detail

getNumberOfParameters

public int getNumberOfParameters()
Returns:
the number of parameters in the set

getNumberOfRasterLayers

public int getNumberOfRasterLayers()
Returns:
the number of parameters requiring raster layers

getNumberOfVectorLayers

public int getNumberOfVectorLayers()
Returns the number of parameters of type vector layer. This does not include multiple inputs of this same type

Returns:
the number of parameters requiring vector layers

getNumberOfPointVectorLayers

public int getNumberOfPointVectorLayers()
Returns:
the number of mandatory parameters requiring point vector layers

getNumberOfLineVectorLayers

public int getNumberOfLineVectorLayers()
Returns:
the number of mandatory parameters requiring line vector layers

getNumberOfPolygonVectorLayers

public int getNumberOfPolygonVectorLayers()
Returns:
the number of mandatory parameters requiring polygon vector layers

getNumberOfTables

public int getNumberOfTables()
Returns the number of parameters of type table. This does not include multiple inputs of this same type

Returns:
the number of parameters of type table

requiresNonDataObjects

public boolean requiresNonDataObjects()
Returns true if the set contains parameters other than tables or layers

Returns:
true if the set contains parameters other than tables or layers (vector or raster)

requiresRasterLayers

public boolean requiresRasterLayers()
Returns true if the set contains parameters requiring raster layers

Returns:
true if the set contains parameters requiring raster layers

requiresMultipleRasterLayers

public boolean requiresMultipleRasterLayers()
Returns true if the set contains parameters requiring multiple raster layers

Returns:
true if the set contains parameters requiring multiple raster layers

requiresMultipleVectorLayers

public boolean requiresMultipleVectorLayers()
Returns true if the set contains parameters requiring multiple vector layers

Returns:
true if the set contains parameters requiring multiple vector layers

requiresMultipleTables

public boolean requiresMultipleTables()
Returns true if the set contains parameters requiring multiple tables

Returns:
true if the set contains parameters requiring multiple tables

requiresMultipleRasterBands

public boolean requiresMultipleRasterBands()
Returns true if the set contains parameters requiring multiple raster bands

Returns:
true if the set contains parameters requiring multiple raster bands

requiresRasterBands

public boolean requiresRasterBands()
Returns true if there is any parameter in the set requiring a single raster band

Returns:
true if there is any parameter in the set requiring a single raster band

requiresVectorLayers

public boolean requiresVectorLayers()
Returns true if the set contains parameters requiring vector layers

Returns:
true if the set contains parameters requiring vector layers

requiresPointVectorLayers

public boolean requiresPointVectorLayers()
Returns true if the set contains parameters requiring point vector layers

Returns:
true if the set contains parameters requiring point vector layers

requiresLineVectorLayers

public boolean requiresLineVectorLayers()
Returns true if the set contains parameters requiring line vector layers

Returns:
true if the set contains parameters requiring line vector layers

requiresPolygonVectorLayers

public boolean requiresPolygonVectorLayers()
Returns true if the set contains parameters requiring polygon vector layers

Returns:
true if the set contains parameters requiring polygon vector layers

requiresTables

public boolean requiresTables()
Returns true if the set contains parameters requiring tables

Returns:
true if the set contains parameters requiring tables

requiresFixedTables

public boolean requiresFixedTables()
Returns true if the set contains fixed table parameters

Returns:
true if the set contains parameters requiring fixed tables

requiresTableFields

public boolean requiresTableFields()
Returns true if the set contains table fields parameters

Returns:
true if the set contains table fields that depend on other fields.

requiresPoints

public boolean requiresPoints()
Returns true if the set contains point parameters.

Returns:
true if the set contains point parameters.

addParameter

public boolean addParameter(Parameter parameter)
                     throws RepeatedParameterNameException
Adds a new parameter to the set

Parameters:
parameter - a parameter
Returns:
true if the parameter was added
Throws:
RepeatedParameterNameException - if already exists a parameter in the set with the same name

removeParameter

public void removeParameter(Parameter parameter)
                     throws WrongParameterIDException
Parameters:
parameter - a parameter
Throws:
WrongParameterIDException - if the parameter does not exist in the set

removeParameter

public void removeParameter(java.lang.String sParameterName)
                     throws WrongParameterIDException
Parameters:
sParameterName - the parameter name
Throws:
WrongParameterIDException - if no parameter with the specified name exists in the set

getParametersOfType

public java.util.ArrayList getParametersOfType(java.lang.Class paramClass)
Parameters:
paramClass - the class of the parameters to retrieve
Returns:
an arrayList with all parameters of the given class

getParameter

public Parameter getParameter(java.lang.String sParameterName)
                       throws WrongParameterIDException
Parameters:
sParameterName - the name of the parameter
Returns:
the parameter
Throws:
WrongParameterIDException - if no parameter with the specified name exists in the set

getParameter

public Parameter getParameter(int iIndex)
                       throws java.lang.ArrayIndexOutOfBoundsException
Parameters:
iIndex - the index of the parameter in the set
Returns:
the parameter
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iIndex is not a valid array index

getParameterValueAsObject

public java.lang.Object getParameterValueAsObject(java.lang.String sParameterName)
                                           throws WrongParameterTypeException,
                                                  WrongParameterIDException,
                                                  NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the parameter as an object
Throws:
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null
WrongParameterTypeException

getParameterValueAsInt

public int getParameterValueAsInt(java.lang.String sParameterName)
                           throws WrongParameterTypeException,
                                  WrongParameterIDException,
                                  NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the int value of the parameter
Throws:
WrongParameterTypeException - if the parameter cannot be cast to an int value
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsDouble

public double getParameterValueAsDouble(java.lang.String sParameterName)
                                 throws WrongParameterTypeException,
                                        WrongParameterIDException,
                                        NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as double
Throws:
WrongParameterTypeException - if the parameter cannot be cast to a double value
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsPoint

public java.awt.geom.Point2D getParameterValueAsPoint(java.lang.String sParameterName)
                                               throws WrongParameterTypeException,
                                                      WrongParameterIDException,
                                                      NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as a Point2D object
Throws:
WrongParameterTypeException - if the parameter cannot be cast to a Point2D value
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsBoolean

public boolean getParameterValueAsBoolean(java.lang.String sParameterName)
                                   throws WrongParameterTypeException,
                                          WrongParameterIDException,
                                          NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the boolean value of the parameter
Throws:
WrongParameterTypeException - if the parameter cannot be cast to a boolean value
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsArrayList

public java.util.ArrayList getParameterValueAsArrayList(java.lang.String sParameterName)
                                                 throws WrongParameterTypeException,
                                                        WrongParameterIDException,
                                                        NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
an array with the value(s) of the parameter
Throws:
WrongParameterTypeException - if the parameter cannot be cast to an ArrayList
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsString

public java.lang.String getParameterValueAsString(java.lang.String sParameterName)
                                           throws WrongParameterTypeException,
                                                  WrongParameterIDException,
                                                  NullParameterValueException,
                                                  NullParameterAdditionalInfoException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as a string
Throws:
WrongParameterTypeException - if the parameter cannot be cast to a string
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null
NullParameterAdditionalInfoException

getParameterValueAsVectorLayer

public IVectorLayer getParameterValueAsVectorLayer(java.lang.String sParameterName)
                                            throws WrongParameterTypeException,
                                                   WrongParameterIDException,
                                                   NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as a vector layer
Throws:
WrongParameterTypeException - if the parameter cannot be converted to a vector layer
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsRasterLayer

public IRasterLayer getParameterValueAsRasterLayer(java.lang.String sParameterName)
                                            throws WrongParameterTypeException,
                                                   WrongParameterIDException,
                                                   NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as a raster layer
Throws:
WrongParameterTypeException - if the parameter cannot be converted to a raster layer
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

getParameterValueAsTable

public ITable getParameterValueAsTable(java.lang.String sParameterName)
                                throws WrongParameterTypeException,
                                       WrongParameterIDException,
                                       NullParameterValueException
Parameters:
sParameterName - the name of the parameter
Returns:
the value of the parameter as a table
Throws:
WrongParameterTypeException - if the parameter cannot be converted to a table
WrongParameterIDException - if no parameter with that name exists in the set
NullParameterValueException - if the parameter is null

addInputVectorLayer

public void addInputVectorLayer(java.lang.String sName,
                                java.lang.String sDescription,
                                int iShapeType,
                                boolean bIsMandatory)
                         throws RepeatedParameterNameException
Adds a vector layer to the parameter set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
iShapeType - the type of shapes
bIsMandatory - true if it is not an optional layer
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addInputRasterLayer

public void addInputRasterLayer(java.lang.String sName,
                                java.lang.String sDescription,
                                boolean bIsMandatory)
                         throws RepeatedParameterNameException
Adds a raster layer to the parameter set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
bIsMandatory - true if it is not an optional layer
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addInputTable

public void addInputTable(java.lang.String sName,
                          java.lang.String sDescription,
                          boolean bIsMandatory)
                   throws RepeatedParameterNameException
Adds a table to the parameter set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
bIsMandatory - true if it is not an optional table
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addMultipleInput

public void addMultipleInput(java.lang.String sName,
                             java.lang.String sDescription,
                             int iDataType,
                             boolean bIsMandatory)
                      throws RepeatedParameterNameException
Adds a multiple input the parameter set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
iDataType - the type of data required
bIsMandatory - true if the number of selected elements cannot be zero
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addTableField

public void addTableField(java.lang.String sName,
                          java.lang.String sDescription,
                          java.lang.String sParentParameterName)
                   throws RepeatedParameterNameException,
                          UndefinedParentParameterNameException,
                          OptionalParentParameterException
Adds a table field to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
sParentParameterName - the name of the parent parameter (vector layer or table) to which this parameter is linked
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set
UndefinedParentParameterNameException
OptionalParentParameterException

addBand

public void addBand(java.lang.String sName,
                    java.lang.String sDescription,
                    java.lang.String sParentParameterName)
             throws RepeatedParameterNameException,
                    UndefinedParentParameterNameException,
                    OptionalParentParameterException
Adds a band to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
sParentParameterName - the name of the parent parameter (raster layer) to which this parameter is linked
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set
UndefinedParentParameterNameException
OptionalParentParameterException

addNumericalValue

public void addNumericalValue(java.lang.String sName,
                              java.lang.String sDescription,
                              int iType,
                              double dDefaultValue,
                              double dMinValue,
                              double dMaxValue)
                       throws RepeatedParameterNameException
Adds a numerical value to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
iType - the type of numerical value (integer or double)
dDefaultValue - the default value to use (or show)
dMinValue - the min value admitted
dMaxValue - the max value admitted
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addNumericalValue

public void addNumericalValue(java.lang.String sName,
                              java.lang.String sDescription,
                              double dDefaultValue,
                              int iType)
                       throws RepeatedParameterNameException
Adds a numerical value to the set. No min or max values are defined, so the parameter can take any value

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
dDefaultValue - the default value to use (or show)
iType - the type of numerical value (integer or double)
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addString

public void addString(java.lang.String sName,
                      java.lang.String sDescription)
               throws RepeatedParameterNameException
Add a string to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addString

public void addString(java.lang.String sName,
                      java.lang.String sDescription,
                      java.lang.String sDefaultString)
               throws RepeatedParameterNameException
Add a string to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
sDefaultString - the default value
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addFilepath

public void addFilepath(java.lang.String sName,
                        java.lang.String sDescription,
                        boolean bFolder,
                        boolean bOpenDialog,
                        java.lang.String sExt)
                 throws RepeatedParameterNameException
Adds a filepath to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
bFolder - true if it is a folder dialog
bOpenDialog - true if it is an open file dialog, false if it's a save file dialog
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addBoolean

public void addBoolean(java.lang.String sName,
                       java.lang.String sDescription,
                       boolean bDefault)
                throws RepeatedParameterNameException
Adds a boolean value to the set

Parameters:
sName - the name of the parameter
sDescription - the descritpion of the parameter
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addSelection

public void addSelection(java.lang.String sName,
                         java.lang.String sDescription,
                         java.lang.String[] sValues)
                  throws RepeatedParameterNameException
Add a selection index (to choose from a list) to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
sValues - the values to choose from
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addFixedTable

public void addFixedTable(java.lang.String sName,
                          java.lang.String sDescription,
                          java.lang.String[] sColumnNames,
                          int iRows,
                          boolean bIsNumberOfRowsFixed)
                   throws RepeatedParameterNameException
Adds a fixed table to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
sColumnNames - names of columns(fields) in the table
iRows - number of rows in the table
bIsNumberOfRowsFixed - true if the number of rows cannot be modified
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

addPoint

public void addPoint(java.lang.String sName,
                     java.lang.String sDescription)
              throws RepeatedParameterNameException
Add a point to the set

Parameters:
sName - the name of the parameter
sDescription - the description of the parameter
Throws:
RepeatedParameterNameException - if a parameter with the same name already exists in the set

getNewInstance

public ParametersSet getNewInstance()
Returns a new instance of the parameter set

Returns:
a new instance of the parameter set

areParameterValuesCorrect

public boolean areParameterValuesCorrect()
Returns true if all parameters in the set have valid values

Returns:
true if all parameters in the set have valid values