root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / geolocation / ui / GeoLocationOpeningRasterTransfPanel.java @ 17503
History | View | Annotate | Download (6.91 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.GridBagConstraints; |
22 |
import java.awt.GridBagLayout; |
23 |
import java.awt.GridLayout; |
24 |
import java.awt.geom.AffineTransform; |
25 |
|
26 |
import javax.swing.JPanel; |
27 |
|
28 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
29 |
import org.gvsig.gui.beans.datainput.DataInputContainer; |
30 |
import org.gvsig.raster.util.MathUtils; |
31 |
import org.gvsig.rastertools.geolocation.listener.GeoLocationPanelListener; |
32 |
|
33 |
import com.iver.andami.PluginServices; |
34 |
import com.iver.cit.gvsig.fmap.ViewPort; |
35 |
|
36 |
/**
|
37 |
* Panel de geolocalizaci?n. Este muestra los par?metros de la matriz de transformaci?n
|
38 |
* que est? aplicandose en esos momentos al raster.
|
39 |
*
|
40 |
* @version 12/12/2007
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*
|
43 |
*/
|
44 |
public class GeoLocationOpeningRasterTransfPanel extends GeolocationBaseClassPanel { |
45 |
private static final long serialVersionUID = -7797379892312214949L; |
46 |
private DataInputContainer ulx = null; |
47 |
private DataInputContainer uly = null; |
48 |
private DataInputContainer psx = null; |
49 |
private DataInputContainer psy = null; |
50 |
private DataInputContainer rotx = null; |
51 |
private DataInputContainer roty = null; |
52 |
|
53 |
|
54 |
private JPanel coordsPanel = null; |
55 |
private JPanel paramsPanel = null; |
56 |
|
57 |
private GeoLocationPanelListener listener = null; |
58 |
|
59 |
/**
|
60 |
* N?mero de decimales a mostrar
|
61 |
*/
|
62 |
private int tailValue = 2; |
63 |
|
64 |
/**
|
65 |
* Constructor
|
66 |
*/
|
67 |
public GeoLocationOpeningRasterTransfPanel(GeoLocationPanelListener list) {
|
68 |
this.listener = list;
|
69 |
GridBagLayout gl = new GridBagLayout(); |
70 |
this.setLayout(gl);
|
71 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "geolocation"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
72 |
|
73 |
ulx = new DataInputContainer();
|
74 |
ulx.setLabelText(PluginServices.getText(this,"ux")); |
75 |
ulx.addValueChangedListener(listener); |
76 |
ulx.addKeyListener(listener); |
77 |
|
78 |
uly = new DataInputContainer();
|
79 |
uly.setLabelText(PluginServices.getText(this,"uy")); |
80 |
uly.addValueChangedListener(listener); |
81 |
uly.addKeyListener(listener); |
82 |
|
83 |
psx = new DataInputContainer();
|
84 |
psx.setLabelText(PluginServices.getText(this,"px")); |
85 |
psx.addValueChangedListener(listener); |
86 |
psx.addKeyListener(listener); |
87 |
|
88 |
psy = new DataInputContainer();
|
89 |
psy.setLabelText(PluginServices.getText(this,"py")); |
90 |
psy.addValueChangedListener(listener); |
91 |
psy.addKeyListener(listener); |
92 |
|
93 |
rotx = new DataInputContainer();
|
94 |
rotx.setLabelText(PluginServices.getText(this,"rx")); |
95 |
rotx.addValueChangedListener(listener); |
96 |
rotx.addKeyListener(listener); |
97 |
|
98 |
roty = new DataInputContainer();
|
99 |
roty.setLabelText(PluginServices.getText(this,"ry")); |
100 |
roty.addValueChangedListener(listener); |
101 |
roty.addKeyListener(listener); |
102 |
|
103 |
coordsPanel = new JPanel(); |
104 |
GridLayout l = new GridLayout(2, 1); |
105 |
l.setVgap(2);
|
106 |
coordsPanel.setLayout(l); |
107 |
|
108 |
paramsPanel = new JPanel(); |
109 |
GridLayout l1 = new GridLayout(2, 2); |
110 |
l1.setVgap(2);
|
111 |
paramsPanel.setLayout(l1); |
112 |
|
113 |
init(); |
114 |
} |
115 |
|
116 |
private void init() { |
117 |
coordsPanel.add(ulx); |
118 |
coordsPanel.add(uly); |
119 |
paramsPanel.add(psx); |
120 |
paramsPanel.add(psy); |
121 |
paramsPanel.add(rotx); |
122 |
paramsPanel.add(roty); |
123 |
|
124 |
GridBagConstraints gbc = new GridBagConstraints(); |
125 |
|
126 |
gbc.fill = GridBagConstraints.HORIZONTAL;
|
127 |
gbc.gridx = 0;
|
128 |
gbc.gridy = 0;
|
129 |
gbc.insets = new java.awt.Insets(1, 1, 1, 1); |
130 |
this.add(coordsPanel, gbc);
|
131 |
|
132 |
gbc.gridy = 1;
|
133 |
gbc.weightx = 1.0;
|
134 |
this.add(paramsPanel, gbc);
|
135 |
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
|
140 |
* del estado de la lista de transformaciones.
|
141 |
* @return
|
142 |
*/
|
143 |
public void activeButtons() { |
144 |
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* Asigna la capa raster del raster seleccionado en el TOC en base
|
149 |
* al cual se asigna la georreferenciaci?n al dialogo.
|
150 |
* @param lyr
|
151 |
*/
|
152 |
public void setParams(FLyrRasterSE lyr, ViewPort vp) { |
153 |
setLayer(lyr); |
154 |
setViewPort(vp); |
155 |
loadTransform(lyr.getAffineTransform()); |
156 |
} |
157 |
|
158 |
/**
|
159 |
* Carga los par?metros en el dialogo a partir de la capa
|
160 |
* @param lyr Capa raster
|
161 |
*/
|
162 |
public void loadTransform(AffineTransform at) { |
163 |
listener.setEnableValueChangeEvent(false);
|
164 |
setUlx(String.valueOf(MathUtils.format(at.getTranslateX(), tailValue)));
|
165 |
setUly(String.valueOf(MathUtils.format(at.getTranslateY(), tailValue)));
|
166 |
setPsx(String.valueOf(MathUtils.format(at.getScaleX(), tailValue)));
|
167 |
setPsy(String.valueOf(MathUtils.format(at.getScaleY(), tailValue)));
|
168 |
setRotx(String.valueOf(MathUtils.format(at.getShearX(), tailValue)));
|
169 |
setRoty(String.valueOf(MathUtils.format(at.getShearY(), tailValue)));
|
170 |
listener.setEnableValueChangeEvent(true);
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* Asigna el tama?o de pixel en X
|
175 |
* @param psx
|
176 |
*/
|
177 |
public void setPsx(String psx) { |
178 |
this.psx.setValue(psx);
|
179 |
} |
180 |
|
181 |
/**
|
182 |
* Asigna el tama?o de pixel en Y
|
183 |
* @param psy
|
184 |
*/
|
185 |
public void setPsy(String psy) { |
186 |
this.psy.setValue(psy);
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* Asigna la rotaci?n en X
|
191 |
* @param rotx
|
192 |
*/
|
193 |
public void setRotx(String rotx) { |
194 |
this.rotx.setValue(rotx);
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Asigna la rotaci?n en Y
|
199 |
* @param roty
|
200 |
*/
|
201 |
public void setRoty(String roty) { |
202 |
this.roty.setValue(roty);
|
203 |
} |
204 |
|
205 |
/**
|
206 |
* Asigna la coordenada superior izquierda
|
207 |
* @param ulx
|
208 |
*/
|
209 |
public void setUlx(String ulx) { |
210 |
this.ulx.setValue(ulx);
|
211 |
} |
212 |
|
213 |
/**
|
214 |
* Asigna la coordenada superior derecha
|
215 |
* @param ulx
|
216 |
*/
|
217 |
public void setUly(String uly) { |
218 |
this.uly.setValue(uly);
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* Obtiene el tama?o de pixel en X
|
223 |
* @return
|
224 |
*/
|
225 |
public DataInputContainer getPsx() {
|
226 |
return psx;
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* Obtiene el tama?o de pixel en Y
|
231 |
* @return
|
232 |
*/
|
233 |
public DataInputContainer getPsy() {
|
234 |
return psy;
|
235 |
} |
236 |
|
237 |
/**
|
238 |
* Obtiene la rotaci?n en X
|
239 |
* @return
|
240 |
*/
|
241 |
public DataInputContainer getRotx() {
|
242 |
return rotx;
|
243 |
} |
244 |
|
245 |
/**
|
246 |
* Obtiene la rotaci?n en Y
|
247 |
* @return
|
248 |
*/
|
249 |
public DataInputContainer getRoty() {
|
250 |
return roty;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* Obtiene la X de la coordenada superior izquierda
|
255 |
* @return
|
256 |
*/
|
257 |
public DataInputContainer getUlx() {
|
258 |
return ulx;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
* Obtiene la Y de la coordenada superior izquierda
|
263 |
* @return
|
264 |
*/
|
265 |
public DataInputContainer getUly() {
|
266 |
return uly;
|
267 |
} |
268 |
|
269 |
} |