Revision 5877
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/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/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.raster.roimask.app.client</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>Raster mask by ROI</name> |
|
8 |
<description>Raster mask by ROI</description> |
|
9 |
<parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<artifactId>org.gvsig.raster.roimask.app</artifactId> |
|
12 |
<version>2.2.36</version> |
|
13 |
</parent> |
|
14 |
<dependencies> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.raster.roimask.lib.api</artifactId> |
|
18 |
<scope>compile</scope> |
|
19 |
</dependency> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>org.gvsig.raster.roimask.lib.impl</artifactId> |
|
23 |
<scope>runtime</scope> |
|
24 |
</dependency> |
|
25 |
<dependency> |
|
26 |
<groupId>org.gvsig</groupId> |
|
27 |
<artifactId>org.gvsig.raster.roimask.swing.api</artifactId> |
|
28 |
<scope>compile</scope> |
|
29 |
</dependency> |
|
30 |
<dependency> |
|
31 |
<groupId>org.gvsig</groupId> |
|
32 |
<artifactId>org.gvsig.raster.roimask.swing.impl</artifactId> |
|
33 |
<scope>runtime</scope> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.raster.roimask.algorithm</artifactId> |
|
38 |
<scope>compile</scope> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
42 |
<artifactId>org.gvsig.raster.roimask.toolbox.algorithm</artifactId> |
|
43 |
<scope>runtime</scope> |
|
44 |
</dependency> |
|
45 |
<dependency> |
|
46 |
<groupId>org.gvsig</groupId> |
|
47 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
48 |
<scope>compile</scope> |
|
49 |
</dependency> |
|
50 |
<dependency> |
|
51 |
<groupId>org.gvsig</groupId> |
|
52 |
<artifactId>org.gvsig.raster.app.common</artifactId> |
|
53 |
<scope>compile</scope> |
|
54 |
</dependency> |
|
55 |
<dependency> |
|
56 |
<groupId>org.gvsig</groupId> |
|
57 |
<artifactId>org.gvsig.raster.lib.api</artifactId> |
|
58 |
<scope>compile</scope> |
|
59 |
</dependency> |
|
60 |
<dependency> |
|
61 |
<groupId>org.gvsig</groupId> |
|
62 |
<artifactId>org.gvsig.raster.lib.impl</artifactId> |
|
63 |
<scope>runtime</scope> |
|
64 |
</dependency> |
|
65 |
<dependency> |
|
66 |
<groupId>org.gvsig</groupId> |
|
67 |
<artifactId>org.gvsig.raster.fmap</artifactId> |
|
68 |
<scope>compile</scope> |
|
69 |
</dependency> |
|
70 |
<dependency> |
|
71 |
<groupId>org.gvsig</groupId> |
|
72 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
73 |
<scope>compile</scope> |
|
74 |
</dependency> |
|
75 |
<dependency> |
|
76 |
<groupId>org.gvsig</groupId> |
|
77 |
<artifactId>org.gvsig.utils</artifactId> |
|
78 |
<scope>compile</scope> |
|
79 |
</dependency> |
|
80 |
<dependency> |
|
81 |
<groupId>org.gvsig</groupId> |
|
82 |
<artifactId>org.gvsig.ui</artifactId> |
|
83 |
<scope>compile</scope> |
|
84 |
</dependency> |
|
85 |
<dependency> |
|
86 |
<groupId>org.gvsig</groupId> |
|
87 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
88 |
<scope>compile</scope> |
|
89 |
</dependency> |
|
90 |
<dependency> |
|
91 |
<groupId>org.gvsig</groupId> |
|
92 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
93 |
<scope>compile</scope> |
|
94 |
</dependency> |
|
95 |
<dependency> |
|
96 |
<groupId>org.gvsig</groupId> |
|
97 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
98 |
<scope>compile</scope> |
|
99 |
</dependency> |
|
100 |
<dependency> |
|
101 |
<groupId>org.gvsig</groupId> |
|
102 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
103 |
<scope>runtime</scope> |
|
104 |
</dependency> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.fmap.mapcontext.operation</artifactId> |
|
108 |
<scope>runtime</scope> |
|
109 |
</dependency> |
|
110 |
<dependency> |
|
111 |
<groupId>org.gvsig</groupId> |
|
112 |
<artifactId>org.gvsig.projection.api</artifactId> |
|
113 |
<scope>compile</scope> |
|
114 |
</dependency> |
|
115 |
<dependency> |
|
116 |
<groupId>org.gvsig</groupId> |
|
117 |
<artifactId>org.gvsig.projection.cresques.impl</artifactId> |
|
118 |
<scope>runtime</scope> |
|
119 |
</dependency> |
|
120 |
<dependency> |
|
121 |
<groupId>org.gvsig</groupId> |
|
122 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
123 |
<scope>compile</scope> |
|
124 |
</dependency> |
|
125 |
<dependency> |
|
126 |
<groupId>org.gvsig</groupId> |
|
127 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
128 |
<scope>compile</scope> |
|
129 |
</dependency> |
|
130 |
<dependency> |
|
131 |
<groupId>org.gvsig</groupId> |
|
132 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
133 |
<scope>compile</scope> |
|
134 |
</dependency> |
|
135 |
<dependency> |
|
136 |
<groupId>org.gvsig</groupId> |
|
137 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
138 |
<scope>compile</scope> |
|
139 |
</dependency> |
|
140 |
<dependency> |
|
141 |
<groupId>org.gvsig</groupId> |
|
142 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
143 |
<scope>compile</scope> |
|
144 |
</dependency> |
|
145 |
<dependency> |
|
146 |
<groupId>org.gvsig</groupId> |
|
147 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
148 |
<scope>compile</scope> |
|
149 |
</dependency> |
|
150 |
<dependency> |
|
151 |
<groupId>org.gvsig</groupId> |
|
152 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
153 |
<scope>compile</scope> |
|
154 |
</dependency> |
|
155 |
<!-- |
|
156 |
<dependency> |
|
157 |
<groupId>org.gvsig</groupId> |
|
158 |
<artifactId>org.gvsig.fmap.geometry.generalpath</artifactId> |
|
159 |
<scope>runtime</scope> |
|
160 |
</dependency> |
|
161 |
<dependency> |
|
162 |
<groupId>org.gvsig</groupId> |
|
163 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
164 |
<scope>runtime</scope> |
|
165 |
</dependency> |
|
166 |
--> |
|
167 |
<dependency> |
|
168 |
<groupId>org.gvsig</groupId> |
|
169 |
<artifactId>org.gvsig.geoprocess.lib.sextante</artifactId> |
|
170 |
<scope>compile</scope> |
|
171 |
</dependency> |
|
172 |
<dependency> |
|
173 |
<groupId>org.gvsig</groupId> |
|
174 |
<artifactId>org.gvsig.geoprocess.app.mainplugin</artifactId> |
|
175 |
<scope>compile</scope> |
|
176 |
</dependency> |
|
177 |
</dependencies> |
|
178 |
|
|
179 |
<properties> |
|
180 |
<gvsig.package.info.state>final</gvsig.package.info.state> |
|
181 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/Raster/pool</gvsig.package.info.poolURL> |
|
182 |
<gvsig.package.info.dependencies>required: org.gvsig.raster.mainplugin -ge 2</gvsig.package.info.dependencies> |
|
183 |
<gvsig.package.info.categories>Raster</gvsig.package.info.categories> |
|
184 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
185 |
</properties> |
|
186 |
</project> |
|
0 | 187 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/buildNumber.properties | ||
---|---|---|
1 |
#Sun Jul 03 13:34:44 CEST 2016 |
|
2 |
buildNumber=43 |
|
0 | 3 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<plugin-config> |
|
3 |
<depends plugin-name="org.gvsig.raster.mainplugin" /> |
|
4 |
|
|
5 |
<depends plugin-name="org.gvsig.geoprocess.app.mainplugin" optional="true" /> |
|
6 |
<depends plugin-name="org.gvsig.geoprocess.app.algorithm" optional="true" /> |
|
7 |
|
|
8 |
<resourceBundle name="text"/> |
|
9 |
<libraries library-dir="lib"/> |
|
10 |
<extensions> |
|
11 |
<extension class-name="org.gvsig.raster.roimask.app.ROIMaskExtension" |
|
12 |
description="" |
|
13 |
active="true" |
|
14 |
priority="1"> |
|
15 |
|
|
16 |
<menu text="Layer/enhanced/roimask" |
|
17 |
name="ROIMask"/> |
|
18 |
|
|
19 |
<action |
|
20 |
name="ROIMask" |
|
21 |
label="roimask" |
|
22 |
action-command="ROIMask" |
|
23 |
icon="mask-icon" |
|
24 |
position="000601720" |
|
25 |
accelerator="" |
|
26 |
/> |
|
27 |
</extension> |
|
28 |
</extensions> |
|
29 |
</plugin-config> |
|
0 | 30 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/resources-plugin/org/gvsig/raster/roimask/app/i18n/text.properties | ||
---|---|---|
1 |
roimask=M\u00e1scara por regi\u00f3n de inter\u00e9s |
|
2 |
applying_mask=Aplicando m\u00e1scara |
|
3 |
mask_process=Proceso de m\u00e1scara |
|
4 |
gv_tools=gvSIG Herramientas |
|
5 |
group_tools=Capas raster |
|
6 |
raster_layer_not_active=Esta herramienta necesita una capa raster seleccionada en la vista |
|
7 |
create_output_layer=Crear capa de salida |
|
0 | 8 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/resources-plugin/org/gvsig/raster/roimask/app/i18n/text_en.properties | ||
---|---|---|
1 |
roimask=Mask by region of interest |
|
2 |
applying_mask=Applying mask |
|
3 |
mask_process=Mask process |
|
4 |
gv_tools=gvSIG Tools |
|
5 |
group_tools=Tools for raster layers |
|
6 |
raster_layer_not_active=This tool needs a raster layer selected in the view |
|
7 |
create_output_layer=Create output layer |
|
0 | 8 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/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.36/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 |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
package org.gvsig.raster.roimask.app.toolbox; |
|
26 |
|
|
27 |
import org.gvsig.andami.PluginServices; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
32 |
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
35 |
import org.gvsig.raster.swing.RasterSwingLibrary; |
|
36 |
|
|
37 |
import es.unex.sextante.dataObjects.IRasterLayer; |
|
38 |
import es.unex.sextante.gui.core.SextanteGUI; |
|
39 |
import es.unex.sextante.gui.core.ToolboxAction; |
|
40 |
|
|
41 |
/** |
|
42 |
* Base class for toolBox actions |
|
43 |
* |
|
44 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
45 |
*/ |
|
46 |
public abstract class AbstractToolboxAction extends ToolboxAction { |
|
47 |
protected FLyrRaster lyr = null; |
|
48 |
|
|
49 |
@Override |
|
50 |
public String getGroup() { |
|
51 |
return Messages.getText("group_tools"); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
@Override |
|
56 |
public boolean isActive() { |
|
57 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
|
58 |
for (int i = 0; i < windows.length; i++) { |
|
59 |
if(windows[i] instanceof AbstractViewPanel) { |
|
60 |
FLayers lyrs = ((AbstractViewPanel)windows[i]).getMapControl().getMapContext().getLayers(); |
|
61 |
for (int j = 0; j < lyrs.getLayersCount(); j++) { |
|
62 |
if(lyrs.getLayer(j) instanceof FLyrRaster) |
|
63 |
return true; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
return false; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns true if the plugin which gives the functionality is installed |
|
72 |
* in gvSIG |
|
73 |
* @return |
|
74 |
*/ |
|
75 |
public abstract boolean isPluginInstalled(); |
|
76 |
|
|
77 |
/** |
|
78 |
* Loads the raster layer for the tool |
|
79 |
* @return |
|
80 |
*/ |
|
81 |
public boolean loadLayer() { |
|
82 |
if(!isPluginInstalled()) { |
|
83 |
RasterSwingLibrary.messageBoxError(Messages.getText("plugin_not_installed"), null); |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
if(!isActive()) { |
|
88 |
RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_valid"), null); |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
boolean existsRasterButNotActive = false; |
|
93 |
lyr = null; |
|
94 |
IWindow[] windows = PluginServices.getMDIManager().getOrderedWindows(); |
|
95 |
MapContext mapCtx = null; |
|
96 |
for (int i = 0; i < windows.length; i++) { |
|
97 |
if(windows[i] instanceof AbstractViewPanel) { |
|
98 |
mapCtx = ((AbstractViewPanel)windows[i]).getMapControl().getMapContext(); |
|
99 |
break; |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
IRasterLayer[] layers = SextanteGUI.getInputFactory().getRasterLayers(); |
|
104 |
for (int i = 0; i < layers.length; i++) { |
|
105 |
FLyrRaster l = (FLyrRaster)((FLyrRasterIRasterLayer)layers[i]).getBaseDataObject(); |
|
106 |
existsRasterButNotActive = true; |
|
107 |
if(l.isActive() && mapCtx == l.getMapContext()) { |
|
108 |
existsRasterButNotActive = false; |
|
109 |
lyr = l; |
|
110 |
break; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
if(existsRasterButNotActive) { |
|
115 |
RasterSwingLibrary.messageBoxError(Messages.getText("raster_layer_not_active"), null); |
|
116 |
return false; |
|
117 |
} |
|
118 |
|
|
119 |
return true; |
|
120 |
} |
|
121 |
|
|
122 |
} |
|
0 | 123 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/toolbox/ROIMaskToolboxAction.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 |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
|
|
25 |
|
|
26 |
package org.gvsig.raster.roimask.app.toolbox; |
|
27 |
|
|
28 |
import javax.swing.ImageIcon; |
|
29 |
|
|
30 |
import org.gvsig.andami.IconThemeHelper; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.geoprocess.sextante.gui.core.GUIFactory; |
|
33 |
import org.gvsig.i18n.Messages; |
|
34 |
import org.gvsig.raster.roimask.app.ROIMaskTocMenuEntry; |
|
35 |
|
|
36 |
/** |
|
37 |
* Input in Sextante framework for clip tool |
|
38 |
* |
|
39 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
|
40 |
*/ |
|
41 |
public class ROIMaskToolboxAction extends AbstractToolboxAction { |
|
42 |
|
|
43 |
public ROIMaskToolboxAction() { |
|
44 |
ImageIcon ico = IconThemeHelper.getImageIcon("gvsig-icon16x16"); |
|
45 |
GUIFactory.registerExternalTool(Messages.getText("gv_tools"), ico, this); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void execute() { |
|
50 |
if(!super.loadLayer()) |
|
51 |
return; |
|
52 |
|
|
53 |
ROIMaskTocMenuEntry.getSingleton().execute(null, new FLayer[]{lyr}); |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getName() { |
|
58 |
return Messages.getText("roimask"); |
|
59 |
} |
|
60 |
|
|
61 |
public ImageIcon getIcon() { |
|
62 |
return (ImageIcon)ROIMaskTocMenuEntry.getSingleton().getIcon(); |
|
63 |
} |
|
64 |
|
|
65 |
public boolean isPluginInstalled() { |
|
66 |
try { |
|
67 |
ROIMaskTocMenuEntry.getSingleton(); |
|
68 |
} catch(Exception e) { |
|
69 |
return false; |
|
70 |
} catch(Error e) { |
|
71 |
return false; |
|
72 |
} |
|
73 |
return true; |
|
74 |
} |
|
75 |
|
|
76 |
} |
|
0 | 77 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/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.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/ROIMaskPreview.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app; |
|
2 |
|
|
3 |
import java.awt.Graphics2D; |
|
4 |
import java.awt.geom.Rectangle2D; |
|
5 |
import java.awt.image.BufferedImage; |
|
6 |
import java.io.File; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.List; |
|
10 |
|
|
11 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
12 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
13 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
14 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
15 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
16 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
17 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
18 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
19 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
20 |
import org.gvsig.fmap.dal.coverage.grid.render.ImageDrawer; |
|
21 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
22 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
23 |
import org.gvsig.gui.beans.imagenavigator.ImageUnavailableException; |
|
24 |
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary; |
|
25 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
26 |
import org.gvsig.raster.algorithm.process.ProcessException; |
|
27 |
import org.gvsig.raster.algorithm.process.ProcessParamsManagement; |
|
28 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
|
29 |
import org.gvsig.raster.roi.ROI; |
|
30 |
import org.gvsig.raster.roimask.algorithm.ROIMaskProcess; |
|
31 |
import org.gvsig.raster.roimask.app.ROIMaskExtension.LayerElement; |
|
32 |
import org.gvsig.raster.roimask.swing.ROIMaskData; |
|
33 |
import org.gvsig.raster.swing.preview.DataSourcePreview; |
|
34 |
import org.gvsig.tools.task.Cancellable; |
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 |
@SuppressWarnings("deprecation") |
|
39 |
public class ROIMaskPreview implements DataSourcePreview { |
|
40 |
private FLyrRaster inputLyr = null; |
|
41 |
private Extent bbox = null; |
|
42 |
private ROIMaskData data = null; |
|
43 |
private static final Logger logger = LoggerFactory.getLogger(ROIMaskPreview.class); |
|
44 |
|
|
45 |
|
|
46 |
public void setData(ROIMaskData data) { |
|
47 |
this.data = data; |
|
48 |
loadLayers(); |
|
49 |
} |
|
50 |
|
|
51 |
private void loadLayers() { |
|
52 |
if(data == null) |
|
53 |
return; |
|
54 |
Object obj = data.getInputLayer(); |
|
55 |
if(obj != null) |
|
56 |
inputLyr = (FLyrRaster)((LayerElement)data.getInputLayer()).getLayer(); |
|
57 |
if(inputLyr != null) |
|
58 |
bbox = inputLyr.getFullRasterExtent(); |
|
59 |
} |
|
60 |
|
|
61 |
public void closePreviewLayer() { |
|
62 |
|
|
63 |
} |
|
64 |
|
|
65 |
public double getCellSize() { |
|
66 |
if(inputLyr != null) |
|
67 |
return inputLyr.getDataStore().getCellSize(); |
|
68 |
return 1; |
|
69 |
} |
|
70 |
|
|
71 |
public DataSourcePreview cloneDataSourcePreview() { |
|
72 |
return this; |
|
73 |
} |
|
74 |
|
|
75 |
public void popStatus() { |
|
76 |
} |
|
77 |
|
|
78 |
public void pushStatus() { |
|
79 |
} |
|
80 |
|
|
81 |
public void draw(BufferedImage image, Graphics2D g, double[] coords, int w, int h, Cancellable cancel, double scale) throws ImageUnavailableException { |
|
82 |
//Posici?n de inicio dibujado dentro del Graphics |
|
83 |
int x = 0; |
|
84 |
int y = 0; |
|
85 |
//Coordenadas de la petici?n |
|
86 |
double iniX = coords[0]; |
|
87 |
double iniY = coords[1]; |
|
88 |
double endX = coords[2]; |
|
89 |
double endY = coords[3]; |
|
90 |
|
|
91 |
//Se ajustan las coordenadas de petici?n, ancho y alto en coordenadas p?xel, |
|
92 |
//as? como la coordenada de inicio de dibujado |
|
93 |
if(bbox.getULX() > coords[0]) { |
|
94 |
iniX = bbox.getULX(); |
|
95 |
x = (int)(((iniX - coords[0]) * w) / Math.abs(coords[2] - coords[0])); |
|
96 |
} |
|
97 |
|
|
98 |
if(bbox.getULY() < coords[1]) { |
|
99 |
iniY = bbox.getULY(); |
|
100 |
y = (int)(((coords[1] - iniY) * h) / Math.abs(coords[3] - coords[1])); |
|
101 |
} |
|
102 |
|
|
103 |
if(bbox.getLRX() < coords[2]) |
|
104 |
endX = bbox.getLRX(); |
|
105 |
|
|
106 |
if(bbox.getLRY() > coords[3]) |
|
107 |
endY = bbox.getLRY(); |
|
108 |
|
|
109 |
if(iniX != coords[0] || endX != coords[2]) { |
|
110 |
w = (int)((Math.abs(endX - iniX) * w) / Math.abs(coords[2] - coords[0])); |
|
111 |
} |
|
112 |
|
|
113 |
if(iniY != coords[1] || endY != coords[3]) { |
|
114 |
h = (int)((Math.abs(iniY - endY) * h) / Math.abs(coords[3] - coords[1])); |
|
115 |
} |
|
116 |
|
|
117 |
Extent ext = RasterLocator.getManager().getDataStructFactory().createExtent(iniX, iniY, endX, endY); |
|
118 |
BufferedImage img = throwProcess(ext, w, h); |
|
119 |
g.drawImage(img, x, y, null); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Throws the process sequentially. Since the preview is small, |
|
124 |
* it should not taken a lot of time |
|
125 |
* is small |
|
126 |
* @param ext |
|
127 |
* @param w |
|
128 |
* @param h |
|
129 |
* @return |
|
130 |
*/ |
|
131 |
private BufferedImage throwProcess(Extent ext, int w, int h) { |
|
132 |
loadLayers(); |
|
133 |
|
|
134 |
DataProcess task; |
|
135 |
try { |
|
136 |
task = RasterBaseAlgorithmLibrary.getManager().createRasterTask("ROIMaskProcess"); |
|
137 |
task.addParam(ROIMaskProcess.RASTER_STORE1, inputLyr.getDataStore()); |
|
138 |
|
|
139 |
task.addParam(ProcessParamsManagement.PREVIEW, true); |
|
140 |
task.addParam(ProcessParamsManagement.WINDOW, ext); |
|
141 |
task.addParam(ProcessParamsManagement.OUTPUT_WIDTH, w); |
|
142 |
task.addParam(ProcessParamsManagement.OUTPUT_HEIGHT, h); |
|
143 |
|
|
144 |
task.addParam(ROIMaskProcess.ROIS, getROIsSelected()); |
|
145 |
task.addParam(ROIMaskProcess.ALPHA, data.getAlpha()); |
|
146 |
task.addParam(ROIMaskProcess.INVERSE, data.isInverse()); |
|
147 |
task.addParam(ROIMaskProcess.NODATA, getNoDataSelected()); |
|
148 |
} catch (ProcessException e1) { |
|
149 |
logger.debug("Error creating task", e1); |
|
150 |
return null; |
|
151 |
} catch (ROIException e) { |
|
152 |
logger.debug("Error creating task", e); |
|
153 |
return null; |
|
154 |
} |
|
155 |
|
|
156 |
task.init(); |
|
157 |
try { |
|
158 |
task.process(); |
|
159 |
} catch (ProcessInterruptedException e1) { |
|
160 |
return null; |
|
161 |
} catch (ProcessException e) { |
|
162 |
logger.debug("Error in process"); |
|
163 |
return null; |
|
164 |
} |
|
165 |
|
|
166 |
HashMap<String, Object> map = (HashMap<String, Object>)task.getResult(); |
|
167 |
Buffer buf = (Buffer)map.get(ROIMaskProcess.BUFFER); |
|
168 |
buf.setDataExtent(ext.toRectangle2D()); |
|
169 |
|
|
170 |
ColorInterpretation ci = inputLyr.getDataStore().getColorInterpretation(); |
|
171 |
Transparency transparency = null; |
|
172 |
if(ci.isRGB() || ci.isRGBA()) { |
|
173 |
Integer alphaBandNumber = (Integer)map.get(ROIMaskProcess.ALPHA_BAND); |
|
174 |
transparency = RasterLocator.getManager().getDataStructFactory().createTransparency(buf.getBandCount()); |
|
175 |
transparency.setTransparencyBand(alphaBandNumber); |
|
176 |
transparency.activeTransparency(); |
|
177 |
} |
|
178 |
|
|
179 |
ImageDrawer drawer = RasterLocator.getManager().createImageDrawerService(); |
|
180 |
drawer.setBuffer(buf); |
|
181 |
drawer.setLastTransparency(transparency); |
|
182 |
try { |
|
183 |
applyFiltersToPreview(drawer); |
|
184 |
|
|
185 |
return (BufferedImage)drawer.drawBufferOverImageObject(); |
|
186 |
} catch (ProcessInterruptedException e) { |
|
187 |
return null; |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Adds filters to the preview. If the original render has a color table |
|
193 |
* , a generic enhanced will be added. |
|
194 |
* @param drawer |
|
195 |
*/ |
|
196 |
private void applyFiltersToPreview(ImageDrawer drawer) { |
|
197 |
RasterFilterList filterList = inputLyr.getRender().getFilterList(); |
|
198 |
List<RasterFilter> list = new ArrayList<RasterFilter>(); |
|
199 |
if(filterList.lenght() > 0) { |
|
200 |
for (int i = 0; i < filterList.lenght(); i++) { |
|
201 |
RasterFilter rf = filterList.get(i); |
|
202 |
if(rf.getName().equals("colortable")) { |
|
203 |
drawer.addEnhanced(inputLyr.getDataStore().getStatistics(), true, 0.2); |
|
204 |
return; |
|
205 |
} |
|
206 |
list.add(rf); |
|
207 |
} |
|
208 |
} |
|
209 |
try { |
|
210 |
drawer.addFilters(inputLyr.getDataStore().getStatistics(), list); |
|
211 |
} catch (FilterTypeException e) { |
|
212 |
logger.debug("Tirando sin filtros", e); |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
private NoData getNoDataSelected() { |
|
217 |
NoData nodata = RasterLocator.getManager().getDataStructFactory().createDefaultNoData( |
|
218 |
inputLyr.getDataStore().getBandCount(), inputLyr.getDataStore().getDataType()[0]); |
|
219 |
nodata.setValue(data.getValueNoData()); |
|
220 |
return nodata; |
|
221 |
} |
|
222 |
|
|
223 |
private ROI[] getROIsSelected() throws ROIException { |
|
224 |
List<ROI> roi = inputLyr.getRois(); |
|
225 |
boolean[] roisSelected = data.getROIsSelected(); |
|
226 |
List<ROI> roisToDraw = new ArrayList<ROI>(); |
|
227 |
for (int i = 0; i < roisSelected.length; i++) { |
|
228 |
if(roisSelected[i]) |
|
229 |
roisToDraw.add(roi.get(i)); |
|
230 |
} |
|
231 |
return roisToDraw.toArray(new ROI[0]); |
|
232 |
} |
|
233 |
|
|
234 |
public Object getSource() { |
|
235 |
return null; |
|
236 |
} |
|
237 |
|
|
238 |
public Rectangle2D getBBoxRectangle() { |
|
239 |
if(inputLyr != null) |
|
240 |
return inputLyr.getFullRasterExtent().toRectangle2D(); |
|
241 |
return new Rectangle2D.Double(); |
|
242 |
} |
|
243 |
|
|
244 |
public void addParams(DataProcess task, String path, String fileName) throws ROIException { |
|
245 |
if(!fileName.matches("([*]\\.[???])")) { |
|
246 |
fileName += ".tif"; |
|
247 |
} |
|
248 |
task.addParam(ROIMaskProcess.PATH, path + File.separator + fileName); |
|
249 |
task.addParam(ROIMaskProcess.RASTER_STORE1, inputLyr.getDataStore()); |
|
250 |
task.addParam(ROIMaskProcess.ROIS, getROIsSelected()); |
|
251 |
task.addParam(ROIMaskProcess.ALPHA, data.getAlpha()); |
|
252 |
task.addParam(ROIMaskProcess.INVERSE, data.isInverse()); |
|
253 |
task.addParam(ROIMaskProcess.NODATA, getNoDataSelected()); |
|
254 |
} |
|
255 |
} |
|
0 | 256 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/org.gvsig.raster.roimask.app/org.gvsig.raster.roimask.app.client/src/main/java/org/gvsig/raster/roimask/app/ROIMaskWindow.java | ||
---|---|---|
1 |
package org.gvsig.raster.roimask.app; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.GridBagConstraints; |
|
5 |
import java.awt.GridBagLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
|
|
9 |
import javax.swing.JComponent; |
|
10 |
import javax.swing.JPanel; |
|
11 |
import javax.swing.JSplitPane; |
|
12 |
import javax.swing.border.Border; |
|
13 |
import javax.swing.plaf.basic.BasicSplitPaneDivider; |
|
14 |
import javax.swing.plaf.basic.BasicSplitPaneUI; |
|
15 |
|
|
16 |
import org.gvsig.andami.PluginServices; |
|
17 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
18 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
19 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
20 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
21 |
|
|
22 |
public class ROIMaskWindow extends DefaultButtonsPanel implements IWindow, ActionListener { |
|
23 |
|
|
24 |
private static final long serialVersionUID = -4401123724140025094L; |
|
25 |
private ActionListener listener = null; |
|
26 |
private WindowInfo info = null; |
|
27 |
|
|
28 |
private Object profile = WindowInfo.EDITOR_PROFILE; |
|
29 |
|
|
30 |
public ROIMaskWindow(JComponent panel, |
|
31 |
JComponent preview, |
|
32 |
String title, |
|
33 |
int w, |
|
34 |
int h, |
|
35 |
boolean fixedPreview, |
|
36 |
ActionListener actionListener) { |
|
37 |
this.listener = actionListener; |
|
38 |
|
|
39 |
if(fixedPreview) |
|
40 |
fixedPreview(panel, preview); |
|
41 |
else |
|
42 |
redimPreview(panel, preview); |
|
43 |
|
|
44 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this); |
|
45 |
//Se elimina el bot?n aplicar pq la ventana es modal. Lo que ocurre es que al terminar el proceso se |
|
46 |
//lanza el dialogo de cargar la capa en el TOC que tambi?n es modal. Esto provoca una excepci?n. El bot?n |
|
47 |
//de aceptar no da problemas pq este cierra antes la ventana inferior. |
|
48 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).setVisible(false); |
|
49 |
//getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this); |
|
50 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this); |
|
51 |
|
|
52 |
info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE); |
|
53 |
info.setTitle(title); |
|
54 |
info.setWidth(w); |
|
55 |
info.setHeight(h); |
|
56 |
} |
|
57 |
|
|
58 |
private void fixedPreview(JComponent panel, JComponent preview) { |
|
59 |
setLayout(new GridBagLayout()); |
|
60 |
GridBagConstraints gbc = new GridBagConstraints(); |
|
61 |
gbc.fill = GridBagConstraints.BOTH; |
|
62 |
gbc.weightx = 1; |
|
63 |
gbc.weighty = 1; |
|
64 |
add(panel, gbc); |
|
65 |
|
|
66 |
if(preview != null) { |
|
67 |
gbc.anchor = GridBagConstraints.NORTH; |
|
68 |
gbc.fill = GridBagConstraints.NONE; |
|
69 |
gbc.weightx = 0; |
|
70 |
gbc.weighty = 0; |
|
71 |
gbc.gridx = 1; |
|
72 |
add(preview, gbc); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
private void redimPreview(JComponent panel, JComponent preview) { |
|
77 |
setLayout(new BorderLayout()); |
|
78 |
JSplitPane splitPane = new JSplitPane(); |
|
79 |
splitPane.setLeftComponent(panel); |
|
80 |
splitPane.setRightComponent(getPreviewForRedimPreviewPanel(preview)); |
|
81 |
splitPane.setResizeWeight(1.0); |
|
82 |
splitPane.setContinuousLayout(true); |
|
83 |
splitPane.setOneTouchExpandable(true); |
|
84 |
splitPane.setUI(new BasicSplitPaneUI() { |
|
85 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
86 |
return new BasicSplitPaneDivider(this) { |
|
87 |
private static final long serialVersionUID = 1L; |
|
88 |
|
|
89 |
public void setBorder(Border b) { |
|
90 |
} |
|
91 |
}; |
|
92 |
} |
|
93 |
}); |
|
94 |
splitPane.setBorder(null); |
|
95 |
add(splitPane, BorderLayout.CENTER); |
|
96 |
} |
|
97 |
|
|
98 |
private JSplitPane getPreviewForRedimPreviewPanel(JComponent preview) { |
|
99 |
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
|
100 |
splitPane.setTopComponent(preview); |
|
101 |
splitPane.setBottomComponent(new JPanel()); |
|
102 |
splitPane.setResizeWeight(0); |
|
103 |
splitPane.setContinuousLayout(true); |
|
104 |
splitPane.setOneTouchExpandable(true); |
|
105 |
splitPane.setUI(new BasicSplitPaneUI() { |
|
106 |
public BasicSplitPaneDivider createDefaultDivider() { |
|
107 |
return new BasicSplitPaneDivider(this) { |
|
108 |
private static final long serialVersionUID = 1L; |
|
109 |
|
|
110 |
public void setBorder(Border b) { |
|
111 |
} |
|
112 |
}; |
|
113 |
} |
|
114 |
}); |
|
115 |
splitPane.setBorder(null); |
|
116 |
return splitPane; |
|
117 |
} |
|
118 |
|
|
119 |
public WindowInfo getWindowInfo() { |
|
120 |
return info; |
|
121 |
} |
|
122 |
|
|
123 |
public Object getWindowProfile() { |
|
124 |
return profile; |
|
125 |
} |
|
126 |
|
|
127 |
public void actionPerformed(ActionEvent e) { |
|
128 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) { |
|
129 |
listener.actionPerformed(e); |
|
130 |
PluginServices.getMDIManager().closeWindow(this); |
|
131 |
} |
|
132 |
|
|
133 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) { |
|
134 |
listener.actionPerformed(e); |
|
135 |
} |
|
136 |
|
|
137 |
if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) { |
|
138 |
PluginServices.getMDIManager().closeWindow(this); |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
0 | 142 |
org.gvsig.raster.roimask/tags/org.gvsig.raster.roimask-2.2.36/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 |
Also available in: Unified diff