Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / gridCalculus / constantGrid / ConstantGridAlgorithm.java @ 59

History | View | Annotate | Download (1.54 KB)

1
package es.unex.sextante.gridCalculus.constantGrid;
2

    
3
import es.unex.sextante.additionalInfo.AdditionalInfoNumericalValue;
4
import es.unex.sextante.core.GeoAlgorithm;
5
import es.unex.sextante.core.Sextante;
6
import es.unex.sextante.dataObjects.IRasterLayer;
7
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
8
import es.unex.sextante.exceptions.RepeatedParameterNameException;
9

    
10
public class ConstantGridAlgorithm
11
         extends
12
            GeoAlgorithm {
13

    
14
   public static final String VALUE     = "VALUE";
15
   public static final String CONSTGRID = "CONSTGRID";
16

    
17

    
18
   @Override
19
   public void defineCharacteristics() {
20

    
21
      setName(Sextante.getText("Constant_grid"));
22
      setGroup(Sextante.getText("Raster_creation_tools"));
23
      setUserCanDefineAnalysisExtent(true);
24

    
25
      try {
26
         m_Parameters.addNumericalValue(VALUE, Sextante.getText("Value"), 1, AdditionalInfoNumericalValue.NUMERICAL_VALUE_DOUBLE);
27
         addOutputRasterLayer(CONSTGRID, Sextante.getText("Constant_grid"));
28
      }
29
      catch (final RepeatedParameterNameException e) {
30
         Sextante.addErrorToLog(e);
31
      }
32

    
33
   }
34

    
35

    
36
   @Override
37
   public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
38

    
39
      double dValue;
40

    
41
      final IRasterLayer result = getNewRasterLayer(CONSTGRID, Sextante.getText("Constant_grid"),
42
               IRasterLayer.RASTER_DATA_TYPE_DOUBLE);
43

    
44
      dValue = m_Parameters.getParameterValueAsDouble(VALUE);
45

    
46
      result.assign(dValue);
47

    
48
      return !m_Task.isCanceled();
49

    
50
   }
51

    
52

    
53
}