Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / project / documents / table / GraphicOperator.java @ 10626

History | View | Annotate | Download (2.11 KB)

1
package com.iver.cit.gvsig.project.documents.table;
2

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

    
6
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
7
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
8
import com.iver.cit.gvsig.fmap.core.IGeometry;
9
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
10
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
11
/**
12
 * @author Vicente Caballero Navarro
13
 */
14
public abstract class GraphicOperator extends AbstractOperator{
15
        private FLyrVect lv=null;
16
        public void setLayer(FLyrVect lv) {
17
                this.lv=lv;
18
        }
19
        public FLyrVect getLayer() {
20
                return lv;
21
        }
22
        public abstract double process(Index index) throws ReadDriverException, ExpansionFileReadException;
23
        protected Double[][] getXY(IGeometry geometry) {
24
        ArrayList xs = new ArrayList();
25
        ArrayList ys = new ArrayList();
26
        double[] theData = new double[6];
27

    
28
        //double[] aux = new double[6];
29
        PathIterator theIterator;
30
        int theType;
31
        int numParts = 0;
32

    
33
        // boolean bFirst = true;
34
        // int xInt, yInt, antX = -1, antY = -1;
35
        theIterator = geometry.getPathIterator(null,FConverter.FLATNESS); //, flatness);
36

    
37
        // int numSegmentsAdded = 0;
38
        while (!theIterator.isDone()) {
39
            theType = theIterator.currentSegment(theData);
40

    
41
            switch (theType) {
42
            case PathIterator.SEG_MOVETO:
43
                numParts++;
44
                xs.add(new Double(theData[0]));
45
                ys.add(new Double(theData[1]));
46

    
47

    
48
                break;
49

    
50
            case PathIterator.SEG_LINETO:
51
                xs.add(new Double(theData[0]));
52
                ys.add(new Double(theData[1]));
53

    
54

    
55
                break;
56

    
57

    
58
            case PathIterator.SEG_CLOSE:
59
                xs.add(new Double(theData[0]));
60
                ys.add(new Double(theData[1]));
61

    
62
                break;
63
            } //end switch
64

    
65
            theIterator.next();
66
        } //end while loop
67

    
68
        Double[] x = (Double[]) xs.toArray(new Double[0]);
69
        Double[] y = (Double[]) ys.toArray(new Double[0]);
70

    
71
        return new Double[][] { x, y };
72

    
73
    }
74

    
75
}