Revision 37204 branches/dal_time_support/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/impl/DefaultMapContextManager.java
DefaultMapContextManager.java | ||
---|---|---|
35 | 35 |
import java.util.Collections; |
36 | 36 |
import java.util.HashMap; |
37 | 37 |
import java.util.Map; |
38 |
import java.util.Random; |
|
39 | 38 |
|
40 | 39 |
import org.cresques.cts.IProjection; |
41 | 40 |
import org.slf4j.Logger; |
... | ... | |
279 | 278 |
public IVectorLegend createDefaultVectorLegend(int shapeType) |
280 | 279 |
throws MapContextRuntimeException { |
281 | 280 |
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); |
|
281 |
// Create legend |
|
282 |
IVectorLegend legend = |
|
283 |
(IVectorLegend) createLegend(getDefaultVectorLegend()); |
|
284 |
if (legend == null) { |
|
285 |
return null; |
|
286 |
} |
|
287 |
// Set legend values |
|
288 |
legend.setDefaultSymbol(getSymbolManager().createSymbol(shapeType)); |
|
297 | 289 |
legend.setShapeType(shapeType); |
298 | 290 |
return legend; |
299 | 291 |
} catch(Exception e) { |
... | ... | |
470 | 462 |
ILegend legend = null; |
471 | 463 |
|
472 | 464 |
//Loading the legend from a store based on file |
465 |
DataServerExplorer dataServerExplorer = null; |
|
473 | 466 |
try { |
474 | 467 |
// This access by reflection is done because the libFMap_dalfile project |
475 | 468 |
// has to be divided in several projects. The commented code is the fine |
... | ... | |
483 | 476 |
// legend = (ILegend)persistenceManager.create(persistentState); |
484 | 477 |
// } |
485 | 478 |
// } |
486 |
DataServerExplorer dataServerExplorer = dataStore.getExplorer();
|
|
479 |
dataServerExplorer = dataStore.getExplorer();
|
|
487 | 480 |
Class[] args = new Class[2]; |
488 | 481 |
args[0] = DataStore.class; |
489 | 482 |
args[1] = String.class; |
... | ... | |
501 | 494 |
} |
502 | 495 |
|
503 | 496 |
} catch (Exception e) { |
504 |
LOG.info("Can't load the specific legend provided by the explorer.", e); |
|
497 |
LOG.debug( |
|
498 |
"Can't load the specific legend provided by the explorer " |
|
499 |
+ dataServerExplorer, e); |
|
505 | 500 |
} |
506 | 501 |
|
507 | 502 |
//If the legend is null, next option is to check if the store has the getLegend method |
... | ... | |
510 | 505 |
legend = (IVectorLegend) dataStore.invokeDynMethod( |
511 | 506 |
"getLegend", null); |
512 | 507 |
} catch (DynMethodNotSupportedException e) { |
513 |
LOG.info("This store {} can not provide a legend.", dataStore.getName(), e); |
|
508 |
LOG.debug("This store {} does not provide a legend.", |
|
509 |
dataStore.getName()); |
|
514 | 510 |
} catch (DynMethodException e) { |
515 |
LOG.error("Can't load the specific legend provided for the store {}.", dataStore.getName(), e); |
|
511 |
LOG.error( |
|
512 |
"Can't load the specific legend provided for the store {}.", |
|
513 |
dataStore.getName(), e); |
|
516 | 514 |
} |
517 | 515 |
} |
518 | 516 |
|
Also available in: Unified diff