svn-gvsig-desktop / branches / org.gvsig.desktop-2018a / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / MapContextLibrary.java @ 43891
History | View | Annotate | Download (5.02 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.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.raster.lib.legend.api.RasterLegendLocator; |
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.Callable; |
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 |
*/
|
55 |
public class MapContextLibrary extends AbstractLibrary { |
56 |
|
57 |
final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class); |
58 |
|
59 |
@Override
|
60 |
public void doRegistration() { |
61 |
registerAsAPI(MapContextLibrary.class); |
62 |
require(DALLibrary.class); |
63 |
require(CompatLibrary.class); |
64 |
} |
65 |
|
66 |
@Override
|
67 |
protected void doInitialize() throws LibraryException { |
68 |
} |
69 |
|
70 |
@Override
|
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 RegisterDefaultVectorialLayer());
|
83 |
caller.add(new FLyrDefault.RegisterMetadata());
|
84 |
caller.add(new DefaultMapContextDrawer.RegisterMapContextDrawer());
|
85 |
|
86 |
caller.add(new ViewPort.RegisterPersistence());
|
87 |
caller.add(new ExtendedPropertiesHelper.RegisterPersistence());
|
88 |
caller.add(new MapContext.RegisterPersistence());
|
89 |
caller.add(new ExtentHistory.RegisterPersistence());
|
90 |
caller.add(new ReprojectDefaultGeometry.RegisterPersistence());
|
91 |
caller.add(new FLayerStatus.RegisterPersistence());
|
92 |
caller.add(new FLyrDefault.RegisterPersistence());
|
93 |
caller.add(new FLyrVect.RegisterPersistence());
|
94 |
caller.add(new FLayers.RegisterPersistence());
|
95 |
|
96 |
caller.add(new ColorPersistenceFactory.RegisterPersistence());
|
97 |
caller.add(new Point2DPersistenceFactory.RegisterPersistence());
|
98 |
caller.add(new FontPersistenceFactory.RegisterPersistence());
|
99 |
caller.add(new Rectangle2DPersistenceFactory.RegisterPersistence());
|
100 |
caller.add(new DimensionPersistenceFactory.RegisterPersistence());
|
101 |
|
102 |
if (!caller.call()) {
|
103 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
104 |
} |
105 |
|
106 |
// Validate there is any implementation registered.
|
107 |
if (!RasterLegendLocator.getInstance().exists(
|
108 |
RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME)) { |
109 |
throw new ReferenceNotRegisteredException( |
110 |
RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME, RasterLegendLocator.getInstance()); |
111 |
} |
112 |
|
113 |
} |
114 |
|
115 |
private static class RegisterDefaultVectorialLayer implements Callable { |
116 |
|
117 |
@Override
|
118 |
public Object call() throws Exception { |
119 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
120 |
manager.registerLayer(FeatureStore.class, FLyrVect.class); |
121 |
return true; |
122 |
} |
123 |
|
124 |
} |
125 |
} |