Statistics
| Revision:

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

History | View | Annotate | Download (3.55 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 IVER T.I. S.A.   {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext;
28

    
29
import org.gvsig.fmap.dal.DataTypes;
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.fmap.mapcontext.impl.DefaultMapContextDrawer;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.fmap.mapcontext.layers.FLayers;
34
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
35
import org.gvsig.fmap.mapcontext.layers.MappingAnnotation;
36
import org.gvsig.fmap.mapcontext.layers.vectorial.FLayerFileVectorial;
37
import org.gvsig.fmap.mapcontext.layers.vectorial.FLayerVectorialDB;
38
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
39
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVectLinkProperties;
40
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry;
41
import org.gvsig.tools.ToolsLocator;
42
import org.gvsig.tools.dynobject.DynClass;
43
import org.gvsig.tools.dynobject.DynField;
44
import org.gvsig.tools.dynobject.DynObjectManager;
45
import org.gvsig.tools.library.LibraryException;
46
import org.gvsig.tools.library.impl.BaseLibrary;
47
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
48

    
49
/**
50
 * Library for the MapContext library API.
51
 * @author jmvivo
52
 */
53
public class MapContextLibrary extends BaseLibrary {
54

    
55
        protected void doInitialize() throws LibraryException {
56
                LayerFactory.getInstance().registerLayerToUseForStore(
57
                                FeatureStore.class, FLyrVect.class);
58
        }
59

    
60
        protected void doPostInitialize() throws LibraryException {
61
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
62

    
63
                DynField field;
64
                DynClass fLayerDynClass = dynManager.get(FLayer.DYNCLASS_NAME);
65
                if (fLayerDynClass == null) {
66
                        fLayerDynClass = dynManager.add(FLayer.DYNCLASS_NAME);
67

    
68
                        field = fLayerDynClass.addDynField("name");
69
                        field.setType(DataTypes.STRING);
70

    
71
                        field = fLayerDynClass.addDynField("SRS");
72
                        field.setType(DataTypes.SRS);
73
                }
74

    
75
                MapContextManager manager = MapContextLocator.getMapContextManager();
76

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

    
83
                try {
84
                        manager.setDefaultMapContextDrawer(DefaultMapContextDrawer.class);
85
                } catch (MapContextException ex) {
86
                        throw new LibraryException(getClass().getName(), ex);
87
                }
88
                
89
                // persistent classes
90
                MapContext.registerPersistent();
91
                
92
                ViewPort.registerPersistent();
93
                ExtentHistory.registerPersistent();
94
                
95
                MappingAnnotation.registerPersistent();
96
                ReprojectDefaultGeometry.registerPersistent();
97

    
98
                FLayerVectorialDB.registerPersistent();
99
                FLayerFileVectorial.registerPersistent();
100
                FLayers.registerPersistent();
101
                
102
                FLyrVectLinkProperties.registerPersistent();
103
        }
104

    
105
}