Revision 20778

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/SingleSymbolLegend.java
201 201
		return getClass().getName();
202 202
	}
203 203

  
204
    public boolean isSuitableForShapeType(int shapeType) {
205
		return getShapeType() == shapeType;
206
	} 
204 207

  
205 208
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/SymbolLegendEvent.java
51 51
 * @author Vicente Caballero Navarro
52 52
 */
53 53
public class SymbolLegendEvent extends ClassificationLegendEvent {
54
	/**
54
/**
55 55
	 * <p>Previous symbol style.</p>
56 56
	 */
57
	private ISymbol oldValue;
57
	private ISymbol oldSymbol;
58 58
	
59 59
	/**
60 60
	 * <p>New symbol style.</p>
61 61
	 */
62
	private ISymbol newValue;
62
	private ISymbol newSymbol;
63 63

  
64 64
	/**
65 65
	 * <p>Creates a new symbol legend event.</p>
......
67 67
	 * @param oldValue previous symbol style
68 68
	 * @param newValue new symbol style
69 69
	 */
70
	public SymbolLegendEvent(ISymbol oldValue, ISymbol newValue) {
71
		this.oldValue = oldValue;
72
		this.newValue = newValue;
70
	public SymbolLegendEvent(ISymbol oldSymbol, ISymbol newSymbol) {
71
		this.oldSymbol = oldSymbol;
72
		this.newSymbol = newSymbol;
73 73
	}
74 74

  
75 75
	/**
......
77 77
	 *
78 78
	 * @return the previous symbol style
79 79
	 */
80
	public ISymbol getOldValue() {
81
		return oldValue;
80
	public ISymbol getOldSymbol() {
81
		return oldSymbol;
82 82
	}
83 83

  
84 84
	/**
......
86 86
	 *
87 87
	 * @return the new symbol style
88 88
	 */
89
	public ISymbol getNewValue() {
90
		return newValue;
89
	public ISymbol getNewSymbol() {
90
		return newSymbol;
91 91
	}
92 92

  
93 93
	/**
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/IVectorLegend.java
137 137
    public ZSort getZSort();
138 138

  
139 139
	public void setZSort(ZSort zSort);
140
	
141
	public boolean isSuitableForShapeType(int shapeType);
140 142
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/ZSort.java
305 305
	}
306 306

  
307 307
	public boolean symbolChanged(SymbolLegendEvent e) {
308
		replaceSymbol(e.getOldValue(), e.getNewValue());
308
		replaceSymbol(e.getOldSymbol(), e.getNewSymbol());
309 309
		return true;
310 310
	}
311 311

  
312 312

  
313 313
	public boolean classifiedSymbolChange(SymbolLegendEvent e) {
314
		replaceSymbol(e.getOldValue(), e.getNewValue());
314
		replaceSymbol(e.getOldSymbol(), e.getNewSymbol());
315 315
		return true;
316 316
	}
317 317

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/AbstractIntervalLegend.java
168 168
	public void addSymbol(Object key, ISymbol symbol) {
169 169
		symbols.put(key, symbol);
170 170
		keys.add(key);
171
		fireClassifiedSymbolChangeEvent(new SymbolLegendEvent(null, symbol));
171 172
	}
172 173

  
173 174
	/*
......
179 180
		ISymbol theSymbol = getSymbolByInterval(interval);
180 181

  
181 182

  
182

  
183
//
184
//		if (shapeType == FShape.POLYGON && theSymbol instanceof IMarkerSymbol) {
185
//			// transform it to a fill symbol
186
//			MarkerFillSymbol aux = new MarkerFillSymbol();
187
//			// tell the fill style to draw the IMarkerSymbol
188
//			// as a IFillSymbol centering it in the shape polygon
189
//			// centroid and applying offset (if any).
190
//			aux.setMarker((IMarkerSymbol) theSymbol);
191
//			SimpleMarkerFillPropertiesStyle p = new SimpleMarkerFillPropertiesStyle();
192
//			p.setFillStyle(SimpleMarkerFillPropertiesStyle.SINGLE_CENTERED_SYMBOL);
193
//			aux.setMarkerFillProperties(p);
194
//			theSymbol = aux;
195
//		}
196

  
197 183
		if (theSymbol != null) {
198 184
			return theSymbol;
199 185
		} else if (useDefaultSymbol) {
......
501 487
	}
502 488

  
503 489
	public void setDefaultSymbol(ISymbol s) {
490
	    ISymbol old = defaultSymbol;
504 491
		if (s == null) throw new NullPointerException("Default symbol cannot be null");
505 492
		defaultSymbol = s;
493
		fireDefaultSymbolChangedEvent(new SymbolLegendEvent(old, defaultSymbol));
506 494
	}
507 495

  
508 496
	public void setClassifyingFieldNames(String[] fieldNames) {
......
567 555
	public void delSymbol(Object obj) {
568 556
		keys.remove(obj);
569 557
		symbols.remove(obj);
558
		fireClassifiedSymbolChangeEvent(
559
				new SymbolLegendEvent(
560
						symbols.remove(obj),
561
						null));
570 562
	}
571 563

  
572 564
	
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/AbstractClassifiedVectorLegend.java
104 104
		this.zSort = zSort;
105 105
		addLegendListener(zSort);
106 106
	}
107
	
108
	
109
	public boolean isSuitableForShapeType(int shapeType) {
110
		return getShapeType() == shapeType;
111
	}
107 112
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerMarkerSymbol.java
312 312
		for (int i = 0; i < layers.length; i++) {
313 313
			newLayers.add(layers[i]);
314 314
		}
315
		newLayers.add(layerIndex, newLayer);
316
		layers = (IMarkerSymbol[]) newLayers.toArray(new IMarkerSymbol[0]);
315
		try {
316
			newLayers.add(layerIndex, newLayer);
317
			layers = (IMarkerSymbol[]) newLayers.toArray(new IMarkerSymbol[0]);
318
		} catch (ArrayStoreException asEx) {
319
			throw new ClassCastException(newLayer.getClassName()+" is not an IMarkerSymbol");
320
		}
317 321
	}
318 322

  
319 323
	public boolean removeLayer(ISymbol layer) {
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerFillSymbol.java
296 296
		for (int i = 0; i < layers.length; i++) {
297 297
			newLayers.add(layers[i]);
298 298
		}
299
		newLayers.add(layerIndex, newLayer);
300
		layers = (IFillSymbol[]) newLayers.toArray(new IFillSymbol[0]);
299
		try {
300
			newLayers.add(layerIndex, newLayer);
301
			layers = (IFillSymbol[]) newLayers.toArray(new IFillSymbol[0]);
302
		} catch (ArrayStoreException asEx) {
303
			throw new ClassCastException(newLayer.getClassName()+" is not an IFillSymbol");
304
		}
301 305
	}
302 306

  
303 307
	public boolean removeLayer(ISymbol layer) {
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerLineSymbol.java
322 322
		for (int i = 0; i < layers.length; i++) {
323 323
			newLayers.add(layers[i]);
324 324
		}
325
		newLayers.add(layerIndex, newLayer);
326
		layers = newLayers.toArray(new ILineSymbol[0]);
325
		try {
326
			newLayers.add(layerIndex, newLayer);
327
			layers = newLayers.toArray(new ILineSymbol[0]);
328
		} catch (ArrayStoreException asEx) {
329
			throw new ClassCastException(newLayer.getClassName()+" is not an ILineSymbol");
330
		}
327 331
	}
328 332

  
329 333
	public boolean removeLayer(ISymbol layer) {
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java
74 74

  
75 75
						// check shape type
76 76
//						if (l.getShapeType() != 0 && m.getShapeType() != l.getShapeType()) {
77
						if(l.getDefaultSymbol().getSymbolType() != m.getShapeType()){
77
						if((l.getDefaultSymbol().getSymbolType() != m.getShapeType())
78
								&& !l.isSuitableForShapeType(m.getShapeType())){
78 79
							errors |= LegendDriverException.LAYER_SHAPETYPE_MISMATCH;
79 80
						}
80 81

  
......
118 119
			// should be unreachable code
119 120
			throw new Error ("file_not_found");
120 121
		} catch (MarshalException e) {
121
			throw new Error ("file_not_found");
122
			throw new Error ("file_corrupt");
122 123
		} catch (ValidationException e) {
123 124
			// should be unreachable code
124 125
			throw new Error ("ValidationException");
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/legend/LegendDriverException.java
10 10
	public static final int LEGEND_TYPE_NOT_YET_SUPPORTED = 16;
11 11
	public static final int SYMBOL_TYPE_NOT_YET_SUPPORTED = 32;
12 12
	
13
	
14 13
	// Geometry exceptions
15 14
	public static final int LAYER_SHAPETYPE_MISMATCH = 64;
16 15
	
......
25 24
	// Filesystem Exceptions
26 25
	public static final int SYSTEM_ERROR = 1048576;
27 26
	
28
	
29 27
	// Parsing Errors
30 28
	public static final int LAYER_NAME_NOT_SPECIFIED = 2097152;
29
	public static final int LAYER_NAME_NOT_FOUND = 4194304;
30
	public static final int UNSUPPORTED_LEGEND_CREATION_FOR_DRIVER = 8388608;
31 31
	
32
	
33
	
34 32
	private int type;
35 33
	
36 34
	public LegendDriverException(int type) {

Also available in: Unified diff