Revision 30121

View differences:

branches/v2_0_0_prep/extensions/org.gvsig.symbology/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractIntervalLegend.java
163 163
//	protected FeatureStore featureStore;
164 164
	protected int intervalType = NATURAL_INTERVALS;
165 165
	protected boolean useDefaultSymbol = false;
166
	
167
	private ISymbol nullIntervalSymbol = null;
166 168

  
167 169
	final static private Logger logger = LoggerFactory.getLogger(AbstractIntervalLegend.class);
168 170
	
169 171
	public void addSymbol(Object key, ISymbol symbol) {
170
		symbols.put(key, symbol);
171
		keys.add(key);
172
		if (key == null) {
173
			nullIntervalSymbol = symbol;
174
		}
175
		else {
176
			symbols.put(key, symbol);
177
			keys.add(key);
178
		}
172 179
		fireClassifiedSymbolChangeEvent(new SymbolLegendEvent(null, symbol));
173 180
	}
174 181

  
......
446 453
    public ISymbol getSymbolByInterval(IInterval key) {
447 454

  
448 455
		if (key == null){
449
			if (isUseDefaultSymbol()) {
456
			if (nullIntervalSymbol != null) {
457
				return nullIntervalSymbol;
458
			}
459
			else if (isUseDefaultSymbol()) {
450 460
				return defaultSymbol;
451 461
			}
452 462
			return null;
......
486 496
	}
487 497

  
488 498
	public ISymbol[] getSymbols() {
489
		return (ISymbol[]) symbols.values().toArray(new ISymbol[0]);
499
		ISymbol[] symbolList;
500
		if (nullIntervalSymbol == null) {
501
			symbolList = new ISymbol[symbols.size()];
502
			return (ISymbol[]) symbols.values().toArray(symbolList);
503
		}
504
		else {
505
			symbolList = new ISymbol[symbols.size() + 1];
506
			symbolList[0] = nullIntervalSymbol;
507
			int i = 1;
508
			for (Iterator iterator = symbols.values().iterator(); iterator
509
					.hasNext();) {
510
				symbolList[i] = (ISymbol) iterator.next();
511
				i++;
512
			}
513
			return symbolList;
514
		}
490 515
	}
491 516

  
492 517
	public String[] getClassifyingFieldNames() {
......
532 557

  
533 558

  
534 559
	public IInterval getInterval(Object v) {
535
		for (int i = 0; i < keys.size(); i++) {
536
			if (((IInterval) keys.get(i)).isInInterval(v)) {
537
				return (IInterval) keys.get(i);
560
		if (v != null ) {
561
			for (int i = 0; i < keys.size(); i++) {
562
				if (((IInterval) keys.get(i)).isInInterval(v)) {
563
					return (IInterval) keys.get(i);
564
				}
538 565
			}
539 566
		}
540 567

  
branches/v2_0_0_prep/extensions/org.gvsig.symbology/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/VectorialUniqueValueLegend.java
114 114
//    private String valueType = NullValue.class.getName();
115 115
    private boolean useDefaultSymbol = false;
116 116
    private Color[] selectedColors=null;
117
	/**
118
     * Constructor method
119
     */
120
    public VectorialUniqueValueLegend() {
121
    }
117
    
118
    private ISymbol nullValueSymbol = null;
122 119

  
123 120
    /**
124 121
     * Constructor method
......
160 157
    }
161 158

  
162 159
    public void addSymbol(Object key, ISymbol symbol) {
163
        ISymbol resul;
164
        resul = (ISymbol)symbols.put(key, symbol);
160
    	ISymbol resul;
161
    	if (key == null) {
162
    		resul = nullValueSymbol;
163
    		nullValueSymbol = symbol;
164
    	}
165
    	else {
166
			resul = (ISymbol) symbols.put(key, symbol);
165 167

  
166
        if (resul != null) {
167
        	logger.error("Error: la clave " + key +
168
                " ya exist?a. Resul = " + resul);
169
            logger.warn("symbol nuevo:" + symbol.getDescription() +
170
                " Sviejo= " + resul.getDescription());
171
        } else {
172
            keys.add(key);
173
        }
174

  
168
			if (resul != null) {
169
				logger.error("Error: la clave " + key + " ya exist?a. Resul = "
170
						+ resul);
171
				logger.warn("symbol nuevo:" + symbol.getDescription()
172
						+ " Sviejo= " + resul.getDescription());
173
			} else {
174
				keys.add(key);
175
			}
176
    	}
177
    	
175 178
        fireClassifiedSymbolChangeEvent(new SymbolLegendEvent(resul, symbol));
176

  
177 179
    }
178 180

  
179 181
    public void clear() {
......
198 200
    }
199 201

  
200 202
     public ISymbol[] getSymbols() {
201
        return (ISymbol[])symbols.values().toArray(new ISymbol[0]);
203
 		ISymbol[] symbolList;
204
		if (nullValueSymbol == null) {
205
			symbolList = new ISymbol[symbols.size()];
206
			return (ISymbol[]) symbols.values().toArray(symbolList);
207
		}
208
		else {
209
			symbolList = new ISymbol[symbols.size() + 1];
210
			symbolList[0] = nullValueSymbol;
211
			int i = 1;
212
			for (Iterator iterator = symbols.values().iterator(); iterator
213
					.hasNext();) {
214
				symbolList[i] = (ISymbol) iterator.next();
215
				i++;
216
			}
217
			return symbolList;
218
		}
202 219
    }
203 220

  
204 221
    public void setClassifyingFieldNames(String[] fNames) {
......
580 597
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getSymbolByValue(com.hardcode.gdbms.engine.values.Value)
581 598
     */
582 599
    public ISymbol getSymbolByValue(Object key) {
583
    	ISymbol symbol = (ISymbol)symbols.get(key);
584
    	if (symbol!=null) {
585
    		return symbol;
586
    	} else if (useDefaultSymbol) {
587
    		return getDefaultSymbol();
600
    	ISymbol symbol = null; 
601
    	if (key == null) {
602
    		symbol = nullValueSymbol;
588 603
    	}
589
    	return null;
604
    	else {
605
    		symbol = (ISymbol)symbols.get(key);
606
    	}
607
    	if (symbol == null && useDefaultSymbol) {
608
    		symbol = getDefaultSymbol();
609
    	}
610
    	return symbol;
590 611

  
591 612
    }
592 613

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/VectorialInterval.java
709 709
				theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
710 710
				theSymbol.setDescription((String) symbolTable.getFieldValue(
711 711
						row, 2));
712
				auxLegend.addSymbol(new NullIntervalValue(), theSymbol);
712
				auxLegend.addSymbol(null, theSymbol);
713 713
			} else {
714 714
				theInterval = (IInterval) symbolTable.getFieldValue(row, 1);
715 715
				theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
......
722 722
			if(defaultSymbolPrev.getSymbol() != null){
723 723
				String description = PluginServices.getText(this,"default");
724 724
				defaultSymbolPrev.getSymbol().setDescription(description);
725
				auxLegend.addSymbol(new NullIntervalValue(), defaultSymbolPrev.getSymbol());
725
				auxLegend.addSymbol(null, defaultSymbolPrev.getSymbol());
726 726
			}
727 727
		}
728 728
	}
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/legend/gui/VectorialUniqueValue.java
251 251
            //Object resul;
252 252
            if (chbUseDefault.isSelected()) {
253 253
                auxLegend.getDefaultSymbol().setDescription("Default");
254
                auxLegend.addSymbol(new NullUniqueValue(),
255
                    auxLegend.getDefaultSymbol());
254
                auxLegend.addSymbol(null, auxLegend.getDefaultSymbol());
256 255
            }
257 256

  
258 257
            ColorItem[] colorScheme = cmbColorScheme.getSelectedColors();
......
460 459
				}
461 460
			}
462 461
		}
463
		clave = new NullUniqueValue();
462
		clave = null;
464 463
		if(chbUseDefault.isSelected()){
465 464
			theSymbol = defaultSymbolPrev.getSymbol();
466 465
			if(theSymbol != null){
......
643 642
     */
644 643
    private void addDefault() {
645 644
        auxLegend.getDefaultSymbol().setDescription("Default");
646
        auxLegend.addSymbol(new NullUniqueValue(), auxLegend.getDefaultSymbol());
645
        auxLegend.addSymbol(null, auxLegend.getDefaultSymbol());
647 646
        symbolTable.addTableRecord(auxLegend.getDefaultSymbol(),
648
            new NullUniqueValue(), auxLegend.getDefaultSymbol().getDescription());
647
            null, auxLegend.getDefaultSymbol().getDescription());
649 648
        symbolTable.repaint();
650 649
    }
651 650

  
......
653 652
     * Elimina el resto de valores que no estan representados por ning�n otro s�mbolo..
654 653
     */
655 654
    private void delDefault() {
656
        auxLegend.delSymbol(new NullUniqueValue());
657
        symbolTable.removeRow(new NullUniqueValue());
655
        auxLegend.delSymbol(null);
656
        symbolTable.removeRow(null);
658 657
        symbolTable.repaint();
659 658
    }
660 659

  

Also available in: Unified diff