Statistics
| Revision:

gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / geolocation / ui / GeoLocationOpeningRasterTransfPanel.java @ 2818

History | View | Annotate | Download (7.01 KB)

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.tools.app.basic.tool.geolocation.ui;
23

    
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.GridLayout;
27
import java.awt.geom.AffineTransform;
28

    
29
import javax.swing.JPanel;
30

    
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.fmap.dal.coverage.RasterLocator;
33
import org.gvsig.fmap.dal.coverage.util.MathUtils;
34
import org.gvsig.fmap.mapcontext.ViewPort;
35
import org.gvsig.gui.beans.datainput.DataInputContainer;
36
import org.gvsig.raster.fmap.layers.FLyrRaster;
37
import org.gvsig.raster.tools.app.basic.tool.geolocation.listener.GeoLocationPanelListener;
38

    
39

    
40
/**
41
 * Panel de geolocalizaci?n. Este muestra los par?metros de la matriz de transformaci?n
42
 * que est? aplicandose en esos momentos al raster. 
43
 * 
44
 * @version 12/12/2007
45
 * @author Nacho Brodin (nachobrodin@gmail.com)
46
 *
47
 */
48
public class GeoLocationOpeningRasterTransfPanel extends GeolocationBaseClassPanel {
49
        private static final long         serialVersionUID = -7797379892312214949L;
50
        private DataInputContainer               ulx = null;
51
        private DataInputContainer               uly = null;
52
        private DataInputContainer               psx = null;
53
        private DataInputContainer               psy = null;
54
        private DataInputContainer               rotx = null;
55
        private DataInputContainer               roty = null;
56
        
57
                
58
        private JPanel                                   coordsPanel = null;
59
        private JPanel                                   paramsPanel = null;
60
        
61
        /**
62
     * N?mero de decimales a mostrar
63
     */
64
    private int                        tailValue = 2;
65
        
66
        /**
67
         * Constructor
68
         */
69
        public GeoLocationOpeningRasterTransfPanel(GeoLocationPanelListener list) {
70
                this.listener = list;
71
                GridBagLayout gl = new GridBagLayout();
72
                this.setLayout(gl);
73
                setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "geolocation"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
74
                
75
                ulx = new DataInputContainer();
76
                ulx.setLabelText(PluginServices.getText(this,"ux"));
77
                ulx.addValueChangedListener(listener);
78
                ulx.addKeyListener(listener);
79
                
80
                uly = new DataInputContainer();
81
                uly.setLabelText(PluginServices.getText(this,"uy"));
82
                uly.addValueChangedListener(listener);
83
                uly.addKeyListener(listener);
84
                
85
                psx = new DataInputContainer();
86
                psx.setLabelText(PluginServices.getText(this,"px"));
87
                psx.addValueChangedListener(listener);
88
                psx.addKeyListener(listener);
89
                
90
                psy = new DataInputContainer();
91
                psy.setLabelText(PluginServices.getText(this,"py"));
92
                psy.addValueChangedListener(listener);
93
                psy.addKeyListener(listener);
94
                
95
                rotx = new DataInputContainer();
96
                rotx.setLabelText(PluginServices.getText(this,"rx"));
97
                rotx.addValueChangedListener(listener);
98
                rotx.addKeyListener(listener);
99
                
100
                roty = new DataInputContainer();
101
                roty.setLabelText(PluginServices.getText(this,"ry"));
102
                roty.addValueChangedListener(listener);
103
                roty.addKeyListener(listener);
104
                                
105
                coordsPanel = new JPanel();
106
                GridLayout l = new GridLayout(2, 1);
107
                l.setVgap(2);
108
                coordsPanel.setLayout(l);
109
                
110
                paramsPanel = new JPanel();
111
                GridLayout l1 = new GridLayout(2, 2);
112
                l1.setVgap(2);
113
                paramsPanel.setLayout(l1);
114

    
115
                init();
116
        }
117
        
118
        private void init() {
119
                coordsPanel.add(ulx);
120
                coordsPanel.add(uly);
121
                paramsPanel.add(psx);
122
                paramsPanel.add(psy);
123
                paramsPanel.add(rotx);
124
                paramsPanel.add(roty);
125
                                
126
                GridBagConstraints gbc = new GridBagConstraints();
127
                                
128
                gbc.fill = GridBagConstraints.HORIZONTAL;
129
                gbc.gridx = 0;
130
                gbc.gridy = 0;
131
                gbc.insets = new java.awt.Insets(1, 1, 1, 1);
132
                this.add(coordsPanel, gbc);
133
                
134
                gbc.gridy = 1;
135
                gbc.weightx = 1.0;
136
                this.add(paramsPanel, gbc);
137
                
138
        }
139
        
140
        /**
141
         * Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
142
         * del estado de la lista de transformaciones.
143
         * @return
144
         */
145
        public void activeButtons() {
146

    
147
        }
148
        
149
        /**
150
         * Asigna la capa raster del raster seleccionado en el TOC en base 
151
         * al cual se asigna la georreferenciaci?n al dialogo.
152
         * @param lyr
153
         */
154
        public void setParams(FLyrRaster lyr, ViewPort vp) {
155
                setLayer(lyr);
156
                setViewPort(vp);
157
                loadTransform(lyr.getAffineTransform());
158
        }
159

    
160
        /**
161
         * Carga los par?metros en el dialogo a partir de la capa
162
         * @param lyr Capa raster
163
         */
164
        public void loadTransform(AffineTransform at) {
165
                listener.setEnableValueChangeEvent(false);
166
                MathUtils math = RasterLocator.getManager().getMathUtils();
167
                setUlx(String.valueOf(math.format(at.getTranslateX(), tailValue)));
168
                setUly(String.valueOf(math.format(at.getTranslateY(), tailValue)));
169
                setPsx(String.valueOf(math.format(at.getScaleX(), tailValue)));
170
                setPsy(String.valueOf(math.format(at.getScaleY(), tailValue)));
171
                setRotx(String.valueOf(math.format(at.getShearX(), tailValue)));
172
                setRoty(String.valueOf(math.format(at.getShearY(), tailValue)));
173
                listener.setEnableValueChangeEvent(true);
174
        }
175
        
176
        /**
177
         * Asigna el tama?o de pixel en X
178
         * @param psx
179
         */
180
        public void setPsx(String psx) {
181
                this.psx.setValue(psx);
182
        }
183

    
184
        /**
185
         * Asigna el tama?o de pixel en Y
186
         * @param psy
187
         */
188
        public void setPsy(String psy) {
189
                this.psy.setValue(psy);
190
        }
191

    
192
        /**
193
         * Asigna la rotaci?n en X
194
         * @param rotx
195
         */
196
        public void setRotx(String rotx) {
197
                this.rotx.setValue(rotx);
198
        }
199

    
200
        /**
201
         * Asigna la rotaci?n en Y
202
         * @param roty
203
         */
204
        public void setRoty(String roty) {
205
                this.roty.setValue(roty);
206
        }
207

    
208
        /**
209
         * Asigna la coordenada superior izquierda
210
         * @param ulx 
211
         */
212
        public void setUlx(String ulx) {
213
                this.ulx.setValue(ulx);
214
        }
215

    
216
        /**
217
         * Asigna la coordenada superior derecha
218
         * @param ulx 
219
         */
220
        public void setUly(String uly) {
221
                this.uly.setValue(uly);
222
        }
223
        
224
        /**
225
         * Obtiene el tama?o de pixel en X
226
         * @return
227
         */
228
        public DataInputContainer getPsx() {
229
                return psx;
230
        }
231

    
232
        /**
233
         * Obtiene el tama?o de pixel en Y
234
         * @return
235
         */
236
        public DataInputContainer getPsy() {
237
                return psy;
238
        }
239

    
240
        /**
241
         * Obtiene la rotaci?n en X
242
         * @return
243
         */
244
        public DataInputContainer getRotx() {
245
                return rotx;
246
        }
247

    
248
        /**
249
         * Obtiene la rotaci?n en Y
250
         * @return
251
         */
252
        public DataInputContainer getRoty() {
253
                return roty;
254
        }
255

    
256
        /**
257
         * Obtiene la X de la coordenada superior izquierda
258
         * @return
259
         */
260
        public DataInputContainer getUlx() {
261
                return ulx;
262
        }
263

    
264
        /**
265
         * Obtiene la Y de la coordenada superior izquierda
266
         * @return
267
         */
268
        public DataInputContainer getUly() {
269
                return uly;
270
        }
271
        
272
}