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 @ 40559
History | View | Annotate | Download (4.69 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 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2008 IVER T.I. S.A. {{Task}}
|
27 |
*/
|
28 |
package org.gvsig.fmap.mapcontext; |
29 |
|
30 |
import org.slf4j.Logger; |
31 |
import org.slf4j.LoggerFactory; |
32 |
|
33 |
import org.gvsig.compat.CompatLibrary; |
34 |
import org.gvsig.fmap.dal.DALLibrary; |
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 |
import org.gvsig.fmap.mapcontext.impl.DefaultMapContextDrawer; |
37 |
import org.gvsig.fmap.mapcontext.layers.FLayerStatus; |
38 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
39 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
40 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
41 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
42 |
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry; |
43 |
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory; |
44 |
import org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory; |
45 |
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory; |
46 |
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory; |
47 |
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory; |
48 |
import org.gvsig.tools.ToolsLocator; |
49 |
import org.gvsig.tools.library.AbstractLibrary; |
50 |
import org.gvsig.tools.library.LibraryException; |
51 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
52 |
import org.gvsig.tools.persistence.PersistenceManager; |
53 |
import org.gvsig.tools.util.Caller; |
54 |
import org.gvsig.tools.util.impl.DefaultCaller; |
55 |
|
56 |
/**
|
57 |
* Library for the MapContext library API.
|
58 |
* @author jmvivo
|
59 |
*/
|
60 |
public class MapContextLibrary extends AbstractLibrary { |
61 |
final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class); |
62 |
|
63 |
public void doRegistration() { |
64 |
registerAsAPI(MapContextLibrary.class); |
65 |
require(DALLibrary.class); |
66 |
require(CompatLibrary.class); |
67 |
} |
68 |
|
69 |
protected void doInitialize() throws LibraryException { |
70 |
LayerFactory.getInstance().registerLayerToUseForStore( |
71 |
FeatureStore.class, FLyrVect.class); |
72 |
} |
73 |
|
74 |
protected void doPostInitialize() throws LibraryException { |
75 |
Caller caller = new DefaultCaller();
|
76 |
|
77 |
FLyrDefault.registerMetadata(); |
78 |
|
79 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
80 |
|
81 |
if (manager == null) { |
82 |
throw new ReferenceNotRegisteredException( |
83 |
MapContextLocator.MAPCONTEXT_MANAGER_NAME, |
84 |
MapContextLocator.getInstance()); |
85 |
} |
86 |
|
87 |
try {
|
88 |
manager.setDefaultMapContextDrawer(DefaultMapContextDrawer.class); |
89 |
} catch (MapContextException ex) {
|
90 |
throw new LibraryException(getClass().getName(), ex); |
91 |
} |
92 |
|
93 |
caller.add( new ViewPort.RegisterPersistence() );
|
94 |
|
95 |
/*
|
96 |
* Do register of all
|
97 |
*/
|
98 |
if( !caller.call() ) {
|
99 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
100 |
} |
101 |
|
102 |
// persistent classes
|
103 |
MapContext.registerPersistent(); |
104 |
|
105 |
ExtentHistory.registerPersistent(); |
106 |
|
107 |
// MappingAnnotation.registerPersistent();
|
108 |
ReprojectDefaultGeometry.registerPersistent(); |
109 |
|
110 |
// FLayerVectorialDB.registerPersistent();
|
111 |
// FLayerFileVectorial.registerPersistent();
|
112 |
|
113 |
FLayerStatus.registerPersistent(); |
114 |
FLyrDefault.registerPersistent(); |
115 |
FLyrVect.registerPersistent(); |
116 |
FLayers.registerPersistent(); |
117 |
|
118 |
////////////////////////////////////////
|
119 |
// Register the persistence factories //
|
120 |
////////////////////////////////////////
|
121 |
PersistenceManager persistenceManager = |
122 |
ToolsLocator.getPersistenceManager(); |
123 |
// Color
|
124 |
persistenceManager.registerFactory(new ColorPersistenceFactory());
|
125 |
// Point2D
|
126 |
persistenceManager.registerFactory(new Point2DPersistenceFactory());
|
127 |
// Font
|
128 |
persistenceManager.registerFactory(new FontPersistenceFactory());
|
129 |
// Rectangle2D
|
130 |
persistenceManager.registerFactory(new Rectangle2DPersistenceFactory());
|
131 |
// awt Dimension
|
132 |
persistenceManager.registerFactory(new DimensionPersistenceFactory());
|
133 |
} |
134 |
|
135 |
} |