Revision 45740 trunk/org.gvsig.desktop/org.gvsig.desktop.library/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
80 80

  
81 81
	private List<Object> keys = new ArrayList<Object>();
82 82

  
83
    private ISymbol defaultSymbol;
84 83
    private int shapeType;
85 84
    private boolean useDefaultSymbol = false;
86 85
    private Color[] selectedColors=null;
......
104 103
        @Override
105 104
    public void setShapeType(int shapeType) {
106 105
    	if (this.shapeType != shapeType) {
107
    		if(defaultSymbol==null || defaultSymbol.getSymbolType()!=shapeType){
108
    			ISymbol old = defaultSymbol;
109
    			defaultSymbol = getSymbolManager().createSymbol(shapeType);
110
    			fireDefaultSymbolChangedEvent(new SymbolLegendEvent(old, defaultSymbol));
106
    		if(nullValueSymbol==null || nullValueSymbol.getSymbolType()!=shapeType){
107
    			ISymbol old = nullValueSymbol;
108
    			nullValueSymbol = getSymbolManager().createSymbol(shapeType);
109
    			fireDefaultSymbolChangedEvent(new SymbolLegendEvent(old, nullValueSymbol));
111 110
    		}
112 111
    		this.shapeType = shapeType;
113 112
    	}
......
175 174

  
176 175
        @Override
177 176
    public String[] getDescriptions() {
178
        String[] descriptions = new String[symbols.size()];
179 177
        ISymbol[] auxSym = getSymbols();
178
        String[] descriptions = new String[auxSym.length];
180 179

  
181 180
        for (int i = 0; i < descriptions.length; i++) {
182
			descriptions[i] = auxSym[i].getDescription();
183
		}
181
            descriptions[i] = auxSym[i].getDescription();
182
        }
184 183

  
185 184
        return descriptions;
186 185
    }
187 186

  
188
        @Override
189
     public ISymbol[] getSymbols() {
190
 		ISymbol[] symbolList;
191
		if (nullValueSymbol == null) {
192
			symbolList = new ISymbol[symbols.size()];
193
			return (ISymbol[]) symbols.values().toArray(symbolList);
194
		}
195
		else {
196
			symbolList = new ISymbol[symbols.size() + 1];
197
			symbolList[0] = nullValueSymbol;
198
			int i = 1;
199
			for (Iterator<ISymbol> iterator = symbols.values().iterator(); iterator
200
					.hasNext();) {
201
				symbolList[i] = iterator.next();
202
				i++;
203
			}
204
			return symbolList;
205
		}
187
    @Override
188
    public ISymbol[] getSymbols() {
189
        ISymbol[] symbolList;
190
        if (nullValueSymbol == null) {
191
            symbolList = new ISymbol[symbols.size()];
192
            return (ISymbol[]) symbols.values().toArray(symbolList);
193
        } else {
194
            symbolList = new ISymbol[symbols.size() + 1];
195
            symbolList[0] = nullValueSymbol;
196
            int i = 1;
197
            for (Iterator<ISymbol> iterator = symbols.values().iterator(); iterator
198
                    .hasNext();) {
199
                symbolList[i] = iterator.next();
200
                i++;
201
            }
202
            return symbolList;
203
        }
206 204
    }
207 205

  
208 206
        @Override
......
240 238
        }
241 239

  
242 240
        if (isUseDefaultSymbol()) {
243
			return defaultSymbol;
241
			return getDefaultSymbol();
244 242
		}
245 243

  
246 244
        return null;
......
250 248
        @Override
251 249
    public ISymbol getDefaultSymbol() {
252 250

  
253
    	if(defaultSymbol==null) {
254
			defaultSymbol = getSymbolManager().createSymbol(shapeType);
255
    		fireDefaultSymbolChangedEvent(new SymbolLegendEvent(null, defaultSymbol));
256
    	}
257
    	return defaultSymbol;
251
        if (nullValueSymbol == null) {
252
            nullValueSymbol = getSymbolManager().createSymbol(shapeType);
253
            fireDefaultSymbolChangedEvent(new SymbolLegendEvent(null, nullValueSymbol));
254
        }
255
        return nullValueSymbol;
258 256
    }
259 257

  
260 258
        @Override
261 259
	public void setDefaultSymbol(ISymbol s) {
262
    	ISymbol mySymbol = defaultSymbol;
260
    	ISymbol mySymbol = nullValueSymbol;
263 261

  
264 262
    	if (s == null) {
265 263
			throw new NullPointerException("Default symbol cannot be null");
266 264
		}
267 265

  
268 266
    	ISymbol old = mySymbol;
269
    	defaultSymbol = s;
267
    	nullValueSymbol = s;
270 268
    	fireDefaultSymbolChangedEvent(new SymbolLegendEvent(old, s));
271 269
    }
272 270

  
......
369 367
				(VectorialUniqueValueLegend) super.clone();
370 368

  
371 369
		// Clone default symbol
372
		if (defaultSymbol != null) {
373
			clone.defaultSymbol = (ISymbol) defaultSymbol.clone();
370
		if (nullValueSymbol != null) {
371
			clone.nullValueSymbol = (ISymbol) nullValueSymbol.clone();
374 372
		}
375 373
		// Clone keys
376 374
		clone.keys = new ArrayList<Object>();

Also available in: Unified diff