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 @ 40596
History | View | Annotate | Download (4.62 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.FLayerStatus; |
34 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
35 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
36 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
37 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
38 |
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry; |
39 |
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory; |
40 |
import org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory; |
41 |
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory; |
42 |
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory; |
43 |
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory; |
44 |
import org.gvsig.tools.ToolsLocator; |
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.persistence.PersistenceManager; |
49 |
import org.gvsig.tools.util.Caller; |
50 |
import org.gvsig.tools.util.impl.DefaultCaller; |
51 |
|
52 |
/**
|
53 |
* Library for the MapContext library API.
|
54 |
* @author jmvivo
|
55 |
*/
|
56 |
public class MapContextLibrary extends AbstractLibrary { |
57 |
final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class); |
58 |
|
59 |
public void doRegistration() { |
60 |
registerAsAPI(MapContextLibrary.class); |
61 |
require(DALLibrary.class); |
62 |
require(CompatLibrary.class); |
63 |
} |
64 |
|
65 |
protected void doInitialize() throws LibraryException { |
66 |
LayerFactory.getInstance().registerLayerToUseForStore( |
67 |
FeatureStore.class, FLyrVect.class); |
68 |
} |
69 |
|
70 |
protected void doPostInitialize() throws LibraryException { |
71 |
Caller caller = new DefaultCaller();
|
72 |
|
73 |
FLyrDefault.registerMetadata(); |
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 |
caller.add( new ViewPort.RegisterPersistence() );
|
90 |
|
91 |
/*
|
92 |
* Do register of all
|
93 |
*/
|
94 |
if( !caller.call() ) {
|
95 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
96 |
} |
97 |
|
98 |
// persistent classes
|
99 |
MapContext.registerPersistent(); |
100 |
|
101 |
ExtentHistory.registerPersistent(); |
102 |
|
103 |
// MappingAnnotation.registerPersistent();
|
104 |
ReprojectDefaultGeometry.registerPersistent(); |
105 |
|
106 |
// FLayerVectorialDB.registerPersistent();
|
107 |
// FLayerFileVectorial.registerPersistent();
|
108 |
|
109 |
FLayerStatus.registerPersistent(); |
110 |
FLyrDefault.registerPersistent(); |
111 |
FLyrVect.registerPersistent(); |
112 |
FLayers.registerPersistent(); |
113 |
|
114 |
////////////////////////////////////////
|
115 |
// Register the persistence factories //
|
116 |
////////////////////////////////////////
|
117 |
PersistenceManager persistenceManager = |
118 |
ToolsLocator.getPersistenceManager(); |
119 |
// Color
|
120 |
persistenceManager.registerFactory(new ColorPersistenceFactory());
|
121 |
// Point2D
|
122 |
persistenceManager.registerFactory(new Point2DPersistenceFactory());
|
123 |
// Font
|
124 |
persistenceManager.registerFactory(new FontPersistenceFactory());
|
125 |
// Rectangle2D
|
126 |
persistenceManager.registerFactory(new Rectangle2DPersistenceFactory());
|
127 |
// awt Dimension
|
128 |
persistenceManager.registerFactory(new DimensionPersistenceFactory());
|
129 |
} |
130 |
|
131 |
} |