Revision 18637
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/java/org/gvsig/raster/roimask/ROIMaskSextanteAlgorithm.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
4 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
5 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
6 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
7 |
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess; |
|
8 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer; |
|
9 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
10 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
11 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
12 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
13 |
import org.gvsig.raster.roi.ROI; |
|
14 |
import org.gvsig.raster.roimask.algorithm.ROIMaskProcess; |
|
15 |
|
|
16 |
import es.unex.sextante.additionalInfo.AdditionalInfoNumericalValue; |
|
17 |
import es.unex.sextante.core.AnalysisExtent; |
|
18 |
import es.unex.sextante.core.Sextante; |
|
19 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
20 |
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException; |
|
21 |
import es.unex.sextante.exceptions.RepeatedParameterNameException; |
|
22 |
|
|
23 |
/** |
|
24 |
* ... |
|
25 |
*/ |
|
26 |
public class ROIMaskSextanteAlgorithm extends AbstractSextanteGeoProcess { |
|
27 |
|
|
28 |
public static final String RESULT = "RESULT"; |
|
29 |
public static final String LAYER = ROIMaskProcess.RASTER_STORE1; |
|
30 |
public static final String ALPHA = ROIMaskProcess.ALPHA; |
|
31 |
public static final String INVERSE = ROIMaskProcess.INVERSE; |
|
32 |
public static final String NODATA = ROIMaskProcess.NODATA; |
|
33 |
|
|
34 |
|
|
35 |
public void defineCharacteristics() { |
|
36 |
setName(getTranslation("mask")); |
|
37 |
setGroup(getTranslation("basic_raster_algorithms")); |
|
38 |
// setGeneratesUserDefinedRasterOutput(false); |
|
39 |
|
|
40 |
try { |
|
41 |
m_Parameters.addInputRasterLayer(LAYER, getTranslation("Input_layer"), true); |
|
42 |
m_Parameters.addNumericalValue(ALPHA, getTranslation("alpha"), 0, |
|
43 |
AdditionalInfoNumericalValue.NUMERICAL_VALUE_INTEGER); |
|
44 |
m_Parameters.addBoolean(INVERSE, getTranslation("Inverse"), false); |
|
45 |
} catch (RepeatedParameterNameException e) { |
|
46 |
Sextante.addErrorToLog(e); |
|
47 |
} |
|
48 |
addOutputRasterLayer(RESULT, getTranslation("mask")); |
|
49 |
} |
|
50 |
|
|
51 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
|
52 |
|
|
53 |
if(existsOutPutFile(ROIMaskSextanteAlgorithm.RESULT, 0)) { |
|
54 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
|
55 |
} |
|
56 |
|
|
57 |
IRasterLayer input = m_Parameters.getParameterValueAsRasterLayer(LAYER); |
|
58 |
int alpha = m_Parameters.getParameterValueAsInt(ALPHA); |
|
59 |
boolean inverse = m_Parameters.getParameterValueAsBoolean(INVERSE); |
|
60 |
FLyrRaster lyrRaster = ((FLyrRaster)input.getBaseDataObject()); |
|
61 |
ROI[] rois = null; |
|
62 |
IRasterLayer output = null; |
|
63 |
DataProcess task = null; |
|
64 |
AnalysisExtent ext = getAnalysisExtent(); |
|
65 |
Extent bbox = RasterLocator.getManager().getDataStructFactory().createExtent( |
|
66 |
ext.getXMin(), ext.getYMax(), ext.getXMax(), ext.getYMin()); |
|
67 |
try { |
|
68 |
output = getNewRORasterLayer( |
|
69 |
RESULT, |
|
70 |
Sextante.getText("Mask_image"), |
|
71 |
input.getDataType(), |
|
72 |
input.getBandsCount()); |
|
73 |
rois = lyrRaster.getRois().toArray(new ROI[lyrRaster.getRois().size()]); |
|
74 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("ROIMaskProcess"); |
|
75 |
} catch (ProcessException e1) { |
|
76 |
Sextante.addErrorToLog(e1); |
|
77 |
} catch (ROIException e1) { |
|
78 |
Sextante.addErrorToLog(e1); |
|
79 |
} |
|
80 |
|
|
81 |
String fileName = ((FLyrRasterIRasterLayer)output).getName(); |
|
82 |
task.addParam(ROIMaskProcess.PATH, fileName); |
|
83 |
task.addParam(ROIMaskProcess.RASTER_STORE1, lyrRaster.getDataStore()); |
|
84 |
task.addParam(ROIMaskProcess.ROIS, rois); |
|
85 |
task.addParam(ROIMaskProcess.ALPHA, alpha); |
|
86 |
task.addParam(ROIMaskProcess.INVERSE, inverse); |
|
87 |
task.addParam(ROIMaskProcess.NODATA, lyrRaster.getNoDataValue()); |
|
88 |
task.addParam(ROIMaskProcess.WINDOW, bbox); |
|
89 |
task.addParam(ROIMaskProcess.OUTPUT_WIDTH, ext.getNX()); |
|
90 |
task.addParam(ROIMaskProcess.OUTPUT_HEIGHT, ext.getNY()); |
|
91 |
|
|
92 |
try { |
|
93 |
task.execute(); |
|
94 |
((FLyrRasterIRasterLayer)output).setBaseDataObject(fileName); |
|
95 |
} catch (ProcessInterruptedException e) { |
|
96 |
Sextante.addErrorToLog(e); |
|
97 |
} catch (ProcessException e) { |
|
98 |
Sextante.addErrorToLog(e); |
|
99 |
} |
|
100 |
|
|
101 |
if(getTaskMonitor().isCanceled()) |
|
102 |
return false; |
|
103 |
|
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
/* |
|
108 |
* TODO: Customized panels |
|
109 |
@Override |
|
110 |
public Class<? extends GeoAlgorithmParametersPanel> getCustomParametersPanelClass() { |
|
111 |
return BufferParametersPanel.class; |
|
112 |
}*/ |
|
113 |
} |
|
0 | 114 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/java/org/gvsig/raster/roimask/ROIMaskToolboxLibrary.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask; |
|
2 |
|
|
3 |
import org.gvsig.i18n.Messages; |
|
4 |
import org.gvsig.tools.library.AbstractLibrary; |
|
5 |
import org.gvsig.tools.library.LibraryException; |
|
6 |
import org.slf4j.LoggerFactory; |
|
7 |
|
|
8 |
/** |
|
9 |
* Initialization of <code>ROIMaskToolboxLibrary</code> library. |
|
10 |
*/ |
|
11 |
public class ROIMaskToolboxLibrary extends AbstractLibrary { |
|
12 |
|
|
13 |
@Override |
|
14 |
protected void doInitialize() throws LibraryException { |
|
15 |
// Nothing to do |
|
16 |
} |
|
17 |
|
|
18 |
@Override |
|
19 |
protected void doPostInitialize() throws LibraryException { |
|
20 |
Messages.addResourceFamily( |
|
21 |
"org.gvsig.raster.roimask.roimask", ROIMaskToolboxLibrary.class |
|
22 |
.getClassLoader(), ROIMaskToolboxLibrary.class.getClass().getName()); |
|
23 |
try { |
|
24 |
org.gvsig.geoprocess.lib.api.GeoProcessLocator.getGeoProcessManager().registerGeoProcess( |
|
25 |
new ROIMaskSextanteAlgorithm()); |
|
26 |
} catch (NoClassDefFoundError e) { |
|
27 |
LoggerFactory.getLogger(ROIMaskToolboxLibrary.class).debug("", e); |
|
28 |
} |
|
29 |
} |
|
30 |
|
|
31 |
} |
|
0 | 32 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources-plugin/org/gvsig/raster/roimask/sextante/i18n/text.properties | ||
---|---|---|
1 |
basic_raster_algorithms=Capas raster |
|
2 |
mask=M?scara por ROI |
|
0 | 3 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources-plugin/org/gvsig/raster/roimask/sextante/i18n/text_en.properties | ||
---|---|---|
1 |
basic_raster_algorithms=Raster layers |
|
2 |
mask=ROI mask |
|
0 | 3 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources/org/gvsig/raster/roimask/roimask.properties | ||
---|---|---|
1 |
applying_mask=Aplicando m?scara |
|
2 |
mask_process=Proceso de m?scara |
|
3 |
mask=M?scara por ROI |
|
4 |
basic_raster_algorithms=Capas r?ster |
|
5 |
alpha=Transparencia |
|
6 |
inverse=Inversa |
|
0 | 7 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources/org/gvsig/raster/roimask/roimask_en.properties | ||
---|---|---|
1 |
applying_mask=Applying mask |
|
2 |
mask_process=Mask process |
|
3 |
mask=ROI mask |
|
4 |
basic_raster_algorithms=Raster layers |
|
5 |
alpha=Alpha |
|
6 |
inverse=Inverse |
|
0 | 7 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources/help/ROIMaskSextanteAlgorithm.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<help> |
|
3 |
<element name="DESCRIPTION" |
|
4 |
text="" |
|
5 |
description="Descripción" type="0"> |
|
6 |
<!-- <image description="" file=""> |
|
7 |
</image> --> |
|
8 |
</element> |
|
9 |
<element name="ADDITIONAL_INFO" text="" |
|
10 |
description="Información adicional" type="0"> |
|
11 |
</element> |
|
12 |
<element name="EXTENSION_AUTHOR" text="" |
|
13 |
description="Algoritmo creado por" type="0"> |
|
14 |
</element> |
|
15 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
16 |
type="0"> |
|
17 |
</element> |
|
18 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
19 |
type="0"> |
|
20 |
</element> |
|
21 |
</help> |
|
0 | 22 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources/help/ROIMaskSextanteAlgorithm_en.xml | ||
---|---|---|
1 |
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?> |
|
2 |
<help> |
|
3 |
<element name="DESCRIPTION" |
|
4 |
text="" |
|
5 |
description="Descripción" type="0"> |
|
6 |
<!-- <image description="" file=""> |
|
7 |
</image> --> |
|
8 |
</element> |
|
9 |
<element name="ADDITIONAL_INFO" text="" |
|
10 |
description="Información adicional" type="0"> |
|
11 |
</element> |
|
12 |
<element name="EXTENSION_AUTHOR" text="" |
|
13 |
description="Algoritmo creado por" type="0"> |
|
14 |
</element> |
|
15 |
<element name="HELP_AUTHOR" text="" description="Ayuda creada por" |
|
16 |
type="0"> |
|
17 |
</element> |
|
18 |
<element name="USER_NOTES" text="" description="Notas de usuario" |
|
19 |
type="0"> |
|
20 |
</element> |
|
21 |
</help> |
|
0 | 22 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.roimask.ROIMaskToolboxLibrary |
|
0 | 2 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.toolbox.algorithm/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
3 |
|
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.roimask.toolbox.algorithm</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.raster.roimask.toolbox.algorithm</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.raster.roimask</artifactId> |
|
11 |
<version>2.2.195</version> |
|
12 |
</parent> |
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.geoprocess.algorithm.base</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.raster.algorithm</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.raster.roimask.algorithm</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>org.gvsig</groupId> |
|
31 |
<artifactId>org.gvsig.geoprocess.lib.sextante</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
<dependency> |
|
35 |
<groupId>org.gvsig</groupId> |
|
36 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
37 |
<scope>compile</scope> |
|
38 |
</dependency> |
|
39 |
<dependency> |
|
40 |
<groupId>org.gvsig</groupId> |
|
41 |
<artifactId>org.gvsig.ui</artifactId> |
|
42 |
<scope>compile</scope> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>org.gvsig</groupId> |
|
46 |
<artifactId>org.gvsig.i18n</artifactId> |
|
47 |
<scope>compile</scope> |
|
48 |
</dependency> |
|
49 |
<dependency> |
|
50 |
<groupId>org.gvsig</groupId> |
|
51 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
52 |
<scope>compile</scope> |
|
53 |
</dependency> |
|
54 |
<dependency> |
|
55 |
<groupId>org.gvsig</groupId> |
|
56 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
57 |
<scope>runtime</scope> |
|
58 |
</dependency> |
|
59 |
<dependency> |
|
60 |
<groupId>org.gvsig</groupId> |
|
61 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
62 |
<scope>compile</scope> |
|
63 |
</dependency> |
|
64 |
<dependency> |
|
65 |
<groupId>org.gvsig</groupId> |
|
66 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
67 |
<scope>runtime</scope> |
|
68 |
</dependency> |
|
69 |
<dependency> |
|
70 |
<groupId>org.gvsig</groupId> |
|
71 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
72 |
<scope>compile</scope> |
|
73 |
</dependency> |
|
74 |
</dependencies> |
|
75 |
</project> |
|
0 | 76 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
|
|
3 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.roimask.app</artifactId> |
|
6 |
<packaging>pom</packaging> |
|
7 |
<name>org.gvsig.raster.roimask.app</name> |
|
8 |
<description /> |
|
9 |
|
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.raster.roimask</artifactId> |
|
13 |
<version>2.2.195</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<scm> |
|
17 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app</connection> |
|
18 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app</developerConnection> |
|
19 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app</url> |
|
20 |
</scm> |
|
21 |
|
|
22 |
<developers> |
|
23 |
<developer> |
|
24 |
<id>nbrodin</id> |
|
25 |
<name>Nacho Brodin</name> |
|
26 |
<email>nachobrodin@gmail.com</email> |
|
27 |
<roles> |
|
28 |
<role>Architect</role> |
|
29 |
<role>Developer</role> |
|
30 |
</roles> |
|
31 |
</developer> |
|
32 |
</developers> |
|
33 |
<repositories> |
|
34 |
<repository> |
|
35 |
<id>gvsig-public-http-repository</id> |
|
36 |
<name>gvSIG maven public HTTP repository</name> |
|
37 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
38 |
<releases> |
|
39 |
<enabled>true</enabled> |
|
40 |
<updatePolicy>daily</updatePolicy> |
|
41 |
<checksumPolicy>warn</checksumPolicy> |
|
42 |
</releases> |
|
43 |
<snapshots> |
|
44 |
<enabled>true</enabled> |
|
45 |
<updatePolicy>daily</updatePolicy> |
|
46 |
<checksumPolicy>warn</checksumPolicy> |
|
47 |
</snapshots> |
|
48 |
</repository> |
|
49 |
</repositories> |
|
50 |
<dependencies> |
|
51 |
<dependency> |
|
52 |
<groupId>org.gvsig</groupId> |
|
53 |
<artifactId>org.gvsig.andami</artifactId> |
|
54 |
<scope>compile</scope> |
|
55 |
</dependency> |
|
56 |
<dependency> |
|
57 |
<groupId>org.gvsig</groupId> |
|
58 |
<artifactId>org.gvsig.i18n</artifactId> |
|
59 |
<scope>compile</scope> |
|
60 |
</dependency> |
|
61 |
<dependency> |
|
62 |
<groupId>org.gvsig</groupId> |
|
63 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
64 |
<scope>compile</scope> |
|
65 |
</dependency> |
|
66 |
<dependency> |
|
67 |
<groupId>org.slf4j</groupId> |
|
68 |
<artifactId>slf4j-api</artifactId> |
|
69 |
<scope>compile</scope> |
|
70 |
</dependency> |
|
71 |
<dependency> |
|
72 |
<groupId>org.slf4j</groupId> |
|
73 |
<artifactId>slf4j-log4j12</artifactId> |
|
74 |
<scope>runtime</scope> |
|
75 |
</dependency> |
|
76 |
</dependencies> |
|
77 |
<modules> |
|
78 |
<module>org.gvsig.raster.roimask.app.client</module> |
|
79 |
</modules> |
|
80 |
</project> |
|
0 | 81 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/buildNumber.properties | ||
---|---|---|
1 |
#Thu Sep 15 21:04:24 CEST 2022 |
|
2 |
buildNumber=203 |
|
0 | 3 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>.</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>${project.artifactId}/lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
<outputDirectory>${project.artifactId}</outputDirectory> |
|
16 |
</file> |
|
17 |
</files> |
|
18 |
|
|
19 |
<fileSets> |
|
20 |
<fileSet> |
|
21 |
<directory>src/main/resources-plugin</directory> |
|
22 |
<outputDirectory>${project.artifactId}</outputDirectory> |
|
23 |
</fileSet> |
|
24 |
</fileSets> |
|
25 |
|
|
26 |
|
|
27 |
<dependencySets> |
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>${project.artifactId}/lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
<include>org.gvsig:org.gvsig.raster.roimask.app.client:jar</include> |
|
34 |
<include>org.gvsig:org.gvsig.raster.roimask.lib.api:jar</include> |
|
35 |
<include>org.gvsig:org.gvsig.raster.roimask.lib.impl:jar</include> |
|
36 |
<include>org.gvsig:org.gvsig.raster.roimask.swing.api:jar</include> |
|
37 |
<include>org.gvsig:org.gvsig.raster.roimask.swing.impl:jar</include> |
|
38 |
<include>org.gvsig:org.gvsig.raster.roimask.algorithm:jar</include> |
|
39 |
<include>org.gvsig:org.gvsig.raster.roimask.toolbox.algorithm:jar</include> |
|
40 |
</includes> |
|
41 |
</dependencySet> |
|
42 |
|
|
43 |
<!-- Copia el algoritmo de toolbox a install/files cuando se empaqueta para que el script de ant lo meta donde toca al instalar |
|
44 |
|
|
45 |
<dependencySet> |
|
46 |
<useProjectArtifact>false</useProjectArtifact> |
|
47 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
48 |
<outputDirectory>${project.artifactId}/install/files</outputDirectory> |
|
49 |
<includes> |
|
50 |
<include>org.gvsig:org.gvsig.raster.roimask.toolbox.algorithm:jar</include> |
|
51 |
</includes> |
|
52 |
</dependencySet>--> |
|
53 |
</dependencySets> |
|
54 |
</assembly> |
|
0 | 55 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/ROIMaskExtension.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.io.File; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import javax.swing.JComponent; |
|
10 |
import javax.swing.JPanel; |
|
11 |
|
|
12 |
import org.gvsig.andami.IconThemeHelper; |
|
13 |
import org.gvsig.andami.PluginServices; |
|
14 |
import org.gvsig.andami.plugins.Extension; |
|
15 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
16 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
17 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
18 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
19 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
20 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
21 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
22 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
23 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
24 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
25 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
26 |
import org.gvsig.gui.beans.table.exceptions.NotInitializeException; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
29 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
30 |
import org.gvsig.raster.algorithm.process.IProcessActions; |
|
31 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
32 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
33 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
34 |
import org.gvsig.raster.mainplugin.RasterMainPluginUtils; |
|
35 |
import org.gvsig.raster.roi.ROI; |
|
36 |
import org.gvsig.raster.roimask.algorithm.ROIMaskProcess; |
|
37 |
import org.gvsig.raster.roimask.app.toolbox.ToolboxROIMaskLoader; |
|
38 |
import org.gvsig.raster.roimask.swing.ROIMaskPanel; |
|
39 |
import org.gvsig.raster.roimask.swing.ROIMaskSwingLocator; |
|
40 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
41 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
42 |
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel; |
|
43 |
import org.gvsig.raster.swing.preview.PreviewPanel; |
|
44 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
45 |
import org.gvsig.tools.ToolsLocator; |
|
46 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
47 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
50 |
|
|
51 |
public class ROIMaskExtension extends Extension implements ActionListener, |
|
52 |
IProcessActions { |
|
53 |
|
|
54 |
private int windowWidth = 600; |
|
55 |
|
|
56 |
private int windowHeight = 370; |
|
57 |
|
|
58 |
private IWindow window = null; |
|
59 |
|
|
60 |
private PreviewPanel previewPanel = null; |
|
61 |
|
|
62 |
private ROIMaskPreview processPreview = null; |
|
63 |
|
|
64 |
private ROIMaskPanel panel = null; |
|
65 |
|
|
66 |
private CreateNewLayerPanel newLayerPanel = null; |
|
67 |
|
|
68 |
private static final Logger logger = LoggerFactory |
|
69 |
.getLogger(ROIMaskExtension.class); |
|
70 |
|
|
71 |
public void initialize() { |
|
72 |
|
|
73 |
// Adds an entry to the TOC's floating menu to those layers defined in this |
|
74 |
// extension |
|
75 |
|
|
76 |
// ExtensionPoint exPoint = |
|
77 |
// ToolsLocator.getExtensionPointManager().add("My_TocActions"); |
|
78 |
// exPoint.append("MyMenuEntry", "", new ROIMaskTocMenuEntry()); |
|
79 |
|
|
80 |
// Adds a new tab to the "add layer" dialog |
|
81 |
|
|
82 |
// AddLayer.addWizard(ROIMaskWizard.class); |
|
83 |
|
|
84 |
// Adds a new button in the raster bar |
|
85 |
|
|
86 |
ExtensionPointManager extensionPoints = ToolsLocator |
|
87 |
.getExtensionPointManager(); |
|
88 |
ExtensionPoint point = extensionPoints.add("GenericToolBarMenu"); |
|
89 |
point.append("ROIMask", "", ROIMaskTocMenuEntry.getSingleton()); |
|
90 |
ROIMaskTocMenuEntry.setExtension(this); |
|
91 |
|
|
92 |
Messages.addResourceFamily("org.gvsig.raster.roimask.app.i18n.text", |
|
93 |
ROIMaskExtension.class.getClassLoader(), ROIMaskExtension.class |
|
94 |
.getClass().getName()); |
|
95 |
|
|
96 |
initilizeIcons(); |
|
97 |
} |
|
98 |
|
|
99 |
public void postInitialize() { |
|
100 |
new ToolboxROIMaskLoader().registerTool(); |
|
101 |
} |
|
102 |
|
|
103 |
public void execute(String actionCommand) { |
|
104 |
if (actionCommand.compareTo("ROIMask") == 0) { |
|
105 |
if (getSelectedLayer() == null) { |
|
106 |
RasterSwingLibrary.messageBoxError("layer_not_selected", null); |
|
107 |
return; |
|
108 |
} |
|
109 |
try { |
|
110 |
initializeMainPanel(); |
|
111 |
} |
|
112 |
catch (ReadException e) { |
|
113 |
logger.error("Error initializing the main panel", e); |
|
114 |
} |
|
115 |
catch (ROIException e) { |
|
116 |
logger.error("Error getting ROI", e); |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Creates and initializes the main panel |
|
123 |
* |
|
124 |
* @throws ReadException |
|
125 |
* @throws ROIException |
|
126 |
*/ |
|
127 |
private void initializeMainPanel() throws ReadException, ROIException { |
|
128 |
try { |
|
129 |
loadROIMaskPanel(); |
|
130 |
} |
|
131 |
catch (NotInitializeException e) { |
|
132 |
throw new ReadException("Error loading the table", e); |
|
133 |
} |
|
134 |
|
|
135 |
MainPanel mainPanel = new MainPanel(getROIMaskPanel().getComponent(), |
|
136 |
(JComponent) getNewLayerPanel()); |
|
137 |
|
|
138 |
window = new ROIMaskWindow(mainPanel, (JPanel) getPreviewPanel(), |
|
139 |
Messages.getText("roimask"), windowWidth, windowHeight, false, this); |
|
140 |
|
|
141 |
PluginServices.getMDIManager().addWindow(window); |
|
142 |
getPreviewPanel().previewInitializeSizes(); |
|
143 |
getPreviewPanel().refreshPreview(); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Loads the main panel with the data |
|
148 |
* |
|
149 |
* @throws NotInitializeException |
|
150 |
* @throws ROIException |
|
151 |
*/ |
|
152 |
private void loadROIMaskPanel() throws NotInitializeException, ROIException { |
|
153 |
FLyrRaster lyr = getSelectedLayer(); |
|
154 |
LayerElement element = new LayerElement(lyr); |
|
155 |
getROIMaskPanel().getDataModel().setInputLayer(element); |
|
156 |
ColorInterpretation ci = lyr.getDataStore().getColorInterpretation(); |
|
157 |
|
|
158 |
if (ci.isRGB() || ci.isRGBA()) { |
|
159 |
getROIMaskPanel().activeSlider(true); |
|
160 |
} |
|
161 |
else |
|
162 |
getROIMaskPanel().activeSlider(false); |
|
163 |
|
|
164 |
if (lyr.getRois() == null || lyr.getRois().size() == 0) |
|
165 |
getROIMaskPanel().showWarning(true); |
|
166 |
else |
|
167 |
getROIMaskPanel().showWarning(false); |
|
168 |
|
|
169 |
getROIMaskPanel().getDataModel().clearROIs(); |
|
170 |
|
|
171 |
List<ROI> roisArray = lyr.getRois(); |
|
172 |
if (roisArray != null) { |
|
173 |
for (int i = 0; i < roisArray.size(); i++) { |
|
174 |
ROI roi = (ROI) roisArray.get(i); |
|
175 |
|
|
176 |
Object row[] = { "", "", "" }; |
|
177 |
|
|
178 |
boolean active = false; |
|
179 |
|
|
180 |
row[0] = new Boolean(active); |
|
181 |
row[1] = roi.getName(); |
|
182 |
row[2] = new Integer(i); |
|
183 |
getROIMaskPanel().getDataModel().addROI(row); |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
if (lyr != null) { |
|
188 |
switch (lyr.getDataStore().getDataType()[0]) { |
|
189 |
case Buffer.TYPE_BYTE: |
|
190 |
getROIMaskPanel().getDataModel().setValueNoData( |
|
191 |
RasterLibrary.defaultByteNoDataValue); |
|
192 |
break; |
|
193 |
case Buffer.TYPE_SHORT: |
|
194 |
getROIMaskPanel().getDataModel().setValueNoData( |
|
195 |
RasterLibrary.defaultShortNoDataValue); |
|
196 |
break; |
|
197 |
case Buffer.TYPE_INT: |
|
198 |
getROIMaskPanel().getDataModel().setValueNoData( |
|
199 |
RasterLibrary.defaultIntegerNoDataValue); |
|
200 |
break; |
|
201 |
case Buffer.TYPE_FLOAT: |
|
202 |
getROIMaskPanel().getDataModel().setValueNoData( |
|
203 |
RasterLibrary.defaultFloatNoDataValue); |
|
204 |
break; |
|
205 |
case Buffer.TYPE_DOUBLE: |
|
206 |
getROIMaskPanel().getDataModel().setValueNoData( |
|
207 |
RasterLibrary.defaultDoubleNoDataValue); |
|
208 |
break; |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Gets the list of layers from the gvSIG view |
|
215 |
* |
|
216 |
* @return |
|
217 |
*/ |
|
218 |
private FLayers getLayers() { |
|
219 |
MapControl mapControl = null; |
|
220 |
IWindow[] windowList = PluginServices.getMDIManager().getOrderedWindows(); |
|
221 |
for (int i = 0; i < windowList.length; i++) { |
|
222 |
if (windowList[i] instanceof AbstractViewPanel) { |
|
223 |
mapControl = ((AbstractViewPanel) windowList[i]).getMapControl(); |
|
224 |
break; |
|
225 |
} |
|
226 |
} |
|
227 |
if (mapControl != null) return mapControl.getMapContext().getLayers(); |
|
228 |
return null; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Gets the selected layer |
|
233 |
* |
|
234 |
* @return |
|
235 |
*/ |
|
236 |
private FLyrRaster getSelectedLayer() { |
|
237 |
FLayers lyrs = getLayers(); |
|
238 |
if (lyrs != null) { |
|
239 |
for (int i = 0; i < lyrs.getLayersCount(); i++) { |
|
240 |
FLayer lyr = lyrs.getLayer(i); |
|
241 |
if (lyr.isActive() && lyr instanceof FLyrRaster) |
|
242 |
return (FLyrRaster) lyr; |
|
243 |
} |
|
244 |
} |
|
245 |
return null; |
|
246 |
} |
|
247 |
|
|
248 |
public boolean isEnabled() { |
|
249 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
250 |
if (selectedLayer == null) return false; |
|
251 |
|
|
252 |
if (selectedLayer != null && selectedLayer.isActive() |
|
253 |
&& selectedLayer instanceof FLyrRaster) { |
|
254 |
return true; |
|
255 |
} |
|
256 |
return false; |
|
257 |
} |
|
258 |
|
|
259 |
public boolean isVisible() { |
|
260 |
FLyrRaster selectedLayer = getSelectedLayer(); |
|
261 |
if (selectedLayer == null) |
|
262 |
return false; |
|
263 |
|
|
264 |
if (!(selectedLayer instanceof IRasterLayerActions)) |
|
265 |
return false; |
|
266 |
|
|
267 |
return ((IRasterLayerActions) selectedLayer).isActionEnabled(IRasterLayerActions.ENHANCED); |
|
268 |
} |
|
269 |
|
|
270 |
void initilizeIcons() { |
|
271 |
IconThemeHelper.registerIcon(null, "gvsig-icon", this); |
|
272 |
IconThemeHelper.registerIcon(null, "mask-icon", this); |
|
273 |
IconThemeHelper.registerIcon(null, "gvsig-icon16x16", this); |
|
274 |
} |
|
275 |
|
|
276 |
/** |
|
277 |
* Gets the {@link ROIMaskPanel} |
|
278 |
* |
|
279 |
* @return {@link ROIMaskPanel} |
|
280 |
*/ |
|
281 |
private CreateNewLayerPanel getNewLayerPanel() { |
|
282 |
if (newLayerPanel == null) |
|
283 |
newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel( |
|
284 |
Messages.getText("create_output_layer")); |
|
285 |
return newLayerPanel; |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* Gets the {@link PreviewPanel} |
|
290 |
* |
|
291 |
* @return {@link PreviewPanel} |
|
292 |
*/ |
|
293 |
private PreviewPanel getPreviewPanel() { |
|
294 |
if (previewPanel == null) |
|
295 |
previewPanel = RasterSwingLocator.getSwingManager() |
|
296 |
.createSinglePreviewPanel(null, getDataSourcePreview()); |
|
297 |
return previewPanel; |
|
298 |
} |
|
299 |
|
|
300 |
/** |
|
301 |
* Gets the {@link ROIMaskPreview} |
|
302 |
* |
|
303 |
* @return {@link ROIMaskPreview} |
|
304 |
*/ |
|
305 |
private ROIMaskPreview getDataSourcePreview() { |
|
306 |
if (processPreview == null) { |
|
307 |
processPreview = new ROIMaskPreview(); |
|
308 |
} |
|
309 |
processPreview.setData(getROIMaskPanel().getDataModel()); |
|
310 |
return processPreview; |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* Gets the {@link ROIMaskPanel} |
|
315 |
* |
|
316 |
* @return {@link ROIMaskPanel} |
|
317 |
*/ |
|
318 |
private ROIMaskPanel getROIMaskPanel() { |
|
319 |
if (panel == null) { |
|
320 |
panel = ROIMaskSwingLocator.getSwingManager().createROIMaskPanel(); |
|
321 |
panel.addListener(this); |
|
322 |
} |
|
323 |
return panel; |
|
324 |
} |
|
325 |
|
|
326 |
public void actionPerformed(ActionEvent e) { |
|
327 |
if (window != null |
|
328 |
&& (e.getSource() == ((ROIMaskWindow) window).getButtonsPanel() |
|
329 |
.getButton(ButtonsPanel.BUTTON_ACCEPT) || e.getSource() == ((ROIMaskWindow) window) |
|
330 |
.getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY))) { |
|
331 |
DataProcess task = null; |
|
332 |
try { |
|
333 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask( |
|
334 |
"ROIMaskProcess"); |
|
335 |
} |
|
336 |
catch (ProcessException e1) { |
|
337 |
RasterSwingLibrary.messageBoxError("error_processing_layer", null, e1); |
|
338 |
} |
|
339 |
task.setActions(this); |
|
340 |
try { |
|
341 |
getDataSourcePreview().addParams(task, |
|
342 |
getNewLayerPanel().getDirectorySelected(), |
|
343 |
getNewLayerPanel().getFileSelected()); |
|
344 |
} |
|
345 |
catch (ROIException e1) { |
|
346 |
RasterSwingLibrary.messageBoxError("error_processing_layer", null, e1); |
|
347 |
} |
|
348 |
task.start(); |
|
349 |
return; |
|
350 |
} |
|
351 |
|
|
352 |
getPreviewPanel().refreshPreview(); |
|
353 |
} |
|
354 |
|
|
355 |
@SuppressWarnings("unchecked") |
|
356 |
public void end(Object params) { |
|
357 |
if (params instanceof HashMap<?, ?>) { |
|
358 |
HashMap<String, Object> map = (HashMap<String, Object>) params; |
|
359 |
String fName = (String) map.get(ROIMaskProcess.FILENAME); |
|
360 |
long milis = (Long) map.get(ROIMaskProcess.TIME); |
|
361 |
processFinalize(fName, milis); |
|
362 |
RasterSwingLocator.getSwingManager().showSummaryProcessDialog(fName, |
|
363 |
milis); |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
367 |
private void processFinalize(String fileName, long milis) { |
|
368 |
if (!new File(fileName).exists()) return; |
|
369 |
|
|
370 |
String viewName = getViewName(); |
|
371 |
if (viewName != null) { |
|
372 |
if (RasterSwingLibrary.messageBoxYesOrNot("cargar_toc", this)) { |
|
373 |
try { |
|
374 |
RasterMainPluginUtils.loadLayer(viewName, fileName, null); |
|
375 |
} |
|
376 |
catch (RasterNotLoadException e) { |
|
377 |
RasterSwingLibrary.messageBoxError("error_load_layer", null, e); |
|
378 |
} |
|
379 |
} |
|
380 |
} |
|
381 |
} |
|
382 |
|
|
383 |
private String getViewName() { |
|
384 |
FLyrRaster lyrRaster = getSelectedLayer(); |
|
385 |
IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
386 |
for (int i = 0; i < w.length; i++) { |
|
387 |
if (w[i] instanceof AbstractViewPanel) { |
|
388 |
FLayers lyrs = ((AbstractViewPanel) w[i]).getMapControl() |
|
389 |
.getMapContext().getLayers(); |
|
390 |
for (int j = 0; j < lyrs.getLayersCount(); j++) { |
|
391 |
FLayer lyr = lyrs.getLayer(j); |
|
392 |
if (lyrRaster == lyr) { |
|
393 |
return PluginServices.getMDIManager() |
|
394 |
.getWindowInfo((AbstractViewPanel) w[i]).getTitle(); |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
} |
|
399 |
return null; |
|
400 |
} |
|
401 |
|
|
402 |
public void interrupted() { |
|
403 |
|
|
404 |
} |
|
405 |
|
|
406 |
public class LayerElement { |
|
407 |
|
|
408 |
private FLayer lyr = null; |
|
409 |
|
|
410 |
public LayerElement(FLayer lyr) { |
|
411 |
this.lyr = lyr; |
|
412 |
} |
|
413 |
|
|
414 |
public FLayer getLayer() { |
|
415 |
return lyr; |
|
416 |
} |
|
417 |
|
|
418 |
public String toString() { |
|
419 |
return lyr.getName(); |
|
420 |
} |
|
421 |
|
|
422 |
public int getNumOfElements() { |
|
423 |
if (lyr instanceof FLyrRaster) |
|
424 |
return ((FLyrRaster) lyr).getDataStore().getBandCount(); |
|
425 |
return 0; |
|
426 |
} |
|
427 |
} |
|
428 |
|
|
429 |
public void updateProgress(int current, int total) { |
|
430 |
// TODO Auto-generated method stub |
|
431 |
|
|
432 |
} |
|
433 |
} |
|
0 | 434 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/ROIMaskTocMenuEntry.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app; |
|
2 |
|
|
3 |
import javax.swing.Icon; |
|
4 |
|
|
5 |
import org.gvsig.andami.IconThemeHelper; |
|
6 |
import org.gvsig.andami.plugins.Extension; |
|
7 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
|
8 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.i18n.Messages; |
|
11 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
12 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
|
13 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
|
14 |
|
|
15 |
public class ROIMaskTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
|
16 |
static private ROIMaskTocMenuEntry singleton = null; |
|
17 |
private static Extension extension = null; |
|
18 |
|
|
19 |
|
|
20 |
public static void setExtension(Extension ext) { |
|
21 |
extension = ext; |
|
22 |
} |
|
23 |
|
|
24 |
private ROIMaskTocMenuEntry() {} |
|
25 |
|
|
26 |
static public ROIMaskTocMenuEntry getSingleton() { |
|
27 |
if (singleton == null) |
|
28 |
singleton = new ROIMaskTocMenuEntry(); |
|
29 |
return singleton; |
|
30 |
} |
|
31 |
|
|
32 |
public String getGroup() { |
|
33 |
return "Enhanced"; |
|
34 |
} |
|
35 |
|
|
36 |
public int getGroupOrder() { |
|
37 |
return 55; |
|
38 |
} |
|
39 |
|
|
40 |
public int getOrder() { |
|
41 |
return 0; |
|
42 |
} |
|
43 |
|
|
44 |
public String getText() { |
|
45 |
return Messages.getText("roimask"); |
|
46 |
} |
|
47 |
|
|
48 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
49 |
if(selectedItems == null || selectedItems.length == 0) |
|
50 |
return false; |
|
51 |
for (int i = 0; i < selectedItems.length; i++) { |
|
52 |
if(selectedItems[i] != null && |
|
53 |
selectedItems[i].isActive() && |
|
54 |
selectedItems[i] instanceof FLyrRaster) |
|
55 |
return true; |
|
56 |
} |
|
57 |
return false; |
|
58 |
} |
|
59 |
|
|
60 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
61 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
|
62 |
return false; |
|
63 |
|
|
64 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
|
65 |
return false; |
|
66 |
|
|
67 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED); |
|
68 |
} |
|
69 |
|
|
70 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
|
71 |
extension.execute("ROIMask"); |
|
72 |
} |
|
73 |
|
|
74 |
public Icon getIcon() { |
|
75 |
return IconThemeHelper.getImageIcon("mask-icon"); |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/MainPanel.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app; |
|
2 |
|
|
3 |
import java.awt.GridBagConstraints; |
|
4 |
import java.awt.GridBagLayout; |
|
5 |
|
|
6 |
import javax.swing.JComponent; |
|
7 |
import javax.swing.JPanel; |
|
8 |
|
|
9 |
public class MainPanel extends JPanel { |
|
10 |
private static final long serialVersionUID = 1L; |
|
11 |
|
|
12 |
public MainPanel(JComponent panel, JComponent createLayer) { |
|
13 |
setLayout(new GridBagLayout()); |
|
14 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
15 |
gbc.anchor = GridBagConstraints.WEST; |
|
16 |
gbc.fill = GridBagConstraints.BOTH; |
|
17 |
gbc.weightx = 1; |
|
18 |
gbc.weighty = 1; |
|
19 |
gbc.gridy = 0; |
|
20 |
add(panel, gbc); |
|
21 |
|
|
22 |
gbc.fill = GridBagConstraints.HORIZONTAL; |
|
23 |
gbc.weightx = 1; |
|
24 |
gbc.weighty = 0; |
|
25 |
gbc.gridy = 1; |
|
26 |
|
|
27 |
add(createLayer, gbc); |
|
28 |
} |
|
29 |
} |
|
0 | 30 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/toolbox/ToolboxROIMaskLoader.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app.toolbox; |
|
2 |
|
|
3 |
import java.lang.reflect.Constructor; |
|
4 |
import java.lang.reflect.InvocationTargetException; |
|
5 |
|
|
6 |
import org.slf4j.Logger; |
|
7 |
import org.slf4j.LoggerFactory; |
|
8 |
|
|
9 |
/** |
|
10 |
* Loader for this tool in the toolbox dialog |
|
11 |
* |
|
12 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
13 |
*/ |
|
14 |
public class ToolboxROIMaskLoader { |
|
15 |
private Logger log = LoggerFactory.getLogger(ToolboxROIMaskLoader.class); |
|
16 |
private String errorMsg = "The tool ROIMask are not been added in the toolbox"; |
|
17 |
|
|
18 |
public void registerTool() { |
|
19 |
try { |
|
20 |
Class<?> c = Class.forName("org.gvsig.raster.roimask.app.toolbox.ROIMaskToolboxAction"); |
|
21 |
Constructor<?> constructor = c.getConstructor(); |
|
22 |
constructor.newInstance(); |
|
23 |
} catch (ClassNotFoundException e) { |
|
24 |
log.info(errorMsg, e); |
|
25 |
} catch (SecurityException e) { |
|
26 |
log.info(errorMsg, e); |
|
27 |
} catch (NoSuchMethodException e) { |
|
28 |
log.info(errorMsg, e); |
|
29 |
} catch (IllegalArgumentException e) { |
|
30 |
log.info(errorMsg, e); |
|
31 |
} catch (InstantiationException e) { |
|
32 |
log.info(errorMsg, e); |
|
33 |
} catch (IllegalAccessException e) { |
|
34 |
log.info(errorMsg, e); |
|
35 |
} catch (InvocationTargetException e) { |
|
36 |
log.info(errorMsg, e); |
|
37 |
} catch (NoClassDefFoundError e) { |
|
38 |
log.info("Geoprocess are not installed." + errorMsg, e); |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
} |
|
0 | 43 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.195/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/toolbox/AbstractToolboxAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
Also available in: Unified diff