Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / MapContextLibrary.java @ 38557

History | View | Annotate | Download (4.64 KB)

1 25795 jmvivo
/* gvSIG. Geographic Information System of the Valencian Government
2 30011 cordinyana
 *
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 25795 jmvivo
23
/*
24 30011 cordinyana
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26 25795 jmvivo
 */
27
package org.gvsig.fmap.mapcontext;
28
29 35142 cordinyana
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31
32 33032 jjdelcerro
import org.gvsig.compat.CompatLibrary;
33
import org.gvsig.fmap.dal.DALLibrary;
34 26816 jmvivo
import org.gvsig.fmap.dal.feature.FeatureStore;
35 28882 cordinyana
import org.gvsig.fmap.mapcontext.impl.DefaultMapContextDrawer;
36 33351 cordinyana
import org.gvsig.fmap.mapcontext.layers.FLayerStatus;
37 30173 jldominguez
import org.gvsig.fmap.mapcontext.layers.FLayers;
38 32880 jjdelcerro
import org.gvsig.fmap.mapcontext.layers.FLyrDefault;
39 26816 jmvivo
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
40
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
41 30173 jldominguez
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry;
42 31548 jjdelcerro
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory;
43 33331 jjdelcerro
import org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory;
44 31548 jjdelcerro
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory;
45
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory;
46 31680 jldominguez
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory;
47 25795 jmvivo
import org.gvsig.tools.ToolsLocator;
48 30633 cordinyana
import org.gvsig.tools.library.AbstractLibrary;
49 30580 cordinyana
import org.gvsig.tools.library.LibraryException;
50 30011 cordinyana
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
51 31677 cordinyana
import org.gvsig.tools.persistence.PersistenceManager;
52 33652 jjdelcerro
import org.gvsig.tools.util.Caller;
53
import org.gvsig.tools.util.impl.DefaultCaller;
54 25795 jmvivo
55
/**
56 30011 cordinyana
 * Library for the MapContext library API.
57 25795 jmvivo
 * @author jmvivo
58
 */
59 30633 cordinyana
public class MapContextLibrary extends AbstractLibrary {
60 33331 jjdelcerro
        final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class);
61 25795 jmvivo
62 35142 cordinyana
    public void doRegistration() {
63
        registerAsAPI(MapContextLibrary.class);
64
        require(DALLibrary.class);
65
        require(CompatLibrary.class);
66
    }
67
68 30580 cordinyana
        protected void doInitialize() throws LibraryException {
69 27245 jmvivo
                LayerFactory.getInstance().registerLayerToUseForStore(
70
                                FeatureStore.class, FLyrVect.class);
71
        }
72
73 30580 cordinyana
        protected void doPostInitialize() throws LibraryException {
74 33652 jjdelcerro
        Caller caller = new DefaultCaller();
75
76 34488 cmartin
        FLyrDefault.registerMetadata();
77 25795 jmvivo
78 30011 cordinyana
                MapContextManager manager = MapContextLocator.getMapContextManager();
79
80
                if (manager == null) {
81
                        throw new ReferenceNotRegisteredException(
82
                                        MapContextLocator.MAPCONTEXT_MANAGER_NAME,
83
                                        MapContextLocator.getInstance());
84
                }
85
86 28882 cordinyana
                try {
87 30011 cordinyana
                        manager.setDefaultMapContextDrawer(DefaultMapContextDrawer.class);
88
                } catch (MapContextException ex) {
89 30580 cordinyana
                        throw new LibraryException(getClass().getName(), ex);
90 30011 cordinyana
                }
91 30173 jldominguez
92 33652 jjdelcerro
        caller.add( new ViewPort.RegisterPersistence() );
93
94
        /*
95
         * Do register of all
96
         */
97
        if( !caller.call() ) {
98
                throw new LibraryException(MapContextLibrary.class, caller.getExceptions());
99
        }
100
101
        // persistent classes
102 30173 jldominguez
                MapContext.registerPersistent();
103
104
                ExtentHistory.registerPersistent();
105
106 32880 jjdelcerro
//                MappingAnnotation.registerPersistent();
107 30173 jldominguez
                ReprojectDefaultGeometry.registerPersistent();
108 30011 cordinyana
109 32880 jjdelcerro
//                FLayerVectorialDB.registerPersistent();
110
//                FLayerFileVectorial.registerPersistent();
111
112 33351 cordinyana
                FLayerStatus.registerPersistent();
113 32880 jjdelcerro
                FLyrDefault.registerPersistent();
114
                FLyrVect.registerPersistent();
115 30173 jldominguez
                FLayers.registerPersistent();
116 33331 jjdelcerro
117 30779 cordinyana
                ////////////////////////////////////////
118
                // Register the persistence factories //
119
                ////////////////////////////////////////
120 31677 cordinyana
                PersistenceManager persistenceManager =
121
                                ToolsLocator.getPersistenceManager();
122
                // Color
123
                persistenceManager.registerFactory(new ColorPersistenceFactory());
124
                // Point2D
125
                persistenceManager.registerFactory(new Point2DPersistenceFactory());
126
                // Font
127
                persistenceManager.registerFactory(new FontPersistenceFactory());
128
                // Rectangle2D
129 31680 jldominguez
                persistenceManager.registerFactory(new Rectangle2DPersistenceFactory());
130 33331 jjdelcerro
                // awt Dimension
131
                persistenceManager.registerFactory(new DimensionPersistenceFactory());
132 25795 jmvivo
        }
133
134 30011 cordinyana
}