Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / fmap / core / GeomEdited.java @ 3852

History | View | Annotate | Download (2.82 KB)

1
package com.iver.cit.gvsig.fmap.core;
2

    
3
import java.awt.geom.Point2D;
4
import java.util.ArrayList;
5

    
6
import com.iver.cit.gvsig.fmap.core.FPolyline2D.PointSelHandler;
7

    
8
public class GeomEdited {
9
        IGeometry geom;
10
        
11
        /**
12
         * DOCUMENT ME!
13
         *
14
         * @author Vicente Caballero Navarro
15
         */
16
        class PointHandler extends AbstractHandler {
17
                /**
18
                 * Crea un nuevo PointHandler.
19
                 *
20
                 * @param x DOCUMENT ME!
21
                 * @param y DOCUMENT ME!
22
                 */
23
                public PointHandler(int i,double x, double y) {
24
                        point = new Point2D.Double(x, y);
25
                        index=i;
26
                }
27

    
28
                /**
29
                 * DOCUMENT ME!
30
                 *
31
                 * @param x DOCUMENT ME!
32
                 * @param y DOCUMENT ME!
33
                 *
34
                 * @return DOCUMENT ME!
35
                 */
36
                public void move(double x, double y) {
37
                        /* gp.pointCoords[index*2]+=x;
38
                        gp.pointCoords[index*2+1]+=y; */
39
                }
40

    
41
                /**
42
                 * @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double)
43
                 */
44
                public void set(double x, double y) {
45
                        /* gp.pointCoords[index*2]=x;
46
                        gp.pointCoords[index*2+1]=y; */
47
                }
48
        }
49
        /**
50
         * DOCUMENT ME!
51
         *
52
         * @author Vicente Caballero Navarro
53
         */
54
        class PointSelHandler extends AbstractHandler {
55
                /**
56
                 * Crea un nuevo PointHandler.
57
                 *
58
                 * @param x DOCUMENT ME!
59
                 * @param y DOCUMENT ME!
60
                 */
61
                public PointSelHandler(int i,double x, double y) {
62
                        point = new Point2D.Double(x, y);
63
                        index=i;
64
                }
65

    
66
                /**
67
                 * DOCUMENT ME!
68
                 *
69
                 * @param x DOCUMENT ME!
70
                 * @param y DOCUMENT ME!
71
                 *
72
                 * @return DOCUMENT ME!
73
                 */
74
                public void move(double x, double y) {
75
                        /* gp.pointCoords[index*2]+=x;
76
                        gp.pointCoords[index*2+1]+=y; */
77
                }
78

    
79
                /**
80
                 * @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double)
81
                 */
82
                public void set(double x, double y) {
83
                /*         gp.pointCoords[index*2]=x;
84
                        gp.pointCoords[index*2+1]=y; */
85
                }
86
        }
87
        
88
        
89
        public GeomEdited(IGeometry geom)
90
        {
91
                this.geom = geom;
92
        }
93
        
94
        public IGeometry getGeometry()
95
        {
96
                return geom;
97
        }
98
        public void setGeometry(IGeometry geom)
99
        {
100
                this.geom = geom;
101
        }
102
        
103
        Handler[] getStretchingHandlers()
104
        {
105
                ArrayList handlers = new ArrayList();
106
                GeneralPathXIterator gpi = null;
107
                gpi = geom.getGeneralPathXIterator();
108

    
109
                double[] theData = new double[6];
110
                int i=0;
111
                while (!gpi.isDone()) {
112
                        int theType = gpi.currentSegment(theData);
113
                        //g.fillRect((int)(theData[0]-3),(int)(theData[1]-3),6,6);
114
                        handlers.add(new PointSelHandler(i,theData[0], theData[1]));
115
                        i++;
116
                        gpi.next();
117
                }
118

    
119
                return (Handler[]) handlers.toArray(new Handler[0]);
120
        }
121
        Handler[] getSelectionHandlers()
122
        {
123
                ArrayList handlers = new ArrayList();
124
                GeneralPathXIterator gpi = null;
125
                gpi = geom.getGeneralPathXIterator();
126
        
127
                double[] theData = new double[6];
128
                int i=0;
129
                while (!gpi.isDone()) {
130
                        int theType = gpi.currentSegment(theData);
131
                        //g.fillRect((int)(theData[0]-3),(int)(theData[1]-3),6,6);
132
                        handlers.add(new PointSelHandler(i,theData[0], theData[1]));
133
                        i++;
134
                        gpi.next();
135
                }
136
        
137
                return (Handler[]) handlers.toArray(new Handler[0]);
138
        }
139
        
140
}