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 / MapContextLibrary.java @ 41350

History | View | Annotate | Download (4.75 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
package org.gvsig.fmap.mapcontext;
25

    
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

    
29
import org.gvsig.compat.CompatLibrary;
30
import org.gvsig.fmap.dal.DALLibrary;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.fmap.mapcontext.impl.DefaultMapContextDrawer;
33
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesHelper;
34
import org.gvsig.fmap.mapcontext.layers.FLayerStatus;
35
import org.gvsig.fmap.mapcontext.layers.FLayers;
36
import org.gvsig.fmap.mapcontext.layers.FLyrDefault;
37
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
38
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
39
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry;
40
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory;
41
import org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory;
42
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory;
43
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory;
44
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory;
45
import org.gvsig.tools.ToolsLocator;
46
import org.gvsig.tools.library.AbstractLibrary;
47
import org.gvsig.tools.library.LibraryException;
48
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
49
import org.gvsig.tools.persistence.PersistenceManager;
50
import org.gvsig.tools.util.Caller;
51
import org.gvsig.tools.util.impl.DefaultCaller;
52

    
53
/**
54
 * Library for the MapContext library API.
55
 * @author jmvivo
56
 */
57
public class MapContextLibrary extends AbstractLibrary {
58
        final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class);
59

    
60
    public void doRegistration() {
61
        registerAsAPI(MapContextLibrary.class);
62
        require(DALLibrary.class);
63
        require(CompatLibrary.class);
64
    }
65

    
66
        protected void doInitialize() throws LibraryException {
67
                LayerFactory.getInstance().registerLayerToUseForStore(
68
                                FeatureStore.class, FLyrVect.class);
69
        }
70

    
71
        protected void doPostInitialize() throws LibraryException {
72
        Caller caller = new DefaultCaller();
73

    
74
        FLyrDefault.registerMetadata();        
75

    
76
                MapContextManager manager = MapContextLocator.getMapContextManager();
77

    
78
                if (manager == null) {
79
                        throw new ReferenceNotRegisteredException(
80
                                        MapContextLocator.MAPCONTEXT_MANAGER_NAME,
81
                                        MapContextLocator.getInstance());
82
                }
83

    
84
                try {
85
                        manager.setDefaultMapContextDrawer(DefaultMapContextDrawer.class);
86
                } catch (MapContextException ex) {
87
                        throw new LibraryException(getClass().getName(), ex);
88
                }
89
                
90
        caller.add( new ViewPort.RegisterPersistence() );
91

    
92
        /*
93
         * Do register of all
94
         */
95
        if( !caller.call() ) {
96
                throw new LibraryException(MapContextLibrary.class, caller.getExceptions());
97
        }
98

    
99
        // persistent classes
100
                ExtendedPropertiesHelper.registerPersistent();
101
                MapContext.registerPersistent();
102
                
103
                ExtentHistory.registerPersistent();
104
                
105
//                MappingAnnotation.registerPersistent();
106
                ReprojectDefaultGeometry.registerPersistent();
107

    
108
//                FLayerVectorialDB.registerPersistent();
109
//                FLayerFileVectorial.registerPersistent();
110
                
111
                FLayerStatus.registerPersistent();
112
                FLyrDefault.registerPersistent();
113
                FLyrVect.registerPersistent();
114
                FLayers.registerPersistent();
115
                                
116
                ////////////////////////////////////////
117
                // Register the persistence factories //
118
                ////////////////////////////////////////
119
                PersistenceManager persistenceManager =
120
                                ToolsLocator.getPersistenceManager();
121
                // Color
122
                persistenceManager.registerFactory(new ColorPersistenceFactory());
123
                // Point2D
124
                persistenceManager.registerFactory(new Point2DPersistenceFactory());
125
                // Font
126
                persistenceManager.registerFactory(new FontPersistenceFactory());
127
                // Rectangle2D
128
                persistenceManager.registerFactory(new Rectangle2DPersistenceFactory());
129
                // awt Dimension
130
                persistenceManager.registerFactory(new DimensionPersistenceFactory());
131
        }
132

    
133
}