Revision 25953

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java
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
    			}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/ZSort.java
208 208
					}
209 209
				}
210 210
			} else {
211
//				if (mySymbol.equals(layer)) {
212
//					return matrix[symbols.get(layer)][0];
213
				 //Cuando la leyenda ha sufrido una clonaci?n, la comparaci?n de arriba no sirve.
214
				//FIXME: Pero esto no es del todo bueno.
215 211
				if (mySymbol.equals(layer)){
216 212
					return matrix[symbols.get(mySymbol)][0];
217 213
				}
......
325 321
	}
326 322

  
327 323
	public boolean valueChange(ValueLegendEvent e) {
328
		System.out.println("log ValueLegendEvent:"+e.getOldValue()+"->"+e.getNewValue());
329 324
		return false;
330 325
	}
331 326

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/AbstractClassifiedVectorLegend.java
44 44
/**
45 45
 * Abstract class that implements the interface for legends composed by
46 46
 * classified symbols.It will have two methods that will be executed
47
 * depending on the action that had been done with the legend (addition 
47
 * depending on the action that had been done with the legend (addition
48 48
 * of a new symbol or clear the legend).
49
 *  
49
 *
50 50
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
51 51
 */
52 52
public abstract class AbstractClassifiedVectorLegend extends AbstractLegend implements IClassifiedVectorLegend {
53 53
	private String[] fieldNames;
54 54
	private int[] fieldTypes;
55 55
	private ZSort zSort;
56
	
56

  
57 57
	/**
58 58
	 * Looks for a change in a classified symbol of a legend. To perform
59 59
	 * it, the Array of LegendListeners is scaned and when the corresponding
......
61 61
	 * @param event
62 62
	 */
63 63
	public void fireClassifiedSymbolChangeEvent(SymbolLegendEvent event) {
64
		for (int i = 0; i < getListeners().length; i++) {
65
			getListeners()[i].symbolChanged(event);
64
		LegendContentsChangedListener[] listeners = getListeners();
65
		for (int i = 0; i < listeners.length; i++) {
66
			listeners[i].symbolChanged(event);
66 67
		}
67 68
	}
68 69
	/**
......
92 93
	public void setClassifyingFieldTypes(int[] fieldTypes) {
93 94
		this.fieldTypes =  fieldTypes;
94 95
	}
95
	
96

  
96 97
	public ZSort getZSort() {
97 98
		return zSort;
98 99
	}
99
	
100

  
100 101
	public void setZSort(ZSort zSort) {
101 102
		if (zSort == null) {
102 103
			removeLegendListener(this.zSort);
......
104 105
		this.zSort = zSort;
105 106
		addLegendListener(zSort);
106 107
	}
107
	
108
	
108

  
109

  
109 110
	public boolean isSuitableForShapeType(int shapeType) {
110 111
		return getShapeType() == shapeType;
111 112
	}

Also available in: Unified diff