Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extJCRS / src / org / gvsig / crs / gui / CRSSelectionTrDialog.java @ 32535

History | View | Annotate | Download (3.92 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Instituto de Desarrollo Regional 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib��ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
 *   Campus Universitario s/n
35
 *   02071 Alabacete
36
 *   Spain
37
 *
38
 *   +34 967 599 200
39
 */
40

    
41
package org.gvsig.crs.gui;
42

    
43
import javax.swing.JPanel;
44

    
45
import org.cresques.cts.IProjection;
46
import org.gvsig.andami.PluginServices;
47
import org.gvsig.andami.ui.mdiManager.IWindow;
48
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
49
import org.gvsig.crs.CrsWkt;
50
import org.gvsig.crs.ICrs;
51
import org.gvsig.crs.persistence.CrsData;
52
import org.gvsig.crs.persistence.RecentCRSsPersistence;
53

    
54

    
55
/**
56
 * Di�logo contenedor del panel de la selecci�n de CRS y transformaci�n
57
 * de la capa a a�adir
58
 * 
59
 * @author Jos� Luis G�mez Mart�nez (JoseLuis.Gomez@uclm.es)
60
 *
61
 */
62

    
63
public class CRSSelectionTrDialog extends JPanel {
64
        
65
        private static final long serialVersionUID = 1L;
66
        
67
        JPanel contentPane = null;
68
        ICrs curProj = null;
69
        private IProjection lastProj = null;
70
        private boolean okPressed = false;
71
        
72
        public CRSSelectionTrDialog(ICrs proj) {
73
                super(false);
74
                curProj = proj;
75
                if (curProj.getSourceTransformationParams() == null && curProj.getTargetTransformationParams() == null) {
76
                        CrsData crsData = new CrsData(proj.getCrsWkt().getAuthority()[0], proj.getCode(),proj.getCrsWkt().getName());
77
                        RecentCRSsPersistence persistence = new RecentCRSsPersistence();
78
                        persistence.addCrsData(crsData);
79
                }
80
                inicializate();
81
        }
82
        public void inicializate(){
83
                this.add(getContentPanel(), null);        
84
        }
85
                        
86
    public CRSMainTrPanel getProjPanel() {
87
        return (CRSMainTrPanel) getContentPanel();
88
    }
89

    
90
        /**
91
         * @return
92
         */
93
        public IProjection getProjection() {
94
                return (IProjection) getProjPanel().getProjection();
95
        }
96
        /**
97
         * @param proj
98
         */
99
        public void setProjection(IProjection proj) {
100
                lastProj = proj;
101
                getProjPanel().setProjection(proj);
102
        }
103

    
104
        public JPanel getContentPanel() {
105
            if (contentPane == null) {                    
106
                    IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
107
                    AbstractViewPanel activeView = null;
108
                    if(activeView instanceof AbstractViewPanel)
109
                            activeView = (org.gvsig.app.project.documents.view.gui.AbstractViewPanel) activeWindow;
110
                    else {
111
                            IWindow[] windows = PluginServices.getMDIManager().getAllWindows();
112
                            for (int i = 0; i < windows.length; i++) {
113
                                        if(windows[i] instanceof AbstractViewPanel)
114
                                                activeView = (AbstractViewPanel)windows[i];
115
                                }
116
                    }
117
                    int target = ((ICrs) activeView.getMapControl().getProjection()).getCode();
118
                    CrsWkt crsWktTarget = ((ICrs) activeView.getMapControl().getProjection()).getCrsWkt();
119
                    if (crsWktTarget.getDatumName().equals("")){                            
120
                    }
121
                contentPane = new CRSMainTrPanel(target, crsWktTarget, curProj);                
122
                                  
123
       }
124
           return contentPane;
125
    }
126
        
127
        public boolean isOkPressed() { return okPressed; }        
128
}