Revision 3836 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableAdapter.java
VectorialEditableAdapter.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.9 2006-01-23 17:30:28 caballero |
|
48 |
* Revision 1.10 2006-01-30 08:18:14 caballero |
|
49 |
* m?todos para deshacer y rehacer |
|
50 |
* |
|
51 |
* Revision 1.9 2006/01/23 17:30:28 caballero |
|
49 | 52 |
* coger los datos del ova |
50 | 53 |
* |
51 | 54 |
* Revision 1.8 2006/01/23 16:16:16 caballero |
... | ... | |
81 | 84 |
import java.io.IOException; |
82 | 85 |
import java.util.HashMap; |
83 | 86 |
import java.util.List; |
87 |
import java.util.Vector; |
|
84 | 88 |
|
85 | 89 |
import com.hardcode.driverManager.DriverLoadException; |
86 | 90 |
import com.hardcode.gdbms.engine.data.DataSource; |
... | ... | |
212 | 216 |
} |
213 | 217 |
} else { |
214 | 218 |
int num = ((Integer) relations.get(integer)).intValue(); |
215 |
IFeature feat = (IFeature) expansionFile.getRow(num); |
|
219 |
IFeature feat = (IFeature) expansionFile.getRow(num).getLinkedRow();
|
|
216 | 220 |
return feat.getAttribute(fieldId); |
217 | 221 |
} |
218 | 222 |
} catch (DriverException e) { |
... | ... | |
293 | 297 |
expansionFile=new MemoryExpansionFile(); |
294 | 298 |
cr=new MemoryCommandRecord(); |
295 | 299 |
this.ova = ova; |
300 |
this.seleccion=new FBitSet(); |
|
296 | 301 |
} |
297 | 302 |
/* |
298 | 303 |
* (non-Javadoc) |
... | ... | |
408 | 413 |
* @throws DriverIOException |
409 | 414 |
* @throws IOException |
410 | 415 |
*/ |
411 |
public int doAddRow(IRow feat) throws DriverIOException, IOException {
|
|
416 |
public int doAddFeature(IRow feat) throws DriverIOException, IOException {
|
|
412 | 417 |
// A?ade la geometr?a |
413 | 418 |
int virtualIndex = ova.getShapeCount() + numAdd; |
414 | 419 |
int pos = expansionFile.addRow(feat); |
... | ... | |
514 | 519 |
} |
515 | 520 |
|
516 | 521 |
public void addRow(IRow row) throws DriverIOException, IOException { |
517 |
int virtualIndex = doAddRow(row);
|
|
522 |
int virtualIndex = doAddFeature(row);
|
|
518 | 523 |
|
519 | 524 |
if (complex) { |
520 | 525 |
commands.add(new AddRowCommand(this, row, virtualIndex)); |
... | ... | |
664 | 669 |
* @throws DriverIOException |
665 | 670 |
* @throws com.iver.cit.gvsig.fmap.DriverException |
666 | 671 |
*/ |
667 |
public int doModifyFeature(int index, IFeature feat)
|
|
672 |
public int doModifyFeature(int index, IRow feat)
|
|
668 | 673 |
throws IOException, DriverIOException { |
669 | 674 |
int pos = -1; |
670 | 675 |
Integer integer = new Integer(index); |
... | ... | |
681 | 686 |
featAnt = ova.getFeature(index); |
682 | 687 |
|
683 | 688 |
Rectangle2D rAnt = featAnt.getGeometry().getBounds2D(); |
684 |
Rectangle2D r = feat.getGeometry().getBounds2D();
|
|
689 |
Rectangle2D r = ((IFeature)feat).getGeometry().getBounds2D();
|
|
685 | 690 |
this.index.remove(new Envelope(rAnt.getX(), |
686 | 691 |
rAnt.getX() + rAnt.getWidth(), rAnt.getY(), |
687 | 692 |
rAnt.getY() + rAnt.getHeight()), new Integer(index)); |
... | ... | |
697 | 702 |
int num = ((Integer) relations.get(integer)).intValue(); |
698 | 703 |
pos = num; |
699 | 704 |
//Obtenemos la geometr?a para actualiza el ?ndice espacialposteriormente |
700 |
featAnt = (IFeature) expansionFile.getRow(num); |
|
705 |
featAnt = (IFeature) expansionFile.getRow(num).getLinkedRow();
|
|
701 | 706 |
/* |
702 | 707 |
* Se modifica la geometr?a y nos guardamos el ?ndice dentro del fichero |
703 | 708 |
* de expansi?n en el que se encuentra la geometr?a modificada |
... | ... | |
711 | 716 |
|
712 | 717 |
//Se modifica el ?ndice espacial |
713 | 718 |
Rectangle2D rAnt = featAnt.getGeometry().getBounds2D(); |
714 |
Rectangle2D r = feat.getGeometry().getBounds2D();
|
|
719 |
Rectangle2D r = ((IFeature)feat).getGeometry().getBounds2D();
|
|
715 | 720 |
this.index.remove(new Envelope(rAnt.getX(), |
716 | 721 |
rAnt.getX() + rAnt.getWidth(), rAnt.getY(), |
717 | 722 |
rAnt.getY() + rAnt.getHeight()), new Integer(index)); |
... | ... | |
738 | 743 |
|
739 | 744 |
return indexes; |
740 | 745 |
} |
746 |
/** |
|
747 |
* @return |
|
748 |
*/ |
|
749 |
public FBitSet getSelection() { |
|
750 |
return seleccion; |
|
751 |
} |
|
752 |
/** |
|
753 |
* Actualiza en el mapa de ?ndices, la posici?n en la que estaba la |
|
754 |
* geometr?a antes de ser modificada. Se marca como v?lida, en caso de que |
|
755 |
* fuera una modificaci?n de una geometr?a que estuviese en el fichero de |
|
756 |
* expansi?n antes de ser modificada y se pone el puntero de escritura del |
|
757 |
* expansion file a justo despues de la penultima geometr?a |
|
758 |
* |
|
759 |
* @param geometryIndex ?ndice de la geometr?a que se quiere deshacer su |
|
760 |
* modificaci?n |
|
761 |
* @param previousExpansionFileIndex ?ndice que ten?a antes la geometr?a en |
|
762 |
* el expansionFile. Si vale -1 quiere decir que es una |
|
763 |
* modificaci?n de una geometr?a original y por tanto no hay que |
|
764 |
* actualizar el mapa de indices sino eliminar su entrada. |
|
765 |
* |
|
766 |
* @throws IOException |
|
767 |
* @throws DriverIOException |
|
768 |
*/ |
|
769 |
public void undoModifyRow(int geometryIndex, |
|
770 |
int previousExpansionFileIndex) throws IOException, DriverIOException { |
|
771 |
/* |
|
772 |
* Si la acci?n de modificar se realiz? sobre una geometr?a original |
|
773 |
*/ |
|
774 |
if (previousExpansionFileIndex == -1) { |
|
775 |
//Se obtiene la geometr?a para actualizar el ?ndice |
|
776 |
IGeometry g = getShape(geometryIndex); |
|
777 |
Rectangle2D r = g.getBounds2D(); |
|
778 |
//Se elimina de las relaciones y del fichero de expansi?n |
|
779 |
relations.remove(new Integer(geometryIndex)); |
|
780 |
expansionFile.deleteLastRow(); |
|
741 | 781 |
|
782 |
//Se actualizan los ?ndices |
|
783 |
IGeometry gAnt = getShape(geometryIndex); |
|
784 |
Rectangle2D rAnt = gAnt.getBounds2D(); |
|
785 |
this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(), |
|
786 |
r.getY(), r.getY() + r.getHeight()), |
|
787 |
new Integer(geometryIndex)); |
|
788 |
this.index.insert(new Envelope(rAnt.getX(), |
|
789 |
rAnt.getX() + rAnt.getWidth(), rAnt.getY(), |
|
790 |
rAnt.getY() + rAnt.getHeight()), new Integer(geometryIndex)); |
|
791 |
} else { |
|
742 | 792 |
|
793 |
//Se obtiene la geometr?a para actualizar el ?ndice |
|
794 |
IGeometry g = null; |
|
795 |
g = getShape(geometryIndex); |
|
796 |
|
|
797 |
Rectangle2D r = g.getBounds2D(); |
|
798 |
this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(), |
|
799 |
r.getY(), r.getY() + r.getHeight()), |
|
800 |
new Integer(geometryIndex)); |
|
801 |
|
|
802 |
//Se actualiza la relaci?n de ?ndices |
|
803 |
Integer integer = new Integer(geometryIndex); |
|
804 |
relations.put(new Integer(geometryIndex), |
|
805 |
new Integer(previousExpansionFileIndex)); |
|
806 |
|
|
807 |
//Se recupera la geometr?a |
|
808 |
expansionFile.validateRow(previousExpansionFileIndex); |
|
809 |
|
|
810 |
//Se actualizan los ?ndices |
|
811 |
g = getShape(geometryIndex); |
|
812 |
r = g.getBounds2D(); |
|
813 |
this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), |
|
814 |
r.getY(), r.getY() + r.getHeight()), |
|
815 |
new Integer(geometryIndex)); |
|
816 |
} |
|
817 |
} |
|
818 |
/** |
|
819 |
* Se desmarca como invalidada en el fichero de expansion o como eliminada |
|
820 |
* en el fichero original |
|
821 |
* |
|
822 |
* @param index DOCUMENT ME! |
|
823 |
* |
|
824 |
* @throws IOException |
|
825 |
* @throws DriverIOException |
|
826 |
*/ |
|
827 |
public void undoRemoveRow(int index) |
|
828 |
throws IOException, DriverIOException { |
|
829 |
// Si la relaci?n |
|
830 |
if (relations.containsKey(new Integer(index))) { |
|
831 |
expansionFile.validateRow(((Integer) relations.get( |
|
832 |
new Integer(index))).intValue()); |
|
833 |
} else { |
|
834 |
delgeometries.set(index, false); |
|
835 |
} |
|
836 |
|
|
837 |
IGeometry g = null; |
|
838 |
g = ((IFeature)getRow(index).getLinkedRow()).getGeometry(); |
|
839 |
|
|
840 |
Rectangle2D r = g.getBounds2D(); |
|
841 |
this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), |
|
842 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
|
843 |
} |
|
844 |
/** |
|
845 |
* Se elimina del final del fichero de expansi?n poniendo el puntero de |
|
846 |
* escritura apuntando al final de la pen?ltima geometr?a. Deber? quitar |
|
847 |
* la relaci?n del mapa de relaciones |
|
848 |
* |
|
849 |
* @param index ?ndice de la geometr?a que se a?adi? |
|
850 |
* |
|
851 |
* @throws DriverIOException |
|
852 |
* @throws IOException |
|
853 |
*/ |
|
854 |
public void undoAddRow(int index) |
|
855 |
throws DriverIOException, IOException { |
|
856 |
//doRemoveGeometry(index); |
|
857 |
IGeometry g = ((IFeature)getRow(index).getLinkedRow()).getGeometry(); |
|
858 |
Rectangle2D r = g.getBounds2D(); |
|
859 |
this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(), |
|
860 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
|
861 |
|
|
862 |
expansionFile.deleteLastRow(); |
|
863 |
relations.remove(new Integer(index)); |
|
864 |
numAdd--; |
|
865 |
} |
|
866 |
|
|
743 | 867 |
} |
Also available in: Unified diff