svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / impl / DefaultMapContextManager.java @ 34303
History | View | Annotate | Download (18 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {DiSiD Technologies} {Create Manager to register MapContextDrawer implementation}
|
26 |
*/
|
27 |
package org.gvsig.fmap.mapcontext.impl; |
28 |
|
29 |
import java.awt.Color; |
30 |
import java.awt.Font; |
31 |
import java.io.File; |
32 |
import java.io.FileFilter; |
33 |
import java.io.FileInputStream; |
34 |
import java.lang.reflect.Method; |
35 |
import java.util.Collections; |
36 |
import java.util.HashMap; |
37 |
import java.util.Map; |
38 |
import java.util.Random; |
39 |
|
40 |
import org.cresques.cts.IProjection; |
41 |
import org.slf4j.Logger; |
42 |
import org.slf4j.LoggerFactory; |
43 |
|
44 |
import org.gvsig.fmap.dal.DataServerExplorer; |
45 |
import org.gvsig.fmap.dal.DataStore; |
46 |
import org.gvsig.fmap.dal.DataStoreParameters; |
47 |
import org.gvsig.fmap.dal.exception.DataException; |
48 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
49 |
import org.gvsig.fmap.dal.feature.FeatureType; |
50 |
import org.gvsig.fmap.mapcontext.MapContextDrawer; |
51 |
import org.gvsig.fmap.mapcontext.MapContextException; |
52 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
53 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
54 |
import org.gvsig.fmap.mapcontext.MapContextRuntimeException; |
55 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
56 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
57 |
import org.gvsig.fmap.mapcontext.layers.LayerFactory; |
58 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
59 |
import org.gvsig.fmap.mapcontext.layers.vectorial.impl.DefaultGraphicLayer; |
60 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
61 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
62 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
63 |
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendReader; |
64 |
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter; |
65 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
67 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol; |
68 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolException; |
69 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
70 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences; |
71 |
import org.gvsig.tools.ToolsLocator; |
72 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
73 |
import org.gvsig.tools.dynobject.exception.DynMethodNotSupportedException; |
74 |
import org.gvsig.tools.persistence.PersistenceManager; |
75 |
import org.gvsig.tools.persistence.PersistentState; |
76 |
|
77 |
/**
|
78 |
* Default implementation of the {@link MapContextManager}.
|
79 |
*
|
80 |
* @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
|
81 |
*/
|
82 |
public class DefaultMapContextManager implements MapContextManager { |
83 |
|
84 |
private static final Logger LOG = LoggerFactory |
85 |
.getLogger(DefaultMapContextManager.class); |
86 |
|
87 |
private Class drawerClazz = DefaultMapContextDrawer.class; |
88 |
|
89 |
private Map legends = Collections.synchronizedMap(new HashMap()); |
90 |
|
91 |
private Map legendReaders = Collections.synchronizedMap(new HashMap()); |
92 |
|
93 |
private Map legendWriters = Collections.synchronizedMap(new HashMap()); |
94 |
|
95 |
private String defaultVectorLegend; |
96 |
|
97 |
public SymbolManager getSymbolManager() {
|
98 |
return MapContextLocator.getSymbolManager();
|
99 |
} |
100 |
|
101 |
private SymbolPreferences getSymbolPreferences() {
|
102 |
return getSymbolManager().getSymbolPreferences();
|
103 |
} |
104 |
|
105 |
public String getSymbolLibraryPath() { |
106 |
return getSymbolPreferences().getSymbolLibraryPath();
|
107 |
} |
108 |
|
109 |
public void setSymbolLibraryPath(String symbolLibraryPath) { |
110 |
getSymbolPreferences().setSymbolLibraryPath(symbolLibraryPath); |
111 |
} |
112 |
|
113 |
public void resetSymbolLibraryPath() { |
114 |
getSymbolPreferences().resetSymbolLibraryPath(); |
115 |
} |
116 |
|
117 |
public Color getDefaultSymbolColor() { |
118 |
return getSymbolPreferences().getDefaultSymbolColor();
|
119 |
} |
120 |
|
121 |
public Color getDefaultSymbolFillColor() { |
122 |
return getSymbolPreferences().getDefaultSymbolFillColor();
|
123 |
} |
124 |
|
125 |
public Font getDefaultSymbolFont() { |
126 |
return getSymbolPreferences().getDefaultSymbolFont();
|
127 |
} |
128 |
|
129 |
public String getSymbolFileExtension() { |
130 |
return getSymbolPreferences().getSymbolFileExtension();
|
131 |
} |
132 |
|
133 |
public boolean isDefaultSymbolFillColorAleatory() { |
134 |
return getSymbolPreferences().isDefaultSymbolFillColorAleatory();
|
135 |
} |
136 |
|
137 |
public void resetDefaultSymbolColor() { |
138 |
getSymbolPreferences().resetDefaultSymbolColor(); |
139 |
} |
140 |
|
141 |
public void resetDefaultSymbolFillColor() { |
142 |
getSymbolPreferences().resetDefaultSymbolFillColor(); |
143 |
} |
144 |
|
145 |
public void resetDefaultSymbolFillColorAleatory() { |
146 |
getSymbolPreferences().resetDefaultSymbolFillColorAleatory(); |
147 |
} |
148 |
|
149 |
public void resetDefaultSymbolFont() { |
150 |
getSymbolPreferences().resetDefaultSymbolFont(); |
151 |
} |
152 |
|
153 |
public void setDefaultSymbolColor(Color defaultSymbolColor) { |
154 |
getSymbolPreferences().setDefaultSymbolColor(defaultSymbolColor); |
155 |
} |
156 |
|
157 |
public void setDefaultSymbolFillColor(Color defaultSymbolFillColor) { |
158 |
getSymbolPreferences().setDefaultSymbolFillColor(defaultSymbolFillColor); |
159 |
} |
160 |
|
161 |
public void setDefaultSymbolFillColorAleatory( |
162 |
boolean defaultSymbolFillColorAleatory) {
|
163 |
getSymbolPreferences().setDefaultSymbolFillColorAleatory( |
164 |
defaultSymbolFillColorAleatory); |
165 |
} |
166 |
|
167 |
public void setDefaultSymbolFont(Font defaultSymbolFont) { |
168 |
getSymbolPreferences().setDefaultSymbolFont(defaultSymbolFont); |
169 |
} |
170 |
|
171 |
public void setSymbolFileExtension(String extension) { |
172 |
getSymbolPreferences().setSymbolFileExtension(extension); |
173 |
} |
174 |
|
175 |
public int getDefaultCartographicSupportMeasureUnit() { |
176 |
return getSymbolPreferences().getDefaultCartographicSupportMeasureUnit();
|
177 |
} |
178 |
|
179 |
public void setDefaultCartographicSupportMeasureUnit( |
180 |
int defaultCartographicSupportMeasureUnit) {
|
181 |
getSymbolPreferences().setDefaultCartographicSupportMeasureUnit( |
182 |
defaultCartographicSupportMeasureUnit); |
183 |
} |
184 |
|
185 |
public int getDefaultCartographicSupportReferenceSystem() { |
186 |
return getSymbolPreferences().getDefaultCartographicSupportReferenceSystem();
|
187 |
} |
188 |
|
189 |
public void setDefaultCartographicSupportReferenceSystem( |
190 |
int defaultCartographicSupportReferenceSystem) {
|
191 |
getSymbolPreferences().setDefaultCartographicSupportReferenceSystem( |
192 |
defaultCartographicSupportReferenceSystem); |
193 |
} |
194 |
|
195 |
public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz) |
196 |
throws MapContextException {
|
197 |
return createMapContextDrawerInstance(drawerClazz, "NONE"); |
198 |
} |
199 |
|
200 |
public MapContextDrawer createDefaultMapContextDrawerInstance()
|
201 |
throws MapContextException {
|
202 |
|
203 |
return createMapContextDrawerInstance(drawerClazz, "default"); |
204 |
} |
205 |
|
206 |
private MapContextDrawer createMapContextDrawerInstance(Class drawerClazz, |
207 |
String name) throws RegisteredClassInstantiationException { |
208 |
try {
|
209 |
return (MapContextDrawer) drawerClazz.newInstance();
|
210 |
} catch (Exception ex) { |
211 |
throw new RegisteredClassInstantiationException( |
212 |
MapContextDrawer.class, drawerClazz, name, ex); |
213 |
} |
214 |
} |
215 |
|
216 |
public void setDefaultMapContextDrawer(Class drawerClazz) |
217 |
throws MapContextException {
|
218 |
|
219 |
validateMapContextDrawer(drawerClazz); |
220 |
this.drawerClazz = drawerClazz;
|
221 |
} |
222 |
|
223 |
public void validateMapContextDrawer(Class drawerClazz) |
224 |
throws MapContextException {
|
225 |
if (!MapContextDrawer.class.isAssignableFrom(drawerClazz)) {
|
226 |
throw new InvalidRegisteredClassException(MapContextDrawer.class, |
227 |
drawerClazz, "UNKNOWN");
|
228 |
} |
229 |
} |
230 |
|
231 |
public GraphicLayer createGraphicsLayer(IProjection projection) {
|
232 |
DefaultGraphicLayer layer = new DefaultGraphicLayer();
|
233 |
try {
|
234 |
layer.initialize(projection); |
235 |
layer.setLegend((IVectorLegend)createLegend(IVectorialUniqueValueLegend.LEGEND_NAME)); |
236 |
} catch (Exception e) { |
237 |
LOG.error("Error initializing the graphics layer", e);
|
238 |
} |
239 |
return layer;
|
240 |
} |
241 |
|
242 |
public String getDefaultVectorLegend() { |
243 |
return defaultVectorLegend;
|
244 |
} |
245 |
|
246 |
public void setDefaultVectorLegend(String defaultVectorLegend) { |
247 |
this.defaultVectorLegend = defaultVectorLegend;
|
248 |
} |
249 |
|
250 |
public void registerLegend(String legendName, Class legendClass) |
251 |
throws MapContextRuntimeException {
|
252 |
|
253 |
if (legendClass == null || !ILegend.class.isAssignableFrom(legendClass)) { |
254 |
throw new InvalidRegisteredClassException(ILegend.class, |
255 |
legendClass, legendName); |
256 |
} |
257 |
|
258 |
legends.put(legendName, legendClass); |
259 |
} |
260 |
|
261 |
public ILegend createLegend(String legendName) |
262 |
throws MapContextRuntimeException {
|
263 |
Class legendClass = (Class) legends.get(legendName); |
264 |
|
265 |
if (legendClass != null) { |
266 |
try {
|
267 |
return (ILegend) legendClass.newInstance();
|
268 |
} catch (InstantiationException e) { |
269 |
throw new RegisteredClassInstantiationException(ILegend.class, |
270 |
legendClass, legendName, e); |
271 |
} catch (IllegalAccessException e) { |
272 |
throw new RegisteredClassInstantiationException(ILegend.class, |
273 |
legendClass, legendName, e); |
274 |
} |
275 |
} |
276 |
return null; |
277 |
} |
278 |
|
279 |
public IVectorLegend createDefaultVectorLegend(int shapeType) |
280 |
throws MapContextRuntimeException {
|
281 |
try {
|
282 |
Random rand = new Random(); |
283 |
|
284 |
int numreg = rand.nextInt(255 / 2); |
285 |
double div = (1 - rand.nextDouble() * 0.66) * 0.9; |
286 |
Color randomColor = new Color(((int) (255 * div + (numreg * rand |
287 |
.nextDouble()))) % 255, ((int) (255 * div + (numreg * rand |
288 |
.nextDouble()))) % 255, ((int) (255 * div + (numreg * rand |
289 |
.nextDouble()))) % 255);
|
290 |
IVectorLegend legend = (IVectorLegend) createLegend(getDefaultVectorLegend()); |
291 |
if( legend == null ) { |
292 |
return null; |
293 |
} |
294 |
ISymbol defaultSymbol = |
295 |
getSymbolManager().createSymbol(shapeType, randomColor); |
296 |
legend.setDefaultSymbol(defaultSymbol); |
297 |
legend.setShapeType(shapeType); |
298 |
return legend;
|
299 |
} catch(Exception e) { |
300 |
throw new MapContextRuntimeException(e); |
301 |
} |
302 |
} |
303 |
|
304 |
public void registerLegendReader(String format, Class readerClass) |
305 |
throws MapContextRuntimeException {
|
306 |
if (readerClass == null |
307 |
|| !ILegendReader.class.isAssignableFrom(readerClass)) { |
308 |
throw new InvalidRegisteredClassException(ILegendReader.class, |
309 |
readerClass, format); |
310 |
} |
311 |
|
312 |
legendReaders.put(format, readerClass); |
313 |
} |
314 |
|
315 |
public ILegendReader createLegendReader(String format) |
316 |
throws MapContextRuntimeException {
|
317 |
Class legendReaderClazz = (Class) legendReaders.get(format); |
318 |
|
319 |
if (legendReaderClazz != null) { |
320 |
try {
|
321 |
return (ILegendReader) legendReaderClazz.newInstance();
|
322 |
} catch (InstantiationException e) { |
323 |
throw new RegisteredClassInstantiationException( |
324 |
ILegendReader.class, legendReaderClazz, format, e); |
325 |
} catch (IllegalAccessException e) { |
326 |
throw new RegisteredClassInstantiationException( |
327 |
ILegendReader.class, legendReaderClazz, format, e); |
328 |
} |
329 |
} |
330 |
return null; |
331 |
} |
332 |
|
333 |
public void registerLegendWriter(String legendName, String format, |
334 |
Class writerClass) throws MapContextRuntimeException { |
335 |
if (writerClass == null |
336 |
|| !ILegendWriter.class.isAssignableFrom(writerClass)) { |
337 |
throw new InvalidRegisteredClassException(ILegendWriter.class, |
338 |
writerClass, format.concat("-").concat(legendName));
|
339 |
} |
340 |
|
341 |
Map legendFormatWriters = (Map) legendWriters.get(format); |
342 |
|
343 |
synchronized (legendWriters) {
|
344 |
if (legendFormatWriters == null) { |
345 |
legendFormatWriters = Collections
|
346 |
.synchronizedMap(new HashMap()); |
347 |
legendWriters.put(format, legendFormatWriters); |
348 |
} |
349 |
} |
350 |
|
351 |
legendFormatWriters.put(legendName, writerClass); |
352 |
} |
353 |
|
354 |
public ILegendWriter createLegendWriter(String legendName, String format) |
355 |
throws MapContextRuntimeException {
|
356 |
Map legendFormatWriters = getLegendWritersForFormat(format);
|
357 |
|
358 |
if (legendFormatWriters != null) { |
359 |
Class legendWriterClazz = (Class) legendFormatWriters |
360 |
.get(legendName); |
361 |
|
362 |
if (legendWriterClazz != null) { |
363 |
try {
|
364 |
return (ILegendWriter) legendWriterClazz.newInstance();
|
365 |
} catch (InstantiationException e) { |
366 |
throw new RegisteredClassInstantiationException( |
367 |
ILegendWriter.class, legendWriterClazz, format |
368 |
.concat("-").concat(legendName), e);
|
369 |
} catch (IllegalAccessException e) { |
370 |
throw new RegisteredClassInstantiationException( |
371 |
ILegendWriter.class, legendWriterClazz, format |
372 |
.concat("-").concat(legendName), e);
|
373 |
} |
374 |
} |
375 |
} |
376 |
return null; |
377 |
} |
378 |
|
379 |
private Map getLegendWritersForFormat(String format) { |
380 |
return (Map) legendWriters.get(format); |
381 |
} |
382 |
|
383 |
public IMultiLayerSymbol createMultiLayerSymbol(int shapeType) |
384 |
throws MapContextRuntimeException {
|
385 |
return getSymbolManager().createMultiLayerSymbol(shapeType);
|
386 |
} |
387 |
|
388 |
public IMultiLayerSymbol createMultiLayerSymbol(String symbolName) |
389 |
throws MapContextRuntimeException {
|
390 |
return getSymbolManager().createMultiLayerSymbol(symbolName);
|
391 |
} |
392 |
|
393 |
public ISymbol createSymbol(int shapeType, Color color) |
394 |
throws MapContextRuntimeException {
|
395 |
return getSymbolManager().createSymbol(shapeType, color);
|
396 |
} |
397 |
|
398 |
public ISymbol createSymbol(int shapeType) |
399 |
throws MapContextRuntimeException {
|
400 |
return getSymbolManager().createSymbol(shapeType);
|
401 |
} |
402 |
|
403 |
public ISymbol createSymbol(String symbolName, Color color) |
404 |
throws MapContextRuntimeException {
|
405 |
return getSymbolManager().createSymbol(symbolName, color);
|
406 |
} |
407 |
|
408 |
public ISymbol createSymbol(String symbolName) |
409 |
throws MapContextRuntimeException {
|
410 |
return getSymbolManager().createSymbol(symbolName);
|
411 |
} |
412 |
|
413 |
public IWarningSymbol getWarningSymbol(String message, String symbolDesc, |
414 |
int symbolDrawExceptionType) throws MapContextRuntimeException { |
415 |
return getSymbolManager().getWarningSymbol(message, symbolDesc,
|
416 |
symbolDrawExceptionType); |
417 |
} |
418 |
|
419 |
public ISymbol[] loadSymbols(File folder, FileFilter filter) |
420 |
throws SymbolException {
|
421 |
return getSymbolManager().loadSymbols(folder, filter);
|
422 |
} |
423 |
|
424 |
public ISymbol[] loadSymbols(File folder) throws SymbolException { |
425 |
return getSymbolManager().loadSymbols(folder);
|
426 |
} |
427 |
|
428 |
public void registerMultiLayerSymbol(String symbolName, Class symbolClass) |
429 |
throws MapContextRuntimeException {
|
430 |
getSymbolManager().registerMultiLayerSymbol(symbolName, symbolClass); |
431 |
} |
432 |
|
433 |
public void registerMultiLayerSymbol(String symbolName, int[] shapeTypes, |
434 |
Class symbolClass) throws MapContextRuntimeException { |
435 |
getSymbolManager().registerMultiLayerSymbol(symbolName, shapeTypes, |
436 |
symbolClass); |
437 |
} |
438 |
|
439 |
public void registerSymbol(String symbolName, Class symbolClass) |
440 |
throws MapContextRuntimeException {
|
441 |
getSymbolManager().registerSymbol(symbolName, symbolClass); |
442 |
} |
443 |
|
444 |
public void registerSymbol(String symbolName, int[] shapeTypes, |
445 |
Class symbolClass) throws MapContextException { |
446 |
getSymbolManager().registerSymbol(symbolName, shapeTypes, symbolClass); |
447 |
} |
448 |
|
449 |
public void saveSymbol(ISymbol symbol, String fileName, File folder, |
450 |
boolean overwrite) throws SymbolException { |
451 |
getSymbolManager().saveSymbol(symbol, fileName, folder, overwrite); |
452 |
} |
453 |
|
454 |
public void saveSymbol(ISymbol symbol, String fileName, File folder) |
455 |
throws SymbolException {
|
456 |
getSymbolManager().saveSymbol(symbol, fileName, folder); |
457 |
} |
458 |
|
459 |
public FLayer createLayer(String layerName, DataStoreParameters parameters) |
460 |
throws LoadLayerException {
|
461 |
return LayerFactory.getInstance().createLayer(layerName, parameters);
|
462 |
} |
463 |
|
464 |
public FLayer createLayer(String layerName, DataStore store) |
465 |
throws LoadLayerException {
|
466 |
return LayerFactory.getInstance().createLayer(layerName, store);
|
467 |
} |
468 |
|
469 |
public ILegend getLegend(DataStore dataStore) {
|
470 |
ILegend legend = null;
|
471 |
|
472 |
//Loading the legend from a store based on file
|
473 |
try {
|
474 |
// This access by reflection is done because the libFMap_dalfile project
|
475 |
// has to be divided in several projects. The commented code is the fine
|
476 |
// code whereas the used code has to be deleted.
|
477 |
//
|
478 |
// if (dataStore.getExplorer() instanceof FilesystemServerExplorer){
|
479 |
// File file = ((FilesystemServerExplorer)dataStore.getExplorer()).getResourcePath(dataStore, "gvl");
|
480 |
// if ((file != null) && (file.exists())){
|
481 |
// PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager();
|
482 |
// PersistentState persistentState = persistenceManager.loadState(new FileInputStream(file));
|
483 |
// legend = (ILegend)persistenceManager.create(persistentState);
|
484 |
// }
|
485 |
// }
|
486 |
DataServerExplorer dataServerExplorer = dataStore.getExplorer(); |
487 |
Class[] args = new Class[2]; |
488 |
args[0] = DataStore.class;
|
489 |
args[1] = String.class; |
490 |
Method method = dataStore.getExplorer().getClass().getMethod("getResourcePath", args); |
491 |
if (method != null){ |
492 |
Object[] params = new Object[2]; |
493 |
params[0] = dataStore;
|
494 |
params[1] = "gvl"; |
495 |
File file = (File)method.invoke(dataServerExplorer, params); |
496 |
if ((file != null) && (file.exists())){ |
497 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
498 |
PersistentState persistentState = persistenceManager.loadState(new FileInputStream(file)); |
499 |
legend = (ILegend)persistenceManager.create(persistentState); |
500 |
} |
501 |
} |
502 |
|
503 |
} catch (Exception e) { |
504 |
LOG.info("Can't load the specific legend provided by the explorer.", e);
|
505 |
} |
506 |
|
507 |
//If the legend is null, next option is to check if the store has the getLegend method
|
508 |
if (legend == null){ |
509 |
try {
|
510 |
legend = (IVectorLegend) dataStore.invokeDynMethod( |
511 |
"getLegend", null); |
512 |
} catch (DynMethodNotSupportedException e) {
|
513 |
LOG.info("Can't load the specific legend provided for the store {}.", dataStore.getName(), e);
|
514 |
} catch (DynMethodException e) {
|
515 |
LOG.error("Can't load the specific legend provided for the store {}.", dataStore.getName(), e);
|
516 |
} |
517 |
} |
518 |
|
519 |
//If legend is null, last step is just try to create the legend by default
|
520 |
if( legend == null ) { |
521 |
FeatureType featureType; |
522 |
try {
|
523 |
featureType = (((FeatureStore)dataStore).getDefaultFeatureType()); |
524 |
int indexGeom = featureType.getDefaultGeometryAttributeIndex();
|
525 |
int typeShape = featureType.getAttributeDescriptor(indexGeom).getGeometryType();
|
526 |
legend = MapContextLocator.getMapContextManager().createDefaultVectorLegend(typeShape); |
527 |
} catch (DataException e) {
|
528 |
LOG.error("Error getting the default feature type", e);
|
529 |
} |
530 |
} |
531 |
|
532 |
return legend;
|
533 |
} |
534 |
|
535 |
} |