Revision 10641

View differences:

org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/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.reproject.app.reprojectclient</artifactId>
6
	<packaging>jar</packaging>
7
	<name>Reprojection support</name>
8
	<description>Reprojection support</description>
9
	
10
    <parent>
11
        <groupId>org.gvsig</groupId>
12
        <artifactId>org.gvsig.raster.reproject</artifactId>
13
        <version>2.2.90</version>
14
    </parent>
15
    
16
    <dependencies>
17
    	<dependency>
18
            <groupId>org.gvsig</groupId>
19
            <artifactId>org.gvsig.raster.app.common</artifactId>
20
            <scope>compile</scope>
21
        </dependency>
22
	    <dependency>
23
            <groupId>org.gvsig</groupId>
24
            <artifactId>org.gvsig.raster.lib.api</artifactId>
25
            <scope>compile</scope>
26
        </dependency>
27
		 <dependency>
28
            <groupId>org.gvsig</groupId>
29
            <artifactId>org.gvsig.ui</artifactId>
30
            <scope>compile</scope>
31
        </dependency>
32
		<dependency>
33
            <groupId>org.gvsig</groupId>
34
            <artifactId>org.gvsig.raster.algorithm</artifactId>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.raster.reproject.algorithm</artifactId>
39
        </dependency>
40
        <dependency>
41
			<groupId>org.gvsig</groupId>
42
			<artifactId>org.gvsig.raster.fmap</artifactId>
43
            <scope>compile</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.fmap.control</artifactId>
53
            <scope>compile</scope>
54
        </dependency>
55
         <dependency>
56
            <groupId>org.gvsig</groupId>
57
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
58
            <scope>compile</scope>
59
        </dependency>
60
        <dependency>
61
            <groupId>org.gvsig</groupId>
62
            <artifactId>org.gvsig.andami</artifactId>
63
            <scope>compile</scope>
64
        </dependency>
65
        <dependency>
66
            <groupId>org.gvsig</groupId>
67
            <artifactId>org.gvsig.i18n</artifactId>
68
            <scope>compile</scope>
69
        </dependency>
70
        <dependency>
71
            <groupId>org.gvsig</groupId>
72
            <artifactId>org.gvsig.tools.lib</artifactId>
73
            <scope>compile</scope>
74
        </dependency>
75
        
76
        
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.gvsig</groupId>
84
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
85
            <scope>compile</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.gvsig</groupId>
89
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
90
            <scope>compile</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
        <dependency>
98
            <groupId>org.gvsig</groupId>
99
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
100
            <scope>runtime</scope>
101
        </dependency>
102
        <dependency>
103
          <groupId>org.gvsig</groupId>
104
          <artifactId>org.gvsig.proj.lib.api</artifactId>
105
          <scope>runtime</scope>
106
      	</dependency>
107
      	<dependency>
108
        	<groupId>org.gvsig</groupId>
109
        	<artifactId>org.gvsig.proj.lib.proj4j</artifactId>
110
        	<scope>runtime</scope>
111
      	</dependency>
112
      	<dependency>
113
	        <groupId>org.osgeo</groupId>
114
    	    <artifactId>proj4j</artifactId>
115
        	<scope>runtime</scope>
116
      	</dependency>
117
        <dependency>
118
            <groupId>org.gvsig</groupId>
119
            <artifactId>org.gvsig.projection.api</artifactId>
120
            <scope>compile</scope>
121
        </dependency>
122
        <dependency>
123
            <groupId>org.gvsig</groupId>
124
            <artifactId>org.gvsig.projection.cresques.ui</artifactId>
125
            <scope>compile</scope>
126
        </dependency>
127
        <dependency>
128
            <groupId>org.gvsig</groupId>
129
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
130
            <scope>runtime</scope>
131
        </dependency>
132
        <dependency>
133
            <groupId>org.gvsig</groupId>
134
            <artifactId>org.gvsig.app.mainplugin</artifactId>
135
            <scope>compile</scope>
136
        </dependency>
137
		<dependency>
138
			<groupId>org.gvsig</groupId>
139
			<artifactId>org.gvsig.geoprocess.lib.sextante</artifactId>
140
			<scope>compile</scope>
141
		</dependency>
142
		<dependency>
143
			<groupId>org.gvsig</groupId>
144
			<artifactId>org.gvsig.geoprocess.app.mainplugin</artifactId>
145
			<scope>compile</scope>
146
		</dependency>
147
	</dependencies>
148
	
149
	<properties>
150
    	<gvsig.package.info.state>final</gvsig.package.info.state>
151
    	<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/Raster/pool</gvsig.package.info.poolURL>
152
        <gvsig.package.info.dependencies>required: org.gvsig.raster.tilecache.app -ge 2, required: org.gvsig.raster.mainplugin -ge 2</gvsig.package.info.dependencies>
153
        <gvsig.package.info.categories>Raster</gvsig.package.info.categories>
154
        <gvsig.package.info.official>true</gvsig.package.info.official>
155
    </properties>
156
</project>
0 157

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/buildNumber.properties
1
#Mon Jan 20 22:46:32 CET 2020
2
buildNumber=142
0 3

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/package.info
1
#
2
#Mon Jun 10 11:57:18 CEST 2013
3
owner=gvSIG Association
4
code=org.gvsig.raster.reproject.app.reprojectclient
5
java-version=j1_5
6
official=true
7
type=plugin
8
version=2.0.1-SNAPSHOT-12
9
state=testing
10
operating-system=all
11
dependencies=required\: org.gvsig.raster.tilecache.app -ge 2.0.0-0, required\: org.gvsig.raster.tools.app.basic -ge 2.0.0-0
12
sources-url=https\://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app.reprojectclient
13
web-url=http\://www.gvsig.com
14
architecture=all
15
model-version=1.0.1
16
categories=Raster
17
description=Reprojection support
18
buildNumber=12
19
gvSIG-version=2.0.0
20
name=Reprojection support
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/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.reproject.app.ReprojectExtension"
12
			description="Reproject plugin for raster" 
13
			active="true" 
14
			priority="1">
15
			
16
			<menu text="Layer/transformaciones_geograficas/reproject_layer"
17
				name="raster-tools-reproject-layer"/>
18
				
19
			<action 
20
        		name="raster-tools-reproject-layer"
21
        		label="reproject_layer"
22
        		tooltip="reproject_layer"
23
        		action-command="Reproject" 
24
        		icon="tools-raster-reproject"
25
        		position="000601800"
26
        		accelerator="Ctrl+Alt+R"
27
        	/>
28
				
29
		</extension>	
30
	</extensions>
31
</plugin-config>
0 32

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/resources-plugin/text.properties
1
reproject_layer=Reproyectar
2
reprojection=Reproyecci?n
3
wrong_size=Tama?o incorrecto en la imagen de salida
4
wrong_projection=Proyecci?n incorrecta
5
error_creating_algorithm=Error construyendo el objeto algoritmo
6
directory_does_not_exists=El directorio de destino no existe
7
file_name_not_valid=Nombre de fichero no v?lido
8
file_exists=El fichero de salida existe
9
overwrite=Quieres sobreescribirlo?
10
valid_characters=Caracteres validos
11
toc_reproject=Reproyectar capa
12
dif_proj_with_projections=La proyecci\u00f3n del raster seleccionado no coincide con la de la vista.
13
view_proj=Proyecci\u00f3n de la vista
14
layer_proj=Proyecci\u00f3n de la capa
0 15

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/resources-plugin/text_en.properties
1
reproject_layer=Reproject
2
reprojection=Reprojection
3
wrong_size=Wrong size in output image
4
wrong_projection=Wrong projection
5
error_creating_algorithm=Error building the algorithm object
6
directory_does_not_exists=The destination directory does not exists
7
file_name_not_valid=File name not valid
8
file_exists=The output file exists
9
overwrite=Do you want overwrite it?
10
valid_characters=Valid characters
11
toc_reproject=Reproject layer
12
dif_proj_with_projections=Projection of selected raster is diferent<br>that view projection.
13
view_proj=View projection
14
layer_proj=View projection
0 15

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/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>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25

  
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
	  <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes> 
32
				<include>org.gvsig:org.gvsig.raster.reproject.app.reprojectclient:jar</include>
33
				<include>org.gvsig:org.gvsig.raster.reproject.algorithm:jar</include>
34
	  </includes>
35
	</dependencySet>
36
  </dependencySets>
37
</assembly>
0 38

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/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.reproject.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
	 * @return Returns true if the plugin which gives the functionality is installed
72
     * in gvSIG
73
	 */
74
	public abstract boolean isPluginInstalled();
75

  
76
	/**
77
	 * Loads the raster layer for the tool
78
	 * @return true if layer load is successfully, otherwise fasle
79
	 */
80
	public boolean loadLayer() {
81
		if(!isPluginInstalled()) {
82
			RasterSwingLibrary.messageBoxError(Messages.getText("plugin_not_installed"), null);
83
			return false;
84
		}
85

  
86
		if(!isActive()) {
87
			RasterSwingLibrary.messageBoxError(Messages.getText("layer_not_valid"), null);
88
			return false;
89
		}
90

  
91
		boolean existsRasterButNotActive = false;
92
		lyr = null;
93
		IWindow[] windows = PluginServices.getMDIManager().getOrderedWindows();
94
		MapContext mapCtx = null;
95
		for (int i = 0; i < windows.length; i++) {
96
			if(windows[i] instanceof AbstractViewPanel) {
97
				mapCtx = ((AbstractViewPanel)windows[i]).getMapControl().getMapContext();
98
				break;
99
			}
100
		}
101

  
102
		IRasterLayer[] layers = SextanteGUI.getInputFactory().getRasterLayers();
103
		for (int i = 0; i < layers.length; i++) {
104
			FLyrRaster l = (FLyrRaster)((FLyrRasterIRasterLayer)layers[i]).getBaseDataObject();
105
			existsRasterButNotActive = true;
106
			if(l.isActive() && mapCtx == l.getMapContext()) {
107
				existsRasterButNotActive = false;
108
				lyr = l;
109
				break;
110
			}
111
		}
112

  
113
		if(existsRasterButNotActive) {
114
			RasterSwingLibrary.messageBoxError(Messages.getText("raster_layer_not_active"), null);
115
			return false;
116
		}
117

  
118
		return true;
119
	}
120

  
121
}
0 122

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/toolbox/ToolboxReprojectLoader.java
1
package org.gvsig.raster.reproject.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 ToolboxReprojectLoader {
15
	private Logger log      = LoggerFactory.getLogger(ToolboxReprojectLoader.class); 
16
	private String errorMsg = "The reprojection tool are not been added in the toolbox";
17

  
18
	public void registerTool() {
19
		try {
20
			Class<?> c = Class.forName("org.gvsig.raster.reproject.app.toolbox.ReprojectToolboxAction");
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.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/toolbox/ReprojectToolboxAction.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.reproject.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.reproject.app.ReprojectTocMenuEntry;
35

  
36
/**
37
 * Input in Sextante framework for Principal Components tool
38
 * 
39
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
40
 */
41
public class ReprojectToolboxAction extends AbstractToolboxAction {
42
	
43
	public ReprojectToolboxAction() {
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
		ReprojectTocMenuEntry.getSingleton().execute(null, new FLayer[]{lyr}); 
53
	}
54

  
55
	@Override
56
	public String getName() {
57
		return Messages.getText("reproject_layer");
58
	}
59

  
60
	public ImageIcon getIcon() {
61
		return (ImageIcon)ReprojectTocMenuEntry.getSingleton().getIcon();
62
	}
63
	
64
	public boolean isPluginInstalled() {
65
		try {
66
			ReprojectTocMenuEntry.getSingleton();
67
		} catch(Exception e) {
68
			return false;
69
		} catch(Error e) {
70
			return false;
71
		}
72
		return true;
73
	}
74
}
0 75

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/PrepareLayerAskProjection.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app;
23

  
24
import java.util.Map;
25

  
26
import org.cresques.cts.IProjection;
27
import org.gvsig.app.prepareAction.PrepareContext;
28
import org.gvsig.app.prepareAction.PrepareContextView;
29
import org.gvsig.app.prepareAction.PrepareDataStoreParameters;
30
import org.gvsig.app.prepareAction.PrepareLayer;
31
import org.gvsig.fmap.dal.DALLocator;
32
import org.gvsig.fmap.dal.DataManager;
33
import org.gvsig.fmap.dal.DataStoreParameters;
34
import org.gvsig.fmap.dal.coverage.RasterException;
35
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
36
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
37
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
40
import org.gvsig.geoprocess.lib.sextante.dataObjects.FLyrRasterIRasterLayer;
41
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster;
42
import org.gvsig.raster.fmap.layers.FLyrRaster;
43
import org.gvsig.tools.exception.BaseException;
44

  
45
import es.unex.sextante.gui.cmd.bshcommands.data;
46

  
47
/**
48
 * Entity to configure data store parameters when raster is projected on the fly
49
 * before open store.
50
 * 
51
 * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
52
 *
53
 */
54
public class PrepareLayerAskProjection implements PrepareDataStoreParameters {
55

  
56
    public DataStoreParameters prepare(DataStoreParameters storeParameters, PrepareContext context)
57
        throws BaseException {
58

  
59
        if (storeParameters instanceof RasterDataParameters) {
60
            RasterDataParameters rasterParameters = (RasterDataParameters) storeParameters;
61
            
62
            DataManager dataManager = DALLocator.getDataManager();
63
            RasterDataStore store =
64
                (RasterDataStore) dataManager.openStore(rasterParameters.getDataStoreName(),
65
                    rasterParameters);
66
            IProjection projection = store.getProjection();
67
            store.dispose();
68
            
69
            if(projection != null){
70
                rasterParameters.setSRS(projection);
71
            }
72
        }
73

  
74
        return storeParameters;
75
    }
76
    
77
    public void pre(DataStoreParameters storeParameters, PrepareContext context) {
78
    }
79

  
80
    public void post(DataStoreParameters storeParameters, PrepareContext context) {
81
    }
82

  
83
    public String getDescription() {
84
        return "Prepare projection for Raster Layer";
85
    }
86

  
87
    public String getName() {
88
        return "PrepareRasterLayerProjection";
89
    }
90

  
91
    public Object create() {
92
        return this;
93
    }
94

  
95
    public Object create(Object[] args) {
96
        return this;
97
    }
98

  
99
    @SuppressWarnings("rawtypes")
100
    public Object create(Map args) {
101
        return this;
102
    }
103
}
0 104

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app;
23

  
24
import org.gvsig.andami.IconThemeHelper;
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.andami.ui.mdiManager.IWindow;
28
import org.gvsig.app.ApplicationLocator;
29
import org.gvsig.app.ApplicationManager;
30
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
31
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.fmap.mapcontext.layers.FLayers;
34
import org.gvsig.raster.fmap.layers.FLyrRaster;
35
import org.gvsig.raster.fmap.layers.ILayerState;
36
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
37
import org.gvsig.raster.reproject.app.toolbox.ToolboxReprojectLoader;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.extensionpoint.ExtensionBuilder;
40
import org.gvsig.tools.extensionpoint.ExtensionPoint;
41
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
42

  
43
/**
44
 * Extension for adding grid netcdf support to gvSIG.
45
 * @author Nacho Brodin (nachobrodin@gmail.com)
46
 */
47
public class ReprojectExtension extends Extension {
48
	private ExtensionPoint      genericToolBarMenuExtensionPoint  = null;
49
	private static String       action                            = "Reproject";
50

  
51
	public void initialize() {
52
		IconThemeHelper.registerIcon("action", "tools-raster-reproject", this);
53
		
54
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
55
		ExtensionPoint point = extensionPoints.add("GenericToolBarMenu");
56
		point.append(action, "", ReprojectTocMenuEntry.getSingleton());
57
		
58
		ApplicationManager appGvSigMan = ApplicationLocator.getManager();
59
		appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareLayerAskProjection());
60
	}
61
	
62
	public void postInitialize() {
63
		new ToolboxReprojectLoader().registerTool();
64
	}
65

  
66
	public void execute(String actionCommand) {
67
		//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que la del actionCommand
68
		//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar la acci?n a
69
		//trav?s de este.
70
		ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(actionCommand).getBuilder();
71
		if(ext != null && ext instanceof AbstractTocContextMenuAction) {
72
			IWindow w = PluginServices.getMDIManager().getActiveWindow();
73
			if(w instanceof AbstractViewPanel) {
74
				FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
75
				FLayer[] actives = lyrs.getActives();
76
				((AbstractTocContextMenuAction)ext).execute(null, actives);
77
			}
78
		}
79
	}
80

  
81
	public boolean isEnabled() {
82
		IWindow w = PluginServices.getMDIManager().getActiveWindow();
83
		if(w instanceof AbstractViewPanel) {
84
			FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
85
			FLayer[] actives = lyrs.getActives();
86
			if(actives != null && actives.length > 0) {
87
				for (int i = 0; i < actives.length; i++) {
88
					if(actives[i] instanceof FLyrRaster && ((ILayerState)actives[i]).isOpen()) {
89
						return true;
90
					}
91
				}
92
			}
93
		}
94
		return false;
95
	}
96

  
97
	public boolean isVisible() {
98
		IWindow w = PluginServices.getMDIManager().getActiveWindow();
99
		if(w instanceof AbstractViewPanel) {
100
			FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
101
			FLayer[] actives = lyrs.getActives();
102
			if(actives != null && actives.length > 0) {
103
				for (int i = 0; i < actives.length; i++) {
104
					if(actives[i] instanceof FLyrRaster && 
105
						((IRasterLayerActions)actives[i]).isActionEnabled(IRasterLayerActions.REPROJECT)) {
106
						return true;
107
					}
108
				}
109
			}
110
		}
111
		return false;
112
	}
113
	
114
	public ExtensionPoint getGenericToolBarMenuExtensionPoint() {
115
		if(genericToolBarMenuExtensionPoint == null) {
116
			ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
117
			genericToolBarMenuExtensionPoint = extensionPoints.get("GenericToolBarMenu");
118
		}
119
		return genericToolBarMenuExtensionPoint;
120
	}
121
}
0 122

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectTocMenuEntry.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app;
23

  
24
import javax.swing.Icon;
25

  
26
import java.awt.Dimension;
27

  
28
import org.gvsig.andami.IconThemeHelper;
29
import org.gvsig.andami.PluginServices;
30
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
31
import org.gvsig.app.project.documents.view.toc.ITocItem;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.i18n.Messages;
34
import org.gvsig.raster.fmap.layers.FLyrRaster;
35
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
36
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem;
37
import org.gvsig.raster.reproject.algorithm.RasterReprojectionSwingLocator;
38
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
39
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
40

  
41

  
42
/**
43
 * @author Nacho Brodin (nachobrodin@gmail.com)
44
 */
45
public class ReprojectTocMenuEntry extends AbstractTocContextMenuAction 
46
	implements IGenericToolBarMenuItem {
47
	static private ReprojectTocMenuEntry    singleton        = null;
48
	private ReprojectListener               listener         = null;
49

  
50
	public String getGroup() {
51
		return "GeoRaster";
52
	}
53

  
54
	public int getGroupOrder() {
55
		return 10;
56
	}
57

  
58
	public int getOrder() {
59
		return 10;
60
	}
61

  
62
	public String getText() {
63
		return Messages.getText("toc_reproject");
64
	}
65
	
66
	/**
67
	 * @return Return singleton instance
68
	 */
69
	static public ReprojectTocMenuEntry getSingleton() {
70
		if (singleton == null)
71
			singleton = new ReprojectTocMenuEntry();
72
		return singleton;
73
	}
74

  
75
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
76
		return true;
77
	}
78

  
79
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
80
		if ((selectedItems == null) || (selectedItems.length != 1))
81
			return false;
82

  
83
		if (!(selectedItems[0] instanceof IRasterLayerActions))
84
			return false;
85

  
86
		return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.REPROJECT);
87
	}
88

  
89
	/**
90
	 * M?todo que se ejecuta cuando se pulsa la entrada en el men? contextual del TOC 
91
	 * correspondiente a "Zoom a la resoluci?n del raster". Aqu? se crear? el mapTool si 
92
	 * no se ha hecho antes y se cargar?.
93
	 */
94
	public void execute(ITocItem item, FLayer[] selectedItems) {
95
		if (selectedItems.length == 1) {
96
			FLayer lyr = selectedItems[0];
97
			if (lyr instanceof FLyrRaster) {
98
				ReprojectionPanelDataModel dataModel = new ReprojectionPanelDataModelImpl((FLyrRaster)lyr);
99
				RasterReprojectionPanel reprojectPanel = RasterReprojectionSwingLocator.getSwingManager().createRasterReprojectPanel(dataModel);
100
				Dimension dimension = reprojectPanel.getComponent().getPreferredSize();
101
				
102
				ReprojectWindow window = new ReprojectWindow(reprojectPanel.getComponent(), Messages.getText("reprojection"), dimension.width, dimension.height);
103
				listener = new ReprojectListener(lyr, dataModel, window, reprojectPanel);
104
				reprojectPanel.addButtonsListener(listener);
105
				PluginServices.getMDIManager().addCentredWindow(window);
106
			}
107
		}
108
	}
109
	
110
	public Icon getIcon() {
111
		return IconThemeHelper.getImageIcon("tools-raster-reproject");
112
	}
113
}
0 114

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/preparelayer/RasterProjectionActionsDialog.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app.preparelayer;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Point;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28

  
29
import javax.swing.JPanel;
30

  
31
import org.cresques.cts.IProjection;
32

  
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.ui.mdiManager.IWindow;
35
import org.gvsig.andami.ui.mdiManager.IWindowListener;
36
import org.gvsig.andami.ui.mdiManager.WindowInfo;
37
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
38
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
39
import org.gvsig.raster.mainplugin.RasterMainPluginUtils;
40

  
41
/**
42
 * Dialogo de opciones de sobre la proyecci?n de la capa raster y la vista.
43
 *
44
 * @author Nacho Brodin nachobrodin@gmail.com
45
 */
46
public class RasterProjectionActionsDialog extends JPanel implements IWindow, IWindowListener, ActionListener {
47
	private static final long            serialVersionUID       = 6954391896451933337L;
48
	private RasterProjectionActionsPanel panel                  = null;
49
	private Point                        posWindow              = null;
50
	private int                          widthWindow            = 390;
51
	private int                          heightWindow           = 260;
52
	private boolean                      layerIsReprojectable   = true;
53
	private String                       layerName              = null;
54
	private int                          defaultAction          = RasterDataParameters.NEW_PROJETION_TO_THE_LAYER;
55
    private IProjection viewProj = null;
56
    private IProjection layerProj = null;
57

  
58
	   /**
59
     * Constructor.
60
     */
61
    public RasterProjectionActionsDialog(boolean layerIsReprojectable, String layerName, int defaultAction) {
62
        this(layerIsReprojectable, layerName, defaultAction, null, null);
63
    }
64
	/**
65
	 * Constructor.
66
	 */
67
	public RasterProjectionActionsDialog(boolean layerIsReprojectable, String layerName, int defaultAction, IProjection viewProj, IProjection layerProj) {
68
	    this.viewProj = viewProj;
69
	    this.layerProj = layerProj;
70
		this.layerIsReprojectable = layerIsReprojectable;
71
		this.layerName = layerName;
72
		this.defaultAction = defaultAction;
73
		BorderLayout bl = new BorderLayout();
74
		bl.setHgap(2);
75
		bl.setVgap(2);
76
		setLayout(bl);
77
		add(getRasterProjectionActionsPanel(), BorderLayout.CENTER);
78
		getRasterProjectionActionsPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
79
		getRasterProjectionActionsPanel().getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
80
		getRasterProjectionActionsPanel().getCheckOption().addActionListener(this);
81
		posWindow = RasterMainPluginUtils.iwindowPosition(widthWindow, heightWindow);
82
		PluginServices.getMDIManager().addWindow(this);
83
	}
84

  
85
	public WindowInfo getWindowInfo() {
86
		WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
87
		m_viewinfo.setTitle(PluginServices.getText(this, "options"));
88
		m_viewinfo.setHeight(heightWindow);
89
		m_viewinfo.setWidth(widthWindow);
90
		if (posWindow != null) {
91
			m_viewinfo.setX((int) posWindow.getX());
92
			m_viewinfo.setY((int) posWindow.getY());
93
		}
94
		return m_viewinfo;
95
	}
96

  
97
	/**
98
	 * Obtiene el panel con las opciones de proyecci?n
99
	 * @return RasterProjectionActionsPanel
100
	 */
101
	public RasterProjectionActionsPanel getRasterProjectionActionsPanel() {
102
		if (panel == null) {
103
			panel = new RasterProjectionActionsPanel(layerIsReprojectable, layerName, defaultAction, viewProj, layerProj);
104
		}
105
		return panel;
106
	}
107

  
108
	/**
109
	 * Obtiene la selecci?n del panel
110
	 * @return entero con la selecci?n. Esta representada por las constantes de la
111
	 *         clase RasterReprojectionPanel.
112
	 */
113
	public int getSelection() {
114
		return getRasterProjectionActionsPanel().getSelection();
115
	}
116

  
117
	/**
118
	 * Obtiene la selecci?n del panel
119
	 * @return entero con la selecci?n. Esta representada por las constantes de la
120
	 *         clase RasterReprojectionPanel.
121
	 */
122
	public boolean getChangeProjectionOption() {
123
		return getRasterProjectionActionsPanel().getCheckOption().isSelected();
124
	}
125

  
126
	public void actionPerformed(ActionEvent e) {
127
		if (e.getSource() == getRasterProjectionActionsPanel().getCheckOption()) {
128
			return;
129
		}
130
		PluginServices.getMDIManager().closeWindow(this);
131
	}
132

  
133
	public void windowClosed() {}
134

  
135
	public void windowActivated() {}
136

  
137
	public Object getWindowProfile() {
138
		return WindowInfo.DIALOG_PROFILE;
139
	}
140
}
0 141

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/preparelayer/RasterProjectionActionsPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app.preparelayer;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27

  
28
import javax.swing.ButtonGroup;
29
import javax.swing.JCheckBox;
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JRadioButton;
33

  
34
import org.cresques.cts.IProjection;
35

  
36
import org.gvsig.andami.PluginServices;
37
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
38
import org.gvsig.i18n.Messages;
39
import org.gvsig.raster.swing.basepanel.AbstractButtonsPanel;
40
import org.gvsig.raster.swing.basepanel.IButtonsPanel;
41

  
42
/**
43
 * Obtiene el panel con las opciones a realizar con la proyecci?n. Nos ofrece
44
 * las siguientes posibilidades:
45
 * <UL>
46
 * <LI>Cambiar la proyecci?n de la vista</LI>
47
 * <LI>Reproyectar el raster</LI>
48
 * <LI>Ignorar la proyecci?n del raster y cargar</LI>
49
 * <LI>No cargar</LI>
50
 * </UL>
51
 *
52
 * @author Nacho Brodin nachobrodin@gmail.com
53
 */
54
public class RasterProjectionActionsPanel extends AbstractButtonsPanel {
55
	private static final long serialVersionUID = -3868504818382448187L;
56

  
57
	private JPanel        buttonsPanel           = null;
58
	private ButtonGroup   group                  = new ButtonGroup();
59
	private JRadioButton  changeViewProjection   = null;
60
	private JRadioButton  reproject              = null;
61
	private JRadioButton  ignoreRasterProjection = null;
62
	private JRadioButton  notLoad                = null;
63
	private JRadioButton  onTheFly               = null;
64
	private JCheckBox     allfiles               = null;
65
	private boolean       layerIsReprojectable   = true;
66

  
67
    private IProjection viewProj = null;
68

  
69
    private IProjection layerProj = null;
70

  
71

  
72
	/**
73
	 * Constructor. Llama al inicializador de componentes gr?ficos.
74
	 */
75
	public RasterProjectionActionsPanel(boolean layerIsReprojectable, String layerName, int defaultAction) {
76
	    this(layerIsReprojectable, layerName, defaultAction, null, null);
77
	}
78

  
79
	   /**
80
     * Constructor. Llama al inicializador de componentes gr?ficos.
81
     */
82
    public RasterProjectionActionsPanel(boolean layerIsReprojectable, String layerName, int defaultAction, IProjection viewProj, IProjection layerProj) {
83
        super(IButtonsPanel.BUTTONS_ACCEPTCANCEL);
84
        this.layerIsReprojectable = layerIsReprojectable;
85
        this.viewProj = viewProj;
86
        this.layerProj = layerProj;
87
        init(layerName);
88
        setSelection(defaultAction);
89
    }
90

  
91
	/**
92
	 * Inicializaci?n de componentes gr?ficos.
93
	 */
94
	public void init(String lyrName) {
95
		BorderLayout bl = new BorderLayout();
96
		bl.setVgap(5);
97
		setLayout(bl);
98
		String msg = "";
99
		if(this.viewProj!=null && this.layerProj!=null){
100
            msg =
101
                "<html><b>" + lyrName + "</b><BR><BR>" + Messages.getText("dif_proj_with_projections") + "<BR>"
102
                    + Messages.getText("view_proj") + ": " + viewProj.getAbrev() + "<BR>"
103
                    + Messages.getText("layer_proj") + ": " + layerProj.getAbrev() + "</html>";
104
		} else {
105
		    msg = "<html><b>" + lyrName + "</b><BR><BR>" + Messages.getText("dif_proj") + "</html>";
106
		}
107
        add(new JLabel(msg), BorderLayout.NORTH);
108
		add(getButtonsActionPanel(), BorderLayout.CENTER);
109
		add(getCheckOption(), BorderLayout.SOUTH);
110
	}
111

  
112
	/**
113
	 * Obtiene el panel con los botones se selecci?n de opci?n.
114
	 * @return JPanel
115
	 */
116
	private JPanel getButtonsActionPanel() {
117
		if (buttonsPanel == null) {
118
			buttonsPanel = new JPanel();
119
			buttonsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, Messages.getText("proj_options"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
120

  
121
			group.add(getIgnoreRasterProjectionButton());
122
			group.add(getChangeViewProjectionButton());
123
			group.add(getReprojectButton());
124
			group.add(getNotLoadButton());
125
			group.add(getOnTheFlyButton());
126

  
127
			buttonsPanel.setLayout(new GridBagLayout());
128
			GridBagConstraints gbc = new GridBagConstraints();
129
			gbc.insets = new java.awt.Insets(0, 5, 5, 0);
130

  
131
			gbc.gridx = 0;
132
			gbc.gridy = 0;
133
			gbc.weightx = 1;
134
			gbc.anchor = GridBagConstraints.WEST;
135
			buttonsPanel.add(getIgnoreRasterProjectionButton(), gbc);
136

  
137
			gbc.gridy = 1;
138
			buttonsPanel.add(getReprojectButton(), gbc);
139

  
140
			gbc.gridy = 2;
141
			buttonsPanel.add(getChangeViewProjectionButton(), gbc);
142

  
143
			gbc.gridy = 3;
144
			buttonsPanel.add(getNotLoadButton(), gbc);
145

  
146
			gbc.gridy = 4;
147
			buttonsPanel.add(getOnTheFlyButton(), gbc);
148
		}
149
		return buttonsPanel;
150
	}
151

  
152
	/**
153
	 * Obtiene el bot?n de cambio de projecci?n de la vista
154
	 * @return
155
	 */
156
	private JRadioButton getChangeViewProjectionButton() {
157
		if(changeViewProjection == null) {
158
			changeViewProjection = new JRadioButton(Messages.getText("change_view_proj"));
159

  
160
			/*IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
161
			if (activeWindow instanceof AbstractViewPanel) {
162
				AbstractViewPanel activeView = (org.gvsig.app.project.documents.view.gui.AbstractViewPanel) activeWindow;
163
				if (activeView.getMapControl().getMapContext().getLayers().getLayersCount() >= 1)
164
					changeViewProjection.setEnabled(false);
165
			}*/
166
		}
167
		return changeViewProjection;
168
	}
169

  
170
	/**
171
	 * Obtiene el bot?n de cambio de reproyecci?n
172
	 * @return
173
	 */
174
	private JRadioButton getReprojectButton() {
175
		if(reproject == null) {
176
			reproject = new JRadioButton(Messages.getText("reproject"));
177
			reproject.setEnabled(layerIsReprojectable);
178
		}
179
		return reproject;
180
	}
181

  
182
	/**
183
	 * Obtiene el bot?n de ignorar la proyecci?n del raster
184
	 * @return
185
	 */
186
	private JRadioButton getIgnoreRasterProjectionButton() {
187
		if(ignoreRasterProjection == null) {
188
			ignoreRasterProjection = new JRadioButton(Messages.getText("ignore_raster_proj"));
189
		}
190
		return ignoreRasterProjection;
191
	}
192

  
193
	/**
194
	 * Obtiene el bot?n de no cargar el raster.
195
	 * @return
196
	 */
197
	private JRadioButton getNotLoadButton() {
198
		if(notLoad == null) {
199
			notLoad = new JRadioButton(Messages.getText("not_load"));
200
		}
201
		return notLoad;
202
	}
203

  
204
	/**
205
	 * Gets the button to reproject on the fly
206
	 * @return
207
	 */
208
	private JRadioButton getOnTheFlyButton() {
209
		if(onTheFly == null) {
210
			onTheFly = new JRadioButton(Messages.getText("reproject_on_the_fly") + " (Not implemented yet)");
211
			onTheFly.setEnabled(false);
212
		}
213
		return onTheFly;
214
	}
215

  
216
	/**
217
	 * Obtiene la selecci?n del panel
218
	 * @return entero con la selecci?n. Esta representada por las constantes de FileOpenRaster.
219
	 */
220
	public int getSelection() {
221
		if (getChangeViewProjectionButton().isSelected())
222
			return RasterDataParameters.REPROJECT_VIEW;
223
		if (getReprojectButton().isSelected())
224
			return RasterDataParameters.REPROJECT_DATA;
225
		if (getIgnoreRasterProjectionButton().isSelected())
226
			return RasterDataParameters.NEW_PROJETION_TO_THE_LAYER;
227
		if (getNotLoadButton().isSelected())
228
			return RasterDataParameters.NOT_LOAD;
229
		if (getOnTheFlyButton().isSelected())
230
			return RasterDataParameters.ON_THE_FLY;
231
		return RasterDataParameters.NEW_PROJETION_TO_THE_LAYER;
232
	}
233

  
234
	/**
235
	 * Asigna una selecci?n de opci?n
236
	 * @param entero con la selecci?n. Esta representada por las constantes de FileOpenRaster.
237
	 */
238
	public void setSelection(int value) {
239
		if (value == RasterDataParameters.NEW_PROJETION_TO_THE_LAYER)
240
			getIgnoreRasterProjectionButton().setSelected(true);
241
		if (value == RasterDataParameters.REPROJECT_DATA)
242
			getReprojectButton().setSelected(true);
243
		if (value == RasterDataParameters.REPROJECT_VIEW)
244
			getChangeViewProjectionButton().setSelected(true);
245
		if (value == RasterDataParameters.NOT_LOAD)
246
			getNotLoadButton().setSelected(true);
247
		if (value == RasterDataParameters.ON_THE_FLY)
248
			getOnTheFlyButton().setSelected(true);
249
	}
250

  
251
	/**
252
	 * Obtiene el check con la opci?n de aplicar a todos los ficheros
253
	 * @return
254
	 */
255
	public JCheckBox getCheckOption() {
256
		if (allfiles == null)
257
			allfiles = new JCheckBox(PluginServices.getText(this, "apply_all"));
258
		return allfiles;
259
	}
260
}
0 261

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.90/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/preparelayer/ReprojectionQueue.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.app.preparelayer;
23

  
24
import org.gvsig.fmap.dal.coverage.RasterLocator;
25
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
26
import org.gvsig.raster.algorithm.process.IProcessActions;
27
import org.gvsig.raster.algorithm.process.ProcessException;
28
import org.gvsig.raster.algorithm.process.DataProcess;
29
import org.gvsig.raster.util.Queue;
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
33
/**
34
 * Cola de procesos de ejecuci?n exclusiva. Los procesos de esta lista se ir?n ejecutando
35
 * por orden de llegada impidiendo que se ejecuten dos al mismo tiempo.
36
 * 
37
 * 16/05/2008
38
 * @author Nacho Brodin nachobrodin@gmail.com
39
 */
40
public class ReprojectionQueue extends Thread {
41
	private Queue                     queue                       = new Queue();
42
	private DataProcess             executionProcess            = null;
43
	static private ReprojectionQueue  singleton                   = null;
44
	private Logger                    logger                      = LoggerFactory.getLogger(ReprojectionQueue.class.toString());
45
	
46
	/**
47
	 * Devuelve una instancia al unico objeto de UniqueProcessQueue que puede existir.
48
	 * @return
49
	 */
50
	static public ReprojectionQueue getSingleton() {
51
		if(singleton == null) {
52
			singleton = new ReprojectionQueue();
53
			synchronized (singleton) {
54
				singleton.start();
55
			}
56
		}
57
		return singleton;
58
	}
59
	
60
	public void run() {
61
		//Cuando arranca el thread se duerme porque la cola est? vacia
62
		synchronized (this) {
63
			try {
64
				wait();
65
			} catch (InterruptedException e) {
66
			}
67
		}
68
		
69
		while(true) {
70
			if(queue.size() >= 1) {
71
				Object[] obj = (Object[])queue.get();
72
				executionProcess = ((DataProcess) obj[0]);
73
				if (executionProcess != null) {
74
					executionProcess.showIncrementableWindow();
75
					try {
76
						executionProcess.execute();
77
					} catch (ProcessInterruptedException e) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff