Revision 43891 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
MapContextLibrary.java | ||
---|---|---|
34 | 34 |
import org.gvsig.fmap.mapcontext.layers.FLayerStatus; |
35 | 35 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
36 | 36 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
37 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
|
38 | 37 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
39 | 38 |
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry; |
40 | 39 |
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory; |
... | ... | |
43 | 42 |
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory; |
44 | 43 |
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory; |
45 | 44 |
import org.gvsig.raster.lib.legend.api.RasterLegendLocator; |
46 |
import org.gvsig.tools.ToolsLocator; |
|
47 | 45 |
import org.gvsig.tools.library.AbstractLibrary; |
48 | 46 |
import org.gvsig.tools.library.LibraryException; |
49 | 47 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
50 |
import org.gvsig.tools.persistence.PersistenceManager;
|
|
48 |
import org.gvsig.tools.util.Callable;
|
|
51 | 49 |
import org.gvsig.tools.util.Caller; |
52 | 50 |
import org.gvsig.tools.util.impl.DefaultCaller; |
53 | 51 |
|
54 | 52 |
/** |
55 | 53 |
* Library for the MapContext library API. |
56 |
* @author jmvivo |
|
57 | 54 |
*/ |
58 | 55 |
public class MapContextLibrary extends AbstractLibrary { |
59 |
final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class); |
|
60 | 56 |
|
57 |
final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class); |
|
58 |
|
|
59 |
@Override |
|
61 | 60 |
public void doRegistration() { |
62 | 61 |
registerAsAPI(MapContextLibrary.class); |
63 | 62 |
require(DALLibrary.class); |
64 | 63 |
require(CompatLibrary.class); |
65 | 64 |
} |
66 | 65 |
|
67 |
protected void doInitialize() throws LibraryException { |
|
68 |
LayerFactory.getInstance().registerLayerToUseForStore( |
|
69 |
FeatureStore.class, FLyrVect.class); |
|
70 |
} |
|
66 |
@Override |
|
67 |
protected void doInitialize() throws LibraryException { |
|
68 |
} |
|
71 | 69 |
|
72 |
protected void doPostInitialize() throws LibraryException { |
|
73 |
Caller caller = new DefaultCaller(); |
|
70 |
@Override |
|
71 |
protected void doPostInitialize() throws LibraryException { |
|
72 |
Caller caller = new DefaultCaller(); |
|
74 | 73 |
|
75 |
MapContextManager manager = MapContextLocator.getMapContextManager();
|
|
74 |
MapContextManager manager = MapContextLocator.getMapContextManager(); |
|
76 | 75 |
|
77 |
if (manager == null) {
|
|
78 |
throw new ReferenceNotRegisteredException(
|
|
79 |
MapContextLocator.MAPCONTEXT_MANAGER_NAME,
|
|
80 |
MapContextLocator.getInstance());
|
|
81 |
}
|
|
76 |
if (manager == null) { |
|
77 |
throw new ReferenceNotRegisteredException( |
|
78 |
MapContextLocator.MAPCONTEXT_MANAGER_NAME, |
|
79 |
MapContextLocator.getInstance()); |
|
80 |
} |
|
82 | 81 |
|
83 |
caller.add( new FLyrDefault.RegisterMetadata() ); |
|
84 |
caller.add( new DefaultMapContextDrawer.RegisterMapContextDrawer() ); |
|
82 |
caller.add(new RegisterDefaultVectorialLayer()); |
|
83 |
caller.add(new FLyrDefault.RegisterMetadata()); |
|
84 |
caller.add(new DefaultMapContextDrawer.RegisterMapContextDrawer()); |
|
85 | 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() );
|
|
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 | 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() );
|
|
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 | 101 |
|
102 |
if( !caller.call() ) {
|
|
103 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions());
|
|
104 |
}
|
|
102 |
if (!caller.call()) {
|
|
103 |
throw new LibraryException(MapContextLibrary.class, caller.getExceptions()); |
|
104 |
} |
|
105 | 105 |
|
106 |
// Validate there is any implementation registered.
|
|
107 |
if (!RasterLegendLocator.getInstance().exists(
|
|
106 |
// Validate there is any implementation registered. |
|
107 |
if (!RasterLegendLocator.getInstance().exists( |
|
108 | 108 |
RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME)) { |
109 |
throw new ReferenceNotRegisteredException(
|
|
109 |
throw new ReferenceNotRegisteredException( |
|
110 | 110 |
RasterLegendLocator.RASTER_LEGEND_MANAGER_NAME, RasterLegendLocator.getInstance()); |
111 |
}
|
|
111 |
} |
|
112 | 112 |
|
113 |
} |
|
113 | 114 |
|
114 |
}
|
|
115 |
private static class RegisterDefaultVectorialLayer implements Callable {
|
|
115 | 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 |
} |
|
116 | 125 |
} |
Also available in: Unified diff