Revision 2102
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/NaturalIntervalGenerator.java | ||
---|---|---|
60 | 60 |
private int miNumIntervalosSolicitados; |
61 | 61 |
private int miNumIntervalosGenerados; |
62 | 62 |
private double[] mdaValoresRuptura; |
63 |
private double[] mdaValInit; |
|
63 | 64 |
|
64 | 65 |
/** |
65 | 66 |
* Crea un nuevo IntervalGenerator. |
... | ... | |
210 | 211 |
// 'S?lo se pueden generar dos intervalos -> hay un valor de ruptura |
211 | 212 |
///ReDim mdaValoresRuptura(0) |
212 | 213 |
mdaValoresRuptura[0] = ((udtDatosEstudio) lVectorDatos.get(0)).Valor; |
214 |
mdaValInit[0] = ((udtDatosEstudio) lVectorDatos.get(0)).Valor; |
|
213 | 215 |
miNumIntervalosGenerados = 2; |
214 | 216 |
|
215 | 217 |
return true; |
... | ... | |
227 | 229 |
llaIndicesRupturas = new int[liNumClasesReales - 1]; |
228 | 230 |
llNumElementosPorClase = (lVectorDatos.size()) / liNumClasesReales; |
229 | 231 |
|
230 |
for (i = 0; i <llaIndicesRupturas.length; i++) { |
|
232 |
for (i = 0; i < llaIndicesRupturas.length; i++) {
|
|
231 | 233 |
if (i == 0) { |
232 | 234 |
llaIndicesRupturas[i] = llNumElementosPorClase - 1; |
233 | 235 |
} else { |
... | ... | |
236 | 238 |
} |
237 | 239 |
} |
238 | 240 |
|
239 |
udtDatosClase[] ldaSDCM_Parciales = new udtDatosClase[llaIndicesRupturas.length+1]; |
|
240 |
udtDatosClase[] ldaSDCM_Validos = new udtDatosClase[llaIndicesRupturas.length+1]; |
|
241 |
udtDatosClase[] ldaSDCM_Parciales = new udtDatosClase[llaIndicesRupturas.length + |
|
242 |
1]; |
|
243 |
udtDatosClase[] ldaSDCM_Validos = new udtDatosClase[llaIndicesRupturas.length + |
|
244 |
1]; |
|
241 | 245 |
|
242 | 246 |
///ReDim ldaSDCM_Parciales(UBound(llaIndicesRupturas()) + 1) |
243 | 247 |
///ReDim ldaSDCM_Validos(UBound(ldaSDCM_Parciales()) + 1) |
244 |
if (llaIndicesRupturas.length==0)return true; |
|
248 |
if (llaIndicesRupturas.length == 0) { |
|
249 |
return true; |
|
250 |
} |
|
251 |
|
|
245 | 252 |
// 'Calcular la bondad inicial |
246 | 253 |
if (!mbCalcularGVF(lVectorDatos, ldaSDCM_Parciales, llaIndicesRupturas, |
247 |
ldSDAM[0], ldUltimaGVF, -1,false)) { |
|
254 |
ldSDAM[0], ldUltimaGVF, -1, false)) {
|
|
248 | 255 |
return false; |
249 | 256 |
} |
250 | 257 |
|
... | ... | |
350 | 357 |
llIndiceRupturaOriginal = llaIndicesRupturas[i]; |
351 | 358 |
|
352 | 359 |
if (lbMoverADerecha) { |
353 |
if (i == llaIndicesRupturas.length-1) {
|
|
360 |
if (i == (llaIndicesRupturas.length - 1)) {
|
|
354 | 361 |
if ((llaIndicesRupturas[i] + 1) >= lVectorDatos.size()) { |
355 | 362 |
exit = true; |
356 | 363 |
} |
... | ... | |
376 | 383 |
} |
377 | 384 |
} //'If i = LBound(llaIndicesRupturas) Then |
378 | 385 |
|
379 |
llaIndicesRupturas[i] = llaIndicesRupturas[i]-1;//////////////////
|
|
386 |
llaIndicesRupturas[i] = llaIndicesRupturas[i] - 1; //////////////////
|
|
380 | 387 |
} //'If lbMoverADerecha Then |
381 | 388 |
|
382 | 389 |
if (!mbCalcularGVF(lVectorDatos, ldaSDCM_Parciales, |
... | ... | |
407 | 414 |
|
408 | 415 |
// 'A partir de aqu? ya no se puede cancelar nada |
409 | 416 |
mdaValoresRuptura = new double[llaIndicesRupturas.length]; |
417 |
mdaValInit = new double[llaIndicesRupturas.length]; |
|
410 | 418 |
|
411 | 419 |
for (i = 0; i < mdaValoresRuptura.length; i++) { // LBound(mdaValoresRuptura) To UBound(mdaValoresRuptura) |
412 | 420 |
mdaValoresRuptura[i] = ((udtDatosEstudio) lVectorDatos.get(llaIndicesRupturas[i])).Valor; |
413 | 421 |
|
422 |
if ((llaIndicesRupturas[i] + 1) < lVectorDatos.size()) { |
|
423 |
mdaValInit[i] = ((udtDatosEstudio) lVectorDatos.get(llaIndicesRupturas[i] + |
|
424 |
1)).Valor; |
|
425 |
} else { |
|
426 |
mdaValInit[i] = ((udtDatosEstudio) lVectorDatos.get(llaIndicesRupturas[i])).Valor; |
|
427 |
} |
|
428 |
|
|
414 | 429 |
// 'Hay que aplicar una peque?a correcci?n a los valores de ruptura para que los intervalos que genera |
415 | 430 |
// 'mapobjects se aprechen en su totalidad, o lo que es lo mismo, vengan todos representados en el mapa. |
416 | 431 |
// 'Con esto tambi?n se consigue hallar intervalos equivalentes a los de ArcView. Esta correcci?n consiste |
... | ... | |
425 | 440 |
|
426 | 441 |
return true; |
427 | 442 |
} |
428 |
private udtDatosClase[] getArray(udtDatosClase[] array){ |
|
429 |
udtDatosClase[] aux=new udtDatosClase[array.length]; |
|
430 |
for (int i=0;i<array.length;i++){ |
|
431 |
aux[i]=new udtDatosClase(); |
|
432 |
aux[i].Media=array[i].Media; |
|
433 |
aux[i].NumElementos=array[i].NumElementos; |
|
434 |
aux[i].SDCM=array[i].SDCM; |
|
435 |
aux[i].SumaCuadradoTotal=array[i].SumaCuadradoTotal; |
|
436 |
aux[i].SumaTotal=array[i].SumaTotal; |
|
443 |
|
|
444 |
/** |
|
445 |
* DOCUMENT ME! |
|
446 |
* |
|
447 |
* @param array DOCUMENT ME! |
|
448 |
* |
|
449 |
* @return DOCUMENT ME! |
|
450 |
*/ |
|
451 |
private udtDatosClase[] getArray(udtDatosClase[] array) { |
|
452 |
udtDatosClase[] aux = new udtDatosClase[array.length]; |
|
453 |
|
|
454 |
for (int i = 0; i < array.length; i++) { |
|
455 |
aux[i] = new udtDatosClase(); |
|
456 |
aux[i].Media = array[i].Media; |
|
457 |
aux[i].NumElementos = array[i].NumElementos; |
|
458 |
aux[i].SDCM = array[i].SDCM; |
|
459 |
aux[i].SumaCuadradoTotal = array[i].SumaCuadradoTotal; |
|
460 |
aux[i].SumaTotal = array[i].SumaTotal; |
|
437 | 461 |
} |
438 |
return aux; |
|
462 |
|
|
463 |
return aux; |
|
439 | 464 |
} |
465 |
|
|
440 | 466 |
/** |
441 | 467 |
* Devuelve la "SDAM" de un conjunto de datos que vienen almacenados en el |
442 | 468 |
* vector rVectorDatos |
... | ... | |
624 | 650 |
|
625 | 651 |
//'Falta la ?ltima clase |
626 | 652 |
if (!mbGetDatosClase(rVectorDatos, |
627 |
rlaIndicesRuptura[rlaIndicesRuptura.length-1] + 1,
|
|
628 |
rVectorDatos.size()-1, raClases, raClases.length-1)) {
|
|
653 |
rlaIndicesRuptura[rlaIndicesRuptura.length - 1] + 1,
|
|
654 |
rVectorDatos.size() - 1, raClases, raClases.length - 1)) {
|
|
629 | 655 |
return false; |
630 | 656 |
} |
631 | 657 |
} else { |
... | ... | |
634 | 660 |
//'Hay que determinar para qu? clases debemos volver a recalcular los datos en funci?n del ?ndice de ruptura que estamos modificando |
635 | 661 |
if (vbDesplazAIzquierda) { |
636 | 662 |
// 'Recalcular los datos de la clase izquierda |
637 |
if (!mbRecalcularDatosClase(raClases,i, rVectorDatos, |
|
663 |
if (!mbRecalcularDatosClase(raClases, i, rVectorDatos,
|
|
638 | 664 |
rlaIndicesRuptura[i] + 1, vdSDAM, false)) { |
639 | 665 |
return false; |
640 | 666 |
} |
641 | 667 |
|
642 | 668 |
// 'Recalcular los datos de la clase derecha |
643 |
if (!mbRecalcularDatosClase(raClases,i + 1, rVectorDatos, |
|
669 |
if (!mbRecalcularDatosClase(raClases, i + 1, rVectorDatos,
|
|
644 | 670 |
rlaIndicesRuptura[i] + 1, vdSDAM, true)) { |
645 | 671 |
return false; |
646 | 672 |
} |
647 | 673 |
} else { |
648 | 674 |
// 'Recalcular los datos de la clase izquierda |
649 |
if (!mbRecalcularDatosClase(raClases,i, rVectorDatos, |
|
675 |
if (!mbRecalcularDatosClase(raClases, i, rVectorDatos,
|
|
650 | 676 |
rlaIndicesRuptura[i], vdSDAM, true)) { |
651 | 677 |
return false; |
652 | 678 |
} |
653 | 679 |
|
654 | 680 |
// 'Recalcular los datos de la clase derecha |
655 |
if (!mbRecalcularDatosClase(raClases,i + 1, rVectorDatos, |
|
681 |
if (!mbRecalcularDatosClase(raClases, i + 1, rVectorDatos,
|
|
656 | 682 |
rlaIndicesRuptura[i], vdSDAM, false)) { |
657 | 683 |
return false; |
658 | 684 |
} |
... | ... | |
701 | 727 |
|
702 | 728 |
// 'Inicializamos los datos de la clase |
703 | 729 |
rClase[numClas] = new udtDatosClase(); |
704 |
|
|
730 |
|
|
705 | 731 |
//'Hallamos la media de la clase |
706 |
for (i = vlLimiteInf; i < vlLimiteSup+1; i++) {
|
|
732 |
for (i = vlLimiteInf; i < (vlLimiteSup + 1); i++) {
|
|
707 | 733 |
rClase[numClas].NumElementos = rClase[numClas].NumElementos + |
708 | 734 |
((udtDatosEstudio) rVectorDatos.get(i)).Coincidencias; |
709 | 735 |
|
... | ... | |
730 | 756 |
* Recalcula los datos de las clases. |
731 | 757 |
* |
732 | 758 |
* @param rClase Clases. |
759 |
* @param i ?adir ?adir ?adir ?adir indica si a la clase se le a?ade un |
|
760 |
* elemento (True) o se le quita (False) |
|
733 | 761 |
* @param rVectorDatos Datos. |
734 | 762 |
* @param vlIndiceElemento es el ?ndice del elemento que se le va a?adir o |
735 | 763 |
* a quitar a la clase |
736 | 764 |
* @param vdSDAM desviaci?n standard. |
737 |
* @param vbA ?adir ?adir ?adir ?adir indica si a la clase se le a?ade un |
|
738 |
* elemento (True) o se le quita (False) |
|
765 |
* @param vbA ?adir DOCUMENT ME! |
|
739 | 766 |
* |
740 | 767 |
* @return True si se ha calculado correctamente. |
741 | 768 |
*/ |
742 |
private boolean mbRecalcularDatosClase(udtDatosClase[] rClase,int i, |
|
769 |
private boolean mbRecalcularDatosClase(udtDatosClase[] rClase, int i,
|
|
743 | 770 |
ArrayList rVectorDatos, int vlIndiceElemento, double vdSDAM, |
744 | 771 |
boolean vbA?adir) { |
745 | 772 |
double ldValor; |
... | ... | |
760 | 787 |
//'Actualizamos el producto total |
761 | 788 |
//'rClase.ProductoTotal = rClase.ProductoTotal * (ldValor * llNumCoincidencias) |
762 | 789 |
//'Actualizamos el n? de elementos |
763 |
rClase[i].NumElementos = rClase[i].NumElementos + llNumCoincidencias; |
|
790 |
rClase[i].NumElementos = rClase[i].NumElementos + |
|
791 |
llNumCoincidencias; |
|
764 | 792 |
} else { |
765 | 793 |
//'Actualizamos la suma total |
766 | 794 |
rClase[i].SumaTotal = rClase[i].SumaTotal - |
... | ... | |
773 | 801 |
// 'Actualizamos el producto total |
774 | 802 |
// 'rClase.ProductoTotal = rClase.ProductoTotal / (ldValor * llNumCoincidencias) |
775 | 803 |
// 'Actualizamos el n? de elementos |
776 |
rClase[i].NumElementos = rClase[i].NumElementos - llNumCoincidencias; |
|
804 |
rClase[i].NumElementos = rClase[i].NumElementos - |
|
805 |
llNumCoincidencias; |
|
777 | 806 |
} // 'If vbA?adir Then |
778 | 807 |
|
779 | 808 |
//'Obtenemos la nueva media |
... | ... | |
800 | 829 |
} |
801 | 830 |
|
802 | 831 |
/** |
832 |
* Devuelve el valor inicial de cada intervalo |
|
833 |
* |
|
834 |
* @param index ?ndice del intervalo |
|
835 |
* |
|
836 |
* @return valor del intervalo. |
|
837 |
*/ |
|
838 |
public double getValInit(int index) { |
|
839 |
return mdaValInit[index]; |
|
840 |
} |
|
841 |
|
|
842 |
/** |
|
803 | 843 |
* Devuelve el n?mero de intervalos que se pueden representar, no tiene |
804 | 844 |
* porque coincidir con el n?mero de intervalos que se piden. |
805 | 845 |
* |
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/edition/FValueCellEditor.java | ||
---|---|---|
1 | 1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
2 |
*
|
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
|
18 |
*
|
|
19 |
* For more information, contact:
|
|
20 |
*
|
|
21 |
* Generalitat Valenciana
|
|
22 |
* Conselleria d'Infraestructures i Transport
|
|
23 |
* Av. Blasco Ib??ez, 50
|
|
24 |
* 46010 VALENCIA
|
|
25 |
* SPAIN
|
|
26 |
*
|
|
27 |
* +34 963862235
|
|
28 |
* gvsig@gva.es
|
|
29 |
* www.gvsig.gva.es
|
|
30 |
*
|
|
31 |
* or
|
|
32 |
*
|
|
33 |
* IVER T.I. S.A
|
|
34 |
* Salamanca 50
|
|
35 |
* 46005 Valencia
|
|
36 |
* Spain
|
|
37 |
*
|
|
38 |
* +34 963163400
|
|
39 |
* dac@iver.es
|
|
40 |
*/
|
|
41 | 41 |
package com.iver.cit.gvsig.gui.thememanager.legendmanager.panels.edition; |
42 |
import java.awt.Component; |
|
43 |
import java.awt.event.KeyEvent; |
|
44 |
import java.awt.event.KeyListener; |
|
45 |
import java.util.Date; |
|
46 | 42 |
|
47 |
import javax.swing.AbstractCellEditor; |
|
48 |
import javax.swing.JOptionPane; |
|
49 |
import javax.swing.JTable; |
|
50 |
import javax.swing.JTextField; |
|
51 |
import javax.swing.table.TableCellEditor; |
|
52 |
|
|
53 | 43 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
54 | 44 |
import com.hardcode.gdbms.engine.values.DateValue; |
55 | 45 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
... | ... | |
60 | 50 |
import com.hardcode.gdbms.engine.values.StringValue; |
61 | 51 |
import com.hardcode.gdbms.engine.values.Value; |
62 | 52 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
63 |
import com.iver.andami.PluginServices; |
|
64 | 53 |
|
54 |
import java.awt.Component; |
|
55 |
import java.awt.event.KeyEvent; |
|
56 |
import java.awt.event.KeyListener; |
|
65 | 57 |
|
58 |
import java.util.Date; |
|
59 |
|
|
60 |
import javax.swing.AbstractCellEditor; |
|
61 |
import javax.swing.JTable; |
|
62 |
import javax.swing.JTextField; |
|
63 |
import javax.swing.table.TableCellEditor; |
|
64 |
|
|
65 |
|
|
66 | 66 |
/** |
67 | 67 |
* Cell Editor sobre los valores ?nicos. |
68 | 68 |
* |
... | ... | |
92 | 92 |
public Component getTableCellEditorComponent(JTable table, Object value, |
93 | 93 |
boolean isSelected, int row, int column) { |
94 | 94 |
System.out.println(value.toString()); |
95 |
this.value = (Value)value; |
|
95 |
this.value = (Value) value;
|
|
96 | 96 |
button.setText(value.toString()); |
97 |
|
|
97 | 98 |
return button; |
98 | 99 |
} |
99 | 100 |
|
101 |
/** |
|
102 |
* DOCUMENT ME! |
|
103 |
* |
|
104 |
* @param e DOCUMENT ME! |
|
105 |
*/ |
|
100 | 106 |
public void keyPressed(KeyEvent e) { |
101 | 107 |
} |
108 |
|
|
109 |
/** |
|
110 |
* DOCUMENT ME! |
|
111 |
* |
|
112 |
* @param e DOCUMENT ME! |
|
113 |
*/ |
|
102 | 114 |
public void keyReleased(KeyEvent e) { |
103 |
value = getValue(value,button.getText()); |
|
115 |
if (value == null) { |
|
116 |
value = ValueFactory.createValue((double) 0); |
|
117 |
} else { |
|
118 |
value = getValue(value, button.getText()); |
|
119 |
} |
|
104 | 120 |
} |
121 |
|
|
122 |
/** |
|
123 |
* DOCUMENT ME! |
|
124 |
* |
|
125 |
* @param e DOCUMENT ME! |
|
126 |
*/ |
|
105 | 127 |
public void keyTyped(KeyEvent e) { |
106 | 128 |
} |
107 |
private Value getValue(Value v,String s) { |
|
108 |
Value val=null; |
|
109 |
try{ |
|
110 |
if (v instanceof DoubleValue) { |
|
111 |
val = ValueFactory.createValue(Double.parseDouble(s)); |
|
112 |
} else if (v instanceof StringValue) { |
|
113 |
val = ValueFactory.createValue(s); |
|
114 |
} else if (v instanceof LongValue) { |
|
115 |
val = ValueFactory.createValue(Long.parseLong(s)); |
|
116 |
} else if (v instanceof IntValue) { |
|
117 |
val = ValueFactory.createValue(Integer.parseInt(s)); |
|
118 |
} else if (v instanceof FloatValue) { |
|
119 |
val = ValueFactory.createValue(Float.parseFloat(s)); |
|
120 |
} else if (v instanceof ShortValue) { |
|
121 |
val = ValueFactory.createValue(Short.parseShort(s)); |
|
122 |
} else if (v instanceof BooleanValue) { |
|
123 |
val = ValueFactory.createValue(Boolean.getBoolean(s)); |
|
124 |
} else if (v instanceof DateValue) { |
|
125 |
val = ValueFactory.createValue(Date.parse(s)); |
|
126 |
} |
|
127 |
}catch (NumberFormatException e) { |
|
128 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Formato de n?mero erroneo")+"."); |
|
129 |
|
|
130 |
/** |
|
131 |
* DOCUMENT ME! |
|
132 |
* |
|
133 |
* @param v DOCUMENT ME! |
|
134 |
* @param s DOCUMENT ME! |
|
135 |
* |
|
136 |
* @return DOCUMENT ME! |
|
137 |
*/ |
|
138 |
private Value getValue(Value v, String s) { |
|
139 |
Value val = null; |
|
140 |
Value cero = null; |
|
141 |
|
|
142 |
try { |
|
143 |
if (v instanceof DoubleValue) { |
|
144 |
val = ValueFactory.createValue(Double.parseDouble(s)); |
|
145 |
cero = ValueFactory.createValue((double) 0); |
|
146 |
} else if (v instanceof StringValue) { |
|
147 |
val = ValueFactory.createValue(s); |
|
148 |
cero = ValueFactory.createValue((String) ""); |
|
149 |
} else if (v instanceof LongValue) { |
|
150 |
val = ValueFactory.createValue(Long.parseLong(s)); |
|
151 |
cero = ValueFactory.createValue((long) 0); |
|
152 |
} else if (v instanceof IntValue) { |
|
153 |
val = ValueFactory.createValue(Integer.parseInt(s)); |
|
154 |
cero = ValueFactory.createValue((int) 0); |
|
155 |
} else if (v instanceof FloatValue) { |
|
156 |
val = ValueFactory.createValue(Float.parseFloat(s)); |
|
157 |
cero = ValueFactory.createValue((float) 0); |
|
158 |
} else if (v instanceof ShortValue) { |
|
159 |
val = ValueFactory.createValue(Short.parseShort(s)); |
|
160 |
cero = ValueFactory.createValue((short) 0); |
|
161 |
} else if (v instanceof BooleanValue) { |
|
162 |
val = ValueFactory.createValue(Boolean.getBoolean(s)); |
|
163 |
cero = ValueFactory.createValue((boolean) false); |
|
164 |
} else if (v instanceof DateValue) { |
|
165 |
val = ValueFactory.createValue(Date.parse(s)); |
|
166 |
cero = ValueFactory.createValue((Date) new Date()); |
|
129 | 167 |
} |
168 |
} catch (NumberFormatException e) { |
|
169 |
///JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Formato de n?mero erroneo")+"."); |
|
170 |
return cero; |
|
171 |
} |
|
172 |
|
|
130 | 173 |
return val; |
131 | 174 |
} |
132 | 175 |
} |
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/FPanelLegendBreaks.java | ||
---|---|---|
120 | 120 |
super(); |
121 | 121 |
initComponents(); |
122 | 122 |
} |
123 |
|
|
123 |
|
|
124 | 124 |
/** |
125 | 125 |
* EQUAL INTERVAL Devuelve un Array con el n?mero de intervalos que se |
126 | 126 |
* quieren crear. Los intervalos se crean con un tama?o igual entre ellos. |
... | ... | |
132 | 132 |
* @return Array con los intervalos. |
133 | 133 |
*/ |
134 | 134 |
FInterval[] calculateEqualIntervals(int numIntervals, |
135 |
double minValue, double maxValue) { |
|
135 |
double minValue, double maxValue,String fieldName) {
|
|
136 | 136 |
FInterval[] theIntervalArray = new FInterval[numIntervals]; |
137 | 137 |
double step = (maxValue - minValue) / numIntervals; |
138 | 138 |
|
139 |
for (int i = 0; i < numIntervals; i++) { |
|
140 |
theIntervalArray[i] = new FInterval(minValue + (i * step), |
|
139 |
if (numIntervals>1){ |
|
140 |
theIntervalArray[0] = new FInterval(minValue,minValue+step); |
|
141 |
for (int i = 1; i < numIntervals-1; i++) { |
|
142 |
theIntervalArray[i] = new FInterval(minValue + (i * step)+0.01, |
|
141 | 143 |
minValue + ((i + 1) * step)); |
142 | 144 |
} |
143 |
|
|
145 |
theIntervalArray[numIntervals-1] = new FInterval(minValue + ((numIntervals-1) * step)+0.01,maxValue); |
|
146 |
}else{ |
|
147 |
theIntervalArray[0] = new FInterval(minValue, maxValue); |
|
148 |
} |
|
144 | 149 |
return theIntervalArray; |
150 |
|
|
145 | 151 |
} |
146 | 152 |
|
147 | 153 |
/** |
... | ... | |
176 | 182 |
|
177 | 183 |
theIntervalArray[0] = new FInterval(minValue, intervalGenerator.getValorRuptura(0)); |
178 | 184 |
for (int i = 1; i < numIntervalsGen-1; i++) { |
179 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValorRuptura(
|
|
180 |
i-1)+0.01, intervalGenerator.getValorRuptura(i));
|
|
185 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit(
|
|
186 |
i-1), intervalGenerator.getValorRuptura(i)); |
|
181 | 187 |
} |
182 | 188 |
|
183 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getValorRuptura(
|
|
184 |
numIntervalsGen-2)+0.01, maxValue);
|
|
189 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getValInit(
|
|
190 |
numIntervalsGen-2), maxValue); |
|
185 | 191 |
}else{ |
186 | 192 |
theIntervalArray[numIntervalsGen-1] = new FInterval(minValue, maxValue); |
187 | 193 |
} |
... | ... | |
212 | 218 |
int numIntervalsGen=intervalGenerator.getNumIntervalGen(); |
213 | 219 |
FInterval[] theIntervalArray = new FInterval[numIntervalsGen]; |
214 | 220 |
if (intervalGenerator.getNumIntervalGen()>1){ |
215 |
theIntervalArray[0] = new FInterval(minValue, intervalGenerator.getNumRuptura(0));
|
|
221 |
theIntervalArray[0] = new FInterval(minValue, intervalGenerator.getValRuptura(0));
|
|
216 | 222 |
for (int i = 1; i < numIntervalsGen-1; i++) { |
217 |
theIntervalArray[i] = new FInterval(intervalGenerator.getNumRuptura(
|
|
218 |
i-1)+0.01, intervalGenerator.getNumRuptura(i));
|
|
223 |
theIntervalArray[i] = new FInterval(intervalGenerator.getValInit(
|
|
224 |
i-1), intervalGenerator.getValRuptura(i));
|
|
219 | 225 |
} |
220 | 226 |
|
221 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getNumRuptura(
|
|
222 |
numIntervalsGen-2)+0.01, maxValue);
|
|
227 |
theIntervalArray[numIntervalsGen-1] = new FInterval(intervalGenerator.getValInit(
|
|
228 |
numIntervalsGen-2), maxValue); |
|
223 | 229 |
}else{ |
224 | 230 |
theIntervalArray[numIntervalsGen-1] = new FInterval(minValue, maxValue); |
225 | 231 |
} |
... | ... | |
508 | 514 |
switch (m_Renderer.getIntervalType()) { |
509 | 515 |
case VectorialIntervalLegend.EQUAL_INTERVALS: |
510 | 516 |
arrayIntervalos = calculateEqualIntervals(numIntervalos, |
511 |
minValue, maxValue); |
|
517 |
minValue, maxValue,fieldName);
|
|
512 | 518 |
|
513 | 519 |
break; |
514 | 520 |
|
branches/gvSIG_03_SLD/applications/appgvSIG/src/com/iver/cit/gvsig/gui/thememanager/legendmanager/panels/QuantileIntervalGenerator.java | ||
---|---|---|
64 | 64 |
private String msFieldName; |
65 | 65 |
private int miNumIntervalosSolicitados; |
66 | 66 |
private double[] mdaValoresRuptura; |
67 |
private double[] mdaValInit; |
|
67 | 68 |
private int num = 0; |
68 | 69 |
|
69 | 70 |
/** |
... | ... | |
94 | 95 |
ArrayList coincidencias = new ArrayList(); |
95 | 96 |
int pos = sds.getFieldIndexByName(msFieldName); |
96 | 97 |
mdaValoresRuptura = new double[miNumIntervalosSolicitados - 1]; |
98 |
mdaValInit = new double[miNumIntervalosSolicitados - 1]; |
|
97 | 99 |
|
98 | 100 |
//int MARGEN = 5; |
99 |
|
|
100 | 101 |
for (int i = 0; i < sds.getRowCount(); i++) { |
101 | 102 |
insertarEnVector(ordenadas, coincidencias, sds.getFieldValue(i, pos)); |
102 | 103 |
} |
... | ... | |
144 | 145 |
|
145 | 146 |
if (x <= index) { |
146 | 147 |
mdaValoresRuptura[i - 1] = getValue((Value) ordenadas.get(j)); |
148 |
|
|
147 | 149 |
/*index = (int) ((x + (auxcoin / miNumIntervalosSolicitados)) - |
148 |
1); |
|
149 |
*/posj = j + 1; |
|
150 |
1); |
|
151 |
*/ |
|
152 |
posj = j + 1; |
|
153 |
|
|
154 |
if (posj < ordenadas.size()) { |
|
155 |
mdaValInit[i - 1] = getValue((Value) ordenadas.get(posj)); |
|
156 |
} else { |
|
157 |
mdaValInit[i - 1] = getValue((Value) ordenadas.get(j)); |
|
158 |
} |
|
159 |
|
|
150 | 160 |
num++; |
151 | 161 |
|
152 | 162 |
break; |
... | ... | |
270 | 280 |
* |
271 | 281 |
* @return valor. |
272 | 282 |
*/ |
273 |
public double getNumRuptura(int index) {
|
|
283 |
public double getValRuptura(int index) {
|
|
274 | 284 |
return mdaValoresRuptura[index]; |
275 | 285 |
} |
276 | 286 |
|
277 | 287 |
/** |
288 |
* Devuelve el valor inicial de cada intervalo. |
|
289 |
* |
|
290 |
* @param index ?ndice del intervalo. |
|
291 |
* |
|
292 |
* @return valor del intervalo. |
|
293 |
*/ |
|
294 |
public double getValInit(int index) { |
|
295 |
return mdaValInit[index]; |
|
296 |
} |
|
297 |
|
|
298 |
/** |
|
278 | 299 |
* Devuelve el n?mero de intervalos que se han generado. |
279 | 300 |
* |
280 | 301 |
* @return N?mero de intervalos generados. |
Also available in: Unified diff