root / org.gvsig.jcrs / extJCRS / src / org / gvsig / crs / JCrsExtension.java @ 40
History | View | Annotate | Download (5.14 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 |
|
42 |
package org.gvsig.crs; |
43 |
|
44 |
import java.util.Arrays; |
45 |
import java.util.Iterator; |
46 |
import java.io.File; |
47 |
|
48 |
import org.geotools.factory.FactoryRegistry; |
49 |
import org.geotools.referencing.operation.MathTransformProvider; |
50 |
import org.gvsig.about.AboutManager; |
51 |
import org.gvsig.about.AboutParticipant; |
52 |
import org.gvsig.andami.PluginServices; |
53 |
import org.gvsig.andami.messages.NotificationManager; |
54 |
import org.gvsig.andami.plugins.Extension; |
55 |
import org.gvsig.app.ApplicationLocator; |
56 |
import org.gvsig.app.ApplicationManager; |
57 |
import org.gvsig.app.extension.About; |
58 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
59 |
import org.gvsig.app.gui.panels.FPanelAbout; |
60 |
import org.gvsig.app.project.ProjectPreferences; |
61 |
import org.gvsig.crs.gui.panels.CrsUIFactory; |
62 |
import org.gvsig.crs.gui.panels.ProjChooserPanel; |
63 |
import org.gvsig.fmap.crs.CRSFactory; |
64 |
import org.gvsig.utils.XMLEntity; |
65 |
|
66 |
|
67 |
public class JCrsExtension extends Extension { |
68 |
|
69 |
private static final String DEFAULT_PROJECTION_KEY_NAME = "DefaultProjection"; |
70 |
private static final String FACTORY_DEFAULT_PROJECTION = "EPSG:23030"; |
71 |
|
72 |
public void initialize() { |
73 |
|
74 |
// Pasamos este codigo comentarizado a la inicializaci?n de la librer?a
|
75 |
// /*
|
76 |
// * Se eliminan del registro de geotools las proyecciones que aporta libJCrs para asegurar que
|
77 |
// * son estas ?ltimas las que se utilizan.
|
78 |
// */
|
79 |
// final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class};
|
80 |
// FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories));
|
81 |
// Iterator providers = registry.getServiceProviders(MathTransformProvider.class);
|
82 |
// Iterator providers2 = null;
|
83 |
// MathTransformProvider provider = null;
|
84 |
// MathTransformProvider provider2 = null;
|
85 |
//
|
86 |
// while (providers.hasNext()){
|
87 |
// provider = (MathTransformProvider) providers.next();
|
88 |
// if(provider.nameMatches("IDR")){
|
89 |
// providers2 = registry.getServiceProviders(MathTransformProvider.class);
|
90 |
// while (providers2.hasNext()){
|
91 |
// provider2 = (MathTransformProvider) providers2.next();
|
92 |
// if(provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR")) {
|
93 |
// registry.deregisterServiceProvider(provider2, categories[0]);
|
94 |
// }
|
95 |
// }
|
96 |
// }
|
97 |
// }
|
98 |
//
|
99 |
// //TODO: Solo para depurar: BORRAR
|
100 |
// providers = registry.getServiceProviders(MathTransformProvider.class);
|
101 |
// while (providers.hasNext()) {
|
102 |
// provider = (MathTransformProvider) providers.next();
|
103 |
// System.out.println(provider.toString());
|
104 |
// }
|
105 |
// /*
|
106 |
// *
|
107 |
// */
|
108 |
|
109 |
|
110 |
// CRSFactory.cp = new CrsFactory();
|
111 |
CRSSelectPanel.registerPanelClass(ProjChooserPanel.class); |
112 |
CRSSelectPanel.registerUIFactory(CrsUIFactory.class); |
113 |
// Default Projection
|
114 |
PluginServices ps = PluginServices.getPluginServices("org.gvsig.app");
|
115 |
XMLEntity xml = ps.getPersistentXML(); |
116 |
String projCode = null; |
117 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
|
118 |
projCode = xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME); |
119 |
} else {
|
120 |
projCode = FACTORY_DEFAULT_PROJECTION; |
121 |
} |
122 |
((ProjectPreferences) ApplicationLocator.getManager().getPreferences( |
123 |
"project")).setDefaultProjection(CRSFactory.getCRS(projCode));
|
124 |
|
125 |
addAboutInfo(); |
126 |
} |
127 |
|
128 |
private void addAboutInfo() { |
129 |
ApplicationManager application = ApplicationLocator.getManager(); |
130 |
|
131 |
AboutManager about = application.getAbout(); |
132 |
|
133 |
about.addDeveloper( |
134 |
"UCLM-IDR",
|
135 |
this.getClass().getClassLoader().getResource("about.html"), |
136 |
1
|
137 |
); |
138 |
|
139 |
AboutParticipant participant = about.getDeveloper("UCLM-IDR");
|
140 |
participant.addContribution( |
141 |
"jCRS",
|
142 |
"Extensi?n para el manejo de Sistemas de Referencia de Coordenadas",
|
143 |
2006,1,1, |
144 |
2007,12,31 |
145 |
); |
146 |
} |
147 |
|
148 |
public void execute(String actionCommand) { |
149 |
|
150 |
|
151 |
} |
152 |
|
153 |
public boolean isEnabled() { |
154 |
|
155 |
return true; |
156 |
} |
157 |
|
158 |
public boolean isVisible() { |
159 |
|
160 |
return false; |
161 |
} |
162 |
|
163 |
} |