Statistics
| Revision:

svn-gvsig-desktop / branches / pilotoDWG / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / ModifyGeometryCommand.java @ 1548

History | View | Annotate | Download (2.06 KB)

1

    
2
package com.iver.cit.gvsig.fmap.edition;
3

    
4
import java.io.IOException;
5

    
6
import com.iver.cit.gvsig.fmap.core.IGeometry;
7
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
8

    
9
/**
10
 * Modifica una geometr?a del EditableFeatureSource 
11
 */
12
public class ModifyGeometryCommand implements Command {
13
        private EditableFeatureSource efs;
14
        private IGeometry geomAnt;
15
        private IGeometry geomNext;
16
        private int indexAnt;
17
        private int indexNext;
18
        public ModifyGeometryCommand(EditableFeatureSource ef,int i,IGeometry newg){
19
                efs=ef;
20
                indexAnt=i;
21
                geomNext=newg;
22
        }
23
        /**
24
         * @see com.iver.cit.gvsig.fmap.edition.Command#execute()
25
         */
26
        public void execute() {
27
                try {
28
                        geomAnt=efs.getGeometry(indexAnt);
29
                } catch (IOException e) {
30
                        e.printStackTrace();
31
                } catch (DriverIOException e) {
32
                        e.printStackTrace();
33
                }
34
        }
35

    
36
        /**
37
         * @see com.iver.cit.gvsig.fmap.edition.Command#undo()
38
         */
39
        public void undo() {
40
        /*        try {
41
                        indexNext=efs.getGeometryCount();
42
                        efs.addGeometry(geomAnt);
43
                        efs.removeGeometry(indexAnt);
44
                } catch (DriverIOException e) {
45
                        e.printStackTrace();
46
                } catch (IOException e) {
47
                        e.printStackTrace();
48
                }
49
                */
50
                        try {
51
                indexNext=indexAnt;
52
                efs.modifyGeometry(indexAnt,geomAnt);
53
                
54
        } catch (IOException e) {
55
                e.printStackTrace();
56
        } catch (DriverIOException e) {
57
                e.printStackTrace();
58
        }
59

    
60
        }
61
        /**
62
         * @see com.iver.cit.gvsig.fmap.edition.Command#redo()
63
         */
64
        public void redo() {
65
        /*        try {
66
                        indexAnt=efs.getGeometryCount();
67
                        efs.addGeometry(geomNext);
68
                        efs.removeGeometry(indexNext);
69
                } catch (DriverIOException e) {
70
                        e.printStackTrace();
71
                } catch (IOException e) {
72
                        e.printStackTrace();
73
                }
74
                */
75
                try {
76
                        efs.modifyGeometry(indexAnt,geomNext);
77
                } catch (IOException e) {
78
                        e.printStackTrace();
79
                } catch (DriverIOException e) {
80
                        e.printStackTrace();
81
                }catch (RuntimeException e) {
82
                        try {
83
                                indexAnt=efs.getGeometryCount();
84
                                efs.addGeometry(geomNext);
85
                                //IGeometry g=geomAnt;
86
                                //geomAnt=geomNext;
87
                                //geomNext=g;
88
                        } catch (DriverIOException e2) {
89
                                e2.printStackTrace();
90
                        } catch (IOException e2) {
91
                                e2.printStackTrace();
92
                        }
93
                }
94
                
95
        }
96
}