svn-gvsig-desktop / trunk / libraries / libGeocoding / src / org / gvsig / geocoding / GeocodingManager.java @ 22684
History | View | Annotate | Download (2.58 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 PRODEVELOP Main development
|
26 |
*/
|
27 |
|
28 |
/**
|
29 |
*
|
30 |
*/
|
31 |
package org.gvsig.geocoding; |
32 |
|
33 |
import java.util.HashMap; |
34 |
import java.util.Map; |
35 |
|
36 |
import org.gvsig.geocoding.styles.GeocodingStyle; |
37 |
|
38 |
/**
|
39 |
* @author <a href="mailto:jsanz@prodevelop.es">
|
40 |
* Jorge Gaspar Sanz Salinas</a>
|
41 |
*
|
42 |
*/
|
43 |
@SuppressWarnings("unchecked") |
44 |
public class GeocodingManager { |
45 |
|
46 |
public static GeocodingManager instance; |
47 |
private Map styles = new HashMap(); |
48 |
|
49 |
/**
|
50 |
* Private constructor
|
51 |
*/
|
52 |
private GeocodingManager(){
|
53 |
registerDefaultStyles(); |
54 |
|
55 |
} |
56 |
|
57 |
private void registerDefaultStyles() { |
58 |
this.registerStyle(new org.gvsig.geocoding.styles.SimpleGeometry()); |
59 |
this.registerStyle(new org.gvsig.geocoding.styles.StreetBuilding()); |
60 |
this.registerStyle(new org.gvsig.geocoding.styles.StreetsCrossing()); |
61 |
} |
62 |
|
63 |
public static synchronized GeocodingManager getInstance(){ |
64 |
if (instance==null){ |
65 |
instance = new GeocodingManager();
|
66 |
} |
67 |
return instance;
|
68 |
} |
69 |
|
70 |
|
71 |
public void registerStyle(String name, GeocodingStyle style){ |
72 |
if (!this.styles.containsKey(name)) |
73 |
this.styles.put(name, style);
|
74 |
} |
75 |
|
76 |
public void registerStyle(GeocodingStyle style){ |
77 |
registerStyle(style.getClass().getName(), style); |
78 |
} |
79 |
|
80 |
public GeocodingStyle getStyle(String name){ |
81 |
Object obj = this.styles.get(name); |
82 |
return obj instanceof GeocodingStyle? (GeocodingStyle) obj:null; |
83 |
} |
84 |
|
85 |
public String[] getStyleNames(){ |
86 |
Object[] keys = this.styles.keySet().toArray(); |
87 |
|
88 |
String[] res = new String[keys.length]; |
89 |
|
90 |
for (int i=0;i<keys.length;i++){ |
91 |
res[i] = keys[i].toString(); |
92 |
} |
93 |
|
94 |
return res;
|
95 |
} |
96 |
} |
97 |
|