root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / geolocation / ui / GeoLocationOpeningRasterDialog.java @ 24986
History | View | Annotate | Download (4.95 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.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.geom.AffineTransform; |
23 |
|
24 |
import javax.swing.JPanel; |
25 |
|
26 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
27 |
import org.gvsig.raster.dataset.serializer.RmfSerializerException; |
28 |
import org.gvsig.raster.util.RasterToolsUtil; |
29 |
import org.gvsig.rastertools.geolocation.behavior.ITransformIO; |
30 |
|
31 |
import com.iver.andami.PluginServices; |
32 |
import com.iver.andami.ui.mdiManager.IWindow; |
33 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
34 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
35 |
import com.iver.cit.gvsig.fmap.MapControl; |
36 |
|
37 |
/**
|
38 |
* Dialogo de geolocalizaci?n de raster. Este es el que se usa para georreferenciar cuando
|
39 |
* se abre una imagen que no tiene georreferenciaci?n asociada, si el usuario as? lo solicita.
|
40 |
*
|
41 |
* @version 12/12/2007
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*
|
44 |
*/
|
45 |
public class GeoLocationOpeningRasterDialog extends JPanel implements IWindow, IWindowListener, ITransformIO { |
46 |
private static final long serialVersionUID = 7362459094802955247L; |
47 |
private GeoLocationOpeningRasterPanel geolocationPanel = null; |
48 |
|
49 |
private int widthWindow = 260; |
50 |
private int heightWindow = 165; |
51 |
|
52 |
/**
|
53 |
* Constructor
|
54 |
*/
|
55 |
public GeoLocationOpeningRasterDialog() {
|
56 |
BorderLayout bl = new BorderLayout(5, 5); |
57 |
this.setLayout(bl);
|
58 |
|
59 |
this.add(getGeoLocationPanel());
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* Constructor. Asigna la capa raster.
|
64 |
*
|
65 |
*/
|
66 |
public GeoLocationOpeningRasterDialog(FLyrRasterSE lyr) {
|
67 |
BorderLayout bl = new BorderLayout(5, 5); |
68 |
this.setLayout(bl);
|
69 |
|
70 |
this.add(getGeoLocationPanel());
|
71 |
getGeoLocationPanel().setParams(lyr); |
72 |
} |
73 |
|
74 |
/**
|
75 |
* Acciones de inicializaci?n
|
76 |
*
|
77 |
*/
|
78 |
public void init(MapControl mapCtrl) { |
79 |
geolocationPanel.setMapCtrl(mapCtrl); |
80 |
FLyrRasterSE lyr = getGeoLocationPanel().getLayer(); |
81 |
if(lyr != null) { |
82 |
lyr.getAffineTransformHistorical().clear(); |
83 |
lyr.getAffineTransformHistorical().add(lyr.getAffineTransform()); |
84 |
loadTransform(lyr.getAffineTransform()); |
85 |
} |
86 |
activeButtons(); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Carga los par?metros en el dialogo a partir de la capa
|
91 |
* @param lyr Capa raster
|
92 |
*/
|
93 |
public void loadTransform(AffineTransform at) { |
94 |
geolocationPanel.loadTransform(at); |
95 |
} |
96 |
|
97 |
/**
|
98 |
* Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
|
99 |
* del estado de la lista de transformaciones.
|
100 |
* @return
|
101 |
*/
|
102 |
public void applyTransformation() { |
103 |
geolocationPanel.setModify(true);
|
104 |
geolocationPanel.activeButtons(); |
105 |
} |
106 |
/**
|
107 |
* Obtiene el panel con el histograma
|
108 |
* @return HistogramPanel
|
109 |
*/
|
110 |
public GeoLocationOpeningRasterPanel getGeoLocationPanel(){
|
111 |
if (geolocationPanel == null) |
112 |
geolocationPanel = new GeoLocationOpeningRasterPanel(this); |
113 |
|
114 |
return geolocationPanel;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
|
119 |
* del estado de la lista de transformaciones.
|
120 |
* @return
|
121 |
*/
|
122 |
public void activeButtons() { |
123 |
getGeoLocationPanel().activeButtons(); |
124 |
} |
125 |
|
126 |
/*
|
127 |
* (non-Javadoc)
|
128 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
129 |
*/
|
130 |
public WindowInfo getWindowInfo() {
|
131 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
132 |
m_viewinfo.setHeight(heightWindow); |
133 |
m_viewinfo.setWidth(widthWindow); |
134 |
/*m_viewinfo.setX(posWindowX);
|
135 |
m_viewinfo.setY(posWindowY);*/
|
136 |
return m_viewinfo;
|
137 |
} |
138 |
|
139 |
/*
|
140 |
* (non-Javadoc)
|
141 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowActivated()
|
142 |
*/
|
143 |
public void windowActivated() { |
144 |
} |
145 |
|
146 |
/*
|
147 |
* (non-Javadoc)
|
148 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
149 |
*/
|
150 |
public void windowClosed() { |
151 |
//Se consulta si se desean salvar los cambios
|
152 |
if(geolocationPanel.getModify()) {
|
153 |
if(RasterToolsUtil.messageBoxYesOrNot(PluginServices.getText(this,"aviso_salir_salvando"), geolocationPanel)) { |
154 |
try {
|
155 |
geolocationPanel.getLayer().saveGeoToRmf(); |
156 |
} catch (RmfSerializerException e1) {
|
157 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this,"error_salvando_rmf"), geolocationPanel, e1); |
158 |
} |
159 |
} |
160 |
geolocationPanel.setModify(false);
|
161 |
} |
162 |
} |
163 |
|
164 |
public Object getWindowProfile() { |
165 |
return WindowInfo.DIALOG_PROFILE;
|
166 |
} |
167 |
} |