root / org.gvsig.jcrs / trunk / extJCRS / src / org / gvsig / crs / JCrsExtension.java @ 56
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 |
|
71 |
public void initialize() { |
72 |
|
73 |
// Pasamos este codigo comentarizado a la inicializaci?n de la librer?a
|
74 |
// /*
|
75 |
// * Se eliminan del registro de geotools las proyecciones que aporta libJCrs para asegurar que
|
76 |
// * son estas ?ltimas las que se utilizan.
|
77 |
// */
|
78 |
// final Class[] categories = {org.geotools.referencing.operation.MathTransformProvider.class};
|
79 |
// FactoryRegistry registry = new FactoryRegistry(Arrays.asList(categories));
|
80 |
// Iterator providers = registry.getServiceProviders(MathTransformProvider.class);
|
81 |
// Iterator providers2 = null;
|
82 |
// MathTransformProvider provider = null;
|
83 |
// MathTransformProvider provider2 = null;
|
84 |
//
|
85 |
// while (providers.hasNext()){
|
86 |
// provider = (MathTransformProvider) providers.next();
|
87 |
// if(provider.nameMatches("IDR")){
|
88 |
// providers2 = registry.getServiceProviders(MathTransformProvider.class);
|
89 |
// while (providers2.hasNext()){
|
90 |
// provider2 = (MathTransformProvider) providers2.next();
|
91 |
// if(provider2.nameMatches(provider.getName().toString()) && !provider2.nameMatches("IDR")) {
|
92 |
// registry.deregisterServiceProvider(provider2, categories[0]);
|
93 |
// }
|
94 |
// }
|
95 |
// }
|
96 |
// }
|
97 |
//
|
98 |
// //TODO: Solo para depurar: BORRAR
|
99 |
// providers = registry.getServiceProviders(MathTransformProvider.class);
|
100 |
// while (providers.hasNext()) {
|
101 |
// provider = (MathTransformProvider) providers.next();
|
102 |
// System.out.println(provider.toString());
|
103 |
// }
|
104 |
// /*
|
105 |
// *
|
106 |
// */
|
107 |
|
108 |
|
109 |
// CRSFactory.cp = new CrsFactory();
|
110 |
CRSSelectPanel.registerPanelClass(ProjChooserPanel.class); |
111 |
CRSSelectPanel.registerUIFactory(CrsUIFactory.class); |
112 |
// Default Projection
|
113 |
PluginServices ps = PluginServices.getPluginServices("org.gvsig.app");
|
114 |
XMLEntity xml = ps.getPersistentXML(); |
115 |
String projCode = null; |
116 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
|
117 |
projCode = xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME); |
118 |
} else {
|
119 |
ProjectPreferences prefs = new ProjectPreferences();
|
120 |
projCode = prefs.getDefaultProjection().getAbrev(); |
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 |
} |