Revision 6631 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/VectorialUniqueValueLegend.java

View differences:

VectorialUniqueValueLegend.java
499 499

  
500 500
            String[] sk = new String[keys.size()];
501 501
            String[] sv = new String[keys.size()];
502

  
502
            int[] stk = new int[keys.size()];
503
            int[] stv = new int[keys.size()];
503 504
            FSymbol[] fsymbols = getSymbols();
504
            Object[] values = (Object[]) getValues();
505
            Object[] values = getValues();
505 506

  
506 507
            for (int i = 0; i < keys.size(); i++) {
507 508
            	if (((Value) keys.get(i)).toString().equals("")) {
......
514 515
            	}else {
515 516
            		sv[i] = ((Value) values[i]).toString();
516 517
            	}
518
            	stk[i]= ((Value)keys.get(i)).getSQLType();
519
            	stv[i]= ((Value)values[i]).getSQLType();
517 520
                xml.addChild(fsymbols[i].getXMLEntity());
518 521

  
519 522
                ///System.out.println("get-----------"+sk[i]+"--"+fsymbols[i].getDescription()+"---"+fsymbols[i].getColor());
......
521 524

  
522 525
            xml.putProperty("keys", sk);
523 526
            xml.putProperty("values", sv);
527
            xml.putProperty("typeKeys",stk);
528
            xml.putProperty("typeValues",stv);
524 529
        }
525 530

  
526 531
        return xml;
......
611 616
            String[] sv = xml.getStringArrayProperty("values");
612 617
            Value auxValue = null;
613 618
            Value auxValue2 = null;
619
            int[] stk=null;
620
            if (xml.contains("typeKeys")) {
621
				stk = xml.getIntArrayProperty("typeKeys");
622
				int[] stv = xml.getIntArrayProperty("typeValues");
623
				for (int i = 0; i < numKeys; i++) {
624
					boolean isDefault = false;
625
					if (getValue(sk[i], stk[i]) == null) {
626
						isDefault = true;
627
					}
614 628

  
615
            for (int i = 0; i < numKeys; i++) {
616
                //try {
617
                boolean isDefault = false;
618

  
619
                if (getValue(sk[i]) == null) {
620
                    isDefault = true;
621
                }
622

  
623
                if (className.equals(
624
                            "com.hardcode.gdbms.engine.values.NullUniqueValue") ||
625
                        isDefault) {
626
                    auxValue = new NullUniqueValue();
627
                    auxValue2 = ValueFactory.createNullValue();
628
                } else {
629
                    auxValue = getValue(sk[i]); //ValueFactory.createValue(sk[i], className);
630
                    auxValue2 = getValue(sv[i]); // ValueFactory.createValue(sv[i], className);
631
                }
632

  
633
                FSymbol sym = FSymbol.createFromXML(xml.getChild(i + 1));
634

  
635
                ///addSymbol(auxValue, sym);
636
                symbols.put(auxValue2, sym);
637
                keys.add(auxValue);
638

  
639
                ///System.out.println("---set------"+auxValue.toString());
640
                /// System.out.println("set-----------"+sk[i]+"--"+sym.getDescription()+"---"+sym.getColor());
641
                //} catch (SemanticException e) {
642
                //	e.printStackTrace();
643
                //}
644
            }
629
					if (className
630
							.equals("com.hardcode.gdbms.engine.values.NullUniqueValue")
631
							|| isDefault) {
632
						auxValue = new NullUniqueValue();
633
						auxValue2 = ValueFactory.createNullValue();
634
					} else {
635
						auxValue = getValue(sk[i], stk[i]); // ValueFactory.createValue(sk[i],
636
															// className);
637
						auxValue2 = getValue(sv[i], stv[i]); // ValueFactory.createValue(sv[i],
638
																// className);
639
					}
640
					FSymbol sym = FSymbol.createFromXML(xml.getChild(i + 1));
641
					symbols.put(auxValue2, sym);
642
					keys.add(auxValue);
643
				}
644
			} else {
645
				for (int i = 0; i < numKeys; i++) {
646
					boolean isDefault = false;
647
					if (getValue(sk[i]) == null) {
648
						isDefault = true;
649
					}
650
					if (className
651
							.equals("com.hardcode.gdbms.engine.values.NullUniqueValue")
652
							|| isDefault) {
653
						auxValue = new NullUniqueValue();
654
						auxValue2 = ValueFactory.createNullValue();
655
					} else {
656
						auxValue = getValue(sk[i]); // ValueFactory.createValue(sk[i],
657
													// className);
658
						auxValue2 = getValue(sv[i]); // ValueFactory.createValue(sv[i],
659
														// className);
660
					}
661
					FSymbol sym = FSymbol.createFromXML(xml.getChild(i + 1));
662
					symbols.put(auxValue2, sym);
663
					keys.add(auxValue);
664
				}
665
			}
645 666
        }
646 667
    }
647 668

  
648 669
    /**
649
     * Devuelve el valor a partir de su valor en un string.
650
     *
651
     * @param s String con el valor.
652
     *
653
     * @return Value.
654
     */
670
	 * Devuelve el valor a partir de su valor en un string.
671
	 *
672
	 * @param s
673
	 *            String con el valor.
674
	 * @deprecated M?todo utilizado hasta la 1.0 alpha 855 Debes utilizar a partir de ahora getValue(String s,int type);
675
	 * @return Value.
676
	 */
655 677
    private Value getValue(String s) {
656 678
        Value val = new NullUniqueValue();
657 679
        if (s.equals("Resto de Valores"))return val;
......
692 714

  
693 715
        return val;
694 716
    }
717
    /**
718
     * Devuelve el valor a partir de su valor en un string.
719
     *
720
     * @param s String con el valor.
721
     *
722
     * @return Value.
723
     */
724
    private Value getValue(String s,int type) {
725
        Value val = new NullUniqueValue();
726
        if (type==Types.OTHER)
727
        	return val;
728
        try {
729
        	val = ValueFactory.createValueByType(s, type);
730
        } catch (ParseException e) {
731
            e.printStackTrace();
732
        }
733
        return val;
734
    }
695 735

  
696 736
    /**
697 737
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
698 738
     */
699 739
    public Legend cloneLegend() throws XMLException {
700
        return (Legend) LegendFactory.createFromXML(getXMLEntity());
740
        return LegendFactory.createFromXML(getXMLEntity());
701 741
    }
702 742

  
703 743
    /* (non-Javadoc)

Also available in: Unified diff