Revision 1879

View differences:

org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/package.info
1 1
#
2
#Fri Jun 07 10:41:26 CEST 2013
2
#Fri Jun 07 12:01:35 CEST 2013
3 3
owner=gvSIG Association
4 4
code=org.gvsig.raster.reproject.app.reprojectclient
5 5
java-version=j1_5
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectPanelDataModelImpl.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.awt.geom.Point2D;
25
import java.util.ArrayList;
26
import java.util.List;
27

  
28
import org.cresques.cts.ICoordTrans;
29
import org.cresques.cts.IProjection;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.dal.coverage.RasterLocator;
35
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
36
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
37
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
38
import org.gvsig.fmap.mapcontext.MapContext;
39
import org.gvsig.fmap.mapcontext.layers.FLayers;
40
import org.gvsig.raster.fmap.layers.FLyrRaster;
41
import org.gvsig.raster.tools.algorithm.reproject.ReprojectProcess;
42
import org.gvsig.raster.tools.algorithm.swing.reproject.ReprojectPanelDataModel;
43

  
44
/**
45
 * Data model for the panel of reprojection
46
 * @author Nacho Brodin (nachobrodin@gmail.com)
47
 */
48
public class ReprojectPanelDataModelImpl implements ReprojectPanelDataModel {
49
	private double               cellSize                 = 0;
50
	private IProjection          dstProjection            = null;
51
	private IProjection          srcProjection            = null;
52
	private List<String>         interpolationMethodList  = null;
53
	private int                  interpolationMethod      = 0;
54
	private String               layerName                = null;
55
	private int[]                size                     = new int[]{0, 0};
56
	private FLyrRaster           lyr                      = null;
57
	private Extent               newBbox                  = null;
58
	
59
	public ReprojectPanelDataModelImpl(FLyrRaster lyr) {
60
		this.lyr = lyr;
61
		cellSize = lyr.getDataStore().getCellSize();
62
		try {
63
			srcProjection = lyr.readProjection();
64
		} catch (RasterDriverException e) {
65
			srcProjection = getViewProjection(lyr);
66
		}
67
		if (srcProjection == null) 
68
			srcProjection = getViewProjection(lyr);
69
		if (srcProjection == null)
70
			srcProjection = CRSFactory.getCRS("EPSG:23030");
71

  
72
		dstProjection = srcProjection;
73
		
74
		layerName = lyr.getName();
75
		size = new int[]{(int)lyr.getDataStore().getWidth(), 
76
						 (int)lyr.getDataStore().getHeight()};
77
		
78
		interpolationMethod = -1;
79
		interpolationMethodList = new ArrayList<String>();
80
		for (int i = 0; i < ReprojectProcess.INTERP_METHODS.length; i++) {
81
			interpolationMethodList.add(ReprojectProcess.INTERP_METHODS[i]);
82
		}
83
		//updateValues(lyr.getDataStore());
84
	}
85
	
86
	/**
87
	 * Gets the projection of the view
88
	 * @param lyr
89
	 * @return
90
	 */
91
	private IProjection getViewProjection(FLyrRaster lyr) {
92
		IWindow[] w = PluginServices.getMDIManager().getAllWindows();
93
		for (int i = 0; i < w.length; i++) {
94
			if(w[i] instanceof AbstractViewPanel) {
95
				MapContext mapContext = ((AbstractViewPanel)w[i]).getMapControl().getMapContext();
96
				FLayers lyrs = mapContext.getLayers();
97
				for (int j = 0; j < lyrs.getLayersCount(); j++) {
98
					if(lyrs.getLayer(j) == lyr) {
99
						return ((AbstractViewPanel)w[i]).getProjection();
100
					}
101
				}
102
			}
103
		}
104
		return null;
105
	}
106
	
107
	private void updateValues(RasterDataStore store) {
108
		//      d1x                 d2x
109
		//   ---------           ---------
110
		//   |  p1x  |           |  p2x  |
111
		//d1y|p1y    |        d2y|p2y    |
112
		//   |       |           |       |
113
		//   ---------           ---------
114
		
115
		ICoordTrans transf = srcProjection.getCT(dstProjection);
116
		Extent bbox = store.getExtent();
117
		Point2D ul = new Point2D.Double(bbox.getULX(), bbox.getULY());
118
		Point2D lr = new Point2D.Double(bbox.getLRX(), bbox.getLRY());
119
		if(transf == null)
120
			return;
121
		ul = transf.convert(ul, ul);
122
		lr = transf.convert(lr, lr);
123
		newBbox = RasterLocator.getManager().getDataStructFactory().createExtent(ul, lr);
124
		
125
		//System.out.println("Old BBox: " + bbox.toString());
126
		//System.out.println("New BBox: " + newBbox.toString());
127
		//System.out.println("Old Pixel Size: " + store.getCellSize());
128
		
129
		//double p1x = store.getWidth();
130
		//double p1y = store.getHeight();
131
		//System.out.println("Old WxH: " + p1x + " " + p1y + " --- " + (p1x / p1y) + "  " + (p1y / p1x));
132
		
133
		//long nPixels = (long)(store.getWidth() * store.getHeight());
134
		double sumSideOldBBox = bbox.width() + bbox.height();
135
		double sumSideNewBBox = newBbox.width() + newBbox.height();
136
		double d1x = (bbox.width() * 100) / sumSideOldBBox; 
137
		double d1y = (bbox.height() * 100) / sumSideOldBBox;
138
		double d2x = (newBbox.width() * 100) / sumSideNewBBox;
139
		double d2y = (newBbox.height() * 100) / sumSideNewBBox;
140
		//System.out.println("Old nPixels: " + nPixels);
141
		//System.out.println("d1x: " + d1x + " d1y: " + d1y + " d2x: " + d2x + " d2y: " + d2y);
142
		double p2y = (store.getHeight() * d2y) / d1y;
143
		double p2x = (store.getWidth() * d2x) / d1x;
144
		//long newNPixels = (long)(p2x * p2y);
145
		//System.out.println("New nPixels: " + newNPixels);
146
		//System.out.println("New WxH: " + p2x + " " + p2y + " --- " + (p2x / p2y) + "  " + (p2y / p2x));
147
		double newCellSize = newBbox.width() / p2x;
148
		
149
		size[0] = (int)Math.round(p2x);
150
		size[1] = (int)Math.round(p2y);
151
		cellSize = newCellSize;
152
		//double newCellSizeY = newBbox.height() / p2y;
153
		//System.out.println("New Pixel Size: " + newCellSize + " " + newCellSizeY);
154
	}
155
	
156
	public double getCellSize() {
157
		return cellSize;
158
	}
159

  
160
	public IProjection getDstProjection() {
161
		return dstProjection;
162
	}
163

  
164
	public List<String> getInterpolationMethodList() {
165
		return interpolationMethodList;
166
	}
167

  
168
	public int getInterpolationMethodSelected() {
169
		return interpolationMethod;
170
	}
171

  
172
	public String getLayerName() {
173
		return layerName;
174
	}
175

  
176
	public int[] getSize() {
177
		return size;
178
	}
179

  
180
	public IProjection getSrcProjection() {
181
		return srcProjection;
182
	}
183

  
184
	public void setCellSize(double cellSize) {
185
		this.cellSize = cellSize;
186
		size[0] = (int)(newBbox.width() / cellSize);
187
		size[1] = (int)(newBbox.height() / cellSize);
188
	}
189

  
190
	public void setDstProjection(IProjection dst) {
191
		this.dstProjection = dst;
192
		updateValues(lyr.getDataStore());
193
	}
194
	
195
	public void setSrcProjection(IProjection src) {
196
		this.srcProjection = src;
197
		updateValues(lyr.getDataStore());
198
	}
199

  
200
	public void setInterpolationMethodList(List<String> list) {
201
		this.interpolationMethodList = list;
202
	}
203

  
204
	public void setInterpolationMethodSelected(int method) {
205
		this.interpolationMethod = method;
206
	}
207

  
208
	public void setLayerName(String layerName) {
209
		this.layerName = layerName;
210
	}
211

  
212
	public void setSize(int w, int h) {
213
		this.size = new int[]{w, h};
214
	}
215
}
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectListener.java
37 37
import org.gvsig.fmap.mapcontext.layers.FLayers;
38 38
import org.gvsig.i18n.Messages;
39 39
import org.gvsig.raster.fmap.layers.FLyrRaster;
40
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
41
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
40 42
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary;
41 43
import org.gvsig.raster.tools.algorithm.base.process.IProcessActions;
42 44
import org.gvsig.raster.tools.algorithm.base.process.ProcessException;
43 45
import org.gvsig.raster.tools.algorithm.base.process.RasterProcess;
44 46
import org.gvsig.raster.tools.algorithm.reproject.ReprojectProcess;
45 47
import org.gvsig.raster.tools.algorithm.swing.reproject.RasterReprojectPanel;
46
import org.gvsig.raster.tools.algorithm.swing.reproject.ReprojectPanelDataModel;
47 48
import org.gvsig.raster.tools.app.basic.RasterToolsUtil;
48 49
import org.gvsig.raster.tools.app.basic.raster.bean.endinfo.EndInfoDialog;
49 50
import org.gvsig.raster.util.RasterNotLoadException;
......
55 56
 * @author Nacho Brodin (nachobrodin@gmail.com)
56 57
 */
57 58
public class ReprojectListener implements ActionListener, IProcessActions {
58
	private RasterReprojectPanel            reprojectPanel   = null;
59
	private FLayer                          lyr              = null;
60
	private ReprojectPanelDataModel         dataModel        = null;
61
	private ReprojectWindow                 window           = null;
59
	private RasterReprojectionPanel            reprojectPanel   = null;
60
	private FLayer                             lyr              = null;
61
	private ReprojectionPanelDataModel         dataModel        = null;
62
	private ReprojectWindow                    window           = null;
62 63

  
63
	public ReprojectListener(FLayer lyr, ReprojectPanelDataModel dataModel, ReprojectWindow window, RasterReprojectPanel reprojectPanel) {
64
	public ReprojectListener(FLayer lyr, ReprojectionPanelDataModel dataModel, ReprojectWindow window, RasterReprojectionPanel reprojectPanel) {
64 65
		this.lyr = lyr;
65 66
		this.dataModel = dataModel;
66 67
		this.window = window;
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectTocMenuEntry.java
31 31
import org.gvsig.i18n.Messages;
32 32
import org.gvsig.raster.fmap.layers.FLyrRaster;
33 33
import org.gvsig.raster.fmap.layers.IRasterLayerActions;
34
import org.gvsig.raster.reproject.algorithm.RasterReprojectionSwingLocator;
35
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
36
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
34 37
import org.gvsig.raster.swing.newlayer.FileNameManagement;
35
import org.gvsig.raster.tools.algorithm.swing.AlgorithmSwingLocator;
36
import org.gvsig.raster.tools.algorithm.swing.reproject.RasterReprojectPanel;
37
import org.gvsig.raster.tools.algorithm.swing.reproject.ReprojectPanelDataModel;
38 38
import org.gvsig.raster.tools.app.basic.raster.gui.IGenericToolBarMenuItem;
39 39

  
40 40

  
......
120 120
			FLayer lyr = selectedItems[0];
121 121
			if (lyr instanceof FLyrRaster) {
122 122
				FileNameManagement fileNameManagement = new FileNameManagementImpl();
123
				ReprojectPanelDataModel dataModel = new ReprojectPanelDataModelImpl((FLyrRaster)lyr);
124
				RasterReprojectPanel reprojectPanel = AlgorithmSwingLocator.getSwingManager().createRasterReprojectPanel(fileNameManagement, dataModel);
123
				ReprojectionPanelDataModel dataModel = new ReprojectionPanelDataModelImpl((FLyrRaster)lyr);
124
				RasterReprojectionPanel reprojectPanel = RasterReprojectionSwingLocator.getSwingManager().createRasterReprojectPanel(fileNameManagement, dataModel);
125 125
				
126 126
				ReprojectWindow window = new ReprojectWindow(reprojectPanel.getComponent(), Messages.getText("reprojection"), 360, 460);
127 127
				listener = new ReprojectListener(lyr, dataModel, window, reprojectPanel);
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/src/main/java/org/gvsig/raster/reproject/app/ReprojectionPanelDataModelImpl.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.awt.geom.Point2D;
25
import java.util.ArrayList;
26
import java.util.List;
27

  
28
import org.cresques.cts.ICoordTrans;
29
import org.cresques.cts.IProjection;
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
33
import org.gvsig.fmap.crs.CRSFactory;
34
import org.gvsig.fmap.dal.coverage.RasterLocator;
35
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
36
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
37
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
38
import org.gvsig.fmap.mapcontext.MapContext;
39
import org.gvsig.fmap.mapcontext.layers.FLayers;
40
import org.gvsig.raster.fmap.layers.FLyrRaster;
41
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
42
import org.gvsig.raster.tools.algorithm.reproject.ReprojectProcess;
43

  
44
/**
45
 * Data model for the panel of reprojection
46
 * @author Nacho Brodin (nachobrodin@gmail.com)
47
 */
48
public class ReprojectionPanelDataModelImpl implements ReprojectionPanelDataModel {
49
	private double               cellSize                 = 0;
50
	private IProjection          dstProjection            = null;
51
	private IProjection          srcProjection            = null;
52
	private List<String>         interpolationMethodList  = null;
53
	private int                  interpolationMethod      = 0;
54
	private String               layerName                = null;
55
	private int[]                size                     = new int[]{0, 0};
56
	private FLyrRaster           lyr                      = null;
57
	private Extent               newBbox                  = null;
58
	
59
	public ReprojectionPanelDataModelImpl(FLyrRaster lyr) {
60
		this.lyr = lyr;
61
		cellSize = lyr.getDataStore().getCellSize();
62
		try {
63
			srcProjection = lyr.readProjection();
64
		} catch (RasterDriverException e) {
65
			srcProjection = getViewProjection(lyr);
66
		}
67
		if (srcProjection == null) 
68
			srcProjection = getViewProjection(lyr);
69
		if (srcProjection == null)
70
			srcProjection = CRSFactory.getCRS("EPSG:23030");
71

  
72
		dstProjection = srcProjection;
73
		
74
		layerName = lyr.getName();
75
		size = new int[]{(int)lyr.getDataStore().getWidth(), 
76
						 (int)lyr.getDataStore().getHeight()};
77
		
78
		interpolationMethod = -1;
79
		interpolationMethodList = new ArrayList<String>();
80
		for (int i = 0; i < ReprojectProcess.INTERP_METHODS.length; i++) {
81
			interpolationMethodList.add(ReprojectProcess.INTERP_METHODS[i]);
82
		}
83
		//updateValues(lyr.getDataStore());
84
	}
85
	
86
	/**
87
	 * Gets the projection of the view
88
	 * @param lyr
89
	 * @return
90
	 */
91
	private IProjection getViewProjection(FLyrRaster lyr) {
92
		IWindow[] w = PluginServices.getMDIManager().getAllWindows();
93
		for (int i = 0; i < w.length; i++) {
94
			if(w[i] instanceof AbstractViewPanel) {
95
				MapContext mapContext = ((AbstractViewPanel)w[i]).getMapControl().getMapContext();
96
				FLayers lyrs = mapContext.getLayers();
97
				for (int j = 0; j < lyrs.getLayersCount(); j++) {
98
					if(lyrs.getLayer(j) == lyr) {
99
						return ((AbstractViewPanel)w[i]).getProjection();
100
					}
101
				}
102
			}
103
		}
104
		return null;
105
	}
106
	
107
	private void updateValues(RasterDataStore store) {
108
		//      d1x                 d2x
109
		//   ---------           ---------
110
		//   |  p1x  |           |  p2x  |
111
		//d1y|p1y    |        d2y|p2y    |
112
		//   |       |           |       |
113
		//   ---------           ---------
114
		
115
		ICoordTrans transf = srcProjection.getCT(dstProjection);
116
		Extent bbox = store.getExtent();
117
		Point2D ul = new Point2D.Double(bbox.getULX(), bbox.getULY());
118
		Point2D lr = new Point2D.Double(bbox.getLRX(), bbox.getLRY());
119
		if(transf == null)
120
			return;
121
		ul = transf.convert(ul, ul);
122
		lr = transf.convert(lr, lr);
123
		newBbox = RasterLocator.getManager().getDataStructFactory().createExtent(ul, lr);
124
		
125
		//System.out.println("Old BBox: " + bbox.toString());
126
		//System.out.println("New BBox: " + newBbox.toString());
127
		//System.out.println("Old Pixel Size: " + store.getCellSize());
128
		
129
		//double p1x = store.getWidth();
130
		//double p1y = store.getHeight();
131
		//System.out.println("Old WxH: " + p1x + " " + p1y + " --- " + (p1x / p1y) + "  " + (p1y / p1x));
132
		
133
		//long nPixels = (long)(store.getWidth() * store.getHeight());
134
		double sumSideOldBBox = bbox.width() + bbox.height();
135
		double sumSideNewBBox = newBbox.width() + newBbox.height();
136
		double d1x = (bbox.width() * 100) / sumSideOldBBox; 
137
		double d1y = (bbox.height() * 100) / sumSideOldBBox;
138
		double d2x = (newBbox.width() * 100) / sumSideNewBBox;
139
		double d2y = (newBbox.height() * 100) / sumSideNewBBox;
140
		//System.out.println("Old nPixels: " + nPixels);
141
		//System.out.println("d1x: " + d1x + " d1y: " + d1y + " d2x: " + d2x + " d2y: " + d2y);
142
		double p2y = (store.getHeight() * d2y) / d1y;
143
		double p2x = (store.getWidth() * d2x) / d1x;
144
		//long newNPixels = (long)(p2x * p2y);
145
		//System.out.println("New nPixels: " + newNPixels);
146
		//System.out.println("New WxH: " + p2x + " " + p2y + " --- " + (p2x / p2y) + "  " + (p2y / p2x));
147
		double newCellSize = newBbox.width() / p2x;
148
		
149
		size[0] = (int)Math.round(p2x);
150
		size[1] = (int)Math.round(p2y);
151
		cellSize = newCellSize;
152
		//double newCellSizeY = newBbox.height() / p2y;
153
		//System.out.println("New Pixel Size: " + newCellSize + " " + newCellSizeY);
154
	}
155
	
156
	public double getCellSize() {
157
		return cellSize;
158
	}
159

  
160
	public IProjection getDstProjection() {
161
		return dstProjection;
162
	}
163

  
164
	public List<String> getInterpolationMethodList() {
165
		return interpolationMethodList;
166
	}
167

  
168
	public int getInterpolationMethodSelected() {
169
		return interpolationMethod;
170
	}
171

  
172
	public String getLayerName() {
173
		return layerName;
174
	}
175

  
176
	public int[] getSize() {
177
		return size;
178
	}
179

  
180
	public IProjection getSrcProjection() {
181
		return srcProjection;
182
	}
183

  
184
	public void setCellSize(double cellSize) {
185
		this.cellSize = cellSize;
186
		size[0] = (int)(newBbox.width() / cellSize);
187
		size[1] = (int)(newBbox.height() / cellSize);
188
	}
189

  
190
	public void setDstProjection(IProjection dst) {
191
		this.dstProjection = dst;
192
		updateValues(lyr.getDataStore());
193
	}
194
	
195
	public void setSrcProjection(IProjection src) {
196
		this.srcProjection = src;
197
		updateValues(lyr.getDataStore());
198
	}
199

  
200
	public void setInterpolationMethodList(List<String> list) {
201
		this.interpolationMethodList = list;
202
	}
203

  
204
	public void setInterpolationMethodSelected(int method) {
205
		this.interpolationMethod = method;
206
	}
207

  
208
	public void setLayerName(String layerName) {
209
		this.layerName = layerName;
210
	}
211

  
212
	public void setSize(int w, int h) {
213
		this.size = new int[]{w, h};
214
	}
215
}
0 216

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.app/org.gvsig.raster.reproject.app.reprojectclient/pom.xml
31 31
            <artifactId>org.gvsig.raster.reproject.algorithm</artifactId>
32 32
        </dependency>
33 33
        <dependency>
34
            <groupId>org.gvsig</groupId>
35
            <artifactId>org.gvsig.raster.tools.algorithm.swing.api</artifactId>
36
        </dependency>
37
        <dependency>
38
            <groupId>org.gvsig</groupId>
39
            <artifactId>org.gvsig.raster.tools.algorithm.swing.impl</artifactId>
40
        </dependency>
41
        <dependency>
42 34
			<groupId>org.gvsig</groupId>
43 35
			<artifactId>org.gvsig.raster.fmap</artifactId>
44 36
            <scope>compile</scope>
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/RasterReprojectAlgorithmLibrary.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
package org.gvsig.raster.reproject.algorithm;
25

  
26
import org.gvsig.i18n.Messages;
27
import org.gvsig.raster.tools.algorithm.base.RasterBaseAlgorithmLibrary;
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.LibraryException;
30

  
31
/**
32
 * Initialization of RasterReprojectAlgorithmLibrary library.
33
 * 
34
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
35
 */
36
public class RasterReprojectAlgorithmLibrary extends AbstractLibrary {
37
	public static final String         PROCESS_LABEL   = "RasterReprojectionProcess";
38
	
39
    @Override
40
    protected void doInitialize() throws LibraryException {
41
        // Nothing to do
42
    }
43

  
44
    @Override
45
    protected void doPostInitialize() throws LibraryException {
46
    	//Registers the process and its parameters
47
    	RasterBaseAlgorithmLibrary.register(PROCESS_LABEL, ReprojectProcess.class);
48
    	ReprojectProcess.registerParameters();
49
    	
50
        Messages.addResourceFamily(
51
            "org.gvsig.raster.tools.algorithm.reproject", 
52
            RasterReprojectAlgorithmLibrary.class.getClassLoader(), 
53
            RasterReprojectAlgorithmLibrary.class.getClass().getName());
54
        //registerGeoProcess(new RasterReprojectAlgorithmLibrary());
55
    }
56
}
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/InterpolationPanel.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.algorithm.swing.impl;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29

  
30
import javax.swing.BorderFactory;
31
import javax.swing.ButtonGroup;
32
import javax.swing.JComboBox;
33
import javax.swing.JPanel;
34
import javax.swing.JRadioButton;
35

  
36
import org.cresques.Messages;
37
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
38

  
39
/**
40
 * Panel para la reproyecci?n de capas cargadas.
41
 * 
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 */
44
public class InterpolationPanel extends JPanel implements ActionListener {
45
	private static final long      serialVersionUID      = 1;
46
	private ButtonGroup            group                 = null;
47
	private JRadioButton           radioNo               = null;
48
	private JRadioButton           radioYes              = null;
49
	private JComboBox              comboInterpMethods    = null;
50
	
51
	/**
52
	 * Constructor
53
	 * @throws RasterDriverException 
54
	 */
55
	public InterpolationPanel() {
56
		init();
57
	}
58
	
59
	/**
60
	 * Inicializaci?n de los componentes gr?ficos.
61
	 * @throws RasterDriverException 
62
	 */
63
	private void init() {
64
		group = new ButtonGroup();
65
		group.add(getRadioYes());
66
		group.add(getRadioNo());
67
		
68
		setBorder(BorderFactory.createTitledBorder(Messages.getText("interpolation")));
69
		
70
		GridBagConstraints gridBagConstraints;
71
		setLayout(new GridBagLayout());
72
		gridBagConstraints = new GridBagConstraints();
73
		gridBagConstraints.fill = GridBagConstraints.BOTH;
74
		gridBagConstraints.gridx = 0;
75
		gridBagConstraints.gridy = 0;
76
		gridBagConstraints.weightx = 1.0;
77
		gridBagConstraints.insets = new Insets(0, 5, 0, 5);
78
		
79
		add(getRadioNo(), gridBagConstraints);
80
		
81
		gridBagConstraints.gridy = 1;
82
		add(getRadioYes(), gridBagConstraints);
83
		
84
		gridBagConstraints.gridy = 2;
85
		gridBagConstraints.insets = new Insets(0, 25, 0, 5);
86
		add(getComboInterpolationMethod(), gridBagConstraints);
87
	}
88

  
89
	public JRadioButton getRadioYes() {
90
		if(radioYes == null) {
91
			radioYes = new JRadioButton(Messages.getText("yes"));
92
			radioYes.setSelected(false);
93
			radioYes.addActionListener(this);
94
		}
95
		return radioYes;
96
	}
97
	
98
	public JRadioButton getRadioNo() {
99
		if(radioNo == null) {
100
			radioNo = new JRadioButton(Messages.getText("no"));
101
			radioNo.setSelected(true);
102
			radioNo.addActionListener(this);
103
		}
104
		return radioNo;
105
	}
106
	
107
	public JComboBox getComboInterpolationMethod() {
108
		if(comboInterpMethods == null) {
109
			comboInterpMethods = new JComboBox();
110
			comboInterpMethods.setEnabled(false);
111
		}
112
		return comboInterpMethods;
113
	}
114

  
115
	public void actionPerformed(ActionEvent e) {
116
		if(e.getSource() == getRadioNo()) {
117
			getComboInterpolationMethod().setEnabled(false);
118
		}
119
		if(e.getSource() == getRadioYes()) {
120
			getComboInterpolationMethod().setEnabled(true);
121
		}
122
	}
123

  
124
}
0 125

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/OutputLayerOptionsPanel.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.algorithm.swing.impl;
23

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

  
28
import javax.swing.BorderFactory;
29
import javax.swing.JLabel;
30
import javax.swing.JPanel;
31
import javax.swing.JTextField;
32

  
33
import org.cresques.Messages;
34
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
35

  
36
/**
37
 * Panel para la reproyecci?n de capas cargadas.
38
 * 
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class OutputLayerOptionsPanel extends JPanel {
42
	private static final long      serialVersionUID     = 1;
43
	private JTextField             textFieldCellSize    = null;
44
	private JTextField             textFieldSizeX       = null;
45
	private JTextField             textFieldSizeY       = null;
46
	private JLabel                 labelSizeX           = null;
47
	private JLabel                 labelSizeY           = null;
48
	private JLabel                 labelCellSize        = null;
49
	
50
	/**
51
	 * Constructor
52
	 * @throws RasterDriverException 
53
	 */
54
	public OutputLayerOptionsPanel() {
55
		init();
56
	}
57
	
58
	/**
59
	 * Inicializaci?n de los componentes gr?ficos.
60
	 * @throws RasterDriverException 
61
	 */
62
	private void init() {
63
		setBorder(BorderFactory.createTitledBorder(Messages.getText("output_options")));
64
		
65
		GridBagConstraints gridBagConstraints;
66
		setLayout(new GridBagLayout());
67
		gridBagConstraints = new GridBagConstraints();
68
		gridBagConstraints.fill = GridBagConstraints.BOTH;
69
		gridBagConstraints.weightx = 1.0;
70
		gridBagConstraints.insets = new Insets(0, 5, 2, 5);
71
		
72
		//FILA 0
73
		gridBagConstraints.fill = GridBagConstraints.NONE;
74
		gridBagConstraints.weightx = 0;
75
		gridBagConstraints.gridx = 0;
76
		gridBagConstraints.gridy = 0;
77
		add(getLabelCellSize(), gridBagConstraints);
78
		
79
		gridBagConstraints.fill = GridBagConstraints.BOTH;
80
		gridBagConstraints.weightx = 1.0;
81
		gridBagConstraints.gridx = 1;
82
		gridBagConstraints.gridy = 0;
83
		gridBagConstraints.gridwidth = 3;
84
		add(getTextFieldCellSize(), gridBagConstraints);
85
		gridBagConstraints.gridwidth = 1;
86
		
87
		//FILA 1
88
		gridBagConstraints.fill = GridBagConstraints.NONE;
89
		gridBagConstraints.weightx = 0;
90
		gridBagConstraints.gridx = 0;
91
		gridBagConstraints.gridy = 1;
92
		add(getLabelSizeX(), gridBagConstraints);
93
		
94
		gridBagConstraints.fill = GridBagConstraints.BOTH;
95
		gridBagConstraints.weightx = 1.0;
96
		gridBagConstraints.gridx = 1;
97
		gridBagConstraints.gridy = 1;
98
		add(getTextFieldSizeX(), gridBagConstraints);
99
		
100
		gridBagConstraints.fill = GridBagConstraints.NONE;
101
		gridBagConstraints.weightx = 0;
102
		gridBagConstraints.gridx = 2;
103
		gridBagConstraints.gridy = 1;
104
		add(getLabelSizeY(), gridBagConstraints);
105
		
106
		gridBagConstraints.fill = GridBagConstraints.BOTH;
107
		gridBagConstraints.weightx = 1.0;
108
		gridBagConstraints.gridx = 3;
109
		gridBagConstraints.gridy = 1;
110
		add(getTextFieldSizeY(), gridBagConstraints);
111
	}
112
	
113
	public JTextField getTextFieldCellSize() {
114
		if(textFieldCellSize == null)
115
			textFieldCellSize = new JTextField();
116
		return textFieldCellSize;
117
	}
118

  
119
	public JTextField getTextFieldSizeX() {
120
		if(textFieldSizeX == null) {
121
			textFieldSizeX = new JTextField();
122
			textFieldSizeX.setEditable(false);
123
		}
124
		return textFieldSizeX;
125
	}
126

  
127
	public JTextField getTextFieldSizeY() {
128
		if(textFieldSizeY == null) {
129
			textFieldSizeY = new JTextField();
130
			textFieldSizeY.setEditable(false);
131
		}
132
		return textFieldSizeY;
133
	}
134

  
135
	public JLabel getLabelSizeX() {
136
		if(labelSizeX == null)
137
			labelSizeX = new JLabel(Messages.getText("sizex"));
138
		return labelSizeX;
139
	}
140

  
141
	public JLabel getLabelSizeY() {
142
		if(labelSizeY == null)
143
			labelSizeY = new JLabel(Messages.getText("sizey"));
144
		return labelSizeY;
145
	}
146

  
147
	public JLabel getLabelCellSize() {
148
		if(labelCellSize == null)
149
			labelCellSize = new JLabel(Messages.getText("cellsize"));
150
		return labelCellSize;
151
	}
152

  
153
}
0 154

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/DefaultRasterReprojectionSwingManager.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.algorithm.swing.impl;
23

  
24
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
25
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionSwingManager;
26
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
27
import org.gvsig.raster.swing.newlayer.FileNameManagement;
28

  
29
/**
30
 * Default implementation of the {@link RasterReprojectionSwingManager}.
31
 * 
32
 * @author gvSIG Team
33
 * @version $Id$
34
 */
35
public class DefaultRasterReprojectionSwingManager implements RasterReprojectionSwingManager {
36

  
37
	public RasterReprojectionPanel createRasterReprojectPanel(
38
			FileNameManagement fileNameManagement,
39
			ReprojectionPanelDataModel dataModel) {
40
		return new RasterReprojectionPanelImpl(fileNameManagement, dataModel);
41
	}
42

  
43
}
0 44

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/RasterReprojectionPanelImpl.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.algorithm.swing.impl;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.Insets;
28
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
30
import java.awt.event.KeyEvent;
31
import java.awt.event.KeyListener;
32
import java.util.List;
33

  
34
import javax.swing.BorderFactory;
35
import javax.swing.JComponent;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38

  
39
import org.gvsig.app.gui.panels.CRSSelectPanel;
40
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
41
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
42
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
43
import org.gvsig.i18n.Messages;
44
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
45
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
46
import org.gvsig.raster.swing.RasterSwingLocator;
47
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel;
48
import org.gvsig.raster.swing.newlayer.FileNameManagement;
49

  
50
/**
51
 * Panel para la reproyecci?n de capas cargadas.
52
 * 
53
 * @author Nacho Brodin (nachobrodin@gmail.com)
54
 */
55
public class RasterReprojectionPanelImpl extends DefaultButtonsPanel implements ActionListener, RasterReprojectionPanel, KeyListener {
56
	private static final long       serialVersionUID      = -1011688195806336071L;
57
	private CRSSelectPanel          projectionSrcSelector = null;
58
	private CRSSelectPanel          projectionDstSelector = null;
59
	private InterpolationPanel      interpolationPanel    = null;
60
	private OutputLayerOptionsPanel layerOptions          = null;
61
	private CreateNewLayerPanel     newLayerPanel         = null;
62
	private FileNameManagement      fileNameManagement    = null;
63
	private ReprojectionPanelDataModel dataModel             = null;
64
	private JLabel                  layerName             = null;
65

  
66
	/**
67
	 * Constructor
68
	 * @throws RasterDriverException 
69
	 */
70
	public RasterReprojectionPanelImpl(
71
			FileNameManagement fileNameManagement,
72
			ReprojectionPanelDataModel dataModel) {
73
		super(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
74
		this.fileNameManagement = fileNameManagement;
75
		this.dataModel = dataModel;
76
		init();
77
		loadPanelFromDataModel();
78
		getInterpolationPanel().getComboInterpolationMethod().addActionListener(this);
79
		getInterpolationPanel().getRadioYes().addActionListener(this);
80
		getInterpolationPanel().getRadioNo().addActionListener(this);
81
	}
82
	
83
	private void loadPanelFromDataModel() {
84
		getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
85
		getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + "");
86
		getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + "");
87
		getLayerName().setText("<html><b>" + dataModel.getLayerName() + "</b></html>");
88
		List<String> list = dataModel.getInterpolationMethodList();
89
		for (int i = 0; i < list.size(); i++) {
90
			getInterpolationPanel().getComboInterpolationMethod().addItem(list.get(i));	
91
		}
92
		
93
		if(dataModel.getInterpolationMethodSelected() < 0) {
94
			getInterpolationPanel().getRadioYes().setSelected(false);
95
			getInterpolationPanel().getRadioNo().setSelected(true);
96
		} else {
97
			getInterpolationPanel().getRadioYes().setSelected(true);
98
			getInterpolationPanel().getRadioNo().setSelected(false);
99
			getInterpolationPanel().getComboInterpolationMethod().setEnabled(true);
100
		}
101
	}
102
	
103
	/**
104
	 * Inicializaci?n de los componentes gr?ficos.
105
	 * @throws RasterDriverException 
106
	 */
107
	private void init() {
108
		GridBagConstraints gridBagConstraints;
109

  
110
		setLayout(new GridBagLayout());
111
		
112
		int posy = 0;
113
		
114
		gridBagConstraints = new GridBagConstraints();
115
		gridBagConstraints.fill = GridBagConstraints.BOTH;
116
		gridBagConstraints.gridx = 0;
117
		gridBagConstraints.gridy = posy;
118
		gridBagConstraints.weightx = 1.0;
119
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
120
		JPanel panelFile = new JPanel();
121
		panelFile.setLayout(new BorderLayout());
122
		panelFile.setBorder(BorderFactory.createTitledBorder(Messages.getText("origen")));
123
		panelFile.add(getLayerName(), BorderLayout.CENTER);
124
		add(panelFile, gridBagConstraints);
125
		
126
		posy++;
127
		gridBagConstraints = new GridBagConstraints();
128
		gridBagConstraints.fill = GridBagConstraints.BOTH;
129
		gridBagConstraints.gridx = 0;
130
		gridBagConstraints.gridy = posy;
131
		gridBagConstraints.weightx = 1.0;
132
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
133
		add(getProjectionSrcSelector(), gridBagConstraints);
134

  
135
		posy++;
136
		gridBagConstraints = new GridBagConstraints();
137
		gridBagConstraints.fill = GridBagConstraints.BOTH;
138
		gridBagConstraints.gridx = 0;
139
		gridBagConstraints.gridy = posy;
140
		gridBagConstraints.weightx = 1.0;
141
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
142
		add(getProjectionDstSelector(), gridBagConstraints);
143
		
144
		posy++;
145
		gridBagConstraints = new GridBagConstraints();
146
		gridBagConstraints.fill = GridBagConstraints.BOTH;
147
		gridBagConstraints.gridx = 0;
148
		gridBagConstraints.gridy = posy;
149
		gridBagConstraints.weightx = 1.0;
150
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
151
		add(getInterpolationPanel(), gridBagConstraints);
152
		
153
		posy++;
154
		gridBagConstraints = new GridBagConstraints();
155
		gridBagConstraints.fill = GridBagConstraints.BOTH;
156
		gridBagConstraints.gridx = 0;
157
		gridBagConstraints.gridy = posy;
158
		gridBagConstraints.weightx = 1.0;
159
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
160
		add(getLayerOptionsPanel(), gridBagConstraints);
161
		
162
		posy++;
163
		gridBagConstraints = new GridBagConstraints();
164
		gridBagConstraints.fill = GridBagConstraints.BOTH;
165
		gridBagConstraints.gridx = 0;
166
		gridBagConstraints.gridy = posy;
167
		gridBagConstraints.weightx = 1.0;
168
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
169
		add((JComponent)getCreateNewLayerPanel(), gridBagConstraints);
170

  
171
		// Insertamos un panel vacio
172
		posy++;
173
		gridBagConstraints = new GridBagConstraints();
174
		gridBagConstraints.gridx = 0;
175
		gridBagConstraints.gridy = posy;
176
		gridBagConstraints.weighty = 1.0;
177
		gridBagConstraints.insets = new Insets(0, 0, 0, 0);
178
		JPanel emptyPanel = new JPanel();
179
		add(emptyPanel, gridBagConstraints);
180
	}
181
	
182
	private JLabel getLayerName() {
183
		if(layerName == null)
184
			layerName = new JLabel();
185
		return layerName;
186
	}
187
	
188
	public CreateNewLayerPanel getCreateNewLayerPanel() {
189
		if(newLayerPanel == null) {
190
			newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(fileNameManagement);
191
			//newLayerPanel = new CreateNewLayerPanelImpl(fileNameManagement);
192
		}
193
		return newLayerPanel;
194
	}
195
	
196
	public InterpolationPanel getInterpolationPanel() {
197
		if(interpolationPanel == null) {
198
			interpolationPanel = new InterpolationPanel();
199
		}
200
		return interpolationPanel;
201
	}
202
	
203
	public OutputLayerOptionsPanel getLayerOptionsPanel() {
204
		if(layerOptions == null) {
205
			layerOptions = new OutputLayerOptionsPanel();
206
			layerOptions.getTextFieldCellSize().addKeyListener(this);
207
		}
208
		return layerOptions;
209
	}
210

  
211
	/**
212
	 * Obtiene el bot?n que lanza el panel de selecci?n de proyecciones.
213
	 * @return
214
	 * @throws RasterDriverException 
215
	 */
216
	private CRSSelectPanel getProjectionSrcSelector() {
217
		if (projectionSrcSelector == null) {
218
			projectionSrcSelector = CRSSelectPanel.getPanel(dataModel.getSrcProjection());
219
			projectionSrcSelector.setCurProj(dataModel.getSrcProjection());
220
			projectionSrcSelector.setTransPanelActive(true);
221
			projectionSrcSelector.setPreferredSize(null);
222
			projectionSrcSelector.addActionListener(new ActionListener() {
223
				public void actionPerformed(ActionEvent e) {
224
					if (projectionSrcSelector.isOkPressed()) {
225
						dataModel.setSrcProjection(projectionSrcSelector.getCurProj());
226
						try {
227
							updateSize();
228
							getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
229
						} catch (Exception exc) {
230
						}
231
					}
232
				}
233
			});
234
			projectionSrcSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("src_proj")));
235
		}
236
		return projectionSrcSelector;
237
	}
238
	
239
	/**
240
	 * Obtiene el bot?n que lanza el panel de selecci?n de proyecciones.
241
	 * @return
242
	 */
243
	private CRSSelectPanel getProjectionDstSelector() {
244
		if (projectionDstSelector == null) {
245
			projectionDstSelector = CRSSelectPanel.getPanel(dataModel.getDstProjection());
246
			projectionDstSelector.setCurProj(dataModel.getDstProjection());
247
			projectionDstSelector.setTransPanelActive(true);
248
			projectionDstSelector.setPreferredSize(null);
249
			projectionDstSelector.addActionListener(new ActionListener() {
250
				public void actionPerformed(ActionEvent e) {
251
					if (projectionDstSelector.isOkPressed()) {
252
						dataModel.setDstProjection(projectionDstSelector.getCurProj());
253
						try {
254
							updateSize();
255
							getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
256
						} catch (Exception exc) {
257
						}
258
					}
259
				}
260
			});
261
			projectionDstSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("dest_proj")));
262
		}
263
		return projectionDstSelector;
264
	}
265

  
266
	public void keyPressed(KeyEvent e) {
267
		// TODO Auto-generated method stub
268
		
269
	}
270

  
271
	public void keyReleased(KeyEvent e) {
272
		try {
273
			Double d = new Double(getLayerOptionsPanel().getTextFieldCellSize().getText());
274
			dataModel.setCellSize(d.doubleValue());
275
			updateSize();
276
		} catch (Exception exc) {
277
		}
278
	}
279

  
280
	private void updateSize() {
281
		getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + "");
282
		getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + "");
283
	}
284
	
285
	public void keyTyped(KeyEvent e) {
286
		
287
	}
288

  
289
	/*
290
	 * (non-Javadoc)
291
	 * @see org.gvsig.raster.tools.algorithm.swing.reproject.RasterReprojectPanel#addButtonsListener(java.awt.event.ActionListener)
292
	 */
293
	public void addButtonsListener(ActionListener listener) {
294
		getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(listener);
295
		getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(listener);
296
	}
297
	
298
	/*
299
	 * (non-Javadoc)
300
	 * @see org.gvsig.raster.tools.algorithm.swing.reproject.RasterReprojectPanel#getObjectSelected(java.lang.Object)
301
	 */
302
	public int getObjectSelected(Object obj) {
303
		if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT))
304
			return BUTTON_ACCEPT;
305
		if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL))
306
			return BUTTON_CANCEL;
307
		return -1;
308
	}
309
	
310
	/*
311
	 * (non-Javadoc)
312
	 * @see org.gvsig.raster.tools.algorithm.swing.reproject.RasterReprojectPanel#getComponent()
313
	 */
314
	public JComponent getComponent() {
315
		return this;
316
	}
317

  
318
	public String getFileSelected() {
319
		return getCreateNewLayerPanel().getFileSelected();
320
	}
321
	
322
	public String getDirectorySelected() {
323
		return getCreateNewLayerPanel().getDirectorySelected();
324
	}
325

  
326
	public void actionPerformed(ActionEvent e) {
327
		if(e.getSource() == getInterpolationPanel().getComboInterpolationMethod()) {
328
			dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex());
329
		}
330
		
331
		if(e.getSource() == getInterpolationPanel().getRadioYes()) {
332
			dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex());
333
		}
334
		
335
		if(e.getSource() == getInterpolationPanel().getRadioNo()) {
336
			dataModel.setInterpolationMethodSelected(-1);
337
		}
338
	}
339
}
0 340

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/ReprojectionPanelDataModel.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.algorithm.swing.api;
23

  
24
import java.util.List;
25

  
26
import org.cresques.cts.IProjection;
27

  
28
/**
29
 * Data model for the reprojection panel
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public interface ReprojectionPanelDataModel {
33
	public IProjection getSrcProjection();
34
	
35
	public IProjection getDstProjection();
36
	
37
	public void setSrcProjection(IProjection src);
38
	
39
	public void setDstProjection(IProjection dst);
40
	
41
	public double getCellSize();
42
	
43
	public void setCellSize(double cellSize);
44
	
45
	public void setSize(int w, int h);
46
	
47
	public int[] getSize();
48
	
49
	public List<String> getInterpolationMethodList();
50
	
51
	public void setInterpolationMethodList(List<String> list);
52
	
53
	public int getInterpolationMethodSelected();
54
	
55
	public void setInterpolationMethodSelected(int method);
56
	
57
	public String getLayerName();
58
	
59
	public void setLayerName(String layerName);
60
}
0 61

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/RasterReprojectionPanel.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.algorithm.swing.api;
23

  
24
import java.awt.event.ActionListener;
25

  
26
import javax.swing.JComponent;
27

  
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
29

  
30
/**
31
 * Panel to reproject raster layers.
32
 * 
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public interface RasterReprojectionPanel {
36
	public static final int           BUTTON_ACCEPT   = ButtonsPanel.BUTTON_ACCEPT;
37
	public static final int           BUTTON_CANCEL   = ButtonsPanel.BUTTON_CANCEL;
38
	
39
	/**
40
	 * Adds listener to buttons
41
	 * @param listener
42
	 */
43
	public void addButtonsListener(ActionListener listener);
44
	
45
	/**
46
	 * Returns the ID of the object selected. The IDs are defined as constants
47
	 * in this interface
48
	 * @param obj
49
	 * @return
50
	 */
51
	public int getObjectSelected(Object obj);
52
	
53
	public String getFileSelected();
54
	
55
	public String getDirectorySelected();
56
	
57
	public JComponent getComponent();
58
}
0 59

  
org.gvsig.raster.reproject/trunk/org.gvsig.raster.reproject/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/RasterReprojectionSwingManager.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.algorithm.swing.api;
23

  
24
import org.gvsig.raster.swing.newlayer.FileNameManagement;
25

  
26

  
27
/**
28
 * This class is responsible of the management of the library's swing user
29
 * interface. It is the swing library's main entry point, and provides all the
30
 * services to manage library swing components.
31
 * 
32
 * @see JValidationServicePanel
33
 * @author gvSIG team
34
 * @version $Id$
35
 */
36
public interface RasterReprojectionSwingManager {
37
	/**
38
	 * Creates a new panel to reproject a raster layer
39
	 * @param fileNameManagement
40
	 * @param dataModel
41
	 * @return
42
	 */
43
	public RasterReprojectionPanel createRasterReprojectPanel(
44
			FileNameManagement fileNameManagement,
45
			ReprojectionPanelDataModel dataModel);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff