Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / panels / CRSSelectPanel.java @ 38564

History | View | Annotate | Download (4.33 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 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
 * 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
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.app.gui.panels;
42

    
43
import java.awt.event.ActionListener;
44
import java.lang.reflect.InvocationTargetException;
45

    
46
import javax.swing.JLabel;
47
import javax.swing.JPanel;
48

    
49
import org.cresques.cts.IProjection;
50
import org.gvsig.andami.PluginServices;
51
import org.gvsig.app.gui.panels.crs.CrsUIFactory;
52
import org.gvsig.app.gui.panels.crs.ICrsUIFactory;
53
import org.gvsig.app.gui.panels.crs.ISelectCRSButton;
54
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
55
import org.gvsig.app.project.documents.view.info.gui.CSSelectionDialog;
56
import org.gvsig.gui.beans.swing.JButton;
57

    
58

    
59
/**
60
 * 
61
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
62
 */
63
public abstract class CRSSelectPanel extends JPanel 
64
   implements ISelectCRSButton {
65
        private static Class panelClass = ProjChooserPanel.class;
66
        private static Class uiFactory = CrsUIFactory.class;
67
        private boolean transPanelActive = false;
68

    
69
        protected ActionListener actionListener = null;
70
        
71
        public static void registerPanelClass(Class panelClass) {
72
                CRSSelectPanel.panelClass = panelClass;
73
        }
74

    
75
        public static void registerUIFactory(Class uiFactory) {
76
                CRSSelectPanel.uiFactory = uiFactory;
77
        }
78
        
79
        public static CRSSelectPanel getPanel(IProjection proj) {
80
                CRSSelectPanel panel = null;
81
                Class [] args = {IProjection.class};
82
                Object [] params = {proj};
83
                try {
84
                        panel = (CRSSelectPanel) panelClass.getConstructor(args).newInstance(params);
85
                } catch (IllegalArgumentException e) {
86
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
87
                } catch (SecurityException e) {
88
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
89
                } catch (InstantiationException e) {
90
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
91
                } catch (IllegalAccessException e) {
92
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
93
                } catch (InvocationTargetException e) {
94
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
95
                } catch (NoSuchMethodException e) {
96
                        PluginServices.getLogger().error("Error creating CRS selection button", e);
97
                }
98
                return panel;
99
        }
100
        
101
        public CRSSelectPanel(IProjection proj) {
102
                super();
103
        }
104
        
105
        abstract public JButton getJBtnChangeProj();
106
        
107
        abstract public JLabel getJLabel();
108
        
109
        abstract public IProjection getCurProj();
110
        
111
        abstract public boolean isOkPressed();
112
        /**
113
         * @param actionListener The actionListener to set.
114
         */
115
        public void addActionListener(ActionListener actionListener) {
116
                this.actionListener = actionListener;
117
        }
118

    
119
        public boolean isTransPanelActive() {
120
                return transPanelActive;
121
        }
122

    
123
        public void setTransPanelActive(boolean transPanelActive) {
124
                this.transPanelActive = transPanelActive;
125
        }
126
        
127
        public static ICrsUIFactory getUIFactory() {
128
                ICrsUIFactory factory;
129
                try {
130
                        factory = (ICrsUIFactory) uiFactory.newInstance();
131
                } catch (InstantiationException e) {
132
                        PluginServices.getLogger().error("Error creating CRS UI factory. Switching to default factory", e);
133
                         factory = new CrsUIFactory();
134
                } catch (IllegalAccessException e) {
135
                        PluginServices.getLogger().error("Error creating CRS UI factory. Switching to default factory", e);
136
                        factory =  new CrsUIFactory();
137
                }
138
                return factory;
139
        }
140
        
141
}