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 @ 44831
History | View | Annotate | Download (4.83 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
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 | 41350 | jjdelcerro | import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesHelper; |
34 | 40435 | jjdelcerro | 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 | 44831 | jjdelcerro | import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
46 | 40435 | jjdelcerro | 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.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 | 44831 | jjdelcerro | final static private Logger LOGGER = LoggerFactory.getLogger(MapContextLibrary.class); |
58 | 40435 | jjdelcerro | |
59 | 44831 | jjdelcerro | @Override
|
60 | 40435 | jjdelcerro | public void doRegistration() { |
61 | registerAsAPI(MapContextLibrary.class); |
||
62 | require(DALLibrary.class); |
||
63 | require(CompatLibrary.class); |
||
64 | } |
||
65 | |||
66 | 44831 | jjdelcerro | @Override
|
67 | 40435 | jjdelcerro | protected void doInitialize() throws LibraryException { |
68 | } |
||
69 | |||
70 | 44831 | jjdelcerro | @Override
|
71 | 40435 | jjdelcerro | protected void doPostInitialize() throws LibraryException { |
72 | 41840 | jjdelcerro | Caller caller = new DefaultCaller();
|
73 | 40435 | jjdelcerro | |
74 | 41840 | jjdelcerro | MapContextManager manager = MapContextLocator.getMapContextManager(); |
75 | 40435 | jjdelcerro | |
76 | 41840 | jjdelcerro | 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 | 44831 | jjdelcerro | caller.add( new FLyrVect.SelfRegister() );
|
93 | 41840 | jjdelcerro | caller.add( new FLayers.RegisterPersistence() );
|
94 | 40435 | jjdelcerro | |
95 | 41840 | jjdelcerro | 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 | 40435 | jjdelcerro | |
101 | 41840 | jjdelcerro | if( !caller.call() ) {
|
102 | throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
||
103 | } |
||
104 | 40435 | jjdelcerro | |
105 | 44831 | jjdelcerro | // Validate there is any implementation registered.
|
106 | if (!RasterLegendLocator.getInstance().exists(
|
||
107 | RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME)) { |
||
108 | throw new ReferenceNotRegisteredException( |
||
109 | RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME, RasterLegendLocator.getInstance()); |
||
110 | } |
||
111 | 40435 | jjdelcerro | } |
112 | |||
113 | 40596 | jjdelcerro | } |