Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / gui / dialogs / GeoreferencingDialog.java @ 5491

History | View | Annotate | Download (39.1 KB)

1
package org.gvsig.georeferencing.gui.dialogs;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.Component;
5
import java.awt.Dimension;
6
import java.awt.FlowLayout;
7
import java.awt.event.ActionListener;
8
import java.awt.event.ComponentEvent;
9
import java.awt.event.ComponentListener;
10
import java.awt.geom.Point2D;
11
import java.awt.geom.Rectangle2D;
12
import java.beans.PropertyVetoException;
13
import java.io.File;
14

    
15
import javax.swing.JButton;
16
import javax.swing.JCheckBox;
17
import javax.swing.JFileChooser;
18
import javax.swing.JInternalFrame;
19
import javax.swing.JOptionPane;
20
import javax.swing.JPanel;
21
import javax.swing.filechooser.FileFilter;
22
import javax.swing.table.DefaultTableModel;
23

    
24
import org.cresques.cts.IProjection;
25
import org.cresques.px.Extent;
26
import org.gvsig.georeferencing.GeoOperations;
27
import org.gvsig.georeferencing.gui.listeners.GeoRasterFrameListener;
28
import org.gvsig.georeferencing.gui.listeners.GeorefMovePointListener;
29
import org.gvsig.georeferencing.gui.listeners.GeorefPanListener;
30
import org.gvsig.georeferencing.gui.listeners.GeorefPointSelectorListener;
31
import org.gvsig.georeferencing.gui.listeners.ZoomGeorefListener;
32
import org.gvsig.georeferencing.gui.panels.ConectorPanel;
33
import org.gvsig.georeferencing.gui.panels.OptionsPanel;
34
import org.gvsig.georeferencing.gui.panels.ZoomControlPanel;
35
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel;
36
import org.gvsig.georeferencing.gui.pointsTable.TablePointsPanel.PointTable;
37
import org.gvsig.georeferencing.gui.selectPoints.SelectPointsPanel;
38
import org.gvsig.georeferencing.toc.GeoRasterTocMenuEntry;
39
import org.gvsig.georeferencing.utils.GeoLayerFactory;
40
import org.gvsig.georeferencing.utils.GeoPointPersistence;
41
import org.gvsig.georeferencing.utils.MathUtils;
42
import org.gvsig.georeferencing.utils.PointManager;
43
import org.gvsig.georeferencing.utils.StackZoom;
44

    
45
import com.iver.andami.PluginServices;
46
import com.iver.cit.gvsig.fmap.DriverException;
47
import com.iver.cit.gvsig.fmap.MapControl;
48
import com.iver.cit.gvsig.fmap.ViewPort;
49
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
50
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
51
import com.iver.cit.gvsig.fmap.layers.FLayers;
52
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster;
53
import com.iver.cit.gvsig.fmap.layers.FLyrPoints;
54
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
55
import com.iver.cit.gvsig.fmap.layers.GeoPoint;
56
import com.iver.cit.gvsig.fmap.layers.IGeoUi;
57
import com.iver.cit.gvsig.fmap.layers.RasterAdapter;
58
import com.iver.cit.gvsig.fmap.layers.RasterFileAdapter;
59
import com.iver.cit.gvsig.fmap.tools.ZoomOutRightButtonListener;
60
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
61
import com.iver.cit.gvsig.fmap.tools.Behavior.DraggedBehavior;
62
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoMoveBehavior;
63
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoRedimBehavior;
64
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
65
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior;
66
import com.iver.cit.gvsig.gui.View;
67
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
68
import com.iver.cit.gvsig.gui.wizards.WizardListener;
69
import com.iver.cit.gvsig.project.Project;
70

    
71
/**
72
 * Panel que contiene el Wizard de georeferenciaci?n con los tabs
73
 * interiores
74
 *
75
 * @author Nacho Brodin (brodin_ign@gva.es)
76
 */
77
public class GeoreferencingDialog extends JPanel implements IGeoUi, ActionListener, ComponentListener {
78
        
79
        //**********************Vars**********************************
80
        static private IProjection                         proj = Project.getProjection();
81
        private JPanel                                                 pBotones = null;  //  @jve:decl-index=0:
82
        private JButton                                         bProcesar = null;  //  @jve:decl-index=0:
83
        private JButton                                         bCancelar = null;  //  @jve:decl-index=0:
84
        private WizardListener                                 wizardListener = new DialogWizardListener();
85
        private JButton                                         bLoadPoints = null;  //  @jve:decl-index=0:
86
        private GeoRedimBehavior                         rb = null;
87
        private GeoMoveBehavior                         mb = null;
88
        private boolean                                         loadTools = false;
89
        private JInternalFrame                                 frame = null;
90
        /**
91
         * Lista de formatos soportados
92
         */
93
        private String[]                                         fileFilters = {"csv"};
94
        /**
95
         * Recuerda la ?ltima ruta seleccionada por el usuario
96
         */
97
        private String                                                 lastPathLoad = "./";
98
        private String                                                 lastPathSave = "./";
99
        private ConectorPanel                                conectorPanel = null;
100
        
101
        private boolean                                         enlarge = false;
102
        private int                                                 normalWidth = 400;
103
        private int                                                 normalHeight = 273;
104
        private int                                                 enlargeHeight = 438;
105
        private int                                                 tmpWidth = normalWidth;
106
        
107
        private JButton                                         bAceptar = null;
108
        
109
        private JButton                                         bSavePoints = null;
110
        private FLyrGeoRaster                                 lyrGeoRaster = null;
111
        private TablePointsPanel                         tablePointsPanel = null;
112
        private        PointManager                                pointManager = null;
113
        /**
114
         * True si ha de crearse un fichero de georreferenciaci?n
115
         */
116
        private boolean                                         createWorldFile = false;
117
        /**
118
         * True si los errores han de incluirse en el fichero csv
119
         */
120
        private boolean                                         errorCSV = true;
121
        /**
122
         * Estado de los botones cuando se ejecuta disableAllControls
123
         */
124
        private boolean[]                                         buttonsState = new boolean[3];
125
        /**
126
         * DisableAllControls ha sido ejecutada si est? a true esta variabled
127
         */
128
        private boolean                                         disableAllControls = false;
129
        //**********************End Vars******************************        
130
        
131
        //**********************Classes*******************************
132
        /**
133
         * Filtro para selecci?n de ficheros.
134
         * @author Nacho Brodin (brodin_ign@gva.es)
135
         */
136
        class SelectFileFilter extends javax.swing.filechooser.FileFilter {
137
                
138
                private JFileChooser chooser = null;
139
                private String file = null;
140
                
141
                public SelectFileFilter(JFileChooser ch, String file){
142
                        this.chooser = ch;
143
                        this.file = file;
144
                }
145
                
146
            public boolean accept(File f) {
147

    
148
                    return f.isDirectory() || f.getName().toLowerCase().endsWith("."+file);
149
            }
150
            
151
            public String getDescription() {
152
                    return file;
153
            }
154
            
155
        }
156
        
157
        /**
158
         * @author Nacho Brodin (brodin_ign@gva.es)
159
         */
160
        public class DialogWizardListener implements WizardListener {
161

    
162
                /**
163
                 * @see org.gvsig.georeferencing.gui.wms.WizardListener#error(java.lang.Exception)
164
                 */
165
                public void error(Exception e) {
166
                }
167

    
168
                /**
169
                 * @see org.gvsig.georeferencing.gui.wms.WizardListener#wizardStateChanged(boolean)
170
                 */
171
                public void wizardStateChanged(boolean finishable) {
172
                        getBProcess().setEnabled(finishable);
173
                }
174
                
175
        }
176
        //**********************End Classes***************************
177
        
178
        //**********************Methods*******************************
179
    /**
180
     * Constructor.
181
     */
182
    public GeoreferencingDialog(JInternalFrame f, FLyrGeoRaster lyr) {
183
            frame = f;
184
            lyrGeoRaster = lyr;
185
            
186
            frame.addComponentListener(this);
187
            initialize();
188
            
189
            //Creamos el pointManager y lo asignamos a la capa de puntos
190
            pointManager = new PointManager(this, lyrGeoRaster.getFLyrPoints());
191
            this.lyrGeoRaster.getFLyrPoints().setPointManager(pointManager);
192
            
193
            //En estos casos entra cuando la capa se crea al abrir un proyecto
194
            if(lyrGeoRaster.getPersistence() == null){
195
                    lyrGeoRaster.setPersistence(new GeoPointPersistence(lyrGeoRaster.getFLyrPoints()));
196
                    f.addInternalFrameListener(new GeoRasterFrameListener());
197
                    GeoRasterTocMenuEntry.isOpen = true;
198
            }
199
            if(lyrGeoRaster.getStackZoom() == null)
200
                    lyrGeoRaster.setZoom(new StackZoom());
201
                    
202
    }
203
      
204
    /**
205
     * En la inicializaci?n de la ventana a?adimos los tags de est? y cargamos 
206
     * ls herramientas para manejar las imagenes a georeferenciar.
207
     */
208
    private void initialize() {
209
            //Cargamos las herramientas la primera vez que abrimos la ventana
210
        if(!loadTools){
211
                com.iver.cit.gvsig.gui.View  vista = null;
212
                        try{
213
                                vista = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
214
                        }catch(ClassCastException exc){
215
                                return;
216
                        }
217
                        
218
                        MapControl mapCtrl = null;
219
                        if(vista != null)
220
                                mapCtrl = vista.getMapControl();
221

    
222
                if(mapCtrl != null){
223
                        loadTools = true;
224
                                StatusBarListener sbl = new StatusBarListener(mapCtrl);
225
                                
226
                                ZoomOutRightButtonListener zoil = new ZoomOutRightButtonListener(mapCtrl);
227
                                ZoomGeorefListener zigl = new ZoomGeorefListener(mapCtrl);
228
                                rb = new GeoRedimBehavior(zigl);
229
                                mapCtrl.addMapTool("geoZoom", new Behavior[]{rb,
230
                                                        new PointBehavior(zoil), new MouseMovementBehavior(sbl)});
231
                                                                
232
                                GeorefPanListener pl = new GeorefPanListener(mapCtrl);
233
                                mb = new GeoMoveBehavior(pl);
234
                                mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)});
235
                                
236
                                //Seleccion de un punto sobre la vista
237
                        GeorefPointSelectorListener psl = new GeorefPointSelectorListener(this);
238
                        mapCtrl.addMapTool("pointLyrSelection", new Behavior[]{new PointBehavior(psl), new MouseMovementBehavior(sbl)});
239
                        
240
                        GeorefMovePointListener mpl = new GeorefMovePointListener(this);
241
                        mapCtrl.addMapTool("geoMovePoint", new Behavior[]{new DraggedBehavior(mpl), new MouseMovementBehavior(sbl)});
242
                }
243
        }
244
        
245
        this.setLayout(new BorderLayout());
246
        if(!enlarge){
247
                this.setPreferredSize(new java.awt.Dimension(normalWidth, normalHeight));
248
                this.setSize(new java.awt.Dimension(400,273));
249
                this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(false);
250
                this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(false);
251
        }else{
252
                this.setPreferredSize(new java.awt.Dimension(normalWidth, enlargeHeight));
253
                this.setSize(new java.awt.Dimension(normalWidth, enlargeHeight));
254
                this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft().setVisible(true);
255
                this.getConectorPanel().getAdjustGeorefPanel().getZoomRight().setVisible(true);
256
        }
257
        this.setLocation(new java.awt.Point(0,0));
258
        
259
        this.add(this.getPBotones(), BorderLayout.SOUTH);
260
        this.add(this.getConectorPanel(), BorderLayout.NORTH);    
261
        
262
        //A?adimos los listener de los botones de la tabla
263
        //Los botones de borrado los gestiona SelectPointsPanel
264
        //Los botones de cargar y exportar los gestiona GeoreferencigDialog
265
        tablePointsPanel = getConectorPanel().getDataPointsTabPanel().getTablePointsPanel(); 
266
        tablePointsPanel.getTableControlerPanel().getBClear().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
267
        tablePointsPanel.getTableControlerPanel().getBDelPoint().addActionListener(this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel());
268
        tablePointsPanel.getPButtonsExportImportPanel().getBLoad().addActionListener(this);
269
        tablePointsPanel.getPButtonsExportImportPanel().getBSave().addActionListener(this);
270
        tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii().addActionListener(this);
271
        conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive().addActionListener(this);
272
    }
273
                    
274
        /**
275
         * Comprueba si existe el fichero pasado por par?metro existe solicitando confirmaci?n
276
         * de sobreescritura. Si el usuario acepta devolver? true y si no acepta devuelve false.
277
         * Si se acepta la sobreescritura el fichero es borrado. 
278
         * @param file Cadena con el nombre del fichero a comprobar su existencia.
279
         * @return Devuelve true si el fichero existe y va a ser sobreescrito
280
         */
281
        public boolean checkFileExists(String file, boolean delete){
282
                File f = new File(file);
283
                if(f.exists()){
284
                        if (messageBoxYesOrNot("file_exists")){ 
285
                                if(delete)
286
                                        f.delete();
287
                                return true;
288
                        }else
289
                                return false;
290
                }
291
                return true;
292
        }
293
        
294
        /**
295
         * MessageBox con dos botones (OK y Cancel) que mostrar? el mensaje pasado por
296
         * par?metro 
297
         * @param msg Mensaje a mostrar
298
         * @return true si el usuario pulsa Ok y false si pulsa Cancel
299
         */
300
        public boolean messageBoxYesOrNot(String msg){
301
                String string1 = PluginServices.getText(this, "yes");
302
                String string2 = PluginServices.getText(this, "no");
303
                Object[] options = {string1, string2};
304
                int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(),
305
                                        PluginServices.getText(this, msg),
306
                                        PluginServices.getText(this, "confirmacion"),
307
                                        JOptionPane.YES_NO_OPTION,
308
                                        JOptionPane.QUESTION_MESSAGE,
309
                                        null,     
310
                                        options,  
311
                                        string1); 
312
                if (n == JOptionPane.YES_OPTION) 
313
                        return true;
314
                else
315
                        return false;
316
        }
317
        
318
        /**
319
         * Acci?n cuando se pulsa el bot?n de aceptar en el dialogo.
320
         * <UL>
321
         * <LI>Cambiamos el nombre a la capa georraster</LI>
322
         * <LI>A la capa Georraster le asignamos la capa de puntos para poder recuperarla</LI>
323
         * <LI>Cerramos la ventana</LI>
324
         * </UL>
325
         */
326
        public void actionPerformed(java.awt.event.ActionEvent e) {
327
                com.iver.cit.gvsig.gui.View  theView = null;
328
                try{
329
                        theView = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
330
                }catch(ClassCastException exc){
331
                        return;
332
                }
333

    
334
                try{
335
                        //ACEPTAR 
336
                        if(e.getSource() == bAceptar){
337
                                accept(theView);        
338
                        }
339
                        
340
                        //CANCELAR
341
                        if(e.getSource() == bCancelar){
342
                                cancel(theView);
343
                        }
344
                        
345
                        //CARGAR PUNTOS
346
                        if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBLoad()){
347
                                loadPoints(theView);
348
                        }
349
                        
350
                        //SALVAR PUNTOS
351
                        if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBSave()){
352
                                savePoints();                                
353
                        }
354
                        
355
                        //EXPORTAR A ASCII
356
                        if(e.getSource() == tablePointsPanel.getPButtonsExportImportPanel().getBExportToAscii()){
357
                                exportToASCII(theView);        
358
                        }
359
                        
360
                        //DESACTIVAR PANELES
361
                        JCheckBox cb = this.conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().getDataPointPanel().getCbActive();
362
                        if(e.getSource() == cb){
363
                                deactivatePanel(theView, cb);
364
                        }        
365
                        
366
                        //PROCESAR
367
                        if(e.getSource() == this.getBProcess()){
368
                                process(theView);
369
                        }
370
                }catch(Exception exc){
371
                        return; 
372
                }                
373
        }
374
        
375
        /**
376
         * Cierra el dialogo
377
         */
378
        public void close(){
379
                try{
380
                        frame.setClosed(true);
381
                }catch(PropertyVetoException exc){}
382
        }
383
                
384
        /**
385
         * Funci?n que se ejecuta al pulsar el bot?n procesar. Este procesamiento calcula a partir de
386
         * los puntos de control la georreferenciaci?n de la imagen y la asigna como extent temporal de
387
         * la capa FLyrGeoRaster. Cuando termina actualiza la visualizaci?n.
388
         * @param theView
389
         */
390
        private void process(View theView)throws Exception{
391
                if(getLyrPoints() == null)
392
                        throw new Exception("LyrPoints not loaded.");
393
                
394
                if(this.getLyrPoints().getCountPoints() > 0){
395
                        
396
                        //Calculamos las coordenadas de georreferenciaci?n
397
                        GeoOperations go = new GeoOperations(getLyrPoints());
398
                        double[] begin = go.transformPoint(0, 0, go.getAffine());
399
                        double[] end = go.transformPoint((int)lyrGeoRaster.getImageWidth(), (int)lyrGeoRaster.getImageHeight(), go.getAffine());
400
                        Extent ext = new Extent(begin[0], begin[1], end[0], end[1]);
401
                        
402
                        //Asignamos el extent temporal a la capa de georreferenciaci?n
403
                        ViewPort vp = theView.getMapControl().getMapContext().getViewPort();
404
                        ((FLyrGeoRaster)theView.getMapControl().getMapContext().getLayers().getLayer(lyrGeoRaster.getName())).setAssignExtent(ext);
405
                        
406
                        //Si la capa tiene puntos de control hacemos un update de estos 
407
                        //a su posici?n para que se actualicen los controles
408
                        for(int i=0; i<lyrGeoRaster.getFLyrPoints().getCountPoints(); i++){
409
                                                
410
                                Point2D center = lyrGeoRaster.img2World(lyrGeoRaster.getFLyrPoints().getPoint(i).pixelPoint);
411
                                lyrGeoRaster.getFLyrPoints().setMiniExtent(        i,
412
                                                                                                                        center,
413
                                                                                                                        //lyrGeoRaster.getGeoDialog().getZoomControlLeft().getCanvas().initViewPort(vp, center, lyrGeoRaster.getFLyrPoints().getPoint(i).leftViewPort),
414
                                                                                                                        lyrGeoRaster.getGeoDialog().getLeftInitViewport(vp, center, lyrGeoRaster.getFLyrPoints().getPoint(i).leftViewPort),
415
                                                                                                                        false);
416
                        }
417
                        
418
                        //Repintamos la vista y las mini im?genes
419
                        int selection = lyrGeoRaster.getGeoDialog().getSelectedPoint();
420
                        GeoPoint gp = lyrGeoRaster.getFLyrPoints().getPoint(selection);
421
                        Point2D px = null; 
422
                        Point2D map = null;
423
                        if(gp != null){
424
                                px = gp.pixelPoint;
425
                                map = gp.mapPoint;
426
                        }
427
                        
428
                        lyrGeoRaster.updateData(selection + 1, px, map, theView);
429
                        if(px == null && map == null)
430
                                theView.getMapControl().getMapContext().invalidate();
431
                }
432
        }
433
        
434
        /**
435
         * Funci?n que se ejecuta al pulsar el bot?n aceptar. Este procesamiento calcula a partir de
436
         * los puntos de control la georreferenciaci?n de la imagen, crear el fichero .rmf de georreferenciaci?n
437
         * y descarga la capa del TOC. A continuaci?n vuelve a cargar la capa como FLyrRaster dando
438
         * por finalizada la georreferenciaci?n. 
439
         * @param theView
440
         */
441
        private void accept(View theView)throws Exception{
442
                if(getLyrPoints() == null)
443
                        throw new Exception("LyrPoints not loaded.");
444
                
445
                if(this.getLyrPoints().getCountPoints() > 0){
446
                        
447
                        //Creamos el fichero de georreferenciaci?n
448
                        GeoOperations go = new GeoOperations(getLyrPoints());
449
                        go.setCreateWorldFile(this.createWorldFile);
450
                        go.createGeorefFile( (int)getLyrGeoRaster().getImageWidth(), 
451
                                                                (int)getLyrGeoRaster().getImageHeight(),
452
                                                                getLyrGeoRaster().getSource().getFiles()[0].getName());
453
                        
454
                        FLayers lyrs = this.getLyrGeoRaster().getParentLayer(); 
455
                        for(int i = 0; i < lyrs.getLayersCount();i++){
456
                                if(this.getLyrGeoRaster().getName().equals(lyrs.getLayer(i).getName())){
457
                                        
458
                                        //Eliminamos la capa
459
                                        lyrs.removeLayer(i);
460
                                        File fich = new File(getLyrGeoRaster().getSource().getFiles()[0].getName());
461
                                        try{
462
                                                //Creamos la nueva capa GeoRaster y la a?adimos al TOC. 
463
                                                /*FLyrGeoRaster lyrGeoRaster = 
464
                                                        GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()), 
465
                                                                                                        (RasterDriver)getLyrGeoRaster().getSource().getDriver(), 
466
                                                                                                        fich,
467
                                                                                                        getLyrGeoRaster().getProjection(),
468
                                                                                                        getLyrGeoRaster().getImageWidth(),
469
                                                                                                        getLyrGeoRaster().getImageHeight());
470
                                                getLyrPoints().setVisible(false);
471
                                                this.getLyrPoints().setLyrGeoRaster(lyrGeoRaster);
472
                                                lyrGeoRaster.setFLyrPoints(this.getLyrPoints());
473
                                                lyrGeoRaster.setGeoDialog(this);
474
                                                this.lyrGeoRaster = lyrGeoRaster;
475
                                                calcNewMiniExtent(theView);
476
                                                lyrs.addLayer(lyrGeoRaster);
477
                                                                                                        
478
                                                lyrGeoRaster.setActive(false);*/
479
                                                
480
                                                FLyrRaster lyrRaster = GeoLayerFactory.createLayer(getLyrGeoRaster().getName().substring(1, getLyrGeoRaster().getName().length()),
481
                                                                                                                                                        (RasterDriver)getLyrGeoRaster().getSource().getDriver(), 
482
                                                                                                                                                        fich,
483
                                                                                                                                                        getLyrGeoRaster().getProjection());
484
                                                lyrs.addLayer(lyrRaster);
485
                                                
486
                                                theView.getMapControl().getMapContext().invalidate();
487
                                                                                                        
488
                                                try{
489
                                                        frame.setClosed(true);
490
                                                }catch(PropertyVetoException exc){}
491
                                                                                                                                                                
492
                                        }catch(DriverException exc){
493
                                                
494
                                        }
495
                                        break;
496
                                }
497
                        }
498
                
499
                }
500
        }
501
        
502
        /**
503
         * Funci?n que se ejecuta al pulsar el bot?n aceptar
504
         * @param theView
505
         */
506
        /*private void accept(View theView)throws Exception{
507
                if(getLyrPoints() == null)
508
                        throw new Exception("LyrPoints not loaded.");
509
                                        
510
                if(lyrGeoRaster != null){
511
                        getLyrPoints().setVisible(false);
512
                        lyrGeoRaster.setName(lyrGeoRaster.getName().substring(1, lyrGeoRaster.getName().length()));
513
                        lyrGeoRaster.setActive(false);
514
                        theView.getMapControl().getMapContext().invalidate();
515
                }
516
                close();
517
        }*/
518
        
519
        /**
520
         * Funci?n que se ejecuta al pulsar el bot?n cancelar
521
         * @param theView
522
         */
523
        private void cancel(View theView)throws Exception{
524
                if(getLyrPoints() == null)
525
                        throw new Exception("LyrPoints not loaded.");
526
                                        
527
                //Cerramos la ventana 
528
                //(se ejecuta el evento internalFrameClosing de GeoRasterFrameListener)
529
                try{
530
                        frame.setClosed(true);
531
                        theView.getMapControl().getMapContext().invalidate();
532
                }catch(PropertyVetoException exc){}
533
        }
534
        
535
        /**
536
         * Funci?n que se ejecuta al pulsar el bot?n de cargar puntos 
537
         * @param theView
538
         */
539
        private void loadPoints(View theView)throws Exception{                
540
                if(getLyrPoints() == null)
541
                        throw new Exception("LyrPoints not loaded.");
542
                
543
                if(messageBoxYesOrNot("cargar_puntos")){
544
                        String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf("."));
545
                        String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
546
                        String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf";
547
                        
548
                        //Antes de cargar puntos plegamos el cuadro 
549
                         getSelectPointsPanel().setEnlarge(true);
550
                         
551
                        getLyrPoints().saveState();
552
                        getLyrPoints().XML2PointList(nameRmf);
553
                        
554
                        //Esto es por si el panel ha sido estirado cuando cargamos los puntos
555
                        frame.pack();
556
                        frame.show();
557
                }
558
        }
559
        
560
        /**
561
         * Funci?n que se ejecuta al pulsar el bot?n salvar puntos
562
         * @param theView
563
         */
564
        public void savePoints()throws Exception{
565
                if(getLyrPoints() == null)
566
                        throw new Exception("LyrPoints not loaded.");
567
                String name = lyrGeoRaster.getName().substring(lyrGeoRaster.getName().indexOf("*") + 1, lyrGeoRaster.getName().lastIndexOf("."));
568
                String path = ((RasterFileAdapter)lyrGeoRaster.getSource()).getFile().getAbsolutePath();
569
                String nameRmf = path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".rmf";
570
                        
571
                File f = new File(nameRmf);
572
                if(f.exists()){
573
                        if (messageBoxYesOrNot("gcps_exist")){ 
574
                                if(getLyrPoints() != null)
575
                                         getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf");
576
                        }
577
                }else
578
                        getLyrPoints().PointList2XML( path.substring(0, path.lastIndexOf(File.separator) + 1) + name + ".grf");                
579
        }
580
        
581
        /**
582
         * Funci?n que se ejecuta al pulsar el bot?n de export a ascii
583
         * @param theView
584
         */
585
        private void exportToASCII(View theView)throws Exception{
586
                if(getLyrPoints() == null)
587
                        throw new Exception("LyrPoints not loaded.");
588
                
589
                JFileChooser chooser = new JFileChooser(lastPathSave);
590
                chooser.setDialogTitle(PluginServices.getText(this, "seleccionar_fichero"));
591
                
592
                FileFilter f = null;
593
                for(int i=0; i<this.fileFilters.length;i++){
594
                        f = new SelectFileFilter(chooser, this.fileFilters[i]);
595
                        chooser.addChoosableFileFilter(f);
596
                }
597
                int returnVal = chooser.showOpenDialog(this);
598
                if(returnVal == JFileChooser.APPROVE_OPTION){
599
                         String fName = chooser.getSelectedFile().toString();
600
                         lastPathSave = chooser.getCurrentDirectory().getAbsolutePath();
601
                         if(checkFileExists(fName, true)){
602
                                 if(getLyrPoints() != null)
603
                                         getLyrPoints().PointList2Ascii(fName);
604
                         }
605
                }                        
606
        }
607
        
608
        /**
609
         * Funci?n que se ejecuta al pulsar el bot?n desactivar panel
610
         * @param theView
611
         */
612
        private void deactivatePanel(View theView, JCheckBox cb)throws Exception{
613
                if(getLyrPoints() == null)
614
                        throw new Exception("LyrPoints not loaded.");
615
                
616
                if(cb.isSelected()){
617
                        this.setEnabled(true);
618
                        getLyrPoints().setPointActive(getSelectedPoint(), true);
619
                }else{
620
                        this.setEnabled(false);
621
                        getLyrPoints().setPointActive(getSelectedPoint(), false);
622
                }
623
                
624
                //Al activar y desactivar tenemos que recalcular errores
625
                this.getPointManager().setErrors(getSelectedPoint());
626
                
627
                theView.getMapControl().getMapContext().invalidate();
628
                getZoomControlLeft().draw();
629
                getZoomControlRight().draw();                
630
        }
631
                 
632
        /**
633
         * Recalcula el extent de la mini-imagen que corresponde a los puntos en coordenadas
634
         * pixel.Para esto calcula el nuevo centro a partir de la capa y con la distancia entre
635
         * el nuevo centro y el viejo desplaza el extent completo de la mini-imagen.
636
         * @param theView
637
         */
638
        private void calcNewMiniExtent(View theView){
639

    
640
                ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort();
641
                for(int j = 0; j < getLyrPoints().getCountPoints(); j++){
642
                        //Calculamos el nuevo centro
643
                        Point2D oldCenter = getLyrPoints().getPoint(j).leftCenterPoint;
644
                        Point2D newCenter = new Point2D.Double();
645
                        newCenter.setLocation(        lyrGeoRaster.img2World(getLyrPoints().getPoint(j).pixelPoint));
646
                        
647
                        double diffX = oldCenter.getX() - newCenter.getX();
648
                        double diffY = oldCenter.getY() - newCenter.getY();
649
                        
650
                        getLyrPoints().getPoint(j).leftCenterPoint = newCenter;        
651
                                                
652
                        ViewPort vpOld = getLyrPoints().getPoint(j).leftViewPort;                        
653
                        Rectangle2D newExtent = new Rectangle2D.Double(        vpOld.getExtent().getMinX() - diffX, 
654
                                                                                                                        vpOld.getExtent().getMinY() - diffY, 
655
                                                                                                                        vpOld.getExtent().getWidth(), 
656
                                                                                                                        vpOld.getExtent().getHeight() );
657
                        ViewPort vpNew = new ViewPort(vpOld.getProjection());
658
                        vpNew.setExtent(newExtent);
659
                        vpNew.setImageSize(vpOld.getImageSize());
660
                        vpNew.setScale();
661
                        getLyrPoints().getPoint(j).leftViewPort = vpNew;
662
                }
663
        }
664
        
665
        /**
666
         * This method initializes jButton        
667
         *         
668
         * @return javax.swing.JButton        
669
         */    
670
        public JButton getBAccept() {
671
                if (bAceptar == null) {
672
                        bAceptar = new JButton();
673
                        bAceptar.setText(PluginServices.getText(this,"aceptar"));
674
                        bAceptar.setToolTipText(PluginServices.getText(this,"accept_tip"));
675
                        bAceptar.addActionListener(this);
676
                }
677
                return bAceptar;
678
        }
679
        
680
        /**
681
         * This method initializes bProcesar        
682
         *         
683
         * @return javax.swing.JButton        
684
         */    
685
        public JButton getBProcess() {
686
                if (bProcesar == null) {
687
                        bProcesar = new JButton();
688
                        bProcesar.setText(PluginServices.getText(this,"procesar"));
689
                        bProcesar.setToolTipText(PluginServices.getText(this,"process_tip"));
690
                        bProcesar.setEnabled(true);
691
                        bProcesar.addActionListener(this);
692
                }
693
                return bProcesar;
694
        }
695
        
696
        /**
697
         * El bot?n cancelar restaura el extent con el que se carg? la imagen a georreferenciar
698
         * y cierra la ventana.         
699
         *         
700
         * @return javax.swing.JButton        
701
         */    
702
        public JButton getBCancel() {
703
                if (bCancelar == null) {
704
                        bCancelar = new JButton();
705
                        bCancelar.setText(PluginServices.getText(this,"cancelar"));
706
                        bCancelar.setToolTipText(PluginServices.getText(this,"cancel_tip"));
707
                        bCancelar.addActionListener(this);
708
                }
709
                return bCancelar;
710
        }
711
                
712
        /**
713
         * This method initializes jButton        
714
         *         
715
         * @return javax.swing.JButton        
716
         */
717
        private JButton getBLoadPoints() {
718
                if (bLoadPoints == null) {
719
                        bLoadPoints = new JButton();
720
                        bLoadPoints.setText(PluginServices.getText(this,"cargar"));
721
                        bLoadPoints.setEnabled(true);
722
                        bLoadPoints.addActionListener(this);
723
                }
724
                return bLoadPoints;
725
        }
726

    
727
        /**
728
         * Asigna a las textbox el valor de pixel pasado
729
         * @param x        valor x
730
         * @param y        valor y
731
         */
732
        public void setPixelText(double x, double y){
733
                getSelectPointsPanel().getDataPointPanel().getTX().setText(String.valueOf(x));
734
                getSelectPointsPanel().getDataPointPanel().getTY().setText(String.valueOf(y));
735
        }
736
        
737
        /**
738
         * Asigna a las textbox el valor de coordenadas pasado
739
         * @param x        valor x
740
         * @param y        valor y
741
         */
742
        public void setMapCoordText(double x, double y){
743
                getSelectPointsPanel().getDataPointPanel().getLongitud().setText(MathUtils.tailDecimals(String.valueOf(x), 5));
744
                getSelectPointsPanel().getDataPointPanel().getLatitud().setText(MathUtils.tailDecimals(String.valueOf(y), 5));
745
        }
746
        
747
        /**
748
         * Esta funci?n resetea los controles del panel de info de un punto.
749
         */
750
        public void resetControls(boolean active){
751
                getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().setSaveToDisk(active);
752
                getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().resetControls(active);                
753
                getConectorPanel().getAdjustGeorefPanel().getZoomLeft().clear();
754
                setEnabled(active);
755
        }
756
        
757
        /* (non-Javadoc)
758
         * @see java.awt.event.ComponentListener#componentHidden(java.awt.event.ComponentEvent)
759
         */
760
        public void componentHidden(ComponentEvent arg0) {
761
                // TODO Auto-generated method stub
762

    
763
        }
764
        /* (non-Javadoc)
765
         * @see java.awt.event.ComponentListener#componentMoved(java.awt.event.ComponentEvent)
766
         */
767
        public void componentMoved(ComponentEvent arg0) {
768
                // TODO Auto-generated method stub
769

    
770
        }
771
        /* (non-Javadoc)
772
         * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
773
         */
774
        public void componentResized(ComponentEvent ev) {
775
                
776
                if(frame.getWidth() <= this.normalWidth + 10)
777
                        frame.setSize(this.normalWidth, frame.getHeight());
778
                
779
                if(this.getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 1){
780
                        tmpWidth = frame.getWidth();
781
                        this.newFrameSize(frame.getWidth(), frame.getHeight() - 10);
782
                }
783
        }
784
        /* (non-Javadoc)
785
         * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent)
786
         */
787
        public void componentShown(ComponentEvent arg0) {
788
                // TODO Auto-generated method stub
789

    
790
        }
791
        
792
    /**
793
     *Inicializa el tama?o del dialogo
794
     */
795
    public void resetSize(){
796
            if(!enlarge){
797
                    frame.setSize(this.normalWidth + 12, this.normalHeight + 10);
798
            }else{
799
                    frame.setSize(this.normalWidth + 12, this.enlargeHeight + 10);
800
            }
801
            newFrameSize((int)Math.round(this.normalWidth / 0.98), this.normalHeight);
802
    }
803
        
804
        /**
805
         * Calculo del nuevo tama?o a partir de un frame redimensionado
806
         * @param w Ancho del frame
807
         * @param h Alto del frame
808
         */
809
        public void newFrameSize(int w, int h){
810
                int newWidth = (int)Math.round(w * 0.98);
811
                                
812
        this.setSize(new java.awt.Dimension(newWidth, normalHeight ));
813
        this.setPreferredSize(new java.awt.Dimension(newWidth, normalHeight ));
814
        this.getConectorPanel().newFrameSize(newWidth, h);    
815
        }
816
        
817
        /**
818
         * Elimina un punto de la tabla de puntos
819
         * @param pos Posici?n del punto a eliminar
820
         */
821
        public void removeTableValueAt(int pos) throws ArrayIndexOutOfBoundsException{
822
                ((DefaultTableModel)this.getTable().getTable().getModel()).removeRow(pos);
823
        }
824
        
825
        /**
826
         * A partir de nuevas coordenadas actualiza la vista, minimagen, capa de puntos el
827
         * dialogo y la tabla.
828
         *
829
         */
830
        public void updateData(int nPunto, Point2D pixel, Point2D map, View view){
831
                getPointManager().updateData(nPunto, pixel, map, this, view);
832
        } 
833
        
834
        /**
835
         * Esta funci?n deshabilita todos los controles y guarda sus valores
836
         * de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue
837
         * se vuelvan a quedar como estaba
838
         */
839
        public void disableAllControls(){
840
                if(!disableAllControls){
841
                        disableAllControls = true;
842
                        
843
                        //Salvamos los estados
844
                        buttonsState[0] = getBProcess().isEnabled();
845
                        buttonsState[1] = getBAccept().isEnabled();
846
                        buttonsState[2] = getBCancel().isEnabled();
847
                        
848
                        //Desactivamos controles
849
                        getBProcess().setEnabled(false);
850
                        getBAccept().setEnabled(false);
851
                        getBCancel().setEnabled(false);
852
                }
853
        }
854
        
855
        /**
856
         * Esta funci?n deja los controles como estaban al ejecutar la funci?n 
857
         * disableAllControls
858
         */
859
        public void restoreControlsValue(){
860
                if(disableAllControls){
861
                        disableAllControls = false;
862
                        getBProcess().setEnabled(buttonsState[0]);
863
                        getBAccept().setEnabled(buttonsState[1]);
864
                        getBCancel().setEnabled(buttonsState[2]);
865
                }
866
        }
867
        //**********************End Methods***************************
868
        
869
        //**********************Setters & Getters*********************
870
        /**
871
         * Obtiene la tabla de puntos
872
         */
873
        public PointTable getTable(){
874
                return this.getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getJTable();
875
        }
876
                
877
        /**
878
         * Asigna un valor a una posici?n de la tabla
879
         * @param value Valor a asignar
880
         * @param row        Fila en la que se asigna
881
         * @param col        Columna en la que se asigna
882
         */
883
        public void setTableValueAt(String value, int row, int col)throws ArrayIndexOutOfBoundsException{
884
                ((DefaultTableModel)this.getTable().getTable().getModel()).setValueAt(value, row, col);
885
        }
886
        
887
        /**
888
         * Obtiene el n?mero de filas de la tabla
889
         * @return N?mero de filas de la tabla
890
         */
891
        public int getTableRowCount(){
892
                return this.getTable().getTable().getRowCount();
893
        }
894
        
895
        /**
896
         * A?ade una nueva fila a la tabla de puntos
897
         */
898
        public void addTableNew(){
899
                this.getTable().getTableModel().addNew();
900
        }
901
        /**
902
         * @return Returns the tmpWidth.
903
         */
904
        public int getTmpWidth() {
905
                return tmpWidth;
906
        }
907
        /**
908
         * @param tmpWidth The tmpWidth to set.
909
         */
910
        public void setTmpWidth(int tmpWidth) {
911
                this.tmpWidth = tmpWidth;
912
        }
913
        /**
914
         * @return Returns the enlargeHeight.
915
         */
916
        public int getEnlargeHeight() {
917
                return enlargeHeight;
918
        }
919
        /**
920
         * @return Returns the normalHeight.
921
         */
922
        public int getNormalHeight() {
923
                return normalHeight;
924
        }
925

    
926
        /**
927
         * @return Returns the normalWidth.
928
         */
929
        public int getNormalWidth() {
930
                return normalWidth;
931
        }
932
        
933
        /**
934
         * This method initializes jButton        
935
         *         
936
         * @return javax.swing.JButton        
937
         */    
938
        private JButton getBSavePoints() {
939
                if (bSavePoints == null) {
940
                        bSavePoints = new JButton();
941
                        bSavePoints.setText(PluginServices.getText(this,"salvar"));
942
                        //bSavePoints.setPreferredSize(new java.awt.Dimension(41,25));
943
                        bSavePoints.addActionListener(this);
944
                }
945
                return bSavePoints;
946
        }
947
        
948
        /**
949
         * Asigna el valor del campo RMS
950
         * @param rms Cadena que representa el RMS
951
         */
952
        public void setRMS(String rms){
953
                this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTRMS().setText(rms);
954
        }
955
        
956
        /**
957
         * Asigna el valor del campo de residuo en X
958
         * @param rms Cadena que representa el RMS
959
         */
960
        public void setResX(String resX){
961
                this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResX().setText(resX);
962
        }
963
        
964
        /**
965
         * Asigna el valor del campo de residuo en Y
966
         * @param rms Cadena que representa el RMS
967
         */
968
        public void setResY(String resY){
969
                this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTResY().setText(resY);
970
        }
971
        
972
        /**
973
         * Asigna el valor del campo RMS
974
         * @param rms Cadena que representa el RMS
975
         */
976
        public void setTotal(String total){
977
                this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getErrorPointPanel().getTTotal().setText(total);
978
        }
979
        
980
        /**
981
         * @return Returns the lyrGeoRaster.
982
         */
983
        public FLyrGeoRaster getLyrGeoRaster() {
984
                return lyrGeoRaster;
985
        }
986

    
987
        /**
988
         * @return Returns the lyrPoints.
989
         */
990
        public FLyrPoints getLyrPoints() {
991
                try{
992
                        return lyrGeoRaster.getFLyrPoints();                                                
993
                }catch(ClassCastException exc){
994
                        return null;
995
                }
996
        }
997
        
998
        /**
999
         * Selecciona un tab del cuadro
1000
         * @param index
1001
         */
1002
        public void setSelectedTab(int index){
1003
                try{
1004
                        this.getConectorPanel().getDataPointsTabPanel().getTbPoints().setSelectedIndex(index);
1005
                }catch(IllegalArgumentException ex){
1006
                        //Si peta al seleccionar un tab, pues nada.
1007
                }
1008
        }
1009
        
1010
        /**
1011
         * @param extended The extended to set.
1012
         */
1013
        public void setEnlarge(boolean enlarge) {
1014
                this.enlarge = enlarge;
1015
                if(!enlarge){
1016
                        frame.setSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10));
1017
                        frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.normalHeight + 10));
1018
                        this.setPreferredSize(new Dimension(this.normalWidth, this.normalHeight));
1019
                        this.setSize(new Dimension(this.normalWidth, this.normalHeight));
1020
                        this.getConectorPanel().setCanvasVisible(false);
1021
                }else{
1022
                        frame.setSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10));
1023
                        frame.setPreferredSize(new Dimension(this.normalWidth + 12, this.enlargeHeight + 10));
1024
                        this.setPreferredSize(new Dimension(this.normalWidth, this.enlargeHeight));
1025
                        this.setSize(new Dimension(this.normalWidth, this.enlargeHeight));
1026
                        this.getConectorPanel().setCanvasVisible(true);                                
1027
                }
1028
                frame.pack();
1029
        }
1030
                
1031
        /**
1032
         * @return Returns the extended.
1033
         */
1034
        public boolean isEnlarge() {
1035
                return enlarge;
1036
        }
1037
        
1038
        /**
1039
     * Obtiene el panel conector
1040
     * @return
1041
     */
1042
    public ConectorPanel getConectorPanel() {
1043
            if (conectorPanel == null) {                            
1044
                    conectorPanel = new ConectorPanel(this);
1045
            }
1046
        
1047
            return conectorPanel;
1048
    }
1049
                 
1050
        /**
1051
         * This method initializes jPanel        
1052
         *         
1053
         * @return javax.swing.JPanel        
1054
         */    
1055
        private JPanel getPBotones() {
1056
                if (pBotones == null) {
1057
                        FlowLayout flowLayout1 = new FlowLayout();
1058
                        pBotones = new JPanel();
1059
                        pBotones.setLayout(flowLayout1);
1060
                        flowLayout1.setHgap(10);
1061
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
1062
                        pBotones.add(getBProcess(), null);
1063
                        pBotones.add(getBAccept(), null);
1064
                        pBotones.add(getBCancel(), null);
1065
                }
1066
                return pBotones;
1067
        }
1068
        
1069
        public static IProjection getLastProjection() {
1070
                return proj;
1071
        }
1072
        public static void setLastProjection(IProjection proj) {
1073
                GeoreferencingDialog.proj = proj;
1074
        }
1075

    
1076
        /**
1077
         * @return Returns the GeoRedimBehavior.
1078
         */
1079
        public GeoRedimBehavior getGeoRedimBehavior() {
1080
                return rb;
1081
        }
1082

    
1083
        /**
1084
         * @param rb The GeoRedimBehavior to set.
1085
         */
1086
        public void setGeoRedimBehavior(GeoRedimBehavior rb) {
1087
                this.rb = rb;
1088
        }
1089
        
1090
        /**
1091
         * @return Returns the GeoMoveBehavior
1092
         */
1093
        public GeoMoveBehavior getGeoMoveBehavior() {
1094
                return mb;
1095
        }
1096

    
1097
        /**
1098
         * @param mb The GeoMoveBehavior to set.
1099
         */
1100
        public void setGeoMoveBehavior(GeoMoveBehavior mb) {
1101
                this.mb = mb;
1102
        }
1103
        
1104

    
1105
        /**
1106
         * Obtiene el punto de la lista que ha sido seleccionado
1107
         * @return
1108
         */
1109
        public int getSelectedPoint(){
1110
                return getConectorPanel().getDataPointsTabPanel().
1111
                        getSelectPointsPanel().getTableControlerPanel().getSelectedIndex();
1112
        }
1113
        
1114
        /**
1115
         * Obtiene el control de la mini imagen que tiene los botones a la izquierda
1116
         * @return ZoomControlPanel
1117
         */
1118
        public ZoomControlPanel getZoomControlLeft(){
1119
                return this.getConectorPanel().getAdjustGeorefPanel().getZoomLeft();
1120
        }
1121
        
1122
        /**
1123
         * Obtiene el control de la mini imagen que tiene los botones a la derecha
1124
         * @return ZoomControlPanel
1125
         */
1126
        public ZoomControlPanel getZoomControlRight(){
1127
                return this.getConectorPanel().getAdjustGeorefPanel().getZoomRight();
1128
        }
1129
        
1130
        /**
1131
         * Obtiene el panel de selecci?n de puntos
1132
         * @return Panel de selecci?n de puntos
1133
         */
1134
        public SelectPointsPanel getSelectPointsPanel(){
1135
                return this.getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel();
1136
        }
1137
        
1138
        /**
1139
         * Obtiene el panel de opciones
1140
         * @return OptionPanel
1141
         */
1142
        public OptionsPanel getOptionsPanel(){
1143
                return getConectorPanel().getAdjustGeorefPanel().getOptionsPanel();
1144
        }
1145
          
1146
    /**
1147
     * Asigna el frame
1148
     * @param f
1149
     */
1150
    public void setFrame(JInternalFrame f){
1151
            frame = f;
1152
            frame.addComponentListener(this);
1153
    }
1154
    
1155
    /**
1156
     * Obtiene el frame
1157
     * @return frame
1158
     */
1159
    public JInternalFrame getFrame(){
1160
            return frame;
1161
    }
1162
    
1163
    /**
1164
     * Obtiene el gestor de puntos
1165
     * @return PointManager
1166
     */
1167
    public PointManager getPointManager() {
1168
                return pointManager;
1169
        }
1170
    
1171
    /**
1172
     * Activa o desactiva este panel y todos los que lo componen
1173
     * @param enabled variable booleana para la activaci?n y/o desactivaci?n
1174
     */
1175
    public void setEnabled(boolean enabled){
1176
            conectorPanel.getDataPointsTabPanel().getSelectPointsPanel().setEnabled(enabled);
1177
            conectorPanel.getAdjustGeorefPanel().setEnabled(enabled);
1178
    }
1179
    
1180
    /**
1181
         * M?todo para notificar si se desea crear o no el fichero de coordenadas .tfw, .wld .jpgw ,... 
1182
         * @param createWorldFile
1183
         */
1184
    public void setCreateWorldFile(boolean createWorldFile) {
1185
                this.createWorldFile = createWorldFile;
1186
        }
1187
    
1188
    /**
1189
     * 
1190
     */
1191
    public ViewPort getLeftInitViewport(ViewPort vp, Point2D center, ViewPort initVp){
1192
            return getZoomControlLeft().getCanvas().initViewPort(vp, center, initVp);
1193
    }
1194
    
1195
    /**
1196
         * Consulta si se desea incluir los errores cuando se exporta a fichero .csv 
1197
         * @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
1198
         */
1199
    public boolean isErrorCSV() {
1200
                return errorCSV;
1201
        }
1202

    
1203
    /**
1204
         * M?todo para notificar si se desea incluir los errores cuando se exporta a fichero .csv 
1205
         * @param errorCVS true si se incluyen los errores dentro del fichero y false si no se incluyen
1206
         */
1207
        public void setErrorCSV(boolean errorCSV) {
1208
                this.errorCSV = errorCSV;
1209
        }
1210
        
1211
        /**
1212
         * Obtiene los errores en una matriz de Nx3 en la que cada fila es un punto y la
1213
         * columna 0 es el error en X, la columna 1 es el error en Y y la columna 2 es el error RMS. 
1214
         * @return matriz de errores
1215
         */
1216
        public double[][] getErrors(){
1217
                return pointManager.getErrors();
1218
        }
1219
        //**********************End Setters & Getters*****************
1220
                
1221
 }  //  @jve:decl-index=0:visual-constraint="10,10"
1222
 //  @jve:visual-info  decl-index=0 visual-constraint="10,10"
1223
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"