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

History | View | Annotate | Download (4.49 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.library.AbstractLibrary;
46
import org.gvsig.tools.library.LibraryException;
47
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
48
import org.gvsig.tools.util.Caller;
49
import org.gvsig.tools.util.impl.DefaultCaller;
50

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

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

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

    
69
        protected void doPostInitialize() throws LibraryException {
70
            Caller caller = new DefaultCaller();
71

    
72
            MapContextManager manager = MapContextLocator.getMapContextManager();
73

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

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

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

    
103
        }
104

    
105
}