root / org.gvsig.proj / branches / refactor2018 / org.gvsig.proj / org.gvsig.proj.swing / org.gvsig.proj.swing.impl / src / main / java / org / gvsig / proj / swing / impl / CoordinateReferenceSystemSwingDefaultImplLibrary.java @ 854
History | View | Annotate | Download (4.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2012 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 2
|
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.proj.swing.impl; |
25 |
|
26 |
import java.net.URL; |
27 |
|
28 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingLibrary; |
29 |
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingLocator; |
30 |
import org.gvsig.tools.ToolsLocator; |
31 |
import org.gvsig.tools.i18n.I18nManager; |
32 |
import org.gvsig.tools.library.AbstractLibrary; |
33 |
import org.gvsig.tools.library.LibraryException; |
34 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
35 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
36 |
import org.slf4j.LoggerFactory; |
37 |
|
38 |
/**
|
39 |
* Library for default swing implementation initialization and configuration.
|
40 |
*
|
41 |
* @author gvSIG team
|
42 |
* @version $Id$
|
43 |
*/
|
44 |
public class CoordinateReferenceSystemSwingDefaultImplLibrary extends |
45 |
AbstractLibrary { |
46 |
|
47 |
@Override
|
48 |
public void doRegistration() { |
49 |
registerAsImplementationOf(CoordinateReferenceSystemSwingLibrary.class); |
50 |
} |
51 |
|
52 |
@Override
|
53 |
protected void doInitialize() throws LibraryException { |
54 |
CoordinateReferenceSystemSwingLocator |
55 |
.registerSwingManager(DefaultCoordinateReferenceSystemSwingManager.class); |
56 |
} |
57 |
|
58 |
@Override
|
59 |
protected void doPostInitialize() throws LibraryException { |
60 |
I18nManager i18nMgr = ToolsLocator.getI18nManager(); |
61 |
i18nMgr.addResourceFamily("org.gvsig.proj.swing.impl.i18n.text",
|
62 |
CoordinateReferenceSystemSwingDefaultImplLibrary.class |
63 |
.getClassLoader(), |
64 |
CoordinateReferenceSystemSwingDefaultImplLibrary.class.getClass() |
65 |
.getName()); |
66 |
|
67 |
registerIcons(); |
68 |
} |
69 |
|
70 |
|
71 |
protected void registerIcons() { |
72 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
73 |
String group = "swingproj"; |
74 |
registerIcon(group, "bullet_add", null, iconTheme); |
75 |
registerIcon(group, "bullet_remove", null, iconTheme); |
76 |
registerIcon(group, "bullet_share", null, iconTheme); |
77 |
registerIcon(group, "crs_add", null, iconTheme); |
78 |
registerIcon(group, "crs", null, iconTheme); |
79 |
registerIcon(group, "ct_add", null, iconTheme); |
80 |
registerIcon(group, "ct", null, iconTheme); |
81 |
registerIcon(group, "dropdown", null, iconTheme); |
82 |
registerIcon(group, "favourite_add", null, iconTheme); |
83 |
registerIcon(group, "favourite", null, iconTheme); |
84 |
registerIcon(group, "favourite_remove", null, iconTheme); |
85 |
registerIcon(group, "filter_alpha", null, iconTheme); |
86 |
registerIcon(group, "filter_spatial", null, iconTheme); |
87 |
registerIcon(group, "folder_closed", null, iconTheme); |
88 |
registerIcon(group, "folder_open", null, iconTheme); |
89 |
registerIcon(group, "recent", null, iconTheme); |
90 |
registerIcon(group, "recent_remove", null, iconTheme); |
91 |
registerIcon(group, "search", null, iconTheme); |
92 |
registerIcon(group, "search_remove", null, iconTheme); |
93 |
registerIcon(group, "unlock", null, iconTheme); |
94 |
registerIcon(group, "spinner", ".gif", iconTheme); |
95 |
} |
96 |
|
97 |
protected void registerIcon(String group, String name, String extension, IconTheme iconTheme) { |
98 |
if (extension==null) { |
99 |
extension = ".png";
|
100 |
} |
101 |
String resourceName = "images/" + group + "/" + name + extension; |
102 |
String provider = this.getClass().getName(); |
103 |
ClassLoader loader = this.getClass().getClassLoader(); |
104 |
URL resource = null; |
105 |
try {
|
106 |
resource = loader.getResource(resourceName); |
107 |
iconTheme.registerDefault(provider, group, name, null, resource);
|
108 |
} catch( Throwable e) { |
109 |
LoggerFactory.getLogger(CoordinateReferenceSystemSwingDefaultImplLibrary.class) |
110 |
.info("Can't register icon '" + name + "'.",e); |
111 |
} |
112 |
} |
113 |
} |