Revision 23303 branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/VectorialUniqueValueLegend.java

View differences:

VectorialUniqueValueLegend.java
42 42

  
43 43
import java.awt.Color;
44 44
import java.sql.Types;
45
import java.text.ParseException;
46 45
import java.util.ArrayList;
47 46
import java.util.Comparator;
48 47
import java.util.Iterator;
......
53 52
import org.gvsig.fmap.data.feature.Feature;
54 53
import org.gvsig.fmap.data.feature.FeatureStore;
55 54
import org.gvsig.fmap.data.feature.FeatureType;
56
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
57 55
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent;
58 56
import org.gvsig.fmap.mapcontext.rendering.symbols.FSymbol;
59 57
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
......
78 76
			new Comparator() { //<Object>
79 77
		public int compare(Object o1, Object o2) {
80 78
			if ((o1 != null) && (o2 != null)) {
81
				Object v2 = (Object) o2;
82
				Object v1 = (Object) o1;
79
				Object v2 = o2;
80
				Object v1 = o1;
83 81
				Boolean boolVal;
84 82

  
85 83
				// TODO estas dos comprobaciones son por evitar un bug en el gdbms, cuando se solucione se puede eliminar.
......
195 193
        String[] descriptions = new String[symbols.size()];
196 194
        ISymbol[] auxSym = getSymbols();
197 195

  
198
        for (int i = 0; i < descriptions.length; i++)
199
            descriptions[i] = auxSym[i].getDescription();
196
        for (int i = 0; i < descriptions.length; i++) {
197
			descriptions[i] = auxSym[i].getDescription();
198
		}
200 199

  
201 200
        return descriptions;
202 201
    }
......
242 241

  
243 242
        }
244 243

  
245
        if (isUseDefaultSymbol())
246
        	return defaultSymbol;
244
        if (isUseDefaultSymbol()) {
245
			return defaultSymbol;
246
		}
247 247

  
248 248
        return null;
249 249
    }
......
270 270

  
271 271
        xml.putProperty("fieldTypes", getClassifyingFieldTypes()[0]);
272 272

  
273
        String[] strColors = new String[selectedColors.length];
274
		for (int i = 0; i < strColors.length; i++) {
275
			strColors[i] = StringUtilities.color2String(selectedColors[i]);
273
        if (selectedColors != null) {
274
			String[] strColors = new String[selectedColors.length];
275
			for (int i = 0; i < strColors.length; i++) {
276
				strColors[i] = StringUtilities.color2String(selectedColors[i]);
277
			}
278
			xml.putProperty("colorScheme", strColors);
276 279
		}
277
		xml.putProperty("colorScheme", strColors);
278 280

  
279 281
        xml.putProperty("labelfield", labelFieldName);
280 282
        xml.putProperty("labelFieldHeight", labelFieldHeight);
......
343 345

  
344 346
	public void setXMLEntity(XMLEntity xml) {
345 347
        clear();
346
        if (xml.contains("fieldName"))
347
        	setClassifyingFieldNames(new String[] {xml.getStringProperty("fieldName")});
348
        else
349
        	setClassifyingFieldNames(xml.getStringArrayProperty("fieldNames"));
348
        if (xml.contains("fieldName")) {
349
			setClassifyingFieldNames(new String[] {xml.getStringProperty("fieldName")});
350
		} else {
351
			setClassifyingFieldNames(xml.getStringArrayProperty("fieldNames"));
352
		}
350 353

  
351
        //TODO Falta ver de recuperar los tipos que ahroa son String
352
//        if (xml.contains("fieldTypes"))
353
//        	setClassifyingFieldTypes(new int[] {xml.getIntProperty("fieldTypes")});
354
        String[] strColors = xml.getStringArrayProperty("colorScheme");
354
        if (xml.contains("fieldTypes")) {
355
			setClassifyingFieldTypes(xml.getStringArrayProperty("fieldTypes"));
356
		}
357
        if (xml.contains("colorScheme")) {
358
			String[] strColors = xml.getStringArrayProperty("colorScheme");
355 359

  
356
		Color[] cc = new Color[strColors.length];
357
		for (int i = 0; i < cc.length; i++) {
358
			cc[i] = StringUtilities.string2Color(strColors[i]);
360
        	Color[] cc = new Color[strColors.length];
361
			for (int i = 0; i < cc.length; i++) {
362
				cc[i] = StringUtilities.string2Color(strColors[i]);
363
			}
364
			setColorScheme(cc);
359 365
		}
360
		setColorScheme(cc);
361 366
        useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol");
362 367
        setDefaultSymbol(SymbologyFactory.createSymbolFromXML(xml.getChild(0), null));
363 368

  
......
432 437
	public void setDefaultSymbol(ISymbol s) {
433 438
    	ISymbol mySymbol = defaultSymbol;
434 439

  
435
    	if (s == null)
436
    		throw new NullPointerException("Default symbol cannot be null");
440
    	if (s == null) {
441
			throw new NullPointerException("Default symbol cannot be null");
442
		}
437 443

  
438 444
    	ISymbol old = mySymbol;
439 445
    	defaultSymbol = s;
......
450 456
	 */
451 457
    private Object getValue(String s) {
452 458
        Object val = new NullUniqueValue();
453
        if (s.equals("Resto de Valores"))return val;
459
        if (s.equals("Resto de Valores")) {
460
			return val;
461
		}
454 462
//        try {
455 463
            try {
456 464
                val = new Integer(s);//(s, Types.INTEGER);
......
498 506
     */
499 507
    private Object getValue(String s,int type) {
500 508
    	Object val = new NullUniqueValue();
501
    	if (type==Types.OTHER)
502
    		return val;
509
    	if (type==Types.OTHER) {
510
			return val;
511
		}
503 512
    	switch (type) {
504 513
    	case Types.INTEGER:
505 514
    		val = new Integer(s);
......
530 539
     */
531 540
    public void setFeatureStore(FeatureStore fs) throws	ReadException {
532 541
		featureStore = fs;
533
		if (getClassifyingFieldNames()!=null)
542
		if (getClassifyingFieldNames()!=null) {
534 543
			fieldId = ((FeatureType)fs.getFeatureTypes().get(0)).getFieldIndex(getClassifyingFieldNames()[0]);
544
		}
535 545
	}
536 546

  
537 547
    /*

Also available in: Unified diff