Revision 15820
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/org.gvsig.raster.reproject.algorithm/src/test/org/gvsig/raster/algorithm/reproject/TestReprojectPanel.java | ||
---|---|---|
1 |
package org.gvsig.raster.algorithm.reproject; |
|
2 |
|
|
3 |
|
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.swing.JFrame; |
|
8 |
|
|
9 |
import org.cresques.cts.IProjection; |
|
10 |
import org.gvsig.raster.swing.newlayer.FileNameManagement; |
|
11 |
import org.gvsig.raster.reproject.algorithm.swing.impl.reproject.RasterReprojectPanelImpl; |
|
12 |
import org.gvsig.raster.reproject.algorithm.swing.reproject.ReprojectPanelDataModel; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
|
|
15 |
public class TestReprojectPanel implements FileNameManagement, ReprojectPanelDataModel { |
|
16 |
private int w = 360; |
|
17 |
private int h = 600; |
|
18 |
private JFrame frame = new JFrame(); |
|
19 |
private RasterReprojectPanelImpl ui = null; |
|
20 |
private int[] size = new int[]{1000, 1500}; |
|
21 |
|
|
22 |
public TestReprojectPanel() { |
|
23 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
24 |
ui = new RasterReprojectPanelImpl(this, this); |
|
25 |
frame.getContentPane().add(ui); |
|
26 |
frame.setSize(w, h); |
|
27 |
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
|
28 |
frame.setVisible(true); |
|
29 |
} |
|
30 |
|
|
31 |
public static void main(String[] args) { |
|
32 |
new TestReprojectPanel(); |
|
33 |
} |
|
34 |
|
|
35 |
public ArrayList<String> getPrefixSupported() { |
|
36 |
ArrayList<String> s = new ArrayList<String>(); |
|
37 |
s.add("tif"); |
|
38 |
s.add("ecw"); |
|
39 |
return s; |
|
40 |
} |
|
41 |
|
|
42 |
public String getUniqueLayerName() { |
|
43 |
return "capa uno"; |
|
44 |
} |
|
45 |
|
|
46 |
public void usesUniqueLayerName() { |
|
47 |
// TODO Auto-generated method stub |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
public String getDefaultFilePath() { |
|
52 |
return "/tmp/prueba.tif"; |
|
53 |
} |
|
54 |
|
|
55 |
public double getCellSize() { |
|
56 |
return 0.5; |
|
57 |
} |
|
58 |
|
|
59 |
public IProjection getDstProjection() { |
|
60 |
// TODO Auto-generated method stub |
|
61 |
return null; |
|
62 |
} |
|
63 |
|
|
64 |
public List<String> getInterpolationMethodList() { |
|
65 |
ArrayList<String> s = new ArrayList<String>(); |
|
66 |
s.add("interp1"); |
|
67 |
s.add("interp2"); |
|
68 |
return s; |
|
69 |
} |
|
70 |
|
|
71 |
public int getInterpolationMethodSelected() { |
|
72 |
return 1; |
|
73 |
} |
|
74 |
|
|
75 |
public String getLayerName() { |
|
76 |
return "My Layer"; |
|
77 |
} |
|
78 |
|
|
79 |
public int[] getSize() { |
|
80 |
return size; |
|
81 |
} |
|
82 |
|
|
83 |
public IProjection getSrcProjection() { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
public void setCellSize(double cellSize) { |
|
88 |
setSize((int)(cellSize * 100), (int)(cellSize * 200)); |
|
89 |
} |
|
90 |
|
|
91 |
public void setDstProjection(IProjection dst) { |
|
92 |
// TODO Auto-generated method stub |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
public void setInterpolationMethodList(List<String> list) { |
|
97 |
// TODO Auto-generated method stub |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
public void setInterpolationMethodSelected(int method) { |
|
102 |
// TODO Auto-generated method stub |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
public void setLayerName(String s) { |
|
107 |
// TODO Auto-generated method stub |
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
public void setSize(int w, int h) { |
|
112 |
size[0] = w; |
|
113 |
size[1] = h; |
|
114 |
} |
|
115 |
|
|
116 |
public void setSrcProjection(IProjection src) { |
|
117 |
// TODO Auto-generated method stub |
|
118 |
|
|
119 |
} |
|
120 |
} |
|
0 | 121 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/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.app.gui.panels.CRSSelectPanelFactory; |
|
41 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
42 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
43 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
|
44 |
import org.gvsig.i18n.Messages; |
|
45 |
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel; |
|
46 |
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel; |
|
47 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
48 |
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel; |
|
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 ReprojectionPanelDataModel dataModel = null; |
|
63 |
private JLabel layerName = null; |
|
64 |
|
|
65 |
/** |
|
66 |
* Constructor |
|
67 |
* @throws RasterDriverException |
|
68 |
*/ |
|
69 |
public RasterReprojectionPanelImpl( |
|
70 |
ReprojectionPanelDataModel dataModel) { |
|
71 |
super(ButtonsPanel.BUTTONS_ACCEPTCANCEL); |
|
72 |
this.dataModel = dataModel; |
|
73 |
init(); |
|
74 |
loadPanelFromDataModel(); |
|
75 |
getInterpolationPanel().getComboInterpolationMethod().addActionListener(this); |
|
76 |
getInterpolationPanel().getRadioYes().addActionListener(this); |
|
77 |
getInterpolationPanel().getRadioNo().addActionListener(this); |
|
78 |
} |
|
79 |
|
|
80 |
private void loadPanelFromDataModel() { |
|
81 |
getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + ""); |
|
82 |
getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + ""); |
|
83 |
getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + ""); |
|
84 |
getLayerName().setText("<html><b>" + dataModel.getLayerName() + "</b></html>"); |
|
85 |
List<String> list = dataModel.getInterpolationMethodList(); |
|
86 |
for (int i = 0; i < list.size(); i++) { |
|
87 |
getInterpolationPanel().getComboInterpolationMethod().addItem(list.get(i)); |
|
88 |
} |
|
89 |
|
|
90 |
if(dataModel.getInterpolationMethodSelected() < 0) { |
|
91 |
getInterpolationPanel().getRadioYes().setSelected(false); |
|
92 |
getInterpolationPanel().getRadioNo().setSelected(true); |
|
93 |
} else { |
|
94 |
getInterpolationPanel().getRadioYes().setSelected(true); |
|
95 |
getInterpolationPanel().getRadioNo().setSelected(false); |
|
96 |
getInterpolationPanel().getComboInterpolationMethod().setEnabled(true); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Inicializaci�n de los componentes gr�ficos. |
|
102 |
* @throws RasterDriverException |
|
103 |
*/ |
|
104 |
private void init() { |
|
105 |
GridBagConstraints gridBagConstraints; |
|
106 |
|
|
107 |
setLayout(new GridBagLayout()); |
|
108 |
|
|
109 |
int posy = 0; |
|
110 |
|
|
111 |
gridBagConstraints = new GridBagConstraints(); |
|
112 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
113 |
gridBagConstraints.gridx = 0; |
|
114 |
gridBagConstraints.gridy = posy; |
|
115 |
gridBagConstraints.weightx = 1.0; |
|
116 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
117 |
JPanel panelFile = new JPanel(); |
|
118 |
panelFile.setLayout(new BorderLayout()); |
|
119 |
panelFile.setBorder(BorderFactory.createTitledBorder(Messages.getText("origen"))); |
|
120 |
panelFile.add(getLayerName(), BorderLayout.CENTER); |
|
121 |
add(panelFile, gridBagConstraints); |
|
122 |
|
|
123 |
posy++; |
|
124 |
gridBagConstraints = new GridBagConstraints(); |
|
125 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
126 |
gridBagConstraints.gridx = 0; |
|
127 |
gridBagConstraints.gridy = posy; |
|
128 |
gridBagConstraints.weightx = 1.0; |
|
129 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
130 |
add(getProjectionSrcSelector(), gridBagConstraints); |
|
131 |
|
|
132 |
posy++; |
|
133 |
gridBagConstraints = new GridBagConstraints(); |
|
134 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
135 |
gridBagConstraints.gridx = 0; |
|
136 |
gridBagConstraints.gridy = posy; |
|
137 |
gridBagConstraints.weightx = 1.0; |
|
138 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
139 |
add(getProjectionDstSelector(), gridBagConstraints); |
|
140 |
|
|
141 |
posy++; |
|
142 |
gridBagConstraints = new GridBagConstraints(); |
|
143 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
144 |
gridBagConstraints.gridx = 0; |
|
145 |
gridBagConstraints.gridy = posy; |
|
146 |
gridBagConstraints.weightx = 1.0; |
|
147 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
148 |
add(getInterpolationPanel(), gridBagConstraints); |
|
149 |
|
|
150 |
posy++; |
|
151 |
gridBagConstraints = new GridBagConstraints(); |
|
152 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
153 |
gridBagConstraints.gridx = 0; |
|
154 |
gridBagConstraints.gridy = posy; |
|
155 |
gridBagConstraints.weightx = 1.0; |
|
156 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
157 |
add(getLayerOptionsPanel(), gridBagConstraints); |
|
158 |
|
|
159 |
posy++; |
|
160 |
gridBagConstraints = new GridBagConstraints(); |
|
161 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
162 |
gridBagConstraints.gridx = 0; |
|
163 |
gridBagConstraints.gridy = posy; |
|
164 |
gridBagConstraints.weightx = 1.0; |
|
165 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
166 |
add((JComponent)getCreateNewLayerPanel(), gridBagConstraints); |
|
167 |
|
|
168 |
// Insertamos un panel vacio |
|
169 |
posy++; |
|
170 |
gridBagConstraints = new GridBagConstraints(); |
|
171 |
gridBagConstraints.gridx = 0; |
|
172 |
gridBagConstraints.gridy = posy; |
|
173 |
gridBagConstraints.weighty = 1.0; |
|
174 |
gridBagConstraints.insets = new Insets(0, 0, 0, 0); |
|
175 |
JPanel emptyPanel = new JPanel(); |
|
176 |
add(emptyPanel, gridBagConstraints); |
|
177 |
} |
|
178 |
|
|
179 |
private JLabel getLayerName() { |
|
180 |
if(layerName == null) |
|
181 |
layerName = new JLabel(); |
|
182 |
return layerName; |
|
183 |
} |
|
184 |
|
|
185 |
public CreateNewLayerPanel getCreateNewLayerPanel() { |
|
186 |
if(newLayerPanel == null) { |
|
187 |
newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel(); |
|
188 |
//newLayerPanel = new CreateNewLayerPanelImpl(fileNameManagement); |
|
189 |
} |
|
190 |
return newLayerPanel; |
|
191 |
} |
|
192 |
|
|
193 |
public InterpolationPanel getInterpolationPanel() { |
|
194 |
if(interpolationPanel == null) { |
|
195 |
interpolationPanel = new InterpolationPanel(); |
|
196 |
} |
|
197 |
return interpolationPanel; |
|
198 |
} |
|
199 |
|
|
200 |
public OutputLayerOptionsPanel getLayerOptionsPanel() { |
|
201 |
if(layerOptions == null) { |
|
202 |
layerOptions = new OutputLayerOptionsPanel(); |
|
203 |
layerOptions.getTextFieldCellSize().addKeyListener(this); |
|
204 |
} |
|
205 |
return layerOptions; |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Obtiene el bot�n que lanza el panel de selecci�n de proyecciones. |
|
210 |
* @return |
|
211 |
* @throws RasterDriverException |
|
212 |
*/ |
|
213 |
private CRSSelectPanel getProjectionSrcSelector() { |
|
214 |
if (projectionSrcSelector == null) { |
|
215 |
projectionSrcSelector = CRSSelectPanelFactory.getPanel(dataModel.getSrcProjection()); |
|
216 |
projectionSrcSelector.setTransPanelActive(true); |
|
217 |
projectionSrcSelector.setPreferredSize(null); |
|
218 |
projectionSrcSelector.addActionListener(new ActionListener() { |
|
219 |
public void actionPerformed(ActionEvent e) { |
|
220 |
if (projectionSrcSelector.isOkPressed()) { |
|
221 |
dataModel.setSrcProjection(projectionSrcSelector.getCurProj()); |
|
222 |
try { |
|
223 |
updateSize(); |
|
224 |
getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + ""); |
|
225 |
} catch (Exception exc) { |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
}); |
|
230 |
projectionSrcSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("src_proj"))); |
|
231 |
} |
|
232 |
return projectionSrcSelector; |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Obtiene el bot�n que lanza el panel de selecci�n de proyecciones. |
|
237 |
* @return |
|
238 |
*/ |
|
239 |
private CRSSelectPanel getProjectionDstSelector() { |
|
240 |
if (projectionDstSelector == null) { |
|
241 |
projectionDstSelector = CRSSelectPanel.getPanel(dataModel.getDstProjection()); |
|
242 |
projectionDstSelector.setTransPanelActive(true); |
|
243 |
projectionDstSelector.setPreferredSize(null); |
|
244 |
projectionDstSelector.addActionListener(new ActionListener() { |
|
245 |
public void actionPerformed(ActionEvent e) { |
|
246 |
if (projectionDstSelector.isOkPressed()) { |
|
247 |
dataModel.setDstProjection(projectionDstSelector.getCurProj()); |
|
248 |
try { |
|
249 |
updateSize(); |
|
250 |
getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + ""); |
|
251 |
} catch (Exception exc) { |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
}); |
|
256 |
projectionDstSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("dest_proj"))); |
|
257 |
} |
|
258 |
return projectionDstSelector; |
|
259 |
} |
|
260 |
|
|
261 |
public void keyPressed(KeyEvent e) { |
|
262 |
|
|
263 |
} |
|
264 |
|
|
265 |
public void keyReleased(KeyEvent e) { |
|
266 |
try { |
|
267 |
Double d = new Double(getLayerOptionsPanel().getTextFieldCellSize().getText()); |
|
268 |
dataModel.setCellSize(d.doubleValue()); |
|
269 |
updateSize(); |
|
270 |
} catch (Exception exc) { |
|
271 |
} |
|
272 |
} |
|
273 |
|
|
274 |
private void updateSize() { |
|
275 |
getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + ""); |
|
276 |
getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + ""); |
|
277 |
} |
|
278 |
|
|
279 |
public void keyTyped(KeyEvent e) { |
|
280 |
|
|
281 |
} |
|
282 |
|
|
283 |
public void addButtonsListener(ActionListener listener) { |
|
284 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(listener); |
|
285 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(listener); |
|
286 |
} |
|
287 |
|
|
288 |
public int getObjectSelected(Object obj) { |
|
289 |
if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) |
|
290 |
return BUTTON_ACCEPT; |
|
291 |
if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) |
|
292 |
return BUTTON_CANCEL; |
|
293 |
return -1; |
|
294 |
} |
|
295 |
|
|
296 |
public JComponent getComponent() { |
|
297 |
return this; |
|
298 |
} |
|
299 |
|
|
300 |
public String getFileSelected() { |
|
301 |
return getCreateNewLayerPanel().getFileSelected(); |
|
302 |
} |
|
303 |
|
|
304 |
public String getDirectorySelected() { |
|
305 |
return getCreateNewLayerPanel().getDirectorySelected(); |
|
306 |
} |
|
307 |
|
|
308 |
public void actionPerformed(ActionEvent e) { |
|
309 |
if(e.getSource() == getInterpolationPanel().getComboInterpolationMethod()) { |
|
310 |
dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex()); |
|
311 |
} |
|
312 |
|
|
313 |
if(e.getSource() == getInterpolationPanel().getRadioYes()) { |
|
314 |
dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex()); |
|
315 |
} |
|
316 |
|
|
317 |
if(e.getSource() == getInterpolationPanel().getRadioNo()) { |
|
318 |
dataModel.setInterpolationMethodSelected(-1); |
|
319 |
} |
|
320 |
} |
|
321 |
} |
|
0 | 322 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/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/tags/org.gvsig.raster.reproject-2.2.156/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/tags/org.gvsig.raster.reproject-2.2.156/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 |
|
|
28 |
/** |
|
29 |
* Default implementation of the {@link RasterReprojectionSwingManager}. |
|
30 |
* |
|
31 |
* @author gvSIG Team |
|
32 |
* @version $Id$ |
|
33 |
*/ |
|
34 |
public class DefaultRasterReprojectionSwingManager implements RasterReprojectionSwingManager { |
|
35 |
|
|
36 |
public RasterReprojectionPanel createRasterReprojectPanel(ReprojectionPanelDataModel dataModel) { |
|
37 |
return new RasterReprojectionPanelImpl(dataModel); |
|
38 |
} |
|
39 |
|
|
40 |
} |
|
0 | 41 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/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/tags/org.gvsig.raster.reproject-2.2.156/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/tags/org.gvsig.raster.reproject-2.2.156/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 |
|
|
25 |
|
|
26 |
/** |
|
27 |
* This class is responsible of the management of the library's swing user |
|
28 |
* interface. It is the swing library's main entry point, and provides all the |
|
29 |
* services to manage library swing components. |
|
30 |
* |
|
31 |
* @see JValidationServicePanel |
|
32 |
* @author gvSIG team |
|
33 |
* @version $Id$ |
|
34 |
*/ |
|
35 |
public interface RasterReprojectionSwingManager { |
|
36 |
/** |
|
37 |
* Creates a new panel to reproject a raster layer |
|
38 |
* @param fileNameManagement |
|
39 |
* @param dataModel |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public RasterReprojectionPanel createRasterReprojectPanel( |
|
43 |
ReprojectionPanelDataModel dataModel); |
|
44 |
} |
|
0 | 45 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/ReprojectException.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; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* This exception is thrown if happen problems processing data with this algorithm. |
|
27 |
* |
|
28 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class ReprojectException extends Exception { |
|
32 |
private static final long serialVersionUID = -3022090543908771484L; |
|
33 |
|
|
34 |
public ReprojectException(String msg){ |
|
35 |
super(msg); |
|
36 |
} |
|
37 |
|
|
38 |
public ReprojectException(String msg, Throwable e){ |
|
39 |
super(msg, e); |
|
40 |
} |
|
41 |
} |
|
0 | 42 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/ReprojectProcess.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; |
|
23 |
|
|
24 |
import org.cresques.cts.IProjection; |
|
25 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
26 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
27 |
import org.gvsig.i18n.Messages; |
|
28 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
29 |
|
|
30 |
/** |
|
31 |
* Process to reproject layers. The size of the new image and the pixel size can |
|
32 |
* be passed by parameter. If some of these values are zero everyone are calculated |
|
33 |
* automatically |
|
34 |
* |
|
35 |
* 10/12/2007 |
|
36 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
37 |
*/ |
|
38 |
public class ReprojectProcess extends DataProcess { |
|
39 |
public static String[] INTERP_METHODS = new String[]{"Nearest", "Bilinear", "InverseDistance"}; |
|
40 |
|
|
41 |
public static String RASTER_STORE = "RasterStore"; |
|
42 |
public static String PATH = "Path"; |
|
43 |
public static String DST_PROJECTION = "DST_Projection"; |
|
44 |
public static String SRC_PROJECTION = "SRC_Projection"; |
|
45 |
public static String SIZEX = "SizeX"; |
|
46 |
public static String SIZEY = "SizeY"; |
|
47 |
public static String CELLSIZE = "CellSize"; |
|
48 |
public static String FILENAME = "FileName"; |
|
49 |
public static String INTERPOLATION = "Interpolation"; |
|
50 |
|
|
51 |
private RasterDataStore store = null; |
|
52 |
private String filename = null; |
|
53 |
private IProjection projdst = null; |
|
54 |
private IProjection projsrc = null; |
|
55 |
private Reproject reproject = null; |
|
56 |
private int w = 0; |
|
57 |
private int h = 0; |
|
58 |
private double cellSize = 0; |
|
59 |
private int interpolation = 0; |
|
60 |
|
|
61 |
public static void registerParameters() { |
|
62 |
registerInputParameter(RASTER_STORE, RasterDataStore.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
63 |
registerInputParameter(PATH, String.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
64 |
registerInputParameter(DST_PROJECTION, IProjection.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
65 |
registerInputParameter(SRC_PROJECTION, IProjection.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
66 |
registerInputParameter(SIZEX, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
67 |
registerInputParameter(SIZEY, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
68 |
registerInputParameter(CELLSIZE, Double.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
69 |
registerInputParameter(INTERPOLATION, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
70 |
|
|
71 |
registerOutputParameter(FILENAME, String.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); |
|
72 |
} |
|
73 |
|
|
74 |
public void init() { |
|
75 |
store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null; |
|
76 |
filename = getStringParam(PATH); |
|
77 |
projdst = getParam(DST_PROJECTION) != null ? (IProjection) getParam(DST_PROJECTION) : null; |
|
78 |
projsrc = getParam(SRC_PROJECTION) != null ? (IProjection) getParam(SRC_PROJECTION) : null; |
|
79 |
w = getIntParam(SIZEX); |
|
80 |
h = getIntParam(SIZEY); |
|
81 |
cellSize = getDoubleParam(CELLSIZE); |
|
82 |
interpolation = getIntParam(INTERPOLATION); |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* M?todo donde se ejecutar? el Thread, aqu? se reproyecta el raster. |
|
87 |
*/ |
|
88 |
public void process() throws ProcessInterruptedException { |
|
89 |
insertLineLog(Messages.getText("reprojecting")); |
|
90 |
|
|
91 |
store = store.newNotTiledDataStore(); |
|
92 |
|
|
93 |
reproject = new Reproject(store, filename, interpolation, this); |
|
94 |
try { |
|
95 |
int result = reproject.warp(projdst, projsrc, w, h, cellSize); |
|
96 |
if(result != 0) { |
|
97 |
if (incrementableTask != null) { |
|
98 |
incrementableTask.processFinalize(); |
|
99 |
setProgressActive(false); |
|
100 |
} |
|
101 |
messageBoxError("transformation_not_possible", this); |
|
102 |
return; |
|
103 |
} |
|
104 |
|
|
105 |
addOutputValue(FILENAME, filename); |
|
106 |
} catch (ReprojectException e) { |
|
107 |
if (incrementableTask != null) |
|
108 |
incrementableTask.processFinalize(); |
|
109 |
messageBoxError("error_reprojecting", this, e); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
public String getTitle() { |
|
114 |
return Messages.getText("reprojecting"); |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.156/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/Reproject.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; |
|
23 |
|
|
24 |
import java.awt.geom.Point2D; |
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.apache.commons.io.FileUtils; |
|
28 |
import org.apache.commons.io.FilenameUtils; |
|
29 |
import org.cresques.cts.ICRSFactory; |
|
30 |
import org.cresques.cts.ICoordTrans; |
|
31 |
import org.cresques.cts.IProjection; |
|
32 |
import org.slf4j.Logger; |
|
33 |
import org.slf4j.LoggerFactory; |
|
34 |
|
|
35 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
36 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
37 |
import org.gvsig.fmap.dal.coverage.dataset.BufferParam; |
|
38 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
39 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
40 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
41 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
43 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
44 |
import org.gvsig.raster.algorithm.process.DataProcess; |
|
45 |
import org.gvsig.raster.algorithm.util.Interpolation; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Reprojects a RasterDataStore. |
|
50 |
* |
|
51 |
* @version 30/04/2008 |
|
52 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
53 |
*/ |
|
54 |
public class Reproject { |
|
55 |
private RasterDataStore store = null; |
|
56 |
private String pathDest = null; |
|
57 |
private int interpolationMethod = 0; |
|
58 |
private Interpolation interpolation = null; |
|
59 |
private DataProcess process = null; |
|
60 |
|
|
61 |
private static final Logger logger = LoggerFactory.getLogger(Reproject.class); |
|
62 |
|
|
63 |
/** |
|
64 |
* Constructor de la clase. |
|
65 |
* @param store |
|
66 |
* @param lyr |
|
67 |
* @param pathDest Ruta de destino |
|
68 |
* @param inter |
|
69 |
* @param process |
|
70 |
*/ |
|
71 |
public Reproject(RasterDataStore store, String pathDest, int inter, DataProcess process) { |
|
72 |
this.store = store; |
|
73 |
this.pathDest = pathDest; |
|
74 |
this.interpolationMethod = inter; |
|
75 |
this.process = process; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* M?todo para la transformaci?n del raster. |
|
80 |
* @param destinationSrs Proyecci?n destino |
|
81 |
* @param sourceSrs |
|
82 |
* @param w |
|
83 |
* @param h |
|
84 |
* @param cellSize |
|
85 |
* @return |
|
86 |
* @throws ReprojectException |
|
87 |
*/ |
|
88 |
public int warp(IProjection destinationSrs, IProjection sourceSrs, int w, int h, double cellSize) throws ReprojectException { |
|
89 |
if (store == null) |
|
90 |
throw new ReprojectException("Capa no valida."); |
|
91 |
if (!store.isReproyectable()) |
|
92 |
throw new ReprojectException("Esta capa no se puede reproyectar."); |
|
93 |
if (destinationSrs == null || destinationSrs.getAbrev() == null) |
|
94 |
throw new ReprojectException("Proyecci?n de destino no valida."); |
|
95 |
|
|
96 |
|
|
97 |
File file = new File(pathDest); |
|
98 |
if (!file.getParentFile().canWrite()) |
|
99 |
throw new ReprojectException("Ruta de destino no valida."); |
|
100 |
|
|
101 |
ICoordTrans transf = sourceSrs.getCT(destinationSrs); |
|
102 |
Extent bbox = store.getExtent(); |
|
103 |
Point2D ul = new Point2D.Double(bbox.getULX(), bbox.getULY()); |
|
104 |
Point2D lr = new Point2D.Double(bbox.getLRX(), bbox.getLRY()); |
|
105 |
//Point2D p = new Point2D.Double(lyr.getFullRasterExtent().getULX(), lyr.getFullRasterExtent().getULY()); |
|
106 |
ul = transf.convert(ul, ul); |
|
107 |
lr = transf.convert(lr, lr); |
|
108 |
Extent newBbox = RasterLocator.getManager().getDataStructFactory().createExtent(ul, lr); |
|
109 |
|
|
110 |
if(w <= 0 || h <= 0 ) { |
|
111 |
double[] size = getSize(bbox, newBbox); |
|
112 |
w = (int)size[0]; |
|
113 |
h = (int)size[1]; |
|
114 |
cellSize = size[2]; |
|
115 |
} |
|
116 |
int dataType = store.getDataType()[0]; |
|
117 |
BufferParam params = RasterLocator.getManager().getBufferFactory().createBufferParams( |
|
118 |
w, h, store.getBandCount(), store.getDataType()[0], true); |
|
119 |
Buffer buf = null; |
|
120 |
try { |
|
121 |
buf = RasterLocator.getManager().getBufferFactory().createBuffer(params); |
|
122 |
} catch (Exception e1) { |
|
123 |
throw new ReprojectException("Error creating the output buffer", e1); |
|
124 |
} |
|
125 |
|
|
126 |
NoData nd = RasterLocator.getManager().getDataStructFactory().createDefaultNoData( |
|
127 |
store.getBandCount(), dataType); |
|
128 |
|
|
129 |
RasterQuery query = RasterLocator.getManager().createQuery(); |
|
130 |
query.setAllDrawableBands(); |
|
131 |
query.setAreaOfInterest(); |
|
132 |
query.setReadOnly(true); |
|
133 |
try { |
|
134 |
ICoordTrans t = destinationSrs.getCT(sourceSrs); |
|
135 |
Buffer sourceBuffer = store.query(query); |
|
136 |
if(interpolationMethod < 0) { |
|
137 |
for (int row = 0; row < buf.getHeight(); row++) { |
|
138 |
for (int col = 0; col < buf.getWidth(); col++) { |
|
139 |
Point2D p = transformPoint(newBbox, col, row, cellSize, t); |
|
140 |
writePixel(dataType, sourceBuffer, buf, p, col, row, nd); |
|
141 |
} |
|
142 |
process.updatePercent(row, buf.getHeight()); |
|
143 |
} |
|
144 |
} else { |
|
145 |
interpolation = new Interpolation(sourceBuffer); |
|
146 |
for (int row = 0; row < buf.getHeight(); row++) { |
|
147 |
for (int col = 0; col < buf.getWidth(); col++) { |
|
148 |
Point2D p = transformPoint(newBbox, col, row, cellSize, t); |
|
149 |
writePixelInterpolated(dataType, sourceBuffer, buf, p, col, row, nd, interpolationMethod); |
|
150 |
} |
|
151 |
process.updatePercent(row, buf.getHeight()); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
boolean exported = process.exportRaster(pathDest, buf, cellSize, newBbox.getULX(), newBbox.getULY()); |
|
156 |
if(exported){ |
|
157 |
savePrjFile(file, destinationSrs); |
|
158 |
} |
|
159 |
} catch (ProcessInterruptedException e) { |
|
160 |
} catch (QueryException e) { |
|
161 |
new ReprojectException("", e); |
|
162 |
} |
|
163 |
|
|
164 |
return 0; |
|
165 |
} |
|
166 |
|
|
167 |
private void savePrjFile(File dataFile, IProjection proj){ |
|
168 |
File file = new File(FilenameUtils.removeExtension(dataFile.getAbsolutePath())+".prj"); |
|
169 |
try { |
|
170 |
String export = proj.export(ICRSFactory.FORMAT_WKT_ESRI); |
|
171 |
if(export!=null){ |
|
172 |
FileUtils.writeStringToFile(file, export); |
|
173 |
} |
|
174 |
} catch (Exception e) { |
|
175 |
logger.info("Can't write prj file '" + file.getAbsolutePath() + "'."); |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Writes one pixel in the destination buffer |
|
181 |
* @param type |
|
182 |
* @param sourceBuffer |
|
183 |
* @param buf |
|
184 |
* @param p |
|
185 |
* @param col |
|
186 |
* @param row |
|
187 |
*/ |
|
188 |
private void writePixel(int type, Buffer sourceBuffer, Buffer buf, Point2D p, int col, int row, NoData nd) { |
|
189 |
if(type == Buffer.TYPE_BYTE) { |
|
190 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
191 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) { |
|
192 |
//if(iBand == 0) |
|
193 |
//System.out.println("Row:" + row + " Col:" + col + " Y:" + (int)p.getY() + " X:" + (int)p.getX()); |
|
194 |
buf.setElem(row, col, iBand, sourceBuffer.getElemByte((int)p.getY(), (int)p.getX(), iBand)); |
|
195 |
} |
|
196 |
else |
|
197 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
198 |
buf.setElem(row, col, iBand, nd.getValue().byteValue()); |
|
199 |
} else if(type == Buffer.TYPE_DOUBLE) { |
|
200 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
201 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
202 |
buf.setElem(row, col, iBand, sourceBuffer.getElemDouble((int)p.getY(), (int)p.getX(), iBand)); |
|
203 |
else |
|
204 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
205 |
buf.setElem(row, col, iBand, nd.getValue().doubleValue()); |
|
206 |
} else if(type == Buffer.TYPE_FLOAT) { |
|
207 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
208 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
209 |
buf.setElem(row, col, iBand, sourceBuffer.getElemFloat((int)p.getY(), (int)p.getX(), iBand)); |
|
210 |
else |
|
211 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
212 |
buf.setElem(row, col, iBand, nd.getValue().floatValue()); |
|
213 |
} else if(type == Buffer.TYPE_SHORT) { |
|
214 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
215 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
216 |
buf.setElem(row, col, iBand, sourceBuffer.getElemShort((int)p.getY(), (int)p.getX(), iBand)); |
|
217 |
else |
|
218 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
219 |
buf.setElem(row, col, iBand, nd.getValue().shortValue()); |
|
220 |
} else if(type == Buffer.TYPE_INT) { |
|
221 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
222 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
223 |
buf.setElem(row, col, iBand, sourceBuffer.getElemInt((int)p.getY(), (int)p.getX(), iBand)); |
|
224 |
else |
|
225 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) |
|
226 |
buf.setElem(row, col, iBand, nd.getValue().intValue()); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
/** |
|
231 |
* Writes one pixel in the destination buffer |
|
232 |
* @param type |
|
233 |
* @param sourceBuffer |
|
234 |
* @param buf |
|
235 |
* @param p |
|
236 |
* @param col |
|
237 |
* @param row |
|
238 |
*/ |
|
239 |
private void writePixelInterpolated(int type, Buffer sourceBuffer, Buffer buf, Point2D p, int col, int row, NoData nd, int interpMethod) { |
|
240 |
double value = 0; |
|
241 |
if(p.getX() > 0 && p.getX() < sourceBuffer.getWidth() && p.getY() > 0 && p.getY() < sourceBuffer.getHeight()) |
|
242 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) { |
|
243 |
if(interpMethod == 0) //Nearest neighbor |
|
244 |
value = interpolation.getNearestNeighbour(p.getX(), p.getY(), iBand); |
|
245 |
if(interpMethod == 1) //Bilinear |
|
246 |
value = interpolation.getBilinearValue(p.getX(), p.getY(), iBand); |
|
247 |
if(interpMethod == 2) //Inverse distance |
|
248 |
value = interpolation.getInverseDistance(p.getX(), p.getY(), iBand); |
|
249 |
if(type == Buffer.TYPE_BYTE) |
|
250 |
buf.setElem(row, col, iBand, (byte)value); |
|
251 |
else if(type == Buffer.TYPE_DOUBLE) |
|
252 |
buf.setElem(row, col, iBand, (double)value); |
|
253 |
else if(type == Buffer.TYPE_FLOAT) |
|
254 |
buf.setElem(row, col, iBand, (float)value); |
|
255 |
else if(type == Buffer.TYPE_SHORT) |
|
256 |
buf.setElem(row, col, iBand, (short)value); |
|
257 |
else if(type == Buffer.TYPE_INT) |
|
258 |
buf.setElem(row, col, iBand, (int)value); |
|
259 |
} |
|
260 |
else |
|
261 |
for (int iBand = 0; iBand < store.getBandCount(); iBand++) { |
|
262 |
if(type == Buffer.TYPE_BYTE) |
|
263 |
buf.setElem(row, col, iBand, nd.getValue().byteValue()); |
|
264 |
else if(type == Buffer.TYPE_DOUBLE) |
|
265 |
buf.setElem(row, col, iBand, nd.getValue().doubleValue()); |
|
266 |
else if(type == Buffer.TYPE_FLOAT) |
|
267 |
buf.setElem(row, col, iBand, nd.getValue().floatValue()); |
|
268 |
else if(type == Buffer.TYPE_SHORT) |
|
269 |
buf.setElem(row, col, iBand, nd.getValue().shortValue()); |
|
270 |
else if(type == Buffer.TYPE_INT) |
|
271 |
buf.setElem(row, col, iBand, nd.getValue().intValue()); |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
/** |
|
276 |
* Transforms the upper left coordinate of a pixel using the transformation |
|
277 |
* which is passed by parameter |
|
278 |
* @param p |
|
279 |
* @param newBbox |
|
280 |
* @param col |
|
281 |
* @param row |
|
282 |
* @param cellSize |
|
283 |
* @param t |
|
284 |
*/ |
|
285 |
private Point2D transformPoint(Extent newBbox, int col, int row, double cellSize, ICoordTrans t) { |
|
286 |
Point2D p = new Point2D.Double( |
|
287 |
newBbox.getULX() + (col * cellSize), |
|
288 |
newBbox.getULY() - (row * cellSize)); |
|
289 |
p = t.convert(p, p); |
|
290 |
p = store.worldToRaster(p); |
|
291 |
return p; |
|
292 |
} |
|
293 |
|
|
294 |
/** |
|
295 |
* Gets the size of the new image |
|
296 |
* @param bbox |
|
297 |
* @param newBbox |
|
298 |
* @return |
|
299 |
*/ |
|
300 |
private double[] getSize(Extent bbox, Extent newBbox) { |
|
301 |
double sumSideOldBBox = bbox.width() + bbox.height(); |
|
302 |
double sumSideNewBBox = newBbox.width() + newBbox.height(); |
|
303 |
double d1x = (bbox.width() * 100) / sumSideOldBBox; |
Also available in: Unified diff