Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.ui / src / main / java / org / gvsig / app / gui / panels / CRSSelectPanelFactory.java @ 40559

History | View | Annotate | Download (2.84 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.gui.panels;
25

    
26
import java.lang.reflect.InvocationTargetException;
27

    
28
import org.cresques.cts.IProjection;
29
import org.gvsig.app.gui.panels.crs.ICrsUIFactory;
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

    
33
public abstract class CRSSelectPanelFactory  {
34
        private static Logger logger = LoggerFactory.getLogger(CRSSelectPanelFactory.class);
35
        
36
        private static Class panelClass = null;
37
        private static Class uiFactory = null;
38

    
39
        public static void registerPanelClass(Class panelClass) {
40
                CRSSelectPanelFactory.panelClass = panelClass;
41
        }
42

    
43
        public static void registerUIFactory(Class uiFactory) {
44
                CRSSelectPanelFactory.uiFactory = uiFactory;
45
        }
46
        
47
        public static CRSSelectPanel getPanel(IProjection proj) {
48
                CRSSelectPanel panel = null;
49
                Class [] args = {IProjection.class};
50
                Object [] params = {proj};
51
                try {
52
                        panel = (CRSSelectPanel) panelClass.getConstructor(args).newInstance(params);
53
                } catch (IllegalArgumentException e) {
54
                        logger.error("Error creating CRS selection button", e);
55
                } catch (SecurityException e) {
56
                        logger.error("Error creating CRS selection button", e);
57
                } catch (InstantiationException e) {
58
                        logger.error("Error creating CRS selection button", e);
59
                } catch (IllegalAccessException e) {
60
                        logger.error("Error creating CRS selection button", e);
61
                } catch (InvocationTargetException e) {
62
                        logger.error("Error creating CRS selection button", e);
63
                } catch (NoSuchMethodException e) {
64
                        logger.error("Error creating CRS selection button", e);
65
                }
66
                return panel;
67
        }
68
                
69
        public static ICrsUIFactory getUIFactory() {
70
                ICrsUIFactory factory = null;
71
                try {
72
                        factory = (ICrsUIFactory) uiFactory.newInstance();
73
                } catch (InstantiationException e) {
74
                        logger.error("Error creating CRS UI factory. Switching to default factory", e);
75
                } catch (IllegalAccessException e) {
76
                        logger.error("Error creating CRS UI factory. Switching to default factory", e);
77
                }
78
                return factory;
79
        }
80
        
81
}