Revision 25074 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/VectorialInterval.java

View differences:

VectorialInterval.java
63 63
import org.apache.log4j.Logger;
64 64
import org.gvsig.fmap.dal.DataTypes;
65 65
import org.gvsig.fmap.dal.exception.DataException;
66
import org.gvsig.fmap.dal.exception.ReadException;
67 66
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
68 67
import org.gvsig.fmap.dal.feature.FeatureStore;
69 68
import org.gvsig.fmap.dal.feature.FeatureType;
......
85 84
import com.iver.andami.PluginServices;
86 85
import com.iver.andami.messages.NotificationManager;
87 86
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
87
import com.iver.utiles.XMLException;
88 88

  
89 89

  
90 90
/**
......
434 434
            auxLegend = LegendFactory.createVectorialIntervalLegend(layer.getShapeType());
435 435
            auxLegend.useDefaultSymbol(false);
436 436

  
437
            if (chkdefaultvalues.isSelected()) {
438
                auxLegend.getDefaultSymbol().setDescription("Default");
439
                auxLegend.addSymbol(new NullIntervalValue(),
440
                		auxLegend.getDefaultSymbol());
441
            }
442

  
443 437
            int symbolType = layer.getShapeType();
444 438
            int numSymbols = 0;
445 439

  
......
486 480
            symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(),
487 481
                auxLegend.getValues(), auxLegend.getDescriptions());
488 482

  
489
        } catch (ReadException e) {
483
        } catch (DataException e) {
490 484
        	NotificationManager.addError(PluginServices.getText(this, "could_not_get_shape_type"), e);
491 485
        } catch (LegendLayerException e) {
492 486
        	NotificationManager.addError(PluginServices.getText(this, "failed_computing_intervals"), e);
......
530 524
    	int shapeType = 0;
531 525
    	try {
532 526
    		shapeType = this.layer.getShapeType();
533
    	} catch (ReadException e) {
527
    	} catch (DataException e) {
534 528
    		NotificationManager.addError(PluginServices.getText(this, "generating_intervals"), e);
535 529
    	}
536 530

  
......
565 559
        cmbFieldType.setSelectedIndex(theLegend.getIntervalType());
566 560
*/
567 561
		if (VectorialIntervalLegend.class.equals(legend.getClass())) {
568
			auxLegend = (VectorialIntervalLegend) legend;
562
			try {
563
				auxLegend = (VectorialIntervalLegend) legend.cloneLegend();
564
			} catch (XMLException e) {
565
				NotificationManager.addError(e);
566
			}
569 567
			chkdefaultvalues.setSelected(auxLegend.isUseDefaultSymbol());
570 568
			cmbField.getModel().setSelectedItem(auxLegend.getClassifyingFieldNames()[0]);
571 569
			symbolTable.fillTableFromSymbolList(auxLegend.getSymbols(),
......
574 572
			colorChooserPanel1.setColor(auxLegend.getEndColor());
575 573
			colorChooserPanel.repaint();
576 574
			colorChooserPanel1.repaint();
577
			txtNumIntervals.setText(String.valueOf(auxLegend.getSymbols().length));
575
			if(auxLegend.isUseDefaultSymbol()) {
576
				txtNumIntervals.setText(String.valueOf(auxLegend.getSymbols().length - 1));
577
			} else {
578
				txtNumIntervals.setText(String.valueOf(auxLegend.getSymbols().length));
579
			}
578 580
		} else {
579 581
			// Si la capa viene con otro tipo de leyenda, creamos
580 582
			// una nueva del tipo que maneja este panel
......
597 599

  
598 600
    protected void fillFieldNames() {
599 601
        FeatureStore rs = null;
600
        ArrayList nomFields = null;
602
        ArrayList<String> nomFields = null;
601 603

  
602 604
        try {
603 605
            rs = ((FLyrVect) layer).getFeatureStore();
604 606
//            logger.debug("rs.start()");
605 607
//            rs.start();
606 608

  
607
            nomFields = new ArrayList();
609
            nomFields = new ArrayList<String>();
608 610

  
609 611
            int type;
610
            Iterator iterator=((FeatureType)rs.getFeatureTypes().get(0)).iterator();
612
            Iterator<FeatureAttributeDescriptor> iterator=rs.getDefaultFeatureType().iterator();
611 613
            while (iterator.hasNext()) {
612
				FeatureAttributeDescriptor descriptor = (FeatureAttributeDescriptor) iterator.next();
614
				FeatureAttributeDescriptor descriptor = iterator.next();
613 615

  
614 616
//			}
615 617
//            for (int i = 0; i < rs.getFieldCount(); i++) {
......
624 626
                		type == DataTypes.FLOAT ||
625 627
                		type  == DataTypes.LONG)
626 628
                {
627
                	nomFields.add(descriptor.getName().trim());
629
                	nomFields.add(descriptor.getName());
628 630
                }
629 631
            }
630 632

  
......
650 652

  
651 653
		auxLegend.useDefaultSymbol(chkdefaultvalues.isSelected());
652 654

  
653
		theLegend = auxLegend;
655
		try {
656
			theLegend = (VectorialIntervalLegend) auxLegend.cloneLegend();
657
		} catch (XMLException e) {
658
			// TODO Auto-generated catch block
659
			e.printStackTrace();
660
		}
654 661
		return theLegend;
655 662
	}
656
     /*
657
    public ILegend getLegend() {
658
        fillSymbolListFromTable();
659 663

  
660
        if (auxLegend != null) {
661
        	// your settings that are not the set of symbols must be located here
662
        	auxLegend.setClassifyingFieldNames(
663
        			new String[] {(String) getCmbFields().getSelectedItem()});
664

  
665

  
666

  
667
        	theLegend = auxLegend;
668
        }
669

  
670
        return theLegend;
671
    }*/
672

  
673 664
    /**
674 665
     * A partir de los registros de la tabla, regenera el FRenderer. (No solo
675 666
     * el symbolList, si no tambi�n el arrayKeys y el defaultRenderer
676 667
     */
677
    /*private void fillSymbolListFromTable() {
678
        ISymbol theSymbol;
679
        IInterval theInterval = null;
680 668

  
681
        // Borramos las anteriores listas:
682
        theLegend.clear();
683

  
684
        String fieldName = (String) cmbField.getSelectedItem();
685
        theLegend.setClassifyingFieldNames(new String[] {fieldName});
686

  
687
        for (int row = 0; row < symbolTable.getRowCount(); row++) {
688
            if (!(symbolTable.getFieldValue(row, 1) instanceof FInterval)) {
689
                theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
690
                theSymbol.setDescription((String) symbolTable.getFieldValue(
691
                        row, 2));
692
                theLegend.addSymbol(new NullIntervalValue(), theSymbol);
693
            } else {
694
                theInterval = (IInterval) symbolTable.getFieldValue(row, 1);
695
                theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
696
                theSymbol.setDescription((String) symbolTable.getFieldValue(
697
                        row, 2));
698
                theLegend.addSymbol(theInterval, theSymbol);
699
            }
700

  
701
        }
702
    }*/
703 669
    private void fillSymbolListFromTable() {
704 670
		ISymbol theSymbol;
705 671
		IInterval theInterval = null;
......
719 685
//			rs.start();
720 686
			FeatureType featureType=rs.getDefaultFeatureType();
721 687
			auxLegend
722
					.setClassifyingFieldTypes(new Integer[] { new Integer(
688
					.setClassifyingFieldTypes(new int[] { new Integer(
723 689
							featureType.getAttributeDescriptor(fieldName)
724 690
									.getDataType()) });
725 691
			logger.debug("rs.start()");
726 692
//			rs.stop();
727 693

  
728
		} catch (ReadException e) {
694
		} catch (DataException e) {
729 695
			NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e);
730 696
		}
731 697

  
......
768 734
    }
769 735

  
770 736
    /**
771
     * A�ade la fila y el s�mbolo para el resto de valores no representados.
772
     */
773
    private void addDefault() {
774

  
775
        auxLegend.getDefaultSymbol().setDescription("Default");
776
        auxLegend.addSymbol(new NullIntervalValue(),
777
            auxLegend.getDefaultSymbol());
778
        symbolTable.addTableRecord(auxLegend.getDefaultSymbol(),
779
            new NullIntervalValue(),
780
            auxLegend.getDefaultSymbol().getDescription());
781
        symbolTable.repaint();
782
    }
783

  
784
    /**
785
     * Elimina la fila de la tabla y el s�mbolo del resto de valores no
786
     * representados por ning�n valor.
787
     */
788
    private void delDefault() {
789
        auxLegend.delSymbol(new NullIntervalValue());
790
        symbolTable.removeRow(new NullIntervalValue());
791
        symbolTable.repaint();
792
    }
793

  
794
    /**
795 737
     * Listener.
796 738
     *
797 739
     * @author Vicente Caballero Navarro
......
835 777
                    		SymbologyFactory.createDefaultSymbolByShapeType(layer.getShapeType()),
836 778
                    		new FInterval(0, 0),
837 779
                    		"0 - 0");
838
                } catch (ReadException e1) {
780
                } catch (DataException e1) {
839 781
                	NotificationManager.addError(PluginServices.getText(this, "could_not_get_shape_type"), e1);
840 782
                }
841 783

  

Also available in: Unified diff