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 @ 44361

History | View | Annotate | Download (4.58 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
            MapContextManager manager = MapContextLocator.getMapContextManager();
75

    
76
            if (manager == null) {
77
                    throw new ReferenceNotRegisteredException(
78
                                    MapContextLocator.MAPCONTEXT_MANAGER_NAME,
79
                                    MapContextLocator.getInstance());
80
            }
81
            
82
            caller.add( new FLyrDefault.RegisterMetadata() );
83
            caller.add( new DefaultMapContextDrawer.RegisterMapContextDrawer() );
84
            
85
            caller.add( new ViewPort.RegisterPersistence() );
86
            caller.add( new ExtendedPropertiesHelper.RegisterPersistence() );
87
            caller.add( new MapContext.RegisterPersistence() );
88
            caller.add( new ExtentHistory.RegisterPersistence() );
89
            caller.add( new ReprojectDefaultGeometry.RegisterPersistence() );
90
            caller.add( new FLayerStatus.RegisterPersistence() );
91
            caller.add( new FLyrDefault.RegisterPersistence() );
92
            caller.add( new FLyrVect.RegisterPersistence() );
93
            caller.add( new FLayers.RegisterPersistence() );
94

    
95
            caller.add( new ColorPersistenceFactory.RegisterPersistence() );
96
            caller.add( new Point2DPersistenceFactory.RegisterPersistence() );
97
            caller.add( new FontPersistenceFactory.RegisterPersistence() );
98
            caller.add( new Rectangle2DPersistenceFactory.RegisterPersistence() );
99
            caller.add( new DimensionPersistenceFactory.RegisterPersistence() );
100

    
101
            if( !caller.call() ) {
102
                    throw new LibraryException(MapContextLibrary.class, caller.getExceptions());
103
            }
104

    
105
        }
106

    
107
}