Revision 917
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.lib/org.gvsig.geoprocess.lib.api/src/main/java/org/gvsig/geoprocess/lib/api/GeoProcessBuiler.java | ||
---|---|---|
1 | 1 |
package org.gvsig.geoprocess.lib.api; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.List; |
|
4 | 5 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
5 | 6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
6 | 7 |
import org.gvsig.fmap.geom.primitive.Envelope; |
... | ... | |
8 | 9 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
9 | 10 |
|
10 | 11 |
public interface GeoProcessBuiler { |
11 |
|
|
12 |
|
|
12 | 13 |
public interface OutputAccesor { |
14 |
|
|
13 | 15 |
public Object get(String name); |
14 | 16 |
|
15 | 17 |
public File getFile(String name); |
... | ... | |
26 | 28 |
|
27 | 29 |
public RasterDataStore getRasterStore(String name); |
28 | 30 |
|
29 |
public FLyrRaster getRasterLayer(String name);
|
|
31 |
public FLyrRaster getRasterLayer(String name); |
|
30 | 32 |
|
31 |
public FLyrVect getVectorLayer(String name);
|
|
33 |
public FLyrVect getVectorLayer(String name); |
|
32 | 34 |
} |
33 |
|
|
35 |
|
|
36 |
public interface ParameterInfo { |
|
37 |
|
|
38 |
public String getName(); |
|
39 |
|
|
40 |
public String getTypeName(); |
|
41 |
|
|
42 |
public String getTooltip(); |
|
43 |
|
|
44 |
public String getDescription(); |
|
45 |
|
|
46 |
public Class getParameterClass(); |
|
47 |
|
|
48 |
public String getDetailedDescription(); |
|
49 |
|
|
50 |
} |
|
51 |
|
|
34 | 52 |
public String getName(); |
35 |
|
|
53 |
|
|
36 | 54 |
public GeoProcessBuiler algorithm(String name); |
37 | 55 |
|
38 | 56 |
public GeoProcessBuiler parameter(String name, String value); |
... | ... | |
54 | 72 |
public GeoProcessBuiler execute(); |
55 | 73 |
|
56 | 74 |
public OutputAccesor output(); |
57 |
|
|
75 |
|
|
76 |
public List<String> getAlgorithmNames(); |
|
77 |
|
|
78 |
public List<String> getParameterNames(); |
|
79 |
|
|
80 |
public ParameterInfo getParameterInfo(String name); |
|
81 |
|
|
58 | 82 |
} |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.lib/org.gvsig.geoprocess.lib.sextante/src/main/java/org/gvsig/geoprocess/lib/sextante/GeoProcessBuilerBase.java | ||
---|---|---|
1 | 1 |
package org.gvsig.geoprocess.lib.sextante; |
2 | 2 |
|
3 |
import es.unex.sextante.additionalInfo.AdditionalInfo; |
|
3 | 4 |
import es.unex.sextante.core.AnalysisExtent; |
4 | 5 |
import es.unex.sextante.core.GeoAlgorithm; |
5 | 6 |
import es.unex.sextante.core.OutputFactory; |
6 | 7 |
import es.unex.sextante.core.OutputObjectsSet; |
8 |
import es.unex.sextante.core.ParametersSet; |
|
7 | 9 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
8 | 10 |
import es.unex.sextante.exceptions.WrongOutputIDException; |
9 | 11 |
import es.unex.sextante.exceptions.WrongParameterIDException; |
... | ... | |
19 | 21 |
import es.unex.sextante.parameters.ParameterVectorLayer; |
20 | 22 |
import java.io.File; |
21 | 23 |
import java.text.MessageFormat; |
24 |
import java.util.ArrayList; |
|
22 | 25 |
import java.util.Iterator; |
26 |
import java.util.List; |
|
23 | 27 |
import org.gvsig.fmap.dal.DALLocator; |
24 | 28 |
import org.gvsig.fmap.dal.DataManager; |
25 | 29 |
import org.gvsig.fmap.dal.DataStoreParameters; |
... | ... | |
47 | 51 |
|
48 | 52 |
private static final Logger logger = LoggerFactory.getLogger(GeoProcessBuilerBase.class); |
49 | 53 |
|
54 |
private class ParameterInfoBase implements ParameterInfo { |
|
55 |
|
|
56 |
private final Parameter param; |
|
57 |
|
|
58 |
public ParameterInfoBase(Parameter param) { |
|
59 |
this.param = param; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public String getName() { |
|
64 |
return this.param.getParameterName(); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public String getTypeName() { |
|
69 |
return this.param.getParameterTypeName(); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String getDescription() { |
|
74 |
return this.param.getParameterDescription(); |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public String getTooltip() { |
|
79 |
return this.param.getParameterTooltip(); |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public Class getParameterClass() { |
|
84 |
return this.param.getParameterClass(); |
|
85 |
} |
|
86 |
|
|
87 |
public String getDetailedDescription() { |
|
88 |
try { |
|
89 |
AdditionalInfo x = this.param.getParameterAdditionalInfo(); |
|
90 |
if( x == null ) { |
|
91 |
return null; |
|
92 |
} |
|
93 |
return x.getTextDescription(); |
|
94 |
} catch (Exception ex) { |
|
95 |
return null; |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
|
|
100 |
} |
|
101 |
|
|
50 | 102 |
private class OutputAccesorBase implements OutputAccesor { |
51 | 103 |
|
52 | 104 |
private Output getOutput(String name) { |
... | ... | |
422 | 474 |
return new OutputAccesorBase(); |
423 | 475 |
} |
424 | 476 |
|
477 |
@Override |
|
478 |
public List<String> getAlgorithmNames() { |
|
479 |
SextanteGeoProcessManager manager = (SextanteGeoProcessManager) GeoProcessLocator.getGeoProcessManager(); |
|
480 |
List<String> algorithms = new ArrayList(manager.getAlgorithms().keySet()); |
|
481 |
return algorithms; |
|
482 |
} |
|
483 |
|
|
484 |
@Override |
|
485 |
public List<String> getParameterNames() { |
|
486 |
List<String> parameterNames = new ArrayList<String>(); |
|
487 |
ParametersSet params = this.algorithm.getParameters(); |
|
488 |
for( int i=0; i<params.getNumberOfParameters(); i++ ) { |
|
489 |
Parameter param = params.getParameter(i); |
|
490 |
parameterNames.add(param.getParameterName()); |
|
491 |
} |
|
492 |
return parameterNames; |
|
493 |
} |
|
494 |
|
|
495 |
@Override |
|
496 |
public ParameterInfo getParameterInfo(String name) { |
|
497 |
Parameter param; |
|
498 |
try { |
|
499 |
param = this.algorithm.getParameters().getParameter(name); |
|
500 |
} catch (WrongParameterIDException ex) { |
|
501 |
throw new IllegalArgumentException( |
|
502 |
MessageFormat.format( |
|
503 |
"Can't access parameter ''{0}'' of the geoprocess ''{1}''.", |
|
504 |
name, |
|
505 |
this.getName() |
|
506 |
), |
|
507 |
ex |
|
508 |
); |
|
509 |
} |
|
510 |
return new ParameterInfoBase(param); |
|
511 |
} |
|
512 |
|
|
513 |
|
|
514 |
|
|
425 | 515 |
} |
Also available in: Unified diff