341 |
341 |
if (bDrawShapes) {
|
342 |
342 |
boolean cacheFeatures = isSpatialCacheEnabled();
|
343 |
343 |
SpatialCache cache = null;
|
344 |
|
if (cacheFeatures) {
|
345 |
|
getSpatialCache().clearAll();
|
346 |
|
cache = getSpatialCache();
|
347 |
|
}
|
|
344 |
if (cacheFeatures) {
|
|
345 |
getSpatialCache().clearAll();
|
|
346 |
cache = getSpatialCache();
|
|
347 |
}
|
348 |
348 |
|
349 |
349 |
try {
|
350 |
350 |
ArrayList<String> fieldList = new ArrayList<String>();
|
... | ... | |
403 |
403 |
|
404 |
404 |
if (cacheFeatures) {
|
405 |
405 |
if (cache.getMaxFeatures() >= cache.size()) {
|
406 |
|
// already reprojected
|
407 |
|
cache.insert(geom.getBounds2D(), geom);
|
408 |
|
}
|
|
406 |
// already reprojected
|
|
407 |
cache.insert(geom.getBounds2D(), geom);
|
|
408 |
}
|
409 |
409 |
}
|
410 |
410 |
|
411 |
411 |
// retrieve the symbol associated to such feature
|
... | ... | |
423 |
423 |
}
|
424 |
424 |
if (selectionIndex!=-1) {
|
425 |
425 |
if (selectionSupport.isSelected(selectionIndex)) {
|
426 |
|
sym = sym.getSymbolForSelection();
|
427 |
|
}
|
428 |
|
}
|
|
426 |
sym = sym.getSymbolForSelection();
|
|
427 |
}
|
|
428 |
}
|
429 |
429 |
|
430 |
430 |
// Check if this symbol is sized with CartographicSupport
|
431 |
431 |
CartographicSupport csSym = null;
|
... | ... | |
437 |
437 |
|| sym instanceof CartographicSupport) {
|
438 |
438 |
|
439 |
439 |
// patch
|
440 |
|
if (!sym.getClass().equals(FSymbol.class)) {
|
441 |
|
csSym = (CartographicSupport) sym;
|
442 |
|
bDrawCartographicSupport = (csSym.getUnit() != -1);
|
443 |
|
}
|
|
440 |
if (!sym.getClass().equals(FSymbol.class)) {
|
|
441 |
csSym = (CartographicSupport) sym;
|
|
442 |
bDrawCartographicSupport = (csSym.getUnit() != -1);
|
|
443 |
}
|
444 |
444 |
}
|
445 |
445 |
|
446 |
446 |
int x = -1;
|
... | ... | |
450 |
450 |
// Check if size is a pixel
|
451 |
451 |
boolean onePoint = bDrawCartographicSupport ?
|
452 |
452 |
isOnePoint(g.getTransform(), viewPort, MapContext.getScreenDPI(), csSym, geom, xyCoords) :
|
453 |
|
isOnePoint(g.getTransform(), viewPort, geom, xyCoords);
|
|
453 |
isOnePoint(g.getTransform(), viewPort, geom, xyCoords);
|
454 |
454 |
|
455 |
|
// Avoid out of bounds exceptions
|
456 |
|
if (onePoint) {
|
457 |
|
x = xyCoords[0];
|
458 |
|
y = xyCoords[1];
|
459 |
|
if (x<0 || y<0 || x>= viewPort.getImageWidth() || y>=viewPort.getImageHeight()) continue;
|
460 |
|
}
|
|
455 |
// Avoid out of bounds exceptions
|
|
456 |
if (onePoint) {
|
|
457 |
x = xyCoords[0];
|
|
458 |
y = xyCoords[1];
|
|
459 |
if (x<0 || y<0 || x>= viewPort.getImageWidth() || y>=viewPort.getImageHeight()) continue;
|
|
460 |
}
|
461 |
461 |
|
462 |
|
if (useZSort) {
|
463 |
|
// Check if this symbol is a multilayer
|
464 |
|
if (sym instanceof IMultiLayerSymbol) {
|
465 |
|
// if so, treat each of its layers as a single symbol
|
466 |
|
// in its corresponding map level
|
467 |
|
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym;
|
468 |
|
for (int i = 0; !cancel.isCanceled() && i < mlSym.getLayerCount(); i++) {
|
469 |
|
ISymbol mySym = mlSym.getLayer(i);
|
470 |
|
int symbolLevel = zSort.getSymbolLevel(mySym);
|
|
462 |
if (useZSort) {
|
|
463 |
// Check if this symbol is a multilayer
|
|
464 |
if (sym instanceof IMultiLayerSymbol) {
|
|
465 |
// if so, treat each of its layers as a single symbol
|
|
466 |
// in its corresponding map level
|
|
467 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym;
|
|
468 |
for (int i = 0; !cancel.isCanceled() && i < mlSym.getLayerCount(); i++) {
|
|
469 |
ISymbol mySym = mlSym.getLayer(i);
|
|
470 |
int symbolLevel = zSort.getSymbolLevel(mySym);
|
471 |
471 |
|
472 |
|
if (symbolLevel == -1) {
|
473 |
|
/* an error occured when managing symbol levels.
|
474 |
|
* some of the legend changed events regarding the
|
475 |
|
* symbols did not finish satisfactory and the legend
|
476 |
|
* is now inconsistent. For this drawing, it will finish
|
477 |
|
* as it was at the bottom (level 0) but, when done, the
|
478 |
|
* ZSort will be reset to avoid app crashes. This is
|
479 |
|
* a bug that has to be fixed.
|
480 |
|
*/
|
481 |
|
bSymbolLevelError = true;
|
482 |
|
symbolLevel=0;
|
483 |
|
}
|
|
472 |
if (symbolLevel == -1) {
|
|
473 |
/* an error occured when managing symbol levels.
|
|
474 |
* some of the legend changed events regarding the
|
|
475 |
* symbols did not finish satisfactory and the legend
|
|
476 |
* is now inconsistent. For this drawing, it will finish
|
|
477 |
* as it was at the bottom (level 0) but, when done, the
|
|
478 |
* ZSort will be reset to avoid app crashes. This is
|
|
479 |
* a bug that has to be fixed.
|
|
480 |
*/
|
|
481 |
bSymbolLevelError = true;
|
|
482 |
symbolLevel=0;
|
|
483 |
}
|
484 |
484 |
|
485 |
|
if (onePoint) {
|
486 |
|
if (x<0 || y<0 || x>= imageLevels[symbolLevel].getWidth() || y>=imageLevels[symbolLevel].getHeight()) continue;
|
487 |
|
imageLevels[symbolLevel].setRGB(x, y, mySym.getOnePointRgb());
|
488 |
|
} else {
|
489 |
|
if (!bDrawCartographicSupport) {
|
490 |
|
geom.drawInts(graphics[symbolLevel], viewPort, mySym, cancel);
|
491 |
|
} else {
|
492 |
|
geom.drawInts(graphics[symbolLevel], viewPort, dpi, (CartographicSupport) mySym, cancel);
|
493 |
|
}
|
494 |
|
}
|
495 |
|
}
|
496 |
|
} else {
|
497 |
|
// else, just draw the symbol in its level
|
498 |
|
if (!bDrawCartographicSupport) {
|
499 |
|
geom.drawInts(graphics[zSort.getSymbolLevel(sym)], viewPort, sym, cancel);
|
500 |
|
} else {
|
501 |
|
geom.drawInts(graphics[zSort.getSymbolLevel(sym)], viewPort, dpi, (CartographicSupport) csSym, cancel);
|
502 |
|
}
|
503 |
|
}
|
|
485 |
if (onePoint) {
|
|
486 |
if (x<0 || y<0 || x>= imageLevels[symbolLevel].getWidth() || y>=imageLevels[symbolLevel].getHeight()) continue;
|
|
487 |
imageLevels[symbolLevel].setRGB(x, y, mySym.getOnePointRgb());
|
|
488 |
} else {
|
|
489 |
if (!bDrawCartographicSupport) {
|
|
490 |
geom.drawInts(graphics[symbolLevel], viewPort, mySym, cancel);
|
|
491 |
} else {
|
|
492 |
geom.drawInts(graphics[symbolLevel], viewPort, dpi, (CartographicSupport) mySym, cancel);
|
|
493 |
}
|
|
494 |
}
|
|
495 |
}
|
|
496 |
} else {
|
|
497 |
// else, just draw the symbol in its level
|
|
498 |
int symbolLevel = zSort.getSymbolLevel(sym);
|
|
499 |
if (symbolLevel == -1) {
|
|
500 |
/* an error occured when managing symbol levels.
|
|
501 |
* some of the legend changed events regarding the
|
|
502 |
* symbols did not finish satisfactory and the legend
|
|
503 |
* is now inconsistent. For this drawing, it will finish
|
|
504 |
* as it was at the bottom (level 0). This is
|
|
505 |
* a bug that has to be fixed.
|
|
506 |
*/
|
|
507 |
// bSymbolLevelError = true;
|
|
508 |
symbolLevel=0;
|
|
509 |
}
|
504 |
510 |
|
505 |
|
// -- visual FX stuff
|
506 |
|
// Cuando el offset!=0 se est? dibujando sobre el Layout y por tanto no tiene que ejecutar el siguiente c?digo.
|
507 |
|
if (offset.getX()==0 && offset.getY()==0)
|
508 |
|
if ((System.currentTimeMillis() - time) > screenRefreshDelay) {
|
509 |
|
virtualBim = new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_ARGB);
|
510 |
|
virtualGraphics = virtualBim.createGraphics();
|
511 |
|
virtualGraphics.drawImage(image,0,0, null);
|
512 |
|
for (int i = 0; !cancel.isCanceled() && i < imageLevels.length; i++) {
|
513 |
|
virtualGraphics.drawImage(imageLevels[i],0,0, null);
|
514 |
|
}
|
515 |
|
g.clearRect(0, 0, image.getWidth(), image.getHeight());
|
516 |
|
g.drawImage(virtualBim, 0, 0, null);
|
517 |
|
time = System.currentTimeMillis();
|
518 |
|
}
|
519 |
|
// -- end visual FX stuff
|
|
511 |
if (!bDrawCartographicSupport) {
|
|
512 |
geom.drawInts(graphics[symbolLevel], viewPort, sym, cancel);
|
|
513 |
} else {
|
|
514 |
geom.drawInts(graphics[symbolLevel], viewPort, dpi, (CartographicSupport) csSym, cancel);
|
|
515 |
}
|
|
516 |
}
|
520 |
517 |
|
521 |
|
} else {
|
522 |
|
// no ZSort, so there is only a map level, symbols are
|
523 |
|
// just drawn.
|
524 |
|
if (onePoint) {
|
525 |
|
if (x<0 || y<0 || x>= image.getWidth() || y>=image.getHeight()) continue;
|
526 |
|
image.setRGB(x, y, sym.getOnePointRgb());
|
527 |
|
} else {
|
528 |
|
if (!bDrawCartographicSupport) {
|
529 |
|
geom.drawInts(g, viewPort, sym, cancel);
|
530 |
|
} else {
|
531 |
|
geom.drawInts(g, viewPort, dpi, csSym, cancel);
|
532 |
|
}
|
533 |
|
}
|
534 |
|
}
|
|
518 |
// -- visual FX stuff
|
|
519 |
// Cuando el offset!=0 se est? dibujando sobre el Layout y por tanto no tiene que ejecutar el siguiente c?digo.
|
|
520 |
if (offset.getX()==0 && offset.getY()==0)
|
|
521 |
if ((System.currentTimeMillis() - time) > screenRefreshDelay) {
|
|
522 |
virtualBim = new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_ARGB);
|
|
523 |
virtualGraphics = virtualBim.createGraphics();
|
|
524 |
virtualGraphics.drawImage(image,0,0, null);
|
|
525 |
for (int i = 0; !cancel.isCanceled() && i < imageLevels.length; i++) {
|
|
526 |
virtualGraphics.drawImage(imageLevels[i],0,0, null);
|
|
527 |
}
|
|
528 |
g.clearRect(0, 0, image.getWidth(), image.getHeight());
|
|
529 |
g.drawImage(virtualBim, 0, 0, null);
|
|
530 |
time = System.currentTimeMillis();
|
|
531 |
}
|
|
532 |
// -- end visual FX stuff
|
|
533 |
|
|
534 |
} else {
|
|
535 |
// no ZSort, so there is only a map level, symbols are
|
|
536 |
// just drawn.
|
|
537 |
if (onePoint) {
|
|
538 |
if (x<0 || y<0 || x>= image.getWidth() || y>=image.getHeight()) continue;
|
|
539 |
image.setRGB(x, y, sym.getOnePointRgb());
|
|
540 |
} else {
|
|
541 |
if (!bDrawCartographicSupport) {
|
|
542 |
geom.drawInts(g, viewPort, sym, cancel);
|
|
543 |
} else {
|
|
544 |
geom.drawInts(g, viewPort, dpi, csSym, cancel);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
}
|
535 |
548 |
}
|
536 |
549 |
|
537 |
550 |
if (useZSort) {
|
538 |
551 |
g.drawImage(image, 0, 0, null);
|
539 |
|
g.translate(offset.getX(), offset.getY());
|
|
552 |
g.translate(offset.getX(), offset.getY());
|
540 |
553 |
for (int i = 0; !cancel.isCanceled() && i < imageLevels.length; i++) {
|
541 |
554 |
g.drawImage(imageLevels[i],0,0, null);
|
542 |
555 |
imageLevels[i] = null;
|
543 |
556 |
graphics[i] = null;
|
544 |
557 |
}
|
545 |
|
g.translate(-offset.getX(), -offset.getY());
|
|
558 |
g.translate(-offset.getX(), -offset.getY());
|
546 |
559 |
imageLevels = null;
|
547 |
560 |
graphics = null;
|
548 |
561 |
}
|