Revision 5389 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.51 2006-05-16 16:07:19 fjp |
|
48 |
* Revision 1.52 2006-05-24 09:29:30 caballero |
|
49 |
* a?adir flatness |
|
50 |
* |
|
51 |
* Revision 1.51 2006/05/16 16:07:19 fjp |
|
49 | 52 |
* snapping. Revisar |
50 | 53 |
* |
51 | 54 |
* Revision 1.50 2006/05/16 07:07:46 caballero |
... | ... | |
227 | 230 |
|
228 | 231 |
/** |
229 | 232 |
* @author fjp |
230 |
*
|
|
233 |
* |
|
231 | 234 |
*/ |
232 | 235 |
public class VectorialEditableAdapter extends EditableAdapter implements |
233 | 236 |
ReadableVectorial, BoundedShapes { |
... | ... | |
241 | 244 |
|
242 | 245 |
protected BufferedImage handlersImage; |
243 | 246 |
|
247 |
private double flatness=0.8; |
|
244 | 248 |
/* |
245 | 249 |
* private class MyFeatureIterator implements IFeatureIterator { int numReg = |
246 | 250 |
* 0; Rectangle2D rect; String epsg; IFeatureIterator origFeatIt; boolean |
247 | 251 |
* bHasNext = true; |
248 |
*
|
|
252 |
* |
|
249 | 253 |
* public MyFeatureIterator(Rectangle2D r, String strEPSG) throws |
250 | 254 |
* DriverException { rect = r; epsg = strEPSG; origFeatIt = |
251 | 255 |
* ova.getFeatureIterator(r, epsg); } public boolean hasNext() throws |
252 | 256 |
* DriverException { return bHasNext; } |
253 |
*
|
|
257 |
* |
|
254 | 258 |
* public IFeature next() throws DriverException { IFeature aux = |
255 | 259 |
* origFeatIt.next(); return null; } |
256 |
*
|
|
260 |
* |
|
257 | 261 |
* public void closeIterator() throws DriverException { |
258 | 262 |
* } |
259 | 263 |
* } |
... | ... | |
274 | 278 |
|
275 | 279 |
/* |
276 | 280 |
* (non-Javadoc) |
277 |
*
|
|
281 |
* |
|
278 | 282 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start() |
279 | 283 |
*/ |
280 | 284 |
public void start() throws DriverIOException { |
... | ... | |
283 | 287 |
|
284 | 288 |
/* |
285 | 289 |
* (non-Javadoc) |
286 |
*
|
|
290 |
* |
|
287 | 291 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop() |
288 | 292 |
*/ |
289 | 293 |
public void stop() throws DriverIOException { |
... | ... | |
292 | 296 |
|
293 | 297 |
/* |
294 | 298 |
* (non-Javadoc) |
295 |
*
|
|
299 |
* |
|
296 | 300 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int) |
297 | 301 |
*/ |
298 | 302 |
public IGeometry getShape(int rowIndex) throws DriverIOException { |
... | ... | |
323 | 327 |
|
324 | 328 |
/* |
325 | 329 |
* (non-Javadoc) |
326 |
*
|
|
330 |
* |
|
327 | 331 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType() |
328 | 332 |
*/ |
329 | 333 |
public int getShapeType() throws DriverIOException { |
... | ... | |
348 | 352 |
|
349 | 353 |
/** |
350 | 354 |
* DOCUMENT ME! |
351 |
*
|
|
355 |
* |
|
352 | 356 |
* @throws EditionException |
353 | 357 |
* DOCUMENT ME! |
354 | 358 |
*/ |
... | ... | |
399 | 403 |
|
400 | 404 |
/* |
401 | 405 |
* (non-Javadoc) |
402 |
*
|
|
406 |
* |
|
403 | 407 |
* @see com.iver.cit.gvsig.fmap.edition.IEditableSource#getRow(int) |
404 | 408 |
*/ |
405 | 409 |
public IRowEdited getRow(int index) throws DriverIOException, IOException { |
... | ... | |
435 | 439 |
* se marca como eliminada (haya sido modificada o no). Si es una geometr?a |
436 | 440 |
* a?adida posteriormente se invalida en el fichero de expansi?n, para que |
437 | 441 |
* una futura compactaci?n termine con ella. |
438 |
*
|
|
442 |
* |
|
439 | 443 |
* @param index |
440 | 444 |
* ?ndice de la geometr?a. |
441 |
*
|
|
445 |
* |
|
442 | 446 |
* @throws DriverIOException |
443 | 447 |
* @throws IOException |
444 | 448 |
*/ |
... | ... | |
489 | 493 |
* fichero de expansi?n (por ser nueva o original pero modificada) se invoca |
490 | 494 |
* el m?todo modifyGeometry y se actualiza el ?ndice de la geometria en el |
491 | 495 |
* fichero. |
492 |
*
|
|
496 |
* |
|
493 | 497 |
* @param calculatedIndex |
494 | 498 |
* DOCUMENT ME! |
495 | 499 |
* @param feat |
496 | 500 |
* DOCUMENT ME! |
497 |
*
|
|
501 |
* |
|
498 | 502 |
* @return position inside ExpansionFile |
499 |
*
|
|
503 |
* |
|
500 | 504 |
* @throws IOException |
501 | 505 |
* @throws DriverIOException |
502 | 506 |
*/ |
... | ... | |
574 | 578 |
* fuera una modificaci?n de una geometr?a que estuviese en el fichero de |
575 | 579 |
* expansi?n antes de ser modificada y se pone el puntero de escritura del |
576 | 580 |
* expansion file a justo despues de la penultima geometr?a |
577 |
*
|
|
581 |
* |
|
578 | 582 |
* @param calculatedIndex |
579 | 583 |
* ?ndice de la geometr?a que se quiere deshacer su modificaci?n |
580 | 584 |
* @param previousExpansionFileIndex |
... | ... | |
582 | 586 |
* vale -1 quiere decir que es una modificaci?n de una geometr?a |
583 | 587 |
* original y por tanto no hay que actualizar el mapa de indices |
584 | 588 |
* sino eliminar su entrada. |
585 |
*
|
|
589 |
* |
|
586 | 590 |
* @throws IOException |
587 | 591 |
* @throws DriverIOException |
588 | 592 |
*/ |
... | ... | |
669 | 673 |
/** |
670 | 674 |
* A?ade una geometria al fichero de expansi?n y guarda la correspondencia |
671 | 675 |
* en la tabla relations. |
672 |
*
|
|
676 |
* |
|
673 | 677 |
* @param feat |
674 | 678 |
* geometr?a a guardar. |
675 |
*
|
|
679 |
* |
|
676 | 680 |
* @return calculatedIndex |
677 |
*
|
|
681 |
* |
|
678 | 682 |
* @throws DriverIOException |
679 | 683 |
* @throws IOException |
680 | 684 |
*/ |
... | ... | |
693 | 697 |
/** |
694 | 698 |
* Se desmarca como invalidada en el fichero de expansion o como eliminada |
695 | 699 |
* en el fichero original |
696 |
*
|
|
700 |
* |
|
697 | 701 |
* @param index |
698 | 702 |
* DOCUMENT ME! |
699 |
*
|
|
703 |
* |
|
700 | 704 |
* @throws IOException |
701 | 705 |
* @throws DriverIOException |
702 | 706 |
*/ |
... | ... | |
716 | 720 |
* Se elimina del final del fichero de expansi?n poniendo el puntero de |
717 | 721 |
* escritura apuntando al final de la pen?ltima geometr?a. Deber? quitar la |
718 | 722 |
* relaci?n del mapa de relaciones |
719 |
*
|
|
723 |
* |
|
720 | 724 |
* @param index |
721 | 725 |
* ?ndice de la geometr?a que se a?adi? |
722 |
*
|
|
726 |
* |
|
723 | 727 |
* @throws DriverIOException |
724 | 728 |
* @throws IOException |
725 | 729 |
*/ |
... | ... | |
739 | 743 |
/** |
740 | 744 |
* Obtiene las geometr?as que se encuentran en el rect?ngulo que se pasa |
741 | 745 |
* como par?metro haciendo uso del ?ndice espacial |
742 |
*
|
|
746 |
* |
|
743 | 747 |
* @param r |
744 | 748 |
* Rect?ngulo indicando la porci?n del espacio para el cual se |
745 | 749 |
* quiere saber los ?ndices de las geometr?as que se encuentran |
746 | 750 |
* dentro de ?l |
747 |
*
|
|
751 |
* |
|
748 | 752 |
* @return Array de ?ndices para su uso con getGeometry, removeGeometry, ... |
749 | 753 |
*/ |
750 | 754 |
/* |
... | ... | |
752 | 756 |
* Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(), r.getY() + |
753 | 757 |
* r.getHeight()); List l = index.query(e); int[] indexes = new |
754 | 758 |
* int[l.size()]; |
755 |
*
|
|
759 |
* |
|
756 | 760 |
* for (int index = 0; index < l.size(); index++) { Integer i = (Integer) |
757 | 761 |
* l.get(index); indexes[index] = getInversedIndex(i.intValue()); } |
758 |
*
|
|
762 |
* |
|
759 | 763 |
* return indexes; } |
760 | 764 |
*/ |
761 | 765 |
/** |
... | ... | |
781 | 785 |
|
782 | 786 |
/** |
783 | 787 |
* Use it BEFORE writing to a file. |
784 |
*
|
|
788 |
* |
|
785 | 789 |
* @return real full extent. |
786 | 790 |
* @throws DriverIOException |
787 | 791 |
*/ |
... | ... | |
801 | 805 |
* En la implementaci?n por defecto podemos hacer que cada feature tenga ID = |
802 | 806 |
* numero de registro. En el DBAdapter podr?amos "overrride" este m?todo y |
803 | 807 |
* poner como ID de la Feature el campo ?nico escogido en la base de datos. |
804 |
*
|
|
808 |
* |
|
805 | 809 |
* @param numReg |
806 | 810 |
* @return |
807 | 811 |
* @throws DriverException |
... | ... | |
830 | 834 |
|
831 | 835 |
public void stopEdition(IWriter writer, int sourceType) |
832 | 836 |
throws EditionException { |
837 |
writer.setFlatness(getFlatness()); |
|
833 | 838 |
super.stopEdition(writer, sourceType); |
834 | 839 |
try { |
835 | 840 |
ova.getDriver().reLoad(); |
... | ... | |
878 | 883 |
* usamos para las b?squedas por ?ndice espacial con el handle. La idea es |
879 | 884 |
* usarlo una vez, guardar las geometr?as que necesitas en ese extent y |
880 | 885 |
* trabajar con ellas hasta el siguiente cambio de extent. |
881 |
*
|
|
886 |
* |
|
882 | 887 |
* @param r |
883 | 888 |
* @param strEPSG |
884 | 889 |
* @return |
... | ... | |
917 | 922 |
|
918 | 923 |
/** |
919 | 924 |
* DOCUMENT ME! |
920 |
*
|
|
925 |
* |
|
921 | 926 |
* @return DOCUMENT ME! |
922 | 927 |
*/ |
923 | 928 |
public Image getSelectionImage() { |
... | ... | |
930 | 935 |
|
931 | 936 |
/** |
932 | 937 |
* DOCUMENT ME! |
933 |
*
|
|
938 |
* |
|
934 | 939 |
* @param i |
935 | 940 |
* DOCUMENT ME! |
936 | 941 |
*/ |
... | ... | |
941 | 946 |
public void setHandlersImage(BufferedImage handlersImage) { |
942 | 947 |
this.handlersImage = handlersImage; |
943 | 948 |
} |
949 |
|
|
950 |
public double getFlatness() { |
|
951 |
return flatness; |
|
952 |
} |
|
953 |
|
|
954 |
public void setFlatness(double d) { |
|
955 |
flatness=d; |
|
956 |
} |
|
944 | 957 |
} |
Also available in: Unified diff