root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / geolocation / listener / GeoLocationPanelListener.java @ 13328
History | View | Annotate | Download (3.71 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.geolocation.listener; |
20 |
|
21 |
import java.awt.event.ActionEvent; |
22 |
import java.awt.event.ActionListener; |
23 |
import java.awt.geom.AffineTransform; |
24 |
import java.io.IOException; |
25 |
|
26 |
import org.gvsig.raster.util.Historical; |
27 |
import org.gvsig.rastertools.RasterToolsUtil; |
28 |
import org.gvsig.rastertools.geolocation.ui.GeoLocationPanel; |
29 |
|
30 |
import com.iver.andami.PluginServices; |
31 |
|
32 |
/**
|
33 |
* Listener para el panel de geolocalizaci?n.
|
34 |
* @version 31/07/2007
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
36 |
*
|
37 |
*/
|
38 |
public class GeoLocationPanelListener implements ActionListener { |
39 |
|
40 |
private GeoLocationPanel panel = null; |
41 |
/**
|
42 |
* Crea un nuevo <code>GeoLocationPanelListener</code>
|
43 |
* @param panel
|
44 |
*/
|
45 |
public GeoLocationPanelListener(GeoLocationPanel panel) {
|
46 |
this.panel = panel;
|
47 |
} |
48 |
|
49 |
/**
|
50 |
* M?todo que se invoca cuando se disparan los eventos de los botones
|
51 |
*/
|
52 |
public void actionPerformed(ActionEvent e) { |
53 |
if(e.getSource() == panel.getSaveButton()) {
|
54 |
if(RasterToolsUtil.messageBoxYesOrNot(PluginServices.getText(this,"aviso_write_transform"), panel)) { |
55 |
try {
|
56 |
panel.getLayer().saveGeoToRmf(); |
57 |
panel.activeButtons(); |
58 |
} catch (IOException e1) { |
59 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this,"error_salvando_rmf"), panel); |
60 |
} |
61 |
panel.setModify(false);
|
62 |
} |
63 |
return;
|
64 |
} |
65 |
|
66 |
//Asignamos la georreferenciaci?n que hay en ese momento en el dialogo
|
67 |
if(e.getSource() == panel.getApplyButton()) {
|
68 |
try {
|
69 |
double ulx = Double.parseDouble(panel.getUlx().getValue()); |
70 |
double uly = Double.parseDouble(panel.getUly().getValue()); |
71 |
double psx = Double.parseDouble(panel.getPsx().getValue()); |
72 |
double psy = Double.parseDouble(panel.getPsy().getValue()); |
73 |
double rotx = Double.parseDouble(panel.getRotx().getValue()); |
74 |
double roty = Double.parseDouble(panel.getRoty().getValue()); |
75 |
AffineTransform at = new AffineTransform(psx, roty, rotx, psy, ulx, uly); |
76 |
panel.getLayer().setAffineTransform(at); |
77 |
panel.getMapCtrl().getMapContext().invalidate(); |
78 |
return;
|
79 |
} catch(NumberFormatException ex) { |
80 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this,"error_transformacion"), panel); |
81 |
return;
|
82 |
} |
83 |
} |
84 |
|
85 |
Historical hist = panel.getHistorical(); |
86 |
if(hist == null) |
87 |
return;
|
88 |
|
89 |
AffineTransform at = null; |
90 |
|
91 |
//Cargamos la primera transformaci?n
|
92 |
if(e.getSource() == panel.getFirstButton())
|
93 |
at = (AffineTransform)hist.getFirst();
|
94 |
|
95 |
//Cargamos la transformaci?n anterior
|
96 |
if(e.getSource() == panel.getBackButton())
|
97 |
at = (AffineTransform)hist.getBack();
|
98 |
|
99 |
////Cargamos la transformaci?n siguiente
|
100 |
if(e.getSource() == panel.getNextButton())
|
101 |
at = (AffineTransform)hist.getNext();
|
102 |
|
103 |
//Entrar? en el caso de que se haya seleccionado alguna transformaci?n
|
104 |
if(at != null) { |
105 |
panel.getLayer().setAT(at); |
106 |
panel.loadTransform(at); |
107 |
panel.activeButtons(); |
108 |
panel.getMapCtrl().getMapContext().invalidate(); |
109 |
} |
110 |
} |
111 |
} |