Revision 38639 branches/v2_0_0_prep/libraries/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/VectorialUniqueValueLegend.java

View differences:

VectorialUniqueValueLegend.java
39 39
import org.gvsig.fmap.mapcontext.MapContextManager;
40 40
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend;
41 41
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent;
42
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
42 43
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
43 44
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
44 45
import org.gvsig.tools.ToolsLocator;
......
323 324
		}
324 325
		// Clone keys
325 326
		clone.keys = new ArrayList<Object>();
327
		
328
        // ====================================================
329
		// Temporarily remove listeners to prevent
330
		// cascade of notifications
331
		LegendContentsChangedListener[] list = this.getListeners();
332
		removeListeners(list);
333
        // ====================================================
326 334

  
327 335
		// Clone symbols
328 336
		if (symbols != null) {
......
337 345
				clone.addSymbol(entry.getKey(), symbolClone);
338 346
			}
339 347
		}
340

  
348
		
349
        // ====================================================
350
        // Restore listeners
351
        addListeners(list);
352
        // ====================================================
341 353
		return clone;
342 354
	}
343 355

  
344 356

  
345
	private Map<Object, ISymbol> createSymbolMap() {
357
    private void addListeners(LegendContentsChangedListener[] list) {
358
        int len = list.length;
359
        for (int i=0; i<len; i++) {
360
            addLegendListener(list[i]);
361
        }
362
    }
363

  
364
    private void removeListeners(LegendContentsChangedListener[] list) {
365
        int len = list.length;
366
        for (int i=0; i<len; i++) {
367
            removeLegendListener(list[i]);
368
        }
369
    }
370

  
371
    private Map<Object, ISymbol> createSymbolMap() {
346 372
		return new TreeMap<Object, ISymbol>(
347 373
				new Comparator<Object>() { 
348 374
					public int compare(Object o1, Object o2) {

Also available in: Unified diff