Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / MapContextLocator.java @ 40559

History | View | Annotate | Download (3.47 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
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2009 {DiSiD Technologies}  {{Task}}
27
 */
28
package org.gvsig.fmap.mapcontext;
29

    
30
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
31
import org.gvsig.tools.locator.BaseLocator;
32
import org.gvsig.tools.locator.Locator;
33
import org.gvsig.tools.locator.LocatorException;
34

    
35
/**
36
 * Locator for the MapContext library.
37
 * 
38
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
39
 */
40
public class MapContextLocator extends BaseLocator {
41

    
42
        public static final String MAPCONTEXT_MANAGER_NAME = "mapcontextlocator.manager";
43

    
44
        private static final String MAPCONTEXT_MANAGER_DESCRIPTION = "MapContext Library manager";
45

    
46
        public static final String SYMBOL_MANAGER_NAME = "symbol.manager";
47

    
48
        private static final String SYMBOL_MANAGER_DESCRIPTION = "Symbols manager";
49

    
50
        private static final MapContextLocator instance = new MapContextLocator();
51

    
52
        /**
53
         * Private constructor, we don't want it to be able to be instantiated
54
         * outside this class.
55
         */
56
        private MapContextLocator() {
57
                // Nothing to do
58
        }
59

    
60
        public static MapContextLocator getInstance() {
61
                return instance;
62
        }
63

    
64
        /**
65
         * Return a reference to MapContextManager.
66
         * 
67
         * @return a reference to MapContextManager
68
         * @throws LocatorException
69
         *             if there is no access to the class or the class cannot be
70
         *             instantiated
71
         * @see Locator#get(String)
72
         */
73
        public static MapContextManager getMapContextManager()
74
                        throws LocatorException {
75
                return (MapContextManager) getInstance().get(MAPCONTEXT_MANAGER_NAME);
76
        }
77

    
78
        /**
79
         * Registers the Class implementing the MapContextManager interface.
80
         * 
81
         * @param clazz
82
         *            implementing the MapContextManager interface
83
         */
84
        public static void registerMapContextManager(Class clazz) {
85
                getInstance().register(MAPCONTEXT_MANAGER_NAME,
86
                                MAPCONTEXT_MANAGER_DESCRIPTION, clazz);
87
        }
88

    
89
        /**
90
         * Return a reference to the {@link SymbolManager}.
91
         * 
92
         * @return a reference to the SymbolManager.
93
         * @throws LocatorException
94
         *             if there is no access to the class or the class cannot be
95
         *             instantiated
96
         * @see Locator#get(String)
97
         */
98
        public static SymbolManager getSymbolManager() throws LocatorException {
99
                return (SymbolManager) getInstance().get(SYMBOL_MANAGER_NAME);
100
        }
101

    
102
        /**
103
         * Registers the Class implementing the SymbolManager interface.
104
         * 
105
         * @param clazz
106
         *            implementing the SymbolManager interface
107
         */
108
        public static void registerSymbolManager(Class clazz) {
109
                getInstance().register(SYMBOL_MANAGER_NAME, SYMBOL_MANAGER_DESCRIPTION,
110
                                clazz);
111
        }
112
}